Class LinearSpring

A spring, connecting two bodies.

The Spring explicitly adds force and angularForce to the bodies.

Example

var spring = new LinearSpring(bodyA, bodyB, {
stiffness: 100,
damping: 1,
localAnchorA: [0,0], // center of bodyA
localAnchorB: [0,0] // center of bodyB
});
world.addSpring(spring);

Hierarchy

Constructors

Properties

bodyA: Body

First connected body.

bodyB: Body

Second connected body.

damping: number

Damping of the spring.

localAnchorA: Vec2

Anchor for bodyA in local bodyA coordinates.

localAnchorB: Vec2

Anchor for bodyB in local bodyB coordinates.

restLength: number

Rest length of the spring. Can be set dynamically.

stiffness: number

Stiffness of the spring.

Methods

  • Apply the spring force to the connected bodies

    Returns void

  • Get the anchor point on body A, in world coordinates.

    Parameters

    Returns void

  • Set the anchor point on body B, using world coordinates.

    Parameters

    Returns void

  • Set the anchor point on body A, using world coordinates.

    Parameters

    • worldAnchorA: Vec2

    Returns void

  • Set the anchor point on body B, using world coordinates.

    Parameters

    • worldAnchorB: Vec2

    Returns void