LittleJS 1.28.0

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

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

Enable/disable the joint motor

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

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

Get the current joint translation

getLocalAnchorA() → Vector2box2d.js:1957

Get the local anchor point relative to objectA's origin

getLocalAnchorB() → Vector2box2d.js:1961

Get the local anchor point relative to objectB's origin

getLocalAxisA() → Vector2box2d.js:1965

Get the local joint axis relative to bodyA

getMaxMotorTorque() → numberbox2d.js:1998

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

getMotorSpeed() → numberbox2d.js:1990

Get the motor speed, clockwise like angle

getMotorTorque(time) → numberbox2d.js:2003

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

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

getSpringFrequencyHz() → numberbox2d.js:2011

Get the spring frequency in Hertz

isMotorEnabled() → booleanbox2d.js:1978

Is the joint motor enabled?

setMaxMotorTorque(torque)box2d.js:1994

Set the maximum motor torque, a magnitude

torque number
setMotorSpeed(speed)box2d.js:1986

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

speed number
setSpringDampingRatio(ratio)box2d.js:2015

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

ratio number
setSpringFrequencyHz(hz)box2d.js:2007

Set the spring frequency in Hertz

hz number