Physics · class

BodySet

Explained in Your first game, Rigid bodies.

class BodySet
import { BodySet } from '@driftengine/physics';

Constructor

new

constructor(capacity?: number)
ParameterTypeDescription
capacity?number

Properties

NameTypeDescription
countnumber
posXFloat32Array
posYFloat32Array
posZFloat32Array
rotXFloat32Array
rotYFloat32Array
rotZFloat32Array
rotWFloat32Array
velXFloat32Array
velYFloat32Array
velZFloat32Array
angXFloat32Array
angYFloat32Array
angZFloat32Array
invMassFloat32Array
invInertiaFloat32ArrayBody-frame inverse inertia, six symmetric terms per body: xx, yy, zz, xy, xz, yz.
comXFloat32ArrayCentre of mass in body frame, which a shape built off-centre has.
comYFloat32Array
comZFloat32Array
frictionFloat32Array
restitutionFloat32Array
typeUint8Array
flagsUint8Array
sleepTicksUint16Array
layerUint32Array
maskUint32Array
shape(ConvexShape | undefined)[]
shapes(readonly ConvexShape[] | undefined)[]The parts of a compound body, or undefined where it has a single shape.

Methods

add

add(desc: BodyDesc): number
ParameterTypeDescription
descBodyDesc

remove

remove(index: number): number

Swap-remove. Returns the index that moved into index, or −1 if it was the last.

ParameterTypeDescription
indexnumber

worldInverseInertia

worldInverseInertia(index: number, out: Float32Array, at?: number): void

Fill out with the world-frame inverse inertia, six symmetric terms.

ParameterTypeDescription
indexnumber
outFloat32Array
at?number
More

R · I⁻¹ · Rᵀ, a congruence, rather than a diagonalisation. Storing three principal moments would need an eigen decomposition, and Jacobi is iterative — a fixed sweep count would be deterministic but is one more thing to get exactly right for no gain. What this gives up is six floats per body instead of three and a congruence per substep. What would make it wrong is a measurement showing that congruence dominates the tick.