Physics · interface

JointDesc

Explained in Your first game, Rigid bodies.

interface JointDesc
import type { JointDesc } from '@driftengine/physics';

Properties

NameTypeDescription
typereadonlyJointType
bodyAreadonlynumber
bodyBreadonlynumber
anchorAXreadonlyoptionalnumberAnchor in each body's local frame.
anchorAYreadonlyoptionalnumber
anchorAZreadonlyoptionalnumber
anchorBXreadonlyoptionalnumber
anchorBYreadonlyoptionalnumber
anchorBZreadonlyoptionalnumber
axisXreadonlyoptionalnumberThe free axis, in A's local frame: a hinge turns about it, a slider travels along it.
axisYreadonlyoptionalnumber
axisZreadonlyoptionalnumber
lengthreadonlyoptionalnumberDistance joints: the length held. Others: unused.
lowerreadonlyoptionalnumberLimits, as a cosine for a cone and as metres or a sine of a half-angle otherwise.
upperreadonlyoptionalnumber
swingCosreadonlyoptionalnumberA cone half-angle's cosine, and a twist half-angle's sine. Cone-twist only.
twistSinreadonlyoptionalnumber
motorSpeedreadonlyoptionalnumber
motorMaxForcereadonlyoptionalnumber
breakImpulsereadonlyoptionalnumberAccumulated impulse above which the joint gives way. Infinity never breaks.
dofreadonlyoptionalreadonly DofMode[]Six-DOF only: what each degree of freedom does.
More

The order is linear x, y, z then angular x, y, z, all in body A's local frame — not in a frame of the joint's own. Cost: a caller wanting axes that are not A's own has to orient A, or place the anchors so that A's frame is the one it means. What would reverse it: a consumer whose parent body cannot be oriented, and the answer then is four more floats per joint holding a frame quaternion.

Shorter than six, or absent, and the rest are locked.

dofLowerreadonlyoptionalreadonly number[]Lower bounds, one per degree, read only where the mode is DOF_LIMITED.
More

Linear bounds are metres of offset from the anchor; angular bounds are sines of half angles. The second is this package's own convention rather than a shortcut — a swing limit compares a dot product against a stored cosine and a twist limit a quaternion component against a half-angle's sine, because Math.acos and Math.atan2 are both on the banned list and the comparison is what the solver wanted anyway. A quarter turn is Math.sin(Math.PI / 4).

dofUpperreadonlyoptionalreadonly number[]Upper bounds, in the same units and the same order.