LittleJS 1.30.1

Box2D

Box2dWheelJoint

Box2D Wheel Joint

  • Provides two degrees of freedom: translation along an axis fixed in objectA and rotation
  • You can use a joint motor to drive the motion or to model joint friction
  • This joint is designed for vehicle suspensions

Extends Box2dJoint

Constructor

new Box2dWheelJoint(objectA, objectB, anchor, worldAxis, collide)box2d.js:1983

Create a wheel 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

enableMotor(enable)box2d.js:2035

Enable/disable the joint motor

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

Get the current joint rotation speed in radians per second, clockwise like angle, which is what this version of Box2D measures for a wheel joint

getJointTranslation() → numberbox2d.js:2022

Get the current joint translation

getLocalAnchorA() → Vector2box2d.js:2010

Get the local anchor point relative to objectA's origin

getLocalAnchorB() → Vector2box2d.js:2014

Get the local anchor point relative to objectB's origin

getLocalAxisA() → Vector2box2d.js:2018

Get the local joint axis relative to bodyA

getMaxMotorTorque() → numberbox2d.js:2051

Get the most torque the wheel's motor can apply, a magnitude

getMotorSpeed() → numberbox2d.js:2043

Get the motor speed, clockwise like angle

getMotorTorque(time) → numberbox2d.js:2056

Get the motor torque over the last step, clockwise like angle

time number optional

The step length in seconds, the world steps by timeDelta

getSpringDampingRatio() → numberbox2d.js:2072

Get how much the suspension spring is damped, 0 for none and 1 to stop it bouncing

getSpringFrequencyHz() → numberbox2d.js:2064

Get the spring frequency in Hertz

isMotorEnabled() → booleanbox2d.js:2031

Is the joint motor enabled?

setMaxMotorTorque(torque)box2d.js:2047

Set the maximum motor torque, a magnitude

torque number
setMotorSpeed(speed)box2d.js:2039

Set the motor speed, the wheel's turn in radians per second, clockwise like angle

speed number
setSpringDampingRatio(ratio)box2d.js:2068

Set how much the suspension spring is damped, 0 for none and 1 to stop it bouncing

ratio number
setSpringFrequencyHz(hz)box2d.js:2060

Set the spring frequency in Hertz

hz number