LittleJS 1.28.0

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

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

Enable/disable the joint limit

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

Enable/disable the joint motor

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

Get the current joint translation speed

getJointTranslation() → numberbox2d.js:1859

Get the current joint translation

getLocalAnchorA() → Vector2box2d.js:1843

Get the local anchor point relative to objectA's origin

getLocalAnchorB() → Vector2box2d.js:1847

Get the local anchor point relative to objectB's origin

getLocalAxisA() → Vector2box2d.js:1851

Get the local joint axis relative to bodyA

getLowerLimit() → numberbox2d.js:1875

Get the lower joint limit

getMaxMotorForce() → numberbox2d.js:1914

Get the maximum motor force

getMotorForce(time) → numberbox2d.js:1919

Get the motor force over the last step

time number optional

The step length in seconds, the world steps by timeDelta

getMotorSpeed() → numberbox2d.js:1906

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

getReferenceAngle() → numberbox2d.js:1855

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

getUpperLimit() → numberbox2d.js:1879

Get the upper joint limit

isLimitEnabled() → booleanbox2d.js:1867

Is the joint limit enabled?

isMotorEnabled() → booleanbox2d.js:1894

Is the motor enabled?

setLimits(min, max)box2d.js:1884

Set the joint limits

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

Set the maximum motor force

force number
setMotorSpeed(speed)box2d.js:1902

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

speed number