Documentation
    Preparing search index...

    Interface PhysicsSolverAdapter

    A resource whose lifetime is owned explicitly (§83).

    Not TC39's Disposable. The member is the plain dispose() below, never [Symbol.dispose](). Implementing both is harmless; implementing only [Symbol.dispose] does not satisfy this interface, and disposeAll then throws TypeError: item.dispose is not a function — in a minified build, with the parameter renamed and no §83 marker to search for.

    The warning is repeated on this symbol rather than left in the module header above, because the header does not travel: measured 2026-09-19 from an installed tarball with the TypeScript API, the documentation attached to this symbol — what an editor shows a consumer who hovers Disposable — was the one-line summary alone. A collision note one file away from the name it is about is a note nobody reads.

    interface PhysicsSolverAdapter {
        capabilities: PhysicsCapabilities;
        name: string;
        version: string;
        createBody(desc: RigidBodyDescriptor): PhysicsBodyHandle;
        createCollider(desc: ColliderDescriptor): PhysicsColliderHandle;
        createJoint(desc: JointDescriptor): PhysicsJointHandle;
        createSnapshot?(): ArrayBuffer;
        destroyBody(handle: PhysicsBodyHandle): void;
        destroyCollider(handle: PhysicsColliderHandle): void;
        destroyJoint(handle: PhysicsJointHandle): void;
        dispose(): void;
        drainEvents(): PhysicsEvent[];
        initialize(options: PhysicsWorldOptions): void | Promise<void>;
        overlap(query: OverlapQuery): QueryHit[];
        pointQuery(query: PointQuery): PointHit[];
        raycast(query: RaycastQuery): RaycastHit[];
        restoreSnapshot?(snapshot: ArrayBuffer): void;
        setEventInterest?(interest: PhysicsEventInterest): void;
        shapeCast(query: ShapeCastQuery): ShapeCastHit[];
        step(delta: number): void;
        syncSceneToSolver(): void;
        syncSolverToScene(): void;
    }

    Hierarchy (View Summary)

    Implemented by

    Index
    capabilities: PhysicsCapabilities

    What this adapter can do (§37). Readable before initialize.

    name: string

    Stable identifier of the backing solver, e.g. "rapier2d". Recorded in snapshots and replays (§34), which refuse to run against a different solver.

    version: string

    Version of the backing solver. Part of a snapshot's validity key (§34): a snapshot is opaque adapter data, valid only for the same adapter, adapter version, and world configuration that produced it.

    • Creates a joint and returns its handle (§37, §28).

      desc is the full plan P6-1 discriminated union (WP-6.1); anchors and axes in it are body-local, already converted from the world-space frames the Joint classes are authored in. An adapter that does not build the type it is handed throws FourError("NOT_IMPLEMENTED") and declares that by leaving the type out of capabilities.jointTypes.

      An adapter with joints also implements SolverJointAccess, without which PhysicsWorld.addJoint refuses to register anything: §37's two methods mint and release a handle but cannot answer for the joint afterwards.

      Parameters

      Returns PhysicsJointHandle

    • Serializes the solver's world (§34). Optional in §37, and present only when capabilities.snapshots is true.

      The buffer is opaque adapter data: valid only for the same adapter, the same adapter version, and the same world configuration that produced it. The replay format records the adapter name and version and refuses to run against a different solver (§34).

      Returns ArrayBuffer

    • Destroys a body and everything attached to it (§37).

      The handle is invalid afterwards. §33's checksum orders bodies by an engine-assigned monotonic id precisely so that destruction cannot perturb that order.

      Parameters

      Returns void

    • Destroys a collider (§37). The handle is invalid afterwards.

      Parameters

      Returns void

    • Destroys a joint (§37). The handle is invalid afterwards.

      The physics package destroys a joint before either of its bodies and before disposal, so an adapter never has to guess what a constraint on a dead body means (§83).

      Parameters

      Returns void

    • Releases the solver's world and every resource this adapter owns (§37, §83). Must be idempotent and terminal; handles minted by this adapter are invalid afterwards.

      Returns void

    • Returns and clears the events accumulated during the preceding step (§37).

      Order must be deterministic for a given step. Returning an empty array is normal. The physics package normalizes these into node-facing events (§101) and dispatches them after the step (§6b, §29) — an adapter never calls user code itself.

      Returns PhysicsEvent[]

    • Creates the solver's world from options (§37).

      May return a promise — WebAssembly-backed solvers load their module here — or nothing when the solver is synchronous; §37 allows both, and the physics package awaits the result either way. Calling it twice is an implementation-defined error, not a second world.

      Parameters

      Returns void | Promise<void>

    • Tests a static shape for overlaps (§30). Requires capabilities.queries.overlap.

      Parameters

      Returns QueryHit[]

    • Tests a point (§30). Requires capabilities.queries.point.

      Parameters

      Returns PointHit[]

    • Restores a world previously captured by PhysicsSolverAdapter.createSnapshot (§34). Body identity and ordering survive the round trip, so §33's checksums remain comparable across a restore.

      Parameters

      • snapshot: ArrayBuffer

      Returns void

    • Tells the adapter which derived events anyone is listening for, so it can skip building the ones nobody will read (2026-09-11). Optional and additive: an adapter that omits it behaves as if every interest were true. PhysicsWorld calls it before step whenever the answer changes (never every step), computed from the registered bodies' listener counts.

      Today the one interest is collisionstay: Rapier reports start/end pairs itself, but a stay event is synthesised per touching pair per step (pair key, contact points, world-space vectors), which the physics benchmark attributes most of a piled-body step to. Start/end events, trigger events, the §33 event order, and the solver's own state are not affected — the interest gates translation, never simulation.

      Parameters

      Returns void

    • Advances the simulation by exactly delta seconds (§7a, §10).

      Called once per fixed step with the world's fixed delta; the accumulator, the sub-step clamp, and the dropped time are §10's business, not the adapter's. An adapter must not sub-divide the step on its own except as part of CCD, and must not read a clock to decide how far to advance (§33).

      Parameters

      • delta: number

      Returns void

    • Pushes scene-authored state into the solver (§37): kinematic targets, teleports, and property changes made since the last step.

      Returns void

    • Publishes solved body transforms back to the scene (§37), which the physics package writes under "physics" transform authority (§42).

      Returns void