Physics · interface

BodyDesc

Explained in Your first game, Rigid bodies.

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

Properties

NameTypeDescription
typereadonlyBodyType
shapereadonlyoptionalConvexShapeThe body's shape, or absent where it is made of several. Exactly one of these two.
More

A body carrying both is refused at addBody, because there is no sensible reading of it: the narrow phase would have to decide which one it meant and either choice is a body that collides as something the caller did not describe.

shapesreadonlyoptionalreadonly ConvexShape[]Several shapes, as one rigid body. What decomposeConvex produces, and where it goes.
More

No offset and no rotation per part, because a ConvexShape is already a point cloud in the body's frame — see vertices above. A decomposition's parts are where they belong the moment they exist, and a field that would always be zero is a field somebody eventually sets wrong. The kinematic Body.parts carries offsets because it wraps shapes built at the origin and placed afterwards; nothing here does that.

Mass is combineMassProperties: volumes added, the centre weighted, each tensor moved to the body's centre by the parallel axis theorem. Contacts are one manifold per touching part, with the part pair folded into every feature id so warm starting cannot confuse two of them.

Refused above MAX_BODY_PARTS, at the call rather than in the tick.

densityreadonlyoptionalnumber
xreadonlyoptionalnumber
yreadonlyoptionalnumber
zreadonlyoptionalnumber
qxreadonlyoptionalnumberUnit quaternion. Defaults to identity.
qyreadonlyoptionalnumber
qzreadonlyoptionalnumber
qwreadonlyoptionalnumber
frictionreadonlyoptionalnumber
restitutionreadonlyoptionalnumber
layerreadonlyoptionalnumberWhich layers this body is on, and which it layersInteract with. 32 bits each.
maskreadonlyoptionalnumber
sensorreadonlyoptionalbooleanA sensor reports overlap and is never pushed out of it.