Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

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 = 1
GEAR: 2 = 2
LOCK: 3 = 3
OTHER: -1 = -1
PRISMATIC: 4 = 4
REVOLUTE: 5 = 5

Accessors

  • get motorEnabled(): boolean
  • set motorEnabled(value: boolean): void
  • Returns boolean

  • Parameters

    • value: boolean

    Returns void

  • get motorMaxForce(): number
  • set motorMaxForce(value: number): void
  • Returns number

  • Parameters

    • value: number

    Returns void

  • get motorSpeed(): number
  • set motorSpeed(value: number): void
  • Returns number

  • Parameters

    • value: number

    Returns void

Methods

  • disableMotor(): void
  • Disable the rotational motor

    deprecated

    Use motorEnabled instead

    Returns void

  • enableMotor(): void
  • Enable the rotational motor

    deprecated

    Use motorEnabled instead

    Returns void

  • getMotorSpeed(): number
  • Get the speed of the rotational constraint motor

    deprecated

    Use .motorSpeed instead

    Returns number

  • motorIsEnabled(): boolean
  • Check if the motor is enabled.

    deprecated

    Use motorEnabled instead

    Returns boolean

  • setLimits(lower: number, upper: number): void
  • Set the constraint angle limits, and enable them.

    Parameters

    • lower: number

      the lower limit

    • upper: number

      the upper limit

    Returns void

  • setMaxBias(maxBias: number): void
  • Set max bias for this constraint.

    Parameters

    • maxBias: number

    Returns void

  • setMotorSpeed(speed: number): void
  • Set the speed of the rotational constraint motor

    deprecated

    Use .motorSpeed instead

    Parameters

    • speed: number

    Returns void

  • setRelaxation(relaxation: number): void
  • Set relaxation for this constraint.

    Parameters

    • relaxation: number

    Returns void

  • setStiffness(stiffness: number): void
  • Set stiffness for this constraint.

    Parameters

    • stiffness: number

    Returns void

  • update(): void
  • Updates the internal constraint parameters before solve.

    Returns void