Spring class

A spring, connecting two bodies. @example const spring = Spring(boxBody, sphereBody, { restLength: 0, stiffness: 50, damping: 1, })

// Compute the force after each step
world.addEventListener('postStep', (event) => {
  spring.applyForce()
})

Constructors

Spring.new(Body bodyA, Body bodyB, {double restLength = 1, double stiffness = 100, double damping = 1, Vector3? localAnchorA, Vector3? localAnchorB, Vector3? worldAnchorA, Vector3? worldAnchorB})

Properties

bodyA Body
First connected body.
getter/setter pair
bodyB Body
Second connected body.
getter/setter pair
damping double
Damping of the spring. A number >= 0.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
localAnchorA ↔ Vector3
Anchor for bodyA in local bodyA coordinates. Where to hook the spring to body A, in local body coordinates.
getter/setter pair
localAnchorB ↔ Vector3
Anchor for bodyB in local bodyB coordinates. Where to hook the spring to body B, in local body coordinates.
getter/setter pair
restLength double
Rest length of the spring. A number > 0.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stiffness double
Stiffness of the spring. A number >= 0.
getter/setter pair

Methods

applyForce() → void
Apply the spring force to the connected bodies.
getWorldAnchorA(Vector3 result) → void
Get the anchor point on body A, in world coordinates. @param result The vector to store the result in.
getWorldAnchorB(Vector3 result) → void
Get the anchor point on body B, in world coordinates. @param result The vector to store the result in.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setWorldAnchorA(Vector3 worldAnchorA) → void
et the anchor point on body A, using world coordinates.
setWorldAnchorB(Vector3 worldAnchorB) → void
Set the anchor point on body B, using world coordinates.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited