Physics · interface
Body
Moving body: center position + half extents. Mutated in place by moveAxis.
Explained in Your first game, Rigid bodies.
interface Bodyimport type { Body } from '@driftengine/physics';Properties
| Name | Type | Description |
|---|---|---|
x | number | |
y | number | |
z | number | |
hx | number | |
hy | number | |
hz | number | |
upXoptional | number | Which way is up for this body, as a unit vector. Omitted means world up.MoreA body is a box, and a box has an orientation whether or not anything models one.
Nothing here did: every volume in this module was world-axis, so a body tilted to
lie along a banked deck — which is how a route is drawn and how a character is drawn
standing on it — collided as though it were still standing bolt upright. The
drawn body then reaches outside its own collision volume by roughly
Only the up axis, deliberately. It is what a surface has to give ( Two invariants for anything that sets it: it must be unit length, because
|
upYoptional | number | |
upZoptional | number | |
fwdXoptional | number | Which way this body faces, as a hint. Omitted means +Z, and it is only a hint:
bodyFrame orthogonalises it against up, so a caller with a yaw and a surface
normal does not have to reconcile them itself.MoreMatters only for a body whose cross-section is not square — a box that is wider than it is deep collides differently depending on which way it is turned, and that is exactly the "crossing objects with different orientation" case. |
fwdYoptional | number | |
fwdZoptional | number | |
shapeoptional | ConvexShape | The volume this body really is, in its own frame. Unset means the
hx/hy/hz box, which is also what the shape's absence has always meant. |
partsoptional | readonly BodyPart[] | A body made of parts — a character is a torso, a head, limbs and skates, and
with parts set it collides as exactly those, wherever its frame tilts
them. Takes precedence over shape. Set, not accumulated, like up. |
pivotYoptional | number | Where the frame rotates, as an offset from the centre along local Y.
Unset means the centre; a standing character wants its feet (-hy),
because that is where the drawn body pivots when it leans onto a bank —
a centre-pivoted tilt swings the feet through the floor and buries a
ground-snapped body up to 0.4 m into the very deck it stands on, while a
feet-pivoted one keeps them planted and swings the head, exactly like the
avatar it collides for. Upright bodies are unaffected bit for bit. |
contactSupportoptional | boolean | Whether the contact that stopped the last blocked downward moveAxis
was support — the body arriving on top of a face whose plane is
walkably horizontal — as opposed to a graze against a side, an edge or an
underside. Written by moveAxis on downward Y moves only; true when the
move was not blocked at all.MoreExists because "the fall was stopped" and "the body is standing on something" are different facts, and every rest rule that conflated them let a body hang in mid-air by a skate corner kissing a slab's flank — measured live as a character standing over the void beside a drawn pad, half a metre below its top. A caller that never reads it loses nothing: the resolution itself is unchanged, bit for bit. |
contactRimXoptional | number | The way off a face this body is perched on the rim of, as a horizontal unit vector.
Zero when the last downward move was supported, was not blocked, or was refused for any
other reason.MoreA rim perch's contact normal points straight up and that is not a mistake — up is genuinely the way out of the clamp. It is also of no use to a caller trying to get a body off something it has been told it is not standing on: the only direction that helps is sideways, and which sideways is a fact about the obstacle's footprint that nothing outside the sweep can see. Without it a body could be held in clear air indefinitely. |
contactRimZoptional | number | |
contactNormalXoptional | number | Which way is out of whatever clamped the last blocked moveAxis — a unit
vector pointing from the obstacle toward the body.MoreOnly meaningful on a move that was actually blocked (compare the returned distance with the requested one); left as it was otherwise, so a caller reading it after an unobstructed move is reading history. The sweep has always known this and always discarded it. Written, not accumulated, exactly like |
contactNormalYoptional | number | |
contactNormalZoptional | number |