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(Body bodyA, Body bodyB, {double restLength = 1, double stiffness = 100, double damping = 1, Vec3? localAnchorA, Vec3? localAnchorB, Vec3? worldAnchorA, Vec3? 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 Vec3
Anchor for bodyA in local bodyA coordinates. Where to hook the spring to body A, in local body coordinates.
getter/setter pair
localAnchorB Vec3
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(Vec3 result) → void
Get the anchor point on body A, in world coordinates. @param result The vector to store the result in.
getWorldAnchorB(Vec3 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(Vec3 worldAnchorA) → void
et the anchor point on body A, using world coordinates.
setWorldAnchorB(Vec3 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