API Docs for: 0.5.0
Show:

DistanceConstraint Class

Constraint that tries to keep the distance between two bodies constant.

Constructor

DistanceConstraint

(
  • bodyA
  • bodyB
  • distance
  • [options]
)

Parameters:

  • bodyA Body
  • bodyB Body
  • distance Number

    The distance to keep between the bodies.

  • [options] Object optional
    • [maxForce=Number.MAX_VALUE] Object optional

      Maximum force to apply.

Methods

getMaxForce

() Number

Get the max force

Returns:

Number:

setMaxForce

(
  • f
)

Set the max force to be used

Parameters:

  • f Number

setRelaxation

(
  • relaxation
)

Set relaxation for this constraint.

Parameters:

  • relaxation Number

setStiffness

(
  • stiffness
)

Set stiffness for this constraint.

Parameters:

  • stiffness Number

update

()

Inherited from Constraint but overwritten in src/constraints/DistanceConstraint.js:53

Update the constraint equations. Should be done if any of the bodies changed position, before solving.

Properties

bodyA

Body

First body participating in the constraint.

bodyB

Body

Second body participating in the constraint.

collideConnected

Boolean

Set to true if you want the connected bodies to collide.

Default: true

distance

Number

The distance to keep.

equations

Array

Equations to be solved in this constraint