Documentation
    Preparing search index...

    Interface RigidBodyDocument

    The document RIGID_BODY_SERIALIZER writes — named so a reader can see the shape without decoding the two functions below.

    The optional members are exactly the state §23 lets a body leave to the solver, plus the initial pose §37 lets a descriptor carry; every one of them is written when, and only when, RigidBody.toDescriptor() emits it. See the module header for the authoredness rule that makes that the interesting property of this record.

    interface RigidBodyDocument {
        angularDamping: number;
        angularVelocity: JsonValue;
        animationWeight: number;
        ccdMode: CCDMode;
        ccdPredictionDistance?: number;
        centerOfMass?: JsonValue;
        gravityScale: number;
        inertiaTensor?: JsonValue;
        linearDamping: number;
        linearVelocity: JsonValue;
        mass?: number;
        physicsWeight: number;
        position?: JsonValue;
        rotation?: JsonValue;
        sleeping?: boolean;
        space?: SpaceMode;
        type: BodyType;
    }
    Index
    angularDamping: number

    §23 angular damping coefficient.

    angularVelocity: JsonValue

    Radians per second (§23); only Z is meaningful in a "2d" world (§21).

    animationWeight: number

    §19 animated share of a "blended" pose.

    ccdMode: CCDMode

    §31 continuous-collision method.

    ccdPredictionDistance?: number

    §31 speculative prediction distance, when the body authored one.

    centerOfMass?: JsonValue

    Local-frame centre of mass (§23), present only when authored.

    gravityScale: number

    §23 multiplier on world gravity.

    inertiaTensor?: JsonValue

    Nine column-major elements (§23), present only when authored.

    linearDamping: number

    §23 linear damping coefficient.

    linearVelocity: JsonValue

    Metres per second (§23), refreshed from the solver every step.

    mass?: number

    Kilograms (§23), present only when the mass was authored.

    physicsWeight: number

    §19 solver share of a "blended" pose.

    position?: JsonValue

    The initial world position a descriptor carried (§37), when it did.

    rotation?: JsonValue

    The initial world rotation a descriptor carried (§37), when it did.

    sleeping?: boolean

    §32 sleep state as diagnostics only — written by this serializer, never read by it.

    Recorded so a saved document says whether the body was simulating, and deliberately not applied on load: sleep is solver state (§34), and RigidBody.sleeping is read-only precisely because only a solver report may change it (§23, §32). It earns its bytes when a §79 document is read beside a §34 snapshot of the same moment — "this body reloaded awake because it was asleep when saved" is otherwise unanswerable from the document alone.

    Optional on the read side (decision, 2026-08-07). The write side always emits it, so every document this build produces carries it and no existing file's bytes moved; the type says ? because deserialize ignores the field entirely, so a hand-written or foreign document that omits it is perfectly valid and must not be described as malformed. The alternative considered — dropping the field — would have changed the bytes of every rigid-body document to save nothing that anyone reads a document for.

    space?: SpaceMode

    The §8 space the body is solved in, present only when it is not "world" (PH-12).

    Absent is the default, so every document written before PH-12 reloads unchanged and a "world" body still writes no field. It round-trips even though PhysicsWorld.addBody refuses every non-"world" value: dropping it would turn a body a world refuses into one it silently accepts after a save-and-reload, which is the class of lie §79's authoredness rules exist to prevent.

    type: BodyType

    §22 simulation model. Required: there is no default body type.