API Docs for: 0.6.1
Show:

Spring Class

A spring, connecting two bodies.

Constructor

Spring

(
  • bodyA
  • bodyB
  • [options]
)

Parameters:

  • bodyA Body
  • bodyB Body
  • [options] Object optional
    • [restLength] Number optional

      A number > 0. Default: 1

    • [stiffness] Number optional

      A number >= 0. Default: 100

    • [damping] Number optional

      A number >= 0. Default: 1

    • [worldAnchorA] Vec3 optional

      Where to hook the spring to body A, in world coordinates.

    • [worldAnchorB] Vec3 optional
    • [localAnchorA] Vec3 optional

      Where to hook the spring to body A, in local body coordinates.

    • [localAnchorB] Vec3 optional

Methods

applyForce

()

Apply the spring force to the connected bodies.

getWorldAnchorA

(
  • result
)

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

Parameters:

  • result Vec3

    The vector to store the result in.

getWorldAnchorB

(
  • result
)

Get the anchor point on body B, in world coordinates.

Parameters:

  • result Vec3

    The vector to store the result in.

setWorldAnchorA

(
  • worldAnchorA
)

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

Parameters:

setWorldAnchorB

(
  • worldAnchorB
)

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

Parameters:

Properties

bodyA

Body

First connected body.

bodyB

Body

Second connected body.

damping

Number

Damping of the spring.

localAnchorA

Vec3

Anchor for bodyA in local bodyA coordinates.

localAnchorB

Vec3

Anchor for bodyB in local bodyB coordinates.

restLength

Number

Rest length of the spring.

stiffness

Number

Stiffness of the spring.