LittleJS 1.30.1

Box2D

Box2dPrismaticJoint

Box2D Prismatic Joint

  • Provides one degree of freedom: translation along an axis fixed in objectA
  • Relative rotation is prevented
  • You can use a joint limit to restrict the range of motion
  • You can use a joint motor to drive the motion or to model joint friction

Extends Box2dJoint

Constructor

new Box2dPrismaticJoint(objectA, objectB, anchor, worldAxis, collide)box2d.js:1867

Create a prismatic joint

objectA Box2dObject
objectB Box2dObject
anchor Vector2 optional

World position, objectB's position if not given

worldAxis Vector2 optional
collide boolean optional, default false

Methods

Inherited from Box2dJoint

Methods

enableLimit(enable)box2d.js:1923

Enable/disable the joint limit

enable boolean optional, default true
enableMotor(enable)box2d.js:1950

Enable/disable the joint motor

enable boolean optional, default true
getJointSpeed() → numberbox2d.js:1915

Get the current joint translation speed

getJointTranslation() → numberbox2d.js:1911

Get the current joint translation

getLocalAnchorA() → Vector2box2d.js:1895

Get the local anchor point relative to objectA's origin

getLocalAnchorB() → Vector2box2d.js:1899

Get the local anchor point relative to objectB's origin

getLocalAxisA() → Vector2box2d.js:1903

Get the local joint axis relative to bodyA

getLowerLimit() → numberbox2d.js:1927

Get the lower joint limit

getMaxMotorForce() → numberbox2d.js:1966

Get the maximum motor force

getMotorForce(time) → numberbox2d.js:1971

Get the motor force over the last step

time number optional

The step length in seconds, the world steps by timeDelta

getMotorSpeed() → numberbox2d.js:1958

Get the speed the motor drives the bodies apart along the axis, in meters per second

getReferenceAngle() → numberbox2d.js:1907

Get the reference angle, objectB angle minus objectA angle in the reference state

getUpperLimit() → numberbox2d.js:1931

Get the upper joint limit

isLimitEnabled() → booleanbox2d.js:1919

Is the joint limit enabled?

isMotorEnabled() → booleanbox2d.js:1946

Is the motor enabled?

setLimits(min, max)box2d.js:1936

Set the joint limits

min number
max number
setMaxMotorForce(force)box2d.js:1962

Set the maximum motor force

force number
setMotorSpeed(speed)box2d.js:1954

Set the speed the motor drives the bodies apart along the axis, in meters per second

speed number