Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GearConstraint

Constrains the angle of two bodies to each other to be equal. If a gear ratio is not one, the angle of bodyA must be a multiple of the angle of bodyB.

example
var constraint = new GearConstraint(bodyA, bodyB);
world.addConstraint(constraint);
example
var constraint = new GearConstraint(bodyA, bodyB, {
ratio: 2,
maxTorque: 1000
});
world.addConstraint(constraint);

Hierarchy

Index

Constructors

Properties

angle: number
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

ratio: number
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.

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

Methods

  • getMaxTorque(): number
  • Get the max torque for the constraint.

    Returns number

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

    Parameters

    • maxBias: number

    Returns void

  • setMaxTorque(torque: number): void
  • Set the max torque for the constraint.

    Parameters

    • torque: 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