Skip to content

Class: WheelJoint ​

A wheel joint. This joint provides two degrees of freedom: translation along an axis fixed in bodyA and rotation in the plane. In other words, it is a point to line constraint with a rotational motor and a linear spring/damper. This joint is designed for vehicle suspensions.

Extends ​

Constructors ​

Constructor ​

new WheelJoint(def): WheelJoint

Parameters ​

def ​

WheelJointDef

Returns ​

WheelJoint

Overrides ​

Joint.constructor

Constructor ​

new WheelJoint(def, bodyA, bodyB, anchor?, axis?): WheelJoint

Parameters ​

def ​

WheelJointOpt

bodyA ​

Body

bodyB ​

Body

anchor? ​

Vec2Value

axis? ​

Vec2Value

Returns ​

WheelJoint

Overrides ​

Joint.constructor

Properties ​

style ​

style: Style = {}

Styling for dev-tools.

Inherited from ​

Joint.style


TYPE ​

static TYPE: "wheel-joint"

Methods ​

enableMotor() ​

enableMotor(flag): void

Enable/disable the joint motor.

Parameters ​

flag ​

boolean

Returns ​

void


getAnchorA() ​

getAnchorA(): Vec2

Get the anchor point on bodyA in world coordinates.

Returns ​

Vec2

Overrides ​

Joint.getAnchorA


getAnchorB() ​

getAnchorB(): Vec2

Get the anchor point on bodyB in world coordinates.

Returns ​

Vec2

Overrides ​

Joint.getAnchorB


getBodyA() ​

getBodyA(): Body

Get the first body attached to this joint.

Returns ​

Body

Inherited from ​

Joint.getBodyA


getBodyB() ​

getBodyB(): Body

Get the second body attached to this joint.

Returns ​

Body

Inherited from ​

Joint.getBodyB


getCollideConnected() ​

getCollideConnected(): boolean

Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.

Returns ​

boolean

Inherited from ​

Joint.getCollideConnected


getJointSpeed() ​

getJointSpeed(): number

Get the current joint translation speed, usually in meters per second.

Returns ​

number


getJointTranslation() ​

getJointTranslation(): number

Get the current joint translation, usually in meters.

Returns ​

number


getLocalAnchorA() ​

getLocalAnchorA(): Vec2

The local anchor point relative to bodyA's origin.

Returns ​

Vec2


getLocalAnchorB() ​

getLocalAnchorB(): Vec2

The local anchor point relative to bodyB's origin.

Returns ​

Vec2


getLocalAxisA() ​

getLocalAxisA(): Vec2

The local joint axis relative to bodyA.

Returns ​

Vec2


getMaxMotorTorque() ​

getMaxMotorTorque(): number

Returns ​

number


getMotorSpeed() ​

getMotorSpeed(): number

Get the motor speed, usually in radians per second.

Returns ​

number


getMotorTorque() ​

getMotorTorque(inv_dt): number

Get the current motor torque given the inverse time step, usually in N-m.

Parameters ​

inv_dt ​

number

Returns ​

number


getNext() ​

getNext(): Joint

Get the next joint the world joint list.

Returns ​

Joint

Inherited from ​

Joint.getNext


getReactionForce() ​

getReactionForce(inv_dt): Vec2

Get the reaction force on bodyB at the joint anchor in Newtons.

Parameters ​

inv_dt ​

number

Returns ​

Vec2

Overrides ​

Joint.getReactionForce


getReactionTorque() ​

getReactionTorque(inv_dt): number

Get the reaction torque on bodyB in N*m.

Parameters ​

inv_dt ​

number

Returns ​

number

Overrides ​

Joint.getReactionTorque


getSpringDampingRatio() ​

getSpringDampingRatio(): number

Returns ​

number


getSpringFrequencyHz() ​

getSpringFrequencyHz(): number

Returns ​

number


getType() ​

getType(): string

Get the type of the concrete joint.

Returns ​

string

Inherited from ​

Joint.getType


getUserData() ​

getUserData(): unknown

Returns ​

unknown

Inherited from ​

Joint.getUserData


initVelocityConstraints() ​

initVelocityConstraints(step): void

Parameters ​

step ​

TimeStep

Returns ​

void

Overrides ​

Joint.initVelocityConstraints


isActive() ​

isActive(): boolean

Short-cut function to determine if either body is inactive.

Returns ​

boolean

Inherited from ​

Joint.isActive


isMotorEnabled() ​

isMotorEnabled(): boolean

Is the joint motor enabled?

Returns ​

boolean


setMaxMotorTorque() ​

setMaxMotorTorque(torque): void

Set/Get the maximum motor force, usually in N-m.

Parameters ​

torque ​

number

Returns ​

void


setMotorSpeed() ​

setMotorSpeed(speed): void

Set the motor speed, usually in radians per second.

Parameters ​

speed ​

number

Returns ​

void


setSpringDampingRatio() ​

setSpringDampingRatio(ratio): void

Set/Get the spring damping ratio

Parameters ​

ratio ​

number

Returns ​

void


setSpringFrequencyHz() ​

setSpringFrequencyHz(hz): void

Set/Get the spring frequency in hertz. Setting the frequency to zero disables the spring.

Parameters ​

hz ​

number

Returns ​

void


setUserData() ​

setUserData(data): void

Parameters ​

data ​

unknown

Returns ​

void

Inherited from ​

Joint.setUserData


shiftOrigin() ​

shiftOrigin(newOrigin): void

Shift the origin for any points stored in world coordinates.

Parameters ​

newOrigin ​

Vec2Value

Returns ​

void

Inherited from ​

Joint.shiftOrigin


solvePositionConstraints() ​

solvePositionConstraints(step): boolean

This returns true if the position errors are within tolerance.

Parameters ​

step ​

TimeStep

Returns ​

boolean

Overrides ​

Joint.solvePositionConstraints


solveVelocityConstraints() ​

solveVelocityConstraints(step): void

Parameters ​

step ​

TimeStep

Returns ​

void

Overrides ​

Joint.solveVelocityConstraints