Interface: LinearSpringEcsComponent
Defined in: physics/components/linear-spring-component.ts:17
ECS-style component interface for a position-based force connecting two
bodies' anchor points, pulling or pushing them towards restLength apart
along the line between them, per Hooke's Law (F = -k * x). Register
createLinearSpringEcsSystem to have the force applied to bodyA/bodyB
every tick while this component's entity exists. Used for vehicle
suspension (supporting weight and pushing a wheel back down after a
bump), rope-like tethers, and other soft connections; typically paired
with a LinearDamperEcsComponent sharing the same anchors to
dissipate the energy it stores.
Properties
anchorA
anchorA:
Vector2
Defined in: physics/components/linear-spring-component.ts:26
The anchor point, relative to bodyA's center of mass and unrotated by
bodyA's angle (i.e. in bodyA's local space).
anchorB
anchorB:
Vector2
Defined in: physics/components/linear-spring-component.ts:32
The anchor point, relative to bodyB's center of mass and unrotated by
bodyB's angle (i.e. in bodyB's local space).
bodyA
bodyA:
RigidBody
Defined in: physics/components/linear-spring-component.ts:18
bodyB
bodyB:
RigidBody
Defined in: physics/components/linear-spring-component.ts:20
restLength
restLength:
number
Defined in: physics/components/linear-spring-component.ts:38
The distance between the two anchors at which the spring exerts no force.
stiffness
stiffness:
number
Defined in: physics/components/linear-spring-component.ts:45
The spring constant (k in Hooke's Law F = -k * x), in N/m. Higher
values produce a stiffer spring that resists compression/extension away
from restLength more strongly.