Class RevoluteConstraint

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

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] });
world.addBody(bodyA);

var bodyB = new Body({ mass: 1, position: [1, 0] });
world.addBody(bodyB);

var constraint = new RevoluteConstraint(bodyA, bodyB, {
worldPivot: [0, 0]
});
world.addConstraint(constraint);

// 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]
});

Hierarchy

Constructors

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: Equation[]

Equations to be solved in this constraint

lowerLimit: number

The lower limit on the constraint angle.

lowerLimitEnabled: boolean

Set to true to enable lower limit

lowerLimitEquation: RotationalLockEquation
maxForce: number
pivotA: Vec2
pivotB: Vec2
type: 2 | 1 | -1 | 3 | 4 | 5

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

upperLimit: number

The upper limit on the constraint angle.

upperLimitEnabled: boolean

Set to true to enable upper limit

upperLimitEquation: RotationalLockEquation
DISTANCE: 1 = ...
GEAR: 2 = ...
LOCK: 3 = ...
OTHER: -1 = ...
PRISMATIC: 4 = ...
REVOLUTE: 5 = ...

Accessors

  • get motorEnabled(): boolean
  • Returns boolean

  • set motorEnabled(value): void
  • Parameters

    • value: boolean

    Returns void

  • get motorMaxForce(): number
  • Returns number

  • set motorMaxForce(value): void
  • Parameters

    • value: number

    Returns void

  • get motorSpeed(): number
  • Returns number

  • set motorSpeed(value): void
  • Parameters

    • value: number

    Returns void

Methods

  • Disable the rotational motor

    Returns void

    Deprecated

    Use motorEnabled instead

  • Enable the rotational motor

    Returns void

    Deprecated

    Use motorEnabled instead

  • Get the speed of the rotational constraint motor

    Returns number

    Deprecated

    Use .motorSpeed instead

  • Check if the motor is enabled.

    Returns boolean

    Deprecated

    Use motorEnabled instead

  • Set the constraint angle limits, and enable them.

    Parameters

    • lower: number

      the lower limit

    • upper: number

      the upper limit

    Returns void

  • Set max bias for this constraint.

    Parameters

    • maxBias: number

    Returns void

  • Set the speed of the rotational constraint motor

    Parameters

    • speed: number

    Returns void

    Deprecated

    Use .motorSpeed instead

  • Set relaxation for this constraint.

    Parameters

    • relaxation: number

    Returns void

  • Set stiffness for this constraint.

    Parameters

    • stiffness: number

    Returns void

  • Updates the internal constraint parameters before solve.

    Returns void