Skip to main content

Class: PrismaticJoint

Defined in: physics/joints/prismatic-joint.ts:74

A constraint that locks two RigidBody instances together except for a single linear degree of freedom: bodyB's anchor may only slide along an axis fixed to bodyA, and the bodies' relative angle is fixed at whatever it was when the joint was created. Used for pistons, elevators, drawers, and other sliding mechanisms. Register with a PhysicsWorld via addJoint for it to be solved every PhysicsWorld.step.

Constructors

Constructor

new PrismaticJoint(options): PrismaticJoint

Defined in: physics/joints/prismatic-joint.ts:103

Creates a new PrismaticJoint instance.

Parameters

options

PrismaticJointOptions

The options for the joint.

Returns

PrismaticJoint

Throws

An error if axis is the zero vector, or if lowerTranslation is greater than upperTranslation.

Properties

bodyA

readonly bodyA: RigidBody

Defined in: physics/joints/prismatic-joint.ts:75


bodyB

readonly bodyB: RigidBody

Defined in: physics/joints/prismatic-joint.ts:77


enableLimit

enableLimit: boolean

Defined in: physics/joints/prismatic-joint.ts:91


localAnchorA

readonly localAnchorA: Vector2

Defined in: physics/joints/prismatic-joint.ts:79


localAnchorB

readonly localAnchorB: Vector2

Defined in: physics/joints/prismatic-joint.ts:81


localAxisA

readonly localAxisA: Vector2

Defined in: physics/joints/prismatic-joint.ts:83


lowerTranslation

lowerTranslation: number

Defined in: physics/joints/prismatic-joint.ts:93


referenceAngle

readonly referenceAngle: number

Defined in: physics/joints/prismatic-joint.ts:89

The relative angle (bodyB.angle - bodyA.angle) locked in place by the joint, captured from the bodies' angles at construction time.


upperTranslation

upperTranslation: number

Defined in: physics/joints/prismatic-joint.ts:95

Accessors

axis

Get Signature

get axis(): Vector2

Defined in: physics/joints/prismatic-joint.ts:145

The world-space axis bodyB's anchor slides along, i.e. localAxisA rotated by bodyA's current angle.

Returns

Vector2


translation

Get Signature

get translation(): number

Defined in: physics/joints/prismatic-joint.ts:154

The signed distance, along axis, between the two bodies' anchor points. Zero when the anchors coincide; increases as bodyB's anchor moves further along the positive axis direction from bodyA's anchor.

Returns

number