Class PrismaticConstraint

Constraint that only allows bodies to move along a line, relative to each other.

Also called "slider constraint".

See

http://www.iforce2d.net/b2dtut/joints-prismatic

Todo

Ability to create using only a point and a worldAxis

Example

var constraint = new PrismaticConstraint(bodyA, bodyB, {
localAxisA: [0, 1]
});
world.addConstraint(constraint);

Hierarchy

Constructors

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

Equations to be solved in this constraint

localAnchorA: Vec2
localAnchorB: Vec2
localAxisA: Vec2
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.

lowerLimitEquation: ContactEquation
maxForce: number

Max force for the motor

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

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

upperLimitEnabled: boolean

Set to true to enable upper limit.

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

Methods

  • Disable the rotational motor

    Returns void

  • Enable the motor

    Returns void

  • Set the constraint limits.

    Parameters

    • lower: number

      lower limit

    • upper: number

      upper limit

    Returns void

  • Set max bias for this constraint.

    Parameters

    • maxBias: number

    Returns void

  • Set relaxation for this constraint.

    Parameters

    • relaxation: number

    Returns void

  • Set stiffness for this constraint.

    Parameters

    • stiffness: number

    Returns void

  • Update the constraint equations. Should be done if any of the bodies changed position, before solving.

    Returns void