API Docs for: 0.7.1
Show:

PrismaticConstraint Class

Constraint that only allows bodies to move along a line, relative to each other. See this tutorial. Also called "slider constraint".

Constructor

PrismaticConstraint

(
  • bodyA
  • bodyB
  • [options]
)

Parameters:

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

      Max force to be applied by the constraint

    • [localAnchorA] Array optional

      Body A's anchor point, defined in its own local frame.

    • [localAnchorB] Array optional

      Body B's anchor point, defined in its own local frame.

    • [localAxisA] Array optional

      An axis, defined in body A frame, that body B's anchor point may slide along.

    • [disableRotationalLock] Boolean optional

      If set to true, bodyB will be free to rotate around its anchor point.

    • [upperLimit] Number optional
    • [lowerLimit] Number optional

Methods

disableMotor

()

Disable the rotational motor

enableMotor

()

Enable the motor

setLimits

(
  • lower
  • upper
)

Set the constraint limits.

Parameters:

  • lower Number

    Lower limit.

  • upper Number

    Upper limit.

setRelaxation

(
  • relaxation
)

Set relaxation for this constraint.

Parameters:

  • relaxation Number

setStiffness

(
  • stiffness
)

Set stiffness for this constraint.

Parameters:

  • stiffness Number

update

()

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

equations

Array

Equations to be solved in this constraint

localAnchorA

Array

localAnchorB

Array

localAxisA

Array

lowerLimit

Number

Lower constraint limit. The constraint position is forced to be larger than this value.

lowerLimitEnabled

Boolean

Set to true to enable lower limit.

motorEnabled

Boolean

The current motor state. Enable or disable the motor using .enableMotor

motorEquation

Equation

Equation used for the motor.

motorSpeed

Number

Set the target speed for the motor.

position

Number

The position of anchor A relative to anchor B, along the constraint axis.

type

Number

The type of constraint. May be one of Constraint.DISTANCE, Constraint.GEAR, Constraint.LOCK, Constraint.PRISMATIC or Constraint.REVOLUTE.

upperLimit

Number

Upper constraint limit. The constraint position is forced to be smaller than this value.

upperLimitEnabled

Boolean

Set to true to enable upper limit.