Physics · interface
MassProperties
A shape's volume, centre of mass and inertia tensor, at a given density.
Explained in Your first game, Rigid bodies.
interface MassPropertiesimport type { MassProperties } from '@driftengine/physics';In depth
Exact for a hull, by tetrahedral decomposition over its face loops — which is why this sits
immediately beside the loops themselves: one build-time addition to ConvexShape pays for both
contact clipping and this, and neither is a separate piece of work.
A rounded hull — radius > 0 with faces — is the Minkowski sum of a hull and a ball, which has
no closed form. Sphere and capsule are handled by the ball case below; anything else with a
radius is approximated by the hull's tensor about the same centre. What that gives up is
accuracy for a heavily rounded hull, where the shell is a large fraction of the volume. What
would make it wrong is a consumer building such a shape and caring how it tumbles, at which
point the answer is a numerical integration over the support function rather than a fudge factor.
Build-time only, like everything else in shape.ts: nothing here may be called per tick.
Properties
| Name | Type | Description |
|---|---|---|
volume | number | |
comX | number | |
comY | number | |
comZ | number | |
ixx | number | The tensor about the centre of mass. Six independent terms, symmetric. |
iyy | number | |
izz | number | |
ixy | number | |
ixz | number | |
iyz | number |