API Docs for: 0.7.1
Show:

RevoluteConstraint Class

Extends Constraint

Connects two bodies at given offset points, letting them rotate relative to each other around this point.

Constructor

`RevoluteConstraint`

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

Parameters:

• `bodyA` Body
• `bodyB` Body
• `[options]` Object optional
• `[worldPivot]` Array optional

A pivot point given in world coordinates. If specified, localPivotA and localPivotB are automatically computed from this value.

• `[localPivotA]` Array optional

The point relative to the center of mass of bodyA which bodyA is constrained to.

• `[localPivotB]` Array optional

See localPivotA.

• `[maxForce]` Number optional

The maximum force that should be applied to constrain the bodies.

Example:

``````// This will create a revolute constraint between two bodies with pivot point in between them.
var bodyA = new Body({ mass: 1, position: [-1, 0] });
var bodyB = new Body({ mass: 1, position: [1, 0] });
var constraint = new RevoluteConstraint(bodyA, bodyB, {
worldPivot: [0, 0]
});

// Using body-local pivot points, the constraint could have been constructed like this:
var constraint = new RevoluteConstraint(bodyA, bodyB, {
localPivotA: [1, 0],
localPivotB: [-1, 0]
});
``````

Methods

`disableMotor`

()

Disable the rotational motor

`enableMotor`

()

Enable the rotational motor

`getMotorSpeed`

() Number

Get the speed of the rotational constraint motor

Returns:

Number:

The current speed, or false if the motor is not enabled.

`motorIsEnabled`

() Boolean deprecated

Check if the motor is enabled.

Boolean:

`setLimits`

(
• `lower`
• `upper`
)

Set the constraint angle limits.

Parameters:

• `lower` Number

Lower angle limit.

• `upper` Number

Upper angle limit.

`setMotorSpeed`

(
• `speed`
)

Set the speed of the rotational constraint motor

Parameters:

• `speed` Number

`setRelaxation`

(
• `relaxation`
)

Set relaxation for this constraint.

Parameters:

• `relaxation` Number

`setStiffness`

(
• `stiffness`
)

Set stiffness for this constraint.

Parameters:

• `stiffness` Number

`update`

()

Updates the internal constraint parameters before solve.

Properties

`angle`

Number

The constraint position.

`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

`lowerLimit`

Boolean

The lower limit on the constraint angle.

`lowerLimitEnabled`

Boolean

Set to true to enable lower limit

`motorEnabled`

Boolean

Indicates whether the motor is enabled. Use .enableMotor() to enable the constraint motor.

Array

Array

`type`

Number

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

`upperLimit`

Boolean

The upper limit on the constraint angle.

`upperLimitEnabled`

Boolean

Set to true to enable upper limit