{"id":"pepeeltoro41/jecs-spring","name":"jecs-spring","scope":"pepeeltoro41","platform":"roblox","description":"Mirrored from the Wally registry.","version":"1.0.2","latest":"1.0.2","versions":["0.1.0","1.0.0","1.0.1","1.0.2"],"license":"MIT","licenseRating":"safe","licenseCaveats":["License identified from the packaged LICENSE file; the manifest declared none."],"licenseVerified":true,"dependencies":{"ukendio/jecs":{"version":"^0.10.0","alias":"jecs"},"littensy/ripple":{"version":"^0.10.0-alpha.3","alias":"ripple"}},"integrity":"8ca126b7a9edb0b9c87ca57e0ec51e079204357b4f013359d1d0f20ea631076f","likes":0,"downloads":0,"install":"forest install pepeeltoro41/jecs-spring","url":"https://forest.dev/p/roblox/pepeeltoro41/jecs-spring","files":"https://api.forest.dev/ai/package/roblox/pepeeltoro41/jecs-spring/files","readme":"# Jecs Spring\r\n\r\nUtility for running springs in Jecs.\r\n\r\n### Setup\r\n\r\n-  Call `jecs_spring.world(world)` **before using it** to set it up with your world.\r\n\r\n-  Add `jecs_spring.system(delta)` to your systems. Set the order right before your component values apply. This system needs the delta time to step the springs.\r\n\r\n```luau\r\nlocal c = require(components)\r\nlocal jecs_spring = require(jecs_spring)\r\n\r\njecs_spring.world(world)\r\n\r\nreturn {\r\n    system = function(delta: number)\r\n        jecs_spring.system(delta)\r\n    end\r\n}\r\n```\r\n\r\n### Usage\r\n\r\n-  Use `jecs_spring.goal` as a pair to set your goal value.\r\n\r\n-  The target should be the component you want to interpolate\r\n\r\n-  The value of the pair should be the goal value. This value should be any of ripple `Animatable` types `(number | vector | Vector3 | Vector2 | CFrame | Color3 | UDim | UDim2 | Rect)`.\r\n\r\n```luau\r\nlocal spring = require(jecs_spring)\r\n\r\nlocal cube = world:entity()\r\n\r\nworld:set(cube, c.size, Vector3.new(1, 1, 1))\r\nworld:set(cube, pair(spring.goal, c.size), Vector3.new(2, 2, 2))\r\n\r\n-- cube will go from 1 -> 2\r\n```\r\n\r\n### Configuring the spring.\r\n\r\n-  Use `jecs_spring.options` as a pair to set the options for the spring. Similar to jecs.goal, the target is the component's spring you want to configure.\r\n\r\n-  Its recommended that you set the options before the goal so the spring starts with the correct configuration.\r\n\r\n```luau\r\nlocal spring = require(jecs_spring)\r\n\r\nlocal cube = world:entity()\r\n\r\nworld:set(cube, c.size, Vector3.new(1, 1, 1))\r\nworld:set(cube, pair(spring.options, c.size), { friction = 30, tension = 800 })\r\nworld:set(cube, pair(spring.goal, c.size), Vector3.new(2, 2, 2))\r\n\r\n-- cube will go from 1 -> 2 with a friction of 30 and tension of 800\r\n```\r\n\r\n### Manipulating the spring object.\r\n\r\n-  The spring object is stored in a `jecs_spring.motion` pair. The target is the component's spring.\r\n\r\n-  The spring object is available right after you set the goal.\r\n\r\n-  The spring object is destroyed when the goal is removed.\r\n\r\n```luau\r\nlocal spring = require(jecs_spring)\r\n\r\nlocal cube = world:entity()\r\n\r\nworld:set(cube, c.size, Vector3.new(1, 1, 1))\r\nworld:set(cube, pair(spring.goal, c.size), Vector3.new(2, 2, 2))\r\n\r\nlocal spring_motion = world:get(cube, pair(spring.motion, c.size))\r\nspring_motion:impulse(Vector3.new(5, 5, 5))\r\n\r\n```\r\n\r\n### Checking spring completion.\r\n\r\n-  Springs that have completed will be marked with a `jecs_spring.completed` pair. The target is the component's spring.\r\n\r\n-  The completed pair is removed if you change the goal.\r\n\r\n-  The completed pair is removed if you remove the goal.\r\n\r\n```luau\r\nlocal spring = require(jecs_spring)\r\n\r\nlocal cube = world:entity()\r\nworld:set(cube, c.size, Vector3.new(3, 3, 3))\r\n\r\ntask.wait(2)\r\n-- animate out\r\nworld:set(cube, pair(spring.goal, c.size), Vector3.zero)\r\n\r\nfunction system()\r\n    for entity in world:query(pair(spring.completed, c.size)) do\r\n        world:delete(entity)\r\n    end\r\nend\r\n```\r\n","readmeTruncated":false}