Physics · class
BodySet
Explained in Your first game, Rigid bodies.
class BodySetimport { BodySet } from '@driftengine/physics';Constructor
new
constructor(capacity?: number)| Parameter | Type | Description |
|---|---|---|
capacity? | number |
Properties
| Name | Type | Description |
|---|---|---|
count | number | |
posX | Float32Array | |
posY | Float32Array | |
posZ | Float32Array | |
rotX | Float32Array | |
rotY | Float32Array | |
rotZ | Float32Array | |
rotW | Float32Array | |
velX | Float32Array | |
velY | Float32Array | |
velZ | Float32Array | |
angX | Float32Array | |
angY | Float32Array | |
angZ | Float32Array | |
invMass | Float32Array | |
invInertia | Float32Array | Body-frame inverse inertia, six symmetric terms per body: xx, yy, zz, xy, xz, yz. |
comX | Float32Array | Centre of mass in body frame, which a shape built off-centre has. |
comY | Float32Array | |
comZ | Float32Array | |
friction | Float32Array | |
restitution | Float32Array | |
type | Uint8Array | |
flags | Uint8Array | |
sleepTicks | Uint16Array | |
layer | Uint32Array | |
mask | Uint32Array | |
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| Parameter | Type | Description |
|---|---|---|
desc | BodyDesc |
remove
remove(index: number): numberSwap-remove. Returns the index that moved into index, or −1 if it was the last.
| Parameter | Type | Description |
|---|---|---|
index | number |
worldInverseInertia
worldInverseInertia(index: number, out: Float32Array, at?: number): voidFill out with the world-frame inverse inertia, six symmetric terms.
| Parameter | Type | Description |
|---|---|---|
index | number | |
out | Float32Array | |
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.