@ignifx/physics 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["specifier"],"sources":["../src/runtime/runtime-key.ts","../src/components/rigidbody.ts","../src/components/character-controller.ts","../src/errors.ts","../src/material.ts","../src/components/collider.ts","../src/lite/havok.ts","../src/components/colliders.ts","../src/lite/havok-module.ts","../src/runtime/host.ts","../src/lite/character.ts","../src/runtime/runtime.ts","../src/runtime/systems.ts","../src/lite/gpu/viewer.ts","../src/lite/queries.ts","../src/service.ts","../src/settings.ts","../src/extension.ts","../src/schemas.ts"],"sourcesContent":["import { createServiceKey } from \"@ignifx/core\";\nimport type { PhysicsHost } from \"./host.js\";\nimport type { ServiceNameKey } from \"@ignifx/core\";\n\n/**\n * The key the extension registers its runtime holder under, so that `Rigidbody`, the colliders, and\n * `CharacterController` can reach the runtime from `this.app.services` without a module-level\n * singleton (`CONSTITUTION.md` §3.6: no globals, two apps in one process).\n *\n * The **holder** is registered rather than the runtime itself, because everything an extension\n * contributes is declared in `register` (`docs/architecture/04-extensions.md` §1) and the runtime\n * does not exist until `onStart`.\n *\n * @internal\n */\nexport const PhysicsHostKey: ServiceNameKey<PhysicsHost> = createServiceKey<PhysicsHost>(\"@ignifx/physics:host\");\n","import { bool, Component, createDefaults, defineSchema, enumOf, f32, record, Vec3 } from \"@ignifx/core\";\nimport { PhysicsHostKey } from \"../runtime/runtime-key.js\";\nimport type { LitePhysicsBody } from \"../lite/havok.js\";\nimport type { PhysicsRuntime } from \"../runtime/runtime.js\";\nimport type { ComponentHooks, MutableVec3, QuatLike, Schema, Vec3Like } from \"@ignifx/core\";\n\n/**\n * Simulate colliders on a root entity; parented bodies log `IGX-0907` because backend pose writes\n * are local. Collision events default to `auto`, following attached callbacks.\n * Velocity limits are world settings; per-body damping, gravity factors, sleep thresholds, and\n * explicit wake-up are unavailable in the pinned Lite adapter.\n */\n\n/**\n * How a body moves.\n *\n * @public\n */\nexport const BODY_TYPES = [\"dynamic\", \"kinematic\", \"static\"] as const;\n\n/**\n * The union of {@link BODY_TYPES}.\n *\n * @public\n */\nexport type BodyType = (typeof BODY_TYPES)[number];\n\n/**\n * Whether a body's display pose is interpolated between fixed steps.\n *\n * @public\n */\nexport const INTERPOLATION_MODES = [\"none\", \"interpolate\"] as const;\n\n/**\n * The union of {@link INTERPOLATION_MODES}.\n *\n * @public\n */\nexport type InterpolationMode = (typeof INTERPOLATION_MODES)[number];\n\n/**\n * Whether collision callbacks are delivered for this body.\n *\n * @public\n */\nexport const COLLISION_EVENT_MODES = [\"auto\", \"on\", \"off\"] as const;\n\n/**\n * The union of {@link COLLISION_EVENT_MODES}.\n *\n * @public\n */\nexport type CollisionEventMode = (typeof COLLISION_EVENT_MODES)[number];\n\n/**\n * How a moved kinematic node reaches Havok.\n *\n * @public\n */\nexport const KINEMATIC_SYNC_MODES = [\"teleport\", \"velocity\"] as const;\n\n/**\n * The union of {@link KINEMATIC_SYNC_MODES}.\n *\n * @public\n */\nexport type KinematicSyncMode = (typeof KINEMATIC_SYNC_MODES)[number];\n\n/**\n * Whether each rotation axis is frozen.\n *\n * @public\n */\nexport interface FreezeRotation {\n /** Freeze rotation about X. */\n readonly x: boolean;\n /** Freeze rotation about Y. */\n readonly y: boolean;\n /** Freeze rotation about Z. */\n readonly z: boolean;\n}\n\n/**\n * The Babylon Lite objects a `Rigidbody` owns. Unstable escape hatch\n * (`docs/architecture/00-overview.md` §3).\n *\n * @public\n */\nexport interface RigidbodyLiteHandles {\n /** The Havok body, or `null` before the first fixed step has built it. */\n readonly body: LitePhysicsBody | null;\n}\n\n/**\n * Makes an entity's colliders a Havok body (`09-physics.md` §2.1).\n *\n * @example\n * ```ts\n * const crate = world.createEntity(\"Crate\");\n * crate.transform.position = { x: 0, y: 5, z: 0 };\n * crate.addComponent(BoxCollider, { size: { x: 1, y: 1, z: 1 } });\n * crate.addComponent(Rigidbody, { mass: 2 });\n * ```\n *\n * @public\n */\nexport class Rigidbody extends Component implements ComponentHooks {\n /** The namespaced registration id. */\n static typeId = \"ignifx/Rigidbody\";\n\n /** One body per entity. */\n static allowMultiple = false;\n\n /** The serialized field declarations (ADR-0004). */\n static schema: Schema = rigidbodySchema();\n\n declare bodyType: BodyType;\n\n declare mass: number;\n\n declare startAsleep: boolean;\n\n declare freezeRotation: FreezeRotation;\n\n declare interpolation: InterpolationMode;\n\n declare collisionEvents: CollisionEventMode;\n\n declare kinematicSync: KinematicSyncMode;\n\n /** Applies the schema defaults, exactly as `Component.define` would. */\n constructor() {\n super();\n Object.assign(this, createDefaults(Rigidbody.schema));\n }\n\n /** Marks the entity's body for a rebuild at the start of the next fixed step. */\n onAttach(): void {\n this.rebuild();\n }\n\n /** Marks the entity's body for a rebuild, which turns it back into an implicit static body. */\n onDetach(): void {\n this.rebuild();\n }\n\n /**\n * Rebuilds the body at the start of the next fixed step. Call it after changing `bodyType`,\n * `mass`, `freezeRotation`, or the entity's scale.\n */\n rebuild(): void {\n this.#runtime()?.markDirty(this.entity);\n }\n\n /**\n * The Babylon Lite handles this component owns.\n *\n * @returns The Havok body, or `null` before the first fixed step built it.\n */\n get lite(): RigidbodyLiteHandles {\n return { body: this.#runtime()?.bodyHandleOf(this.entity) ?? null };\n }\n\n /**\n * The body's linear velocity in metres per second.\n *\n * @returns A freshly allocated vector; use {@link Rigidbody.linearVelocityToRef} in hot code.\n */\n get linearVelocity(): Vec3 {\n const out = new Vec3();\n this.linearVelocityToRef(out);\n return out;\n }\n\n /**\n * Replaces the body's linear velocity.\n *\n * @param value - Metres per second, world space.\n */\n set linearVelocity(value: Vec3Like) {\n this.#runtime()?.setLinearVelocity(this.entity, value);\n }\n\n /**\n * Reads the linear velocity without allocating.\n *\n * @param out - The vector to write.\n * @returns `out`.\n */\n linearVelocityToRef(out: MutableVec3): MutableVec3 {\n this.#runtime()?.readLinear(this.entity, out);\n return out;\n }\n\n /**\n * The body's angular velocity in radians per second.\n *\n * @returns A freshly allocated vector; use {@link Rigidbody.angularVelocityToRef} in hot code.\n */\n get angularVelocity(): Vec3 {\n const out = new Vec3();\n this.angularVelocityToRef(out);\n return out;\n }\n\n /**\n * Replaces the body's angular velocity.\n *\n * @param value - Radians per second, world space.\n */\n set angularVelocity(value: Vec3Like) {\n this.#runtime()?.setAngularVelocity(this.entity, value);\n }\n\n /**\n * Reads the angular velocity without allocating.\n *\n * @param out - The vector to write.\n * @returns `out`.\n */\n angularVelocityToRef(out: MutableVec3): MutableVec3 {\n this.#runtime()?.readAngular(this.entity, out);\n return out;\n }\n\n /**\n * Applies a force for one fixed step. Call it from `fixedUpdate`.\n *\n * @param force - Newtons, world space.\n * @param point - Where to apply it; defaults to the entity's world position.\n *\n * @example\n * ```ts\n * fixedUpdate(): void {\n * this.body.addForce({ x: 0, y: 20, z: 0 });\n * }\n * ```\n */\n addForce(force: Vec3Like, point?: Vec3Like): void {\n this.#runtime()?.addForce(this.entity, force, point ?? this.transform.position);\n }\n\n /**\n * Applies an instantaneous impulse.\n *\n * @param impulse - Newton-seconds, world space.\n * @param point - Where to apply it; defaults to the entity's world position.\n */\n addImpulse(impulse: Vec3Like, point?: Vec3Like): void {\n this.#runtime()?.addImpulse(this.entity, impulse, point ?? this.transform.position);\n }\n\n /**\n * Moves the body without integrating a velocity, and resets the interpolation history so the\n * display pose does not slide across the gap.\n *\n * @param position - The new world position.\n * @param rotation - The new world rotation; defaults to the current one.\n */\n teleport(position: Vec3Like, rotation?: QuatLike): void {\n this.#runtime()?.teleport(this.entity, position, rotation ?? this.transform.rotation);\n }\n\n /**\n * The runtime, or `null` when the extension is not registered on this app.\n *\n * @returns The runtime.\n */\n #runtime(): PhysicsRuntime | null {\n return this.app.services.tryGet(PhysicsHostKey)?.runtime ?? null;\n }\n}\n\n/**\n * Builds the `Rigidbody` schema.\n *\n * @returns The schema.\n */\nfunction rigidbodySchema(): Schema {\n return defineSchema({\n bodyType: enumOf(BODY_TYPES, \"dynamic\"),\n mass: f32(1, { min: 0 }),\n startAsleep: bool(false),\n freezeRotation: record({ x: bool(false), y: bool(false), z: bool(false) }),\n interpolation: enumOf(INTERPOLATION_MODES, \"interpolate\"),\n collisionEvents: enumOf(COLLISION_EVENT_MODES, \"auto\"),\n kinematicSync: enumOf(KINEMATIC_SYNC_MODES, \"teleport\"),\n });\n}\n","import { Component, createDefaults, defineSchema, enumOf, f32, Signal, Vec3, vec3 } from \"@ignifx/core\";\nimport { PhysicsHostKey } from \"../runtime/runtime-key.js\";\nimport { INTERPOLATION_MODES } from \"./rigidbody.js\";\nimport type { CharacterCollision } from \"../events.js\";\nimport type { InterpolationMode } from \"./rigidbody.js\";\nimport type { PhysicsRuntime } from \"../runtime/runtime.js\";\nimport type { ComponentHooks, Schema, Vec3Like } from \"@ignifx/core\";\n\n/**\n * Sum `move` displacements during `fixedUpdate` and apply them in the physics step.\n * The controller owns world position after the step; game code owns rotation and gravity.\n * `supportState` is the last step's result. `pushStrength` scales Lite's default strength, not newtons.\n */\n\n/**\n * How the character is supported by whatever is under it.\n *\n * @public\n */\nexport const SUPPORT_STATES = [\"unsupported\", \"sliding\", \"supported\"] as const;\n\n/**\n * The union of {@link SUPPORT_STATES}.\n *\n * @public\n */\nexport type SupportStateName = (typeof SUPPORT_STATES)[number];\n\n/**\n * A kinematic capsule that walks, slides, and pushes (`09-physics.md` §2.3).\n *\n * @example\n * ```ts\n * class Walk extends Script implements ScriptCallbacks {\n * static typeId = \"mygame/Walk\";\n * fixedUpdate(dt: number): void {\n * const controller = this.entity.requireComponent(CharacterController);\n * controller.move({ x: 2 * dt, y: 0, z: 0 });\n * }\n * }\n * ```\n *\n * @public\n */\nexport class CharacterController extends Component implements ComponentHooks {\n /** The namespaced registration id. */\n static typeId = \"ignifx/CharacterController\";\n\n /** One controller per entity. */\n static allowMultiple = false;\n\n /** The serialized field declarations (ADR-0004). */\n static schema: Schema = characterSchema();\n\n declare radius: number;\n\n declare height: number;\n\n declare center: Vec3Like;\n\n declare slopeLimit: number;\n\n declare skinWidth: number;\n\n declare pushStrength: number;\n\n declare interpolation: InterpolationMode;\n\n /** The displacement requested so far this fixed step. */\n readonly #pendingMove = new Vec3();\n\n /** The averaged normal of the supporting surface, written by the step system. */\n readonly #groundNormal = new Vec3(0, 1, 0);\n\n /** How the character was supported at the end of the last step. */\n #supportState: SupportStateName = \"unsupported\";\n\n /** Emitted for every dynamic body the character pushed; created on first access. */\n #onCollided: Signal<CharacterCollision> | null = null;\n\n /** Applies the schema defaults. */\n constructor() {\n super();\n Object.assign(this, createDefaults(CharacterController.schema));\n }\n\n /** Creates the Lite controller at the start of the next fixed step. */\n onAttach(): void {\n this.rebuild();\n }\n\n /** Releases the Lite controller. */\n onDetach(): void {\n this.#runtime()?.releaseController(this);\n }\n\n /** Rebuilds the capsule at the start of the next fixed step. */\n rebuild(): void {\n this.#runtime()?.markControllerDirty(this);\n }\n\n /**\n * Requests a displacement for this fixed step. Displacements accumulate until the step runs.\n *\n * @param displacement - The world-space displacement to attempt.\n */\n move(displacement: Vec3Like): void {\n this.#pendingMove.set(\n this.#pendingMove.x + displacement.x,\n this.#pendingMove.y + displacement.y,\n this.#pendingMove.z + displacement.z,\n );\n }\n\n /**\n * Sets the controller's velocity, which is what `integrate` advances.\n *\n * @param velocity - Metres per second, world space.\n */\n setVelocity(velocity: Vec3Like): void {\n this.#runtime()?.setControllerVelocity(this, velocity);\n }\n\n /**\n * The controller's current velocity.\n *\n * @returns A freshly allocated vector.\n */\n get velocity(): Vec3 {\n const out = new Vec3();\n this.#runtime()?.readControllerVelocity(this, out);\n return out;\n }\n\n /**\n * Whether the character is standing on a walkable surface.\n *\n * @returns `true` when the last step's probe reported `supported`.\n */\n get isGrounded(): boolean {\n return this.#supportState === \"supported\";\n }\n\n /**\n * How the character was supported at the end of the last step.\n *\n * @returns `\"unsupported\"`, `\"sliding\"`, or `\"supported\"`.\n */\n get supportState(): SupportStateName {\n return this.#supportState;\n }\n\n /**\n * The averaged normal of the supporting surface.\n *\n * @returns A live view; copy it if you keep it.\n */\n get groundNormal(): Vec3 {\n return this.#groundNormal;\n }\n\n /**\n * Emitted once per dynamic body the character pushed during a step.\n *\n * @returns The signal, created on first access.\n */\n get onCollided(): Signal<CharacterCollision> {\n this.#onCollided ??= new Signal<CharacterCollision>();\n return this.#onCollided;\n }\n\n /**\n * Changes the capsule height without losing the controller's state — the crouch primitive.\n *\n * @param height - The new total height, tip to tip.\n * @param preserveFeet - Whether the foot position stays fixed; defaults to `true`.\n */\n setHeight(height: number, preserveFeet: boolean = true): void {\n this.height = height;\n this.#runtime()?.resizeController(this, preserveFeet);\n }\n\n /**\n * Teleports the character, clearing any swept motion and the interpolation history.\n *\n * @param position - The new world position of the entity.\n */\n teleport(position: Vec3Like): void {\n this.#runtime()?.teleportController(this, position);\n }\n\n /**\n * The displacement requested so far this step, consumed by the step system.\n *\n * @returns A live view of the accumulator.\n *\n * @internal\n */\n takePendingMove(): Vec3 {\n return this.#pendingMove;\n }\n\n /**\n * Records the outcome of a step.\n *\n * @param state - The support classification.\n * @param normal - The averaged supporting normal.\n *\n * @internal\n */\n applyStepResult(state: SupportStateName, normal: Vec3Like): void {\n this.#supportState = state;\n this.#groundNormal.set(normal.x, normal.y, normal.z);\n this.#pendingMove.set(0, 0, 0);\n }\n\n /**\n * Emits `onCollided` if anything is listening.\n *\n * @param collision - The push to report.\n *\n * @internal\n */\n reportPush(collision: CharacterCollision): void {\n this.#onCollided?.emit(collision);\n }\n\n /**\n * The runtime, or `null` when the extension is not registered on this app.\n *\n * @returns The runtime.\n */\n #runtime(): PhysicsRuntime | null {\n return this.app.services.tryGet(PhysicsHostKey)?.runtime ?? null;\n }\n}\n\n/**\n * Builds the `CharacterController` schema.\n *\n * @returns The schema.\n */\nfunction characterSchema(): Schema {\n return defineSchema({\n radius: f32(0.4, { min: 0 }),\n height: f32(1.8, { min: 0 }),\n center: vec3(),\n slopeLimit: f32(45, { min: 0, max: 90 }),\n skinWidth: f32(0.05, { min: 0 }),\n pushStrength: f32(1, { min: 0 }),\n interpolation: enumOf(INTERPOLATION_MODES, \"interpolate\"),\n });\n}\n","import { IgnifxError } from \"@ignifx/core\";\nimport type { ErrorContext } from \"@ignifx/core\";\n\n/**\n * The diagnostic codes `@ignifx/physics` owns. The package sits in the `09` subsystem range of\n * `docs/architecture/15-devtools-and-diagnostics.md` §1, so every code reads `IGX-09##`.\n *\n * The table lives here rather than in `@ignifx/core`'s `CoreErrorCode`: an extension owns its own\n * codes and hands them to the app through `ExtensionContext.registerErrorCodes`\n * (`docs/architecture/04-extensions.md` §3).\n */\n\n/**\n * Every diagnostic code `@ignifx/physics` can throw or report, keyed by an intention-revealing name\n * so call sites read as prose and the compiler catches typos (coding standards §5.2).\n *\n * @example\n * ```ts\n * throw physicsError(PhysicsErrorCode.queryBeforeStep, \"raycast() ran before the first step.\", {\n * context: { query: \"raycast\" },\n * });\n * ```\n *\n * @public\n */\nexport const PhysicsErrorCode = {\n /** An entity with colliders but no `Rigidbody` moved after its implicit static body was placed. */\n movedStaticBody: \"IGX-0901\",\n /** A query ran before the first completed fixed step, so Havok has no broadphase yet. */\n queryBeforeStep: \"IGX-0902\",\n /** The Havok WebAssembly module could not be loaded. */\n havokUnavailable: \"IGX-0903\",\n /** A `.physicsmaterial.json` file is not an `ignifx.physicsmaterial` document this build reads. */\n invalidMaterialFile: \"IGX-0904\",\n /** The `physics.collisionMatrix` setting names a layer the project does not declare. */\n unknownLayer: \"IGX-0905\",\n /** A `MeshCollider` has no geometry to build a shape from. */\n colliderGeometryUnavailable: \"IGX-0906\",\n /** A physics body was built for an entity that has a parent, whose node pose is not world space. */\n bodyOnChildEntity: \"IGX-0907\",\n // IGX-0908 is retired: it was the ADR-0013 collision drain's guard, removed with the drain.\n // Do not reuse it, so an old log or bug report never points at the wrong failure.\n} as const;\n\n/**\n * The union of the codes the `PhysicsErrorCode` table declares.\n *\n * @public\n */\nexport type PhysicsErrorCode = (typeof PhysicsErrorCode)[keyof typeof PhysicsErrorCode];\n\n/**\n * The one-line message template of every code, as `ExtensionContext.registerErrorCodes` wants it.\n * Context keys appear in braces, matching the core table's convention.\n *\n * @public\n */\nexport const PHYSICS_ERROR_MESSAGES: Readonly<Record<string, string>> = Object.freeze({\n \"IGX-0901\": \"{entity} has colliders but no Rigidbody, and it moved after its static body was placed.\",\n \"IGX-0902\": \"{query} needs at least one completed fixed step before Havok can answer it.\",\n \"IGX-0903\": \"The Havok WebAssembly module could not be loaded from {url}.\",\n \"IGX-0904\": \"{file} is not an ignifx.physicsmaterial document this build can read.\",\n \"IGX-0905\": \"physics.collisionMatrix names the layer {layer}, which the project does not declare.\",\n \"IGX-0906\": \"{entity} has a MeshCollider with no geometry to build a shape from.\",\n \"IGX-0907\": \"{entity} carries a physics body but is not a root entity; Havok writes its local pose.\",\n});\n\n/**\n * Options accepted by {@link physicsError}: the same subset of `IgnifxErrorOptions` this package\n * uses.\n *\n * @public\n */\nexport interface PhysicsErrorOptions {\n /** Identifiers that locate the failure. */\n readonly context?: ErrorContext;\n /** One sentence telling the developer what to do about it. */\n readonly hint?: string;\n /** The failure being wrapped, when there is one. */\n readonly cause?: unknown;\n}\n\n/**\n * Builds an `IgnifxError` carrying one of this package's codes.\n *\n * @param code - The code from the `PhysicsErrorCode` table.\n * @param message - The actionable development sentence.\n * @param options - Context identifiers, a remedy hint, and the wrapped cause.\n * @returns The error to throw or to reject with.\n *\n * @example\n * ```ts\n * throw physicsError(PhysicsErrorCode.unknownLayer, \"physics.collisionMatrix names Enemy.\", {\n * context: { layer: \"Enemy\" },\n * });\n * ```\n *\n * @public\n */\nexport function physicsError(code: PhysicsErrorCode, message: string, options?: PhysicsErrorOptions): IgnifxError {\n return new IgnifxError(code, message, {\n ...(options?.context === undefined ? {} : { context: options.context }),\n ...(options?.hint === undefined ? {} : { hint: options.hint }),\n ...(options?.cause === undefined ? {} : { cause: options.cause }),\n });\n}\n","import { PhysicsErrorCode, physicsError } from \"./errors.js\";\nimport type { PhysicsMaterialValues } from \"./settings.js\";\nimport type { AssetLoader, JsonObject, JsonValue, LoaderContext, SchemaDescription } from \"@ignifx/core\";\n\n/**\n * The `ignifx.physicsmaterial` asset (`docs/architecture/09-physics.md` §2.4,\n * `05-assets-and-loading.md` §5): a surface's friction and bounciness, saved next to the scene that\n * uses it so an artist can retune a floor without touching code.\n */\n\n/**\n * The asset type name `.physicsmaterial.json` addresses resolve to.\n *\n * @public\n */\nexport const PHYSICS_MATERIAL_ASSET_TYPE = \"physicsmaterial\";\n\n/**\n * The address suffix that selects the loader.\n *\n * @public\n */\nexport const PHYSICS_MATERIAL_FILE_EXTENSION = \".physicsmaterial.json\";\n\n/**\n * The `format` string every physics-material document declares.\n *\n * @public\n */\nexport const PHYSICS_MATERIAL_FILE_FORMAT = \"ignifx.physicsmaterial\";\n\n/**\n * The file format version; `1` before ignifx 1.0.\n *\n * @public\n */\nexport const PHYSICS_MATERIAL_FORMAT_VERSION = 1;\n\n/**\n * A loaded surface material. The values are the ones Havok's `setPhysicsShapeMaterial` takes\n * (`index.d.ts` 10853).\n *\n * @example\n * ```ts\n * const ice = await app.assets.load<PhysicsMaterial>(\"materials/ice.physicsmaterial.json\");\n * floor.addComponent(BoxCollider, { size: { x: 10, y: 1, z: 10 }, material: ice });\n * ```\n *\n * @public\n */\nexport class PhysicsMaterial implements PhysicsMaterialValues {\n /** The asset type token, so `asset(PhysicsMaterial)` fields resolve. */\n static assetType: string = PHYSICS_MATERIAL_ASSET_TYPE;\n\n /** A human-readable name, used in diagnostics. */\n readonly name: string;\n\n /** The dynamic friction coefficient. */\n readonly friction: number;\n\n /** The static friction coefficient. */\n readonly staticFriction: number;\n\n /** How much of the approach speed is returned, `0` to `1`. */\n readonly restitution: number;\n\n /**\n * Wraps parsed values. The loader constructs these; game code uses\n * {@link PhysicsMaterial.fromValues} when it wants one in code.\n *\n * @param name - A human-readable name.\n * @param values - Friction, static friction, and restitution.\n */\n constructor(name: string, values: PhysicsMaterialValues) {\n this.name = name;\n this.friction = values.friction;\n this.staticFriction = values.staticFriction;\n this.restitution = values.restitution;\n }\n\n /**\n * Builds a material in code, filling in the fields the caller omitted.\n *\n * @param name - A human-readable name.\n * @param values - Any subset of the three coefficients.\n * @returns The material.\n *\n * @example\n * ```ts\n * const bouncy = PhysicsMaterial.fromValues(\"bouncy\", { restitution: 0.9 });\n * ```\n */\n static fromValues(name: string, values: Partial<PhysicsMaterialValues>): PhysicsMaterial {\n const friction = values.friction ?? 0.6;\n return new PhysicsMaterial(name, {\n friction,\n staticFriction: values.staticFriction ?? friction,\n restitution: values.restitution ?? 0,\n });\n }\n}\n\n/**\n * Builds the loader for `.physicsmaterial.json` files.\n *\n * @returns The loader, ready for `ctx.registerAssetLoader`.\n *\n * @public\n */\nexport function createPhysicsMaterialLoader(): AssetLoader<PhysicsMaterial> {\n return {\n type: PHYSICS_MATERIAL_ASSET_TYPE,\n extensions: [PHYSICS_MATERIAL_FILE_EXTENSION],\n load: async (ctx: LoaderContext): Promise<PhysicsMaterial> => {\n const document = await ctx.fetchJson<JsonValue>();\n return parsePhysicsMaterial(ctx.address, document);\n },\n };\n}\n\n/**\n * Parses one `ignifx.physicsmaterial` document.\n *\n * @param address - The address it came from, for the diagnostic.\n * @param document - The parsed JSON.\n * @returns The material.\n * @throws IgnifxError with code `IGX-0904` when the document is not one this build can read.\n *\n * @public\n */\nexport function parsePhysicsMaterial(address: string, document: JsonValue): PhysicsMaterial {\n const object = asObject(document);\n if (object === null || object[\"format\"] !== PHYSICS_MATERIAL_FILE_FORMAT) {\n throw physicsError(PhysicsErrorCode.invalidMaterialFile, `${address} is not an ${PHYSICS_MATERIAL_FILE_FORMAT}.`, {\n context: { file: address },\n hint: `Add \"format\": \"${PHYSICS_MATERIAL_FILE_FORMAT}\" to the document.`,\n });\n }\n const version = numberAt(object, \"formatVersion\", PHYSICS_MATERIAL_FORMAT_VERSION);\n if (version > PHYSICS_MATERIAL_FORMAT_VERSION) {\n throw physicsError(PhysicsErrorCode.invalidMaterialFile, `${address} is version ${String(version)}.`, {\n context: { file: address, version },\n hint: \"Upgrade @ignifx/physics, or re-save the material from this version of the editor.\",\n });\n }\n const friction = numberAt(object, \"friction\", 0.6);\n const name = typeof object[\"name\"] === \"string\" ? object[\"name\"] : address;\n return new PhysicsMaterial(name, {\n friction,\n staticFriction: numberAt(object, \"staticFriction\", friction),\n restitution: numberAt(object, \"restitution\", 0),\n });\n}\n\n/**\n * Describes the `ignifx.physicsmaterial` file format for the documentation harness\n * (`docs/architecture/16-docs-harness-and-skill.md` §3).\n *\n * @returns The description of the top-level file fields.\n *\n * @public\n */\nexport function describePhysicsMaterialFileFormat(): SchemaDescription {\n return {\n title: \"Physics material file\",\n format: PHYSICS_MATERIAL_FILE_FORMAT,\n description: \"A surface's friction and bounciness, referenced by a collider's material field.\",\n fields: {\n format: {\n kind: \"str\",\n default: PHYSICS_MATERIAL_FILE_FORMAT,\n description: `Always \"${PHYSICS_MATERIAL_FILE_FORMAT}\".`,\n },\n formatVersion: {\n kind: \"u32\",\n default: PHYSICS_MATERIAL_FORMAT_VERSION,\n description: \"The file format version; 1 before ignifx 1.0.\",\n },\n name: { kind: \"str\", default: \"\", description: \"A human-readable name; defaults to the address.\" },\n friction: { kind: \"f32\", default: 0.6, description: \"The dynamic friction coefficient.\" },\n staticFriction: {\n kind: \"f32\",\n default: 0.6,\n description: \"The static friction coefficient; defaults to friction.\",\n },\n restitution: { kind: \"f32\", default: 0, description: \"How much approach speed is returned, 0 to 1.\" },\n },\n };\n}\n\n/**\n * Views a JSON value as an object.\n *\n * @param value - The parsed JSON.\n * @returns The object, or `null` when the value is not one.\n */\nfunction asObject(value: JsonValue): JsonObject | null {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return null;\n }\n // The guard above is exactly `JsonObject` — an object\n // that is neither `null` nor an array — which is what `JsonValue` leaves in the union.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return value as JsonObject;\n}\n\n/**\n * Reads a numeric property, tolerating its absence.\n *\n * @param object - The document.\n * @param key - The property name.\n * @param fallback - What to use when the property is missing or not a number.\n * @returns The value.\n */\nfunction numberAt(object: JsonObject, key: string, fallback: number): number {\n const value = object[key];\n return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n","import { asset, bool, Component, createDefaults, optional, record, str, vec3, f32 } from \"@ignifx/core\";\nimport { PhysicsMaterial } from \"../material.js\";\nimport { PhysicsHostKey } from \"../runtime/runtime-key.js\";\nimport type { LitePhysicsShape, LitePhysicsWorld } from \"../lite/havok.js\";\nimport type { PhysicsMaterialValues } from \"../settings.js\";\nimport type { AssetHandle, ComponentHooks, LiteSceneNode, MutableVec3, Schema, Vec3Like } from \"@ignifx/core\";\n\n/**\n * Collider dimensions use local units and the entity's scale at build time; call `rebuild` after\n * changing scale. Material assets take precedence over inline material, then project defaults.\n */\n\n/**\n * The fields every collider declares. It is a function because a field kind is a function call and\n * module scope holds declarations only (`CONSTITUTION.md` §3.5).\n *\n * @returns The shared field declarations, ready to spread into a collider's own schema.\n *\n * @public\n */\nexport function colliderFields(): Schema {\n return {\n center: vec3(),\n isTrigger: bool(false),\n material: asset(PhysicsMaterial),\n inlineMaterial: optional(\n record({\n friction: f32(0.6, { min: 0 }),\n staticFriction: f32(0.6, { min: 0 }),\n restitution: f32(0, { min: 0, max: 1 }),\n }),\n ),\n layerOverride: str(\"\"),\n };\n}\n\n/**\n * The base class of every collider. It is never registered on its own; `entity.getComponents` and\n * `world.components` accept it because the concrete colliders extend it.\n *\n * @public\n */\nexport abstract class Collider extends Component implements ComponentHooks {\n /** Several colliders on one entity form one compound body (`09-physics.md` §2.2). */\n static allowMultiple = true;\n\n /** The shape's offset from the entity origin, in local units. */\n declare center: Vec3Like;\n\n /** When `true` the shape reports overlaps and resolves no contacts. */\n declare isTrigger: boolean;\n\n /** A `.physicsmaterial.json` reference; wins over {@link Collider.inlineMaterial}. */\n declare material: AssetHandle<PhysicsMaterial> | null;\n\n /** An inline surface, used when {@link Collider.material} is `null`. */\n declare inlineMaterial: PhysicsMaterialValues | null;\n\n /** The name of the layer this collider filters as, or `\"\"` to use `entity.layer`. */\n declare layerOverride: string;\n\n /**\n * Applies the shared defaults. A concrete collider calls `super()` and then applies its own.\n */\n constructor() {\n super();\n Object.assign(this, createDefaults(colliderFields()));\n }\n\n /** Marks the entity's body for a rebuild at the start of the next fixed step. */\n onAttach(): void {\n this.rebuild();\n }\n\n /** Marks the entity's body for a rebuild, which removes this collider from it. */\n onDetach(): void {\n this.rebuild();\n }\n\n /**\n * Rebuilds the entity's body and shapes at the start of the next fixed step. Call it after\n * changing a size, a `center`, `isTrigger`, or the entity's scale.\n *\n * @example\n * ```ts\n * box.size = { x: 2, y: 2, z: 2 };\n * box.rebuild();\n * ```\n */\n rebuild(): void {\n this.app.services.tryGet(PhysicsHostKey)?.runtime?.markDirty(this.entity);\n }\n\n /**\n * Resolves the surface this collider presents to Havok.\n *\n * @param fallback - The world's `physics.defaultMaterial`.\n * @returns The asset's values, the inline values, or the fallback.\n */\n resolveMaterial(fallback: PhysicsMaterialValues): PhysicsMaterialValues {\n return this.material?.value ?? this.inlineMaterial ?? fallback;\n }\n\n /**\n * Builds the Havok shape this collider stands for.\n *\n * @param world - The Havok world.\n * @param scale - The entity's lossy scale.\n * @param node - The entity's Lite node, for the colliders that read geometry from it.\n * @returns The shape handle.\n *\n * @internal\n */\n abstract createShape(world: LitePhysicsWorld, scale: Vec3Like, node: LiteSceneNode): LitePhysicsShape;\n\n /**\n * Writes the half-extents of this collider's local bounding box, scale applied. The service's\n * `overlap` and `shapeCast` use it to resolve entities that Lite's queries do not identify.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The vector to write.\n *\n * @internal\n */\n abstract halfExtentsToRef(scale: Vec3Like, out: MutableVec3): void;\n}\n","import {\n addPhysicsShapeChild,\n applyPhysicsBodyForce,\n applyPhysicsBodyImpulse,\n createHavokWorld,\n createHeightFieldShape,\n createNullEngine,\n createPhysicsBody,\n createPhysicsShape,\n createSceneContext,\n disposePhysics,\n disposeScene,\n getPhysicsBodyAngularVelocity,\n getPhysicsBodyLinearVelocity,\n lockPhysicsBodyRotationAxes,\n onPhysicsAfterStep,\n onPhysicsCollision,\n onPhysicsTriggerBodies,\n releasePhysicsShape,\n removePhysicsBody,\n setPhysicsBodyAngularVelocity,\n setPhysicsBodyCollisionEventsEnabled,\n setPhysicsBodyLinearVelocity,\n setPhysicsBodyMass,\n setPhysicsBodyPrestepType,\n setPhysicsBodyShape,\n setPhysicsBodyTransform,\n setPhysicsGravity,\n setPhysicsShapeFilterCollideMask,\n setPhysicsShapeFilterMembershipMask,\n setPhysicsShapeIsTrigger,\n setPhysicsShapeMaterial,\n setPhysicsTimestep,\n setPhysicsVelocityLimits,\n stepScene,\n unlockPhysicsBodyRotationAxes,\n} from \"@babylonjs/lite\";\nimport type { PhysicsBody, PhysicsRotationAxis, PhysicsShape, PhysicsWorld } from \"@babylonjs/lite\";\nimport type { LiteEngine, LiteScene, LiteSceneNode, MutableQuat, MutableVec3, QuatLike, Vec3Like } from \"@ignifx/core\";\n\n/**\n * The Havok half of this package's Babylon Lite adapter (ADR-0002, ADR-0003,\n * `docs/architecture/09-physics.md` §1). Every `@babylonjs/lite` symbol the extension uses is named\n * here once, so the rest of `src/` never imports Lite (`ignifx/no-lite-outside-adapter`).\n *\n * ## Facts verified against `@babylonjs/lite@1.27.0`\n *\n * - `createHavokWorld(scene, hknp, gravity)` (`index.d.ts` 2592, `lib/physics/havok.js:44`) unshifts\n * one step callback onto `scene._beforeRender`. Hosting it on a **null-engine** scene and driving\n * that scene with `stepScene` (12438) is what gives ignifx the accumulator ADR-0003 requires.\n * - `_stepWorld` (`lib/physics/havok.js:73-107`) pre-syncs node→body only for `ANIMATED` bodies and\n * for bodies with `_preStep` set, then steps once, then syncs body→node for `DYNAMIC` bodies. A\n * `DYNAMIC` body therefore never reads its node, which is what makes the interpolated display\n * pose of `09-physics.md` §1 safe (spike S4.3).\n * - `_syncBodyToNode` writes `node.position` / `node.rotationQuaternion` — the node's **local** TRS.\n * A body's node must therefore be a root node for its pose to be world space; the extension\n * reports `IGX-0907` otherwise.\n * - `setPhysicsTimestep(world, dt)` (10863) stores `dt * 1000` in `world._fixedDeltaMs`, and the\n * step clamps at 100 ms (`MAX_STEP_MS`), so the fixed step and Lite's step agree exactly.\n *\n * Everything here is `@internal`.\n */\n\n/**\n * Lite's opaque Havok world handle.\n *\n * @internal\n */\nexport type LitePhysicsWorld = PhysicsWorld;\n\n/**\n * Lite's opaque Havok body handle. It carries the node it is bound to, which is how the extension\n * resolves a body back to an entity.\n *\n * @internal\n */\nexport type LitePhysicsBody = PhysicsBody;\n\n/**\n * Lite's opaque Havok collision-shape handle.\n *\n * @internal\n */\nexport type LitePhysicsShape = PhysicsShape;\n\n/**\n * How a body moves, in ignifx's vocabulary. The numbers are Lite's `PhysicsMotionType` values\n * (`index.d.ts` 8543) so no translation table is needed on a per-body path.\n *\n * @internal\n */\nexport const BodyMotion = {\n /** Immovable; `PhysicsMotionType.STATIC`. */\n static: 0,\n /** Driven by the node transform; `PhysicsMotionType.ANIMATED`. */\n kinematic: 1,\n /** Simulated; `PhysicsMotionType.DYNAMIC`. */\n dynamic: 2,\n} as const;\n\n/**\n * The union of {@link BodyMotion} values.\n *\n * @internal\n */\nexport type BodyMotion = (typeof BodyMotion)[keyof typeof BodyMotion];\n\n/**\n * How a moved node reaches its body before a step; Lite's `PhysicsPrestepType` (8557).\n *\n * @internal\n */\nexport const PrestepMode = {\n /** No sync at all. */\n disabled: 0,\n /** Snap the body onto the node. */\n teleport: 1,\n /** Give the body the velocity that reaches the node, so resting bodies are dragged along. */\n velocity: 2,\n} as const;\n\n/**\n * The union of {@link PrestepMode} values.\n *\n * @internal\n */\nexport type PrestepMode = (typeof PrestepMode)[keyof typeof PrestepMode];\n\n/**\n * The shape geometries this package builds; Lite's `PhysicsShapeType` (8606).\n *\n * @internal\n */\nexport const ShapeGeometry = {\n /** A sphere. */\n sphere: 0,\n /** A capsule between two points. */\n capsule: 1,\n /** A cylinder between two points. */\n cylinder: 2,\n /** An axis-aligned box in shape space. */\n box: 3,\n /** The convex hull of a node's meshes. */\n convexHull: 4,\n /** A compound of child shapes. */\n container: 5,\n /** A triangle mesh built from a node's meshes. */\n mesh: 6,\n} as const;\n\n/**\n * The union of {@link ShapeGeometry} values.\n *\n * @internal\n */\nexport type ShapeGeometry = (typeof ShapeGeometry)[keyof typeof ShapeGeometry];\n\n/**\n * Geometry parameters for {@link createShape}; the subset of Lite's `PhysicsShapeParameters` (8596)\n * this package writes.\n *\n * @internal\n */\nexport interface ShapeParameters {\n /** The shape's centre in shape space. */\n readonly center?: Vec3Like;\n /** The radius of a sphere, capsule, or cylinder. */\n readonly radius?: number;\n /** The first end point of a capsule or cylinder. */\n readonly pointA?: Vec3Like;\n /** The second end point of a capsule or cylinder. */\n readonly pointB?: Vec3Like;\n /** The full extents of a box. */\n readonly extents?: Vec3Like;\n /** The rotation of a box in shape space. */\n readonly rotation?: QuatLike;\n}\n\n/** The engine and scene the simulation runs on. */\nexport interface SimulationHandles {\n /** Lite's null engine — no device, no surface. */\n readonly engine: LiteEngine;\n /** A scene with no default render task, advanced only by {@link stepSimulation}. */\n readonly scene: LiteScene;\n}\n\n/**\n * Creates the null-engine scene the Havok world is hosted on (`09-physics.md` §1, spike S4.1).\n *\n * @returns The engine and scene. Release with {@link disposeSimulation}.\n *\n * @internal\n */\nexport function createSimulation(): SimulationHandles {\n const engine = createNullEngine();\n return { engine, scene: createSceneContext(engine, { defaultRenderTask: false }) };\n}\n\n/**\n * Releases the simulation scene. The null engine owns no GPU resource and must not be handed to\n * Lite's `disposeEngine` (ADR-0009 Validation).\n *\n * @param handles - What {@link createSimulation} returned.\n *\n * @internal\n */\nexport function disposeSimulation(handles: SimulationHandles): void {\n disposeScene(handles.scene);\n}\n\n/**\n * Advances the simulation scene by exactly one Havok step.\n *\n * @param handles - The engine and scene.\n * @param deltaMs - The fixed step in milliseconds.\n *\n * @internal\n */\nexport function stepSimulation(handles: SimulationHandles, deltaMs: number): void {\n stepScene(handles.engine, handles.scene, deltaMs);\n}\n\n/**\n * Creates the Havok world on a simulation scene.\n *\n * @param scene - The simulation scene.\n * @param havok - The instantiated Havok WebAssembly module; Lite types it as `any`.\n * @param gravity - The world gravity.\n * @returns The world handle.\n *\n * @internal\n */\nexport function createWorld(scene: LiteScene, havok: unknown, gravity: Vec3Like): LitePhysicsWorld {\n return createHavokWorld(scene, havok, { x: gravity.x, y: gravity.y, z: gravity.z });\n}\n\n/**\n * Releases every body and the native world. Call it before the simulation scene is disposed\n * (`docs/architecture/07-rendering.md` §7 ordering).\n *\n * @param world - The world handle.\n *\n * @internal\n */\nexport function destroyWorld(world: LitePhysicsWorld): void {\n disposePhysics(world);\n}\n\n/**\n * Pins Lite's per-step delta to ignifx's fixed step, so the two never disagree.\n *\n * @param world - The world handle.\n * @param seconds - The fixed step in seconds.\n *\n * @internal\n */\nexport function setTimestep(world: LitePhysicsWorld, seconds: number): void {\n setPhysicsTimestep(world, seconds);\n}\n\n/**\n * Sets world gravity.\n *\n * @param world - The world handle.\n * @param gravity - The acceleration vector, in metres per second squared.\n *\n * @internal\n */\nexport function setGravity(world: LitePhysicsWorld, gravity: Vec3Like): void {\n setPhysicsGravity(world, { x: gravity.x, y: gravity.y, z: gravity.z });\n}\n\n/**\n * Sets the world-wide speed limits.\n *\n * @param world - The world handle.\n * @param linear - Maximum linear speed, in metres per second.\n * @param angular - Maximum angular speed, in radians per second.\n *\n * @internal\n */\nexport function setVelocityLimits(world: LitePhysicsWorld, linear: number, angular: number): void {\n setPhysicsVelocityLimits(world, linear, angular);\n}\n\n/**\n * Creates a body bound to a scene node.\n *\n * @param world - The world handle.\n * @param node - The node whose local pose is the body pose.\n * @param motion - How the body moves.\n * @param startsAsleep - Whether the body starts asleep.\n * @returns The body handle.\n *\n * @internal\n */\nexport function createBody(\n world: LitePhysicsWorld,\n node: LiteSceneNode,\n motion: BodyMotion,\n startsAsleep: boolean,\n): LitePhysicsBody {\n return createPhysicsBody(world, node, motion, startsAsleep);\n}\n\n/**\n * Removes a body from the world.\n *\n * @param world - The world handle.\n * @param body - The body to remove.\n *\n * @internal\n */\nexport function destroyBody(world: LitePhysicsWorld, body: LitePhysicsBody): void {\n removePhysicsBody(world, body);\n}\n\n/**\n * Attaches a shape to a body.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param shape - The shape.\n *\n * @internal\n */\nexport function setBodyShape(world: LitePhysicsWorld, body: LitePhysicsBody, shape: LitePhysicsShape): void {\n setPhysicsBodyShape(world, body, shape);\n}\n\n/**\n * Sets a body's mass. Havok recomputes the shape-derived inertia around it.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param mass - The mass in kilograms; `0` for an infinite-mass body.\n *\n * @internal\n */\nexport function setBodyMass(world: LitePhysicsWorld, body: LitePhysicsBody, mass: number): void {\n setPhysicsBodyMass(world, body, mass);\n}\n\n/**\n * Chooses how a moved node reaches the body before the next step.\n *\n * @param body - The body.\n * @param mode - The prestep mode.\n *\n * @internal\n */\nexport function setBodyPrestep(body: LitePhysicsBody, mode: PrestepMode): void {\n setPhysicsBodyPrestepType(body, mode);\n}\n\n/**\n * Turns collision-event reporting on or off for one body.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param enabled - Whether the body contributes to the collision stream.\n *\n * @internal\n */\nexport function setBodyCollisionEvents(world: LitePhysicsWorld, body: LitePhysicsBody, enabled: boolean): void {\n setPhysicsBodyCollisionEventsEnabled(world, body, enabled);\n}\n\n/**\n * Teleports a body, keeping the node it drives consistent.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param position - The world position.\n * @param rotation - The world rotation.\n *\n * @internal\n */\nexport function setBodyTransform(\n world: LitePhysicsWorld,\n body: LitePhysicsBody,\n position: Vec3Like,\n rotation: QuatLike,\n): void {\n setPhysicsBodyTransform(\n world,\n body,\n { x: position.x, y: position.y, z: position.z },\n { x: rotation.x, y: rotation.y, z: rotation.z, w: rotation.w },\n );\n}\n\n/**\n * Reads a body's linear velocity into an out parameter (coding standards §7).\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param out - The vector to write.\n *\n * @internal\n */\nexport function readLinearVelocity(world: LitePhysicsWorld, body: LitePhysicsBody, out: MutableVec3): void {\n const value = getPhysicsBodyLinearVelocity(world, body);\n out.set(value.x, value.y, value.z);\n}\n\n/**\n * Reads a body's angular velocity into an out parameter.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param out - The vector to write.\n *\n * @internal\n */\nexport function readAngularVelocity(world: LitePhysicsWorld, body: LitePhysicsBody, out: MutableVec3): void {\n const value = getPhysicsBodyAngularVelocity(world, body);\n out.set(value.x, value.y, value.z);\n}\n\n/**\n * Sets a body's linear velocity.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param velocity - Metres per second, world space.\n *\n * @internal\n */\nexport function writeLinearVelocity(world: LitePhysicsWorld, body: LitePhysicsBody, velocity: Vec3Like): void {\n setPhysicsBodyLinearVelocity(world, body, { x: velocity.x, y: velocity.y, z: velocity.z });\n}\n\n/**\n * Sets a body's angular velocity.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param velocity - Radians per second, world space.\n *\n * @internal\n */\nexport function writeAngularVelocity(world: LitePhysicsWorld, body: LitePhysicsBody, velocity: Vec3Like): void {\n setPhysicsBodyAngularVelocity(world, body, { x: velocity.x, y: velocity.y, z: velocity.z });\n}\n\n/**\n * Applies a force for one fixed step.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param force - Newtons, world space.\n * @param point - The world-space application point.\n *\n * @internal\n */\nexport function applyForce(world: LitePhysicsWorld, body: LitePhysicsBody, force: Vec3Like, point: Vec3Like): void {\n applyPhysicsBodyForce(world, body, { x: force.x, y: force.y, z: force.z }, { x: point.x, y: point.y, z: point.z });\n}\n\n/**\n * Applies an instantaneous impulse.\n *\n * @param body - The body.\n * @param impulse - Newton-seconds, world space.\n * @param point - The world-space application point.\n *\n * @internal\n */\nexport function applyImpulse(body: LitePhysicsBody, impulse: Vec3Like, point: Vec3Like): void {\n applyPhysicsBodyImpulse(body, { x: impulse.x, y: impulse.y, z: impulse.z }, { x: point.x, y: point.y, z: point.z });\n}\n\n/**\n * Locks or unlocks a body's rotation axes. Havok expresses a locked degree of freedom as zero\n * inertia (`index.d.ts` 6956).\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param locked - The axes to lock; every other axis is unlocked.\n *\n * @internal\n */\nexport function setRotationLocks(\n world: LitePhysicsWorld,\n body: LitePhysicsBody,\n locked: readonly PhysicsRotationAxis[],\n): void {\n const free: PhysicsRotationAxis[] = [];\n for (const axis of ROTATION_AXES) {\n if (!locked.includes(axis)) {\n free.push(axis);\n }\n }\n if (free.length > 0) {\n unlockPhysicsBodyRotationAxes(world, body, free);\n }\n if (locked.length > 0) {\n lockPhysicsBodyRotationAxes(world, body, locked);\n }\n}\n\n/** The three rotation axes Lite names, in a stable order. */\nconst ROTATION_AXES: readonly PhysicsRotationAxis[] = Object.freeze([\"x\", \"y\", \"z\"]);\n\n/**\n * Creates a primitive collision shape.\n *\n * @param world - The world handle.\n * @param geometry - Which primitive to build.\n * @param parameters - Its geometry parameters.\n * @returns The shape handle.\n *\n * @internal\n */\nexport function createShape(\n world: LitePhysicsWorld,\n geometry: ShapeGeometry,\n parameters: ShapeParameters,\n): LitePhysicsShape {\n return createPhysicsShape(world, { type: geometry, parameters: { ...parameters } });\n}\n\n/**\n * Creates a triangle-mesh or convex-hull shape from a node's meshes.\n *\n * @remarks\n * Lite documents this as unsupported on the null engine (`index.d.ts` 2781: \"Mesh/convex-hull\n * colliders that require `node.worldMatrix`\"), and a headless `MeshAsset` uploads no geometry at\n * all, so the extension refuses with `IGX-0906` rather than building an empty shape.\n *\n * @param world - The world handle.\n * @param node - The node whose meshes supply the geometry.\n * @param convex - `true` for a convex hull, `false` for a triangle mesh.\n * @param includeChildren - Whether descendant meshes are accumulated.\n * @returns The shape handle.\n *\n * @internal\n */\nexport function createMeshShape(\n world: LitePhysicsWorld,\n node: LiteSceneNode,\n convex: boolean,\n includeChildren: boolean,\n): LitePhysicsShape {\n return createPhysicsShape(world, {\n type: convex ? ShapeGeometry.convexHull : ShapeGeometry.mesh,\n mesh: node,\n includeChildMeshes: includeChildren,\n });\n}\n\n/**\n * Creates a heightfield shape from an explicit sample grid (`index.d.ts` 2601, 6266).\n *\n * @remarks\n * The explicit path only calls `hknp._malloc` and `HP_Shape_CreateHeightField`\n * (`lib/physics/havok-heightfield.js:4-22`), so it works on the null engine; the `groundMesh` path\n * reads `mesh._cpuPositions` and `worldMatrix` and does not.\n *\n * @param world - The world handle.\n * @param samplesX - How many samples along X.\n * @param samplesZ - How many samples along Z.\n * @param sizeX - The world-space size along X.\n * @param sizeZ - The world-space size along Z.\n * @param heights - `samplesX * samplesZ` row-major height samples.\n * @returns The shape handle.\n *\n * @internal\n */\nexport function createHeightfieldShape(\n world: LitePhysicsWorld,\n samplesX: number,\n samplesZ: number,\n sizeX: number,\n sizeZ: number,\n heights: Float32Array,\n): LitePhysicsShape {\n return createHeightFieldShape(world, {\n numHeightFieldSamplesX: samplesX,\n numHeightFieldSamplesZ: samplesZ,\n heightFieldSizeX: sizeX,\n heightFieldSizeZ: sizeZ,\n heightFieldData: heights,\n });\n}\n\n/**\n * Creates the empty compound shape several colliders on one entity are added to.\n *\n * @param world - The world handle.\n * @returns The container shape.\n *\n * @internal\n */\nexport function createContainer(world: LitePhysicsWorld): LitePhysicsShape {\n return createPhysicsShape(world, { type: ShapeGeometry.container });\n}\n\n/**\n * Adds a child shape to a container at a local offset.\n *\n * @param world - The world handle.\n * @param container - The container shape.\n * @param child - The child shape.\n * @param translation - The child's offset inside the container.\n * @param rotation - The child's rotation inside the container.\n *\n * @internal\n */\nexport function addContainerChild(\n world: LitePhysicsWorld,\n container: LitePhysicsShape,\n child: LitePhysicsShape,\n translation: Vec3Like,\n rotation: QuatLike,\n): void {\n addPhysicsShapeChild(\n world,\n container,\n child,\n { x: translation.x, y: translation.y, z: translation.z },\n { x: rotation.x, y: rotation.y, z: rotation.z, w: rotation.w },\n );\n}\n\n/**\n * Releases a shape no body references any more.\n *\n * @param world - The world handle.\n * @param shape - The shape.\n *\n * @internal\n */\nexport function destroyShape(world: LitePhysicsWorld, shape: LitePhysicsShape): void {\n releasePhysicsShape(world, shape);\n}\n\n/**\n * Marks a shape as a trigger volume: it reports overlaps and resolves no contacts.\n *\n * @param world - The world handle.\n * @param shape - The shape.\n * @param isTrigger - Whether the shape is a trigger.\n *\n * @internal\n */\nexport function setShapeTrigger(world: LitePhysicsWorld, shape: LitePhysicsShape, isTrigger: boolean): void {\n setPhysicsShapeIsTrigger(world, shape, isTrigger);\n}\n\n/**\n * Sets a shape's surface material.\n *\n * @param world - The world handle.\n * @param shape - The shape.\n * @param friction - The dynamic friction coefficient.\n * @param restitution - The bounciness, `0` to `1`.\n * @param staticFriction - The static friction coefficient.\n *\n * @internal\n */\nexport function setShapeMaterial(\n world: LitePhysicsWorld,\n shape: LitePhysicsShape,\n friction: number,\n restitution: number,\n staticFriction: number,\n): void {\n setPhysicsShapeMaterial(world, shape, friction, restitution, staticFriction);\n}\n\n/**\n * Sets a shape's collision filter masks (`09-physics.md` §3).\n *\n * @param world - The world handle.\n * @param shape - The shape.\n * @param membership - The 32-bit membership mask, `1 << entity.layer`.\n * @param collideWith - The 32-bit mask of layers the shape collides with.\n *\n * @internal\n */\nexport function setShapeFilter(\n world: LitePhysicsWorld,\n shape: LitePhysicsShape,\n membership: number,\n collideWith: number,\n): void {\n setPhysicsShapeFilterMembershipMask(world, shape, membership);\n setPhysicsShapeFilterCollideMask(world, shape, collideWith);\n}\n\n/**\n * Reads a node's local pose into out parameters.\n *\n * @param node - The node.\n * @param position - The vector to write the position into.\n * @param rotation - The quaternion to write the rotation into.\n *\n * @internal\n */\nexport function readNodePose(node: LiteSceneNode, position: MutableVec3, rotation: MutableQuat): void {\n const local = node.position;\n const quaternion = node.rotationQuaternion;\n position.set(local.x, local.y, local.z);\n rotation.set(quaternion.x, quaternion.y, quaternion.z, quaternion.w);\n}\n\n/**\n * Writes a node's local pose.\n *\n * @param node - The node.\n * @param position - The position to write.\n * @param rotation - The rotation to write.\n *\n * @internal\n */\nexport function writeNodePose(node: LiteSceneNode, position: Vec3Like, rotation: QuatLike): void {\n node.position.set(position.x, position.y, position.z);\n node.rotationQuaternion.set(rotation.x, rotation.y, rotation.z, rotation.w);\n}\n\n/**\n * What the trigger drain reports for one overlap.\n *\n * @internal\n */\nexport interface TriggerRecord {\n /** `true` for `ENTERED`, `false` for `EXITED`. */\n readonly entered: boolean;\n /** The first node, or `null` when Lite no longer tracks the body. */\n readonly nodeA: LiteSceneNode | null;\n /** The second node, or `null`. */\n readonly nodeB: LiteSceneNode | null;\n}\n\n/**\n * Registers the trigger drain (`index.d.ts` 7787). It runs inside `stepScene`, from Lite's\n * post-step hook, so the callback must only buffer.\n *\n * @param world - The world handle.\n * @param sink - Called once per trigger event.\n * @returns A disposer that removes the drain.\n *\n * @internal\n */\nexport function onTriggerEvents(world: LitePhysicsWorld, sink: (record: TriggerRecord) => void): () => void {\n return onPhysicsTriggerBodies(world, (info): void => {\n sink({\n entered: info.type === \"ENTERED\",\n nodeA: info.bodyA === null ? null : info.bodyA.node,\n nodeB: info.bodyB === null ? null : info.bodyB.node,\n });\n });\n}\n\n/**\n * What the collision drain reports for one contact.\n *\n * @internal\n */\nexport interface ContactRecord {\n /** `0` for `STARTED`, `1` for `CONTINUED`, `2` for `FINISHED`. */\n readonly phase: number;\n /** The world-space contact point. */\n readonly point: Vec3Like;\n /** The world-space contact normal. */\n readonly normal: Vec3Like;\n /** The magnitude of the resolving impulse; `0` for a contact that just ended. */\n readonly impulse: number;\n /** The node of the first body (Lite's `collider`). */\n readonly nodeA: LiteSceneNode;\n /** The node of the second body (Lite's `collidedAgainst`). */\n readonly nodeB: LiteSceneNode;\n}\n\n/** `ContactRecord.phase` for a contact that just started. */\nexport const CONTACT_STARTED: number = 0;\n\n/** `ContactRecord.phase` for a contact that persists. */\nexport const CONTACT_CONTINUED: number = 1;\n\n/** `ContactRecord.phase` for a contact that just ended. */\nexport const CONTACT_FINISHED: number = 2;\n\n/**\n * Registers the collision drain (`onPhysicsCollision`, `index.d.ts` 9315). Each\n * `PhysicsCollisionInfo` (10030) names both bodies as `collider` and `collidedAgainst`, and they are\n * resolved to nodes the same way the trigger drain resolves `bodyA`/`bodyB`. Lite skips an event\n * whose bodies it no longer tracks (`lib/physics/havok-collision.js:47-52`), so both are present.\n *\n * @remarks\n * `colliderIndex` and `collidedAgainstIndex` are thin-instance indices. ignifx never creates\n * thin-instance bodies, so they are always `0` and are ignored.\n *\n * @param world - The world handle.\n * @param sink - Called once per collision event.\n *\n * @internal\n */\nexport function onCollisionEvents(world: LitePhysicsWorld, sink: (record: ContactRecord) => void): void {\n onPhysicsCollision(world, (info): void => {\n sink({\n phase:\n info.type === \"STARTED\" ? CONTACT_STARTED : info.type === \"CONTINUED\" ? CONTACT_CONTINUED : CONTACT_FINISHED,\n point: info.point,\n normal: info.normal,\n impulse: info.impulse,\n nodeA: info.collider.node,\n nodeB: info.collidedAgainst.node,\n });\n });\n}\n\n/**\n * Registers a callback that runs after every Havok step (`index.d.ts` 7753). Lite's own drains use\n * the same hook, and the hooks run in registration order, so the extension's buffer flush is\n * registered last and sees everything the drains produced.\n *\n * @param world - The world handle.\n * @param callback - What to run after each step.\n *\n * @internal\n */\nexport function afterStep(world: LitePhysicsWorld, callback: () => void): void {\n onPhysicsAfterStep(world, (): void => {\n callback();\n });\n}\n","import {\n createDefaults,\n defineSchema,\n MeshAsset,\n Quat,\n Vec3,\n array,\n bool,\n asset,\n enumOf,\n f32,\n u32,\n vec3,\n} from \"@ignifx/core\";\nimport { PhysicsErrorCode, physicsError } from \"../errors.js\";\nimport { createHeightfieldShape, createMeshShape, createShape, ShapeGeometry } from \"../lite/havok.js\";\nimport { Collider, colliderFields } from \"./collider.js\";\nimport type { LitePhysicsShape, LitePhysicsWorld } from \"../lite/havok.js\";\nimport type { AssetHandle, LiteSceneNode, MutableVec3, Schema, Vec3Like } from \"@ignifx/core\";\n\n/**\n * The concrete colliders (`docs/architecture/09-physics.md` §2.2). Each one maps to exactly one\n * Havok shape type (`index.d.ts` 8606) and bakes its `center` into the shape's own parameters, so a\n * single collider needs no compound wrapper.\n *\n * Sizes are authored in local units and multiplied by the entity's lossy scale when the shape is\n * built; Havok cannot rescale a built shape, so a later scale change needs `collider.rebuild()`.\n */\n\n/**\n * The axis a capsule stands along.\n *\n * @public\n */\nexport const CAPSULE_DIRECTIONS = [\"x\", \"y\", \"z\"] as const;\n\n/**\n * The union of {@link CAPSULE_DIRECTIONS}.\n *\n * @public\n */\nexport type CapsuleDirection = (typeof CAPSULE_DIRECTIONS)[number];\n\n/**\n * A box collider, sized in local units (`09-physics.md` §2.2).\n *\n * @example\n * ```ts\n * const floor = world.createEntity(\"Floor\");\n * floor.addComponent(BoxCollider, { size: { x: 20, y: 1, z: 20 } });\n * ```\n *\n * @public\n */\nexport class BoxCollider extends Collider {\n /** The namespaced registration id. */\n static typeId = \"ignifx/BoxCollider\";\n\n /** The serialized field declarations (ADR-0004). */\n static schema: Schema = boxSchema();\n\n declare size: Vec3Like;\n\n /** Applies this collider's defaults on top of the shared ones. */\n constructor() {\n super();\n Object.assign(this, createDefaults(BoxCollider.schema));\n }\n\n /**\n * Builds this collider's Havok shape.\n *\n * @param world - The Havok world the shape belongs to.\n * @param scale - The entity's lossy scale, applied to the authored dimensions.\n * @returns The shape handle.\n */\n createShape(world: LitePhysicsWorld, scale: Vec3Like): LitePhysicsShape {\n return createShape(world, ShapeGeometry.box, {\n extents: { x: this.size.x * abs(scale.x), y: this.size.y * abs(scale.y), z: this.size.z * abs(scale.z) },\n center: scaled(this.center, scale),\n rotation: new Quat(),\n });\n }\n\n /**\n * Writes half the size of this collider's local bounding box, scale applied.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The vector to write.\n */\n halfExtentsToRef(scale: Vec3Like, out: MutableVec3): void {\n out.set((this.size.x * abs(scale.x)) / 2, (this.size.y * abs(scale.y)) / 2, (this.size.z * abs(scale.z)) / 2);\n }\n}\n\n/**\n * A sphere collider. Non-uniform scale is not representable as a sphere, so the largest scale axis\n * wins — the same rule Unity applies.\n *\n * @public\n */\nexport class SphereCollider extends Collider {\n /** The namespaced registration id. */\n static typeId = \"ignifx/SphereCollider\";\n\n /** The serialized field declarations. */\n static schema: Schema = sphereSchema();\n\n declare radius: number;\n\n /** Applies this collider's defaults on top of the shared ones. */\n constructor() {\n super();\n Object.assign(this, createDefaults(SphereCollider.schema));\n }\n\n /**\n * Builds this collider's Havok shape.\n *\n * @param world - The Havok world the shape belongs to.\n * @param scale - The entity's lossy scale, applied to the authored dimensions.\n * @returns The shape handle.\n */\n createShape(world: LitePhysicsWorld, scale: Vec3Like): LitePhysicsShape {\n return createShape(world, ShapeGeometry.sphere, {\n radius: this.radius * maxAxis(scale),\n center: scaled(this.center, scale),\n });\n }\n\n /**\n * Writes half the size of this collider's local bounding box, scale applied.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The vector to write.\n */\n halfExtentsToRef(scale: Vec3Like, out: MutableVec3): void {\n const radius = this.radius * maxAxis(scale);\n out.set(radius, radius, radius);\n }\n}\n\n/**\n * A capsule collider: a cylinder with hemispherical caps, standing along one axis.\n *\n * @remarks\n * `height` is the **total** tip-to-tip height, so a capsule shorter than `2 * radius` degenerates to\n * a sphere of that radius rather than inverting.\n *\n * @public\n */\nexport class CapsuleCollider extends Collider {\n /** The namespaced registration id. */\n static typeId = \"ignifx/CapsuleCollider\";\n\n /** The serialized field declarations. */\n static schema: Schema = capsuleSchema();\n\n declare radius: number;\n\n declare height: number;\n\n declare direction: CapsuleDirection;\n\n /** Applies this collider's defaults on top of the shared ones. */\n constructor() {\n super();\n Object.assign(this, createDefaults(CapsuleCollider.schema));\n }\n\n /**\n * Builds this collider's Havok shape.\n *\n * @param world - The Havok world the shape belongs to.\n * @param scale - The entity's lossy scale, applied to the authored dimensions.\n * @returns The shape handle.\n */\n createShape(world: LitePhysicsWorld, scale: Vec3Like): LitePhysicsShape {\n const radius = this.radius * radialScale(this.direction, scale);\n const half = Math.max(0, (this.height * axisScale(this.direction, scale)) / 2 - radius);\n const center = scaled(this.center, scale);\n return createShape(world, ShapeGeometry.capsule, {\n radius,\n pointA: offsetAlong(center, this.direction, -half),\n pointB: offsetAlong(center, this.direction, half),\n });\n }\n\n /**\n * Writes half the size of this collider's local bounding box, scale applied.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The vector to write.\n */\n halfExtentsToRef(scale: Vec3Like, out: MutableVec3): void {\n const radius = this.radius * radialScale(this.direction, scale);\n const half = Math.max(radius, (this.height * axisScale(this.direction, scale)) / 2);\n out.set(\n this.direction === \"x\" ? half : radius,\n this.direction === \"y\" ? half : radius,\n this.direction === \"z\" ? half : radius,\n );\n }\n}\n\n/**\n * A cylinder collider standing along Y.\n *\n * @public\n */\nexport class CylinderCollider extends Collider {\n /** The namespaced registration id. */\n static typeId = \"ignifx/CylinderCollider\";\n\n /** The serialized field declarations. */\n static schema: Schema = cylinderSchema();\n\n declare radius: number;\n\n declare height: number;\n\n /** Applies this collider's defaults on top of the shared ones. */\n constructor() {\n super();\n Object.assign(this, createDefaults(CylinderCollider.schema));\n }\n\n /**\n * Builds this collider's Havok shape.\n *\n * @param world - The Havok world the shape belongs to.\n * @param scale - The entity's lossy scale, applied to the authored dimensions.\n * @returns The shape handle.\n */\n createShape(world: LitePhysicsWorld, scale: Vec3Like): LitePhysicsShape {\n const radius = this.radius * Math.max(abs(scale.x), abs(scale.z));\n const half = (this.height * abs(scale.y)) / 2;\n const center = scaled(this.center, scale);\n return createShape(world, ShapeGeometry.cylinder, {\n radius,\n pointA: { x: center.x, y: center.y - half, z: center.z },\n pointB: { x: center.x, y: center.y + half, z: center.z },\n });\n }\n\n /**\n * Writes half the size of this collider's local bounding box, scale applied.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The vector to write.\n */\n halfExtentsToRef(scale: Vec3Like, out: MutableVec3): void {\n const radius = this.radius * Math.max(abs(scale.x), abs(scale.z));\n out.set(radius, (this.height * abs(scale.y)) / 2, radius);\n }\n}\n\n/**\n * A collider built from real geometry: either an explicit `MeshAsset` or, when `mesh` is\n * `null`, whatever the entity's `MeshRenderer`/`Model` put under its node.\n *\n * @remarks\n * **Headless is not supported.** `@babylonjs/lite@1.27.0` documents mesh and convex-hull colliders\n * as unavailable on the null engine (`index.d.ts` 2781), and a headless `MeshAsset` uploads no\n * geometry at all (`MeshAsset.lite.mesh` is `null`), so building one reports `IGX-0906` instead of\n * producing an empty shape. Use a primitive collider in headless tests.\n *\n * @public\n */\nexport class MeshCollider extends Collider {\n /** The namespaced registration id. */\n static typeId = \"ignifx/MeshCollider\";\n\n /** The serialized field declarations. */\n static schema: Schema = meshSchema();\n\n declare mesh: AssetHandle<MeshAsset> | null;\n\n declare convex: boolean;\n\n declare includeChildren: boolean;\n\n /** Applies this collider's defaults on top of the shared ones. */\n constructor() {\n super();\n Object.assign(this, createDefaults(MeshCollider.schema));\n }\n\n /**\n * Builds this collider's Havok shape from real geometry.\n *\n * @param world - The Havok world the shape belongs to.\n * @param _scale - Unused: a mesh shape carries the geometry's own world scale.\n * @param node - The entity's node, whose meshes supply the vertices when `mesh` is `null`.\n * @returns The shape handle.\n */\n createShape(world: LitePhysicsWorld, _scale: Vec3Like, node: LiteSceneNode): LitePhysicsShape {\n const source = this.#sourceNode(node);\n return createMeshShape(world, source, this.convex, this.includeChildren);\n }\n\n /**\n * Writes half the size of this collider's local bounding box — zero, because measuring a triangle\n * soup means reading its vertices, which is GPU territory.\n *\n * @param _scale - Unused.\n * @param out - The vector to write.\n */\n halfExtentsToRef(_scale: Vec3Like, out: MutableVec3): void {\n // The bounds index cannot measure a triangle soup without reading its vertices, which is GPU\n // territory. A mesh collider therefore contributes a point to `overlap`/`shapeCast` resolution\n // and is documented as such.\n out.set(0, 0, 0);\n }\n\n /**\n * The node whose meshes supply the geometry.\n *\n * @param entityNode - The entity's own node.\n * @returns The node to hand Lite.\n * @throws IgnifxError with code `IGX-0906` when there is no geometry to read.\n */\n #sourceNode(entityNode: LiteSceneNode): LiteSceneNode {\n const explicit = this.mesh?.value.lite.mesh ?? null;\n if (explicit !== null) {\n return explicit;\n }\n if (this.mesh !== null) {\n throw physicsError(\n PhysicsErrorCode.colliderGeometryUnavailable,\n \"The MeshCollider's mesh asset has no geometry.\",\n {\n context: { entity: this.entity.name },\n hint: \"Mesh colliders need a GPU app; a headless MeshAsset uploads nothing to build a shape from.\",\n },\n );\n }\n if (entityNode.children.length === 0) {\n throw physicsError(PhysicsErrorCode.colliderGeometryUnavailable, \"The MeshCollider has no mesh to read.\", {\n context: { entity: this.entity.name },\n hint: \"Add a MeshRenderer or Model to the entity, or set the collider's mesh field.\",\n });\n }\n return entityNode;\n }\n}\n\n/**\n * A heightfield collider: a regular grid of height samples in the XZ plane, which is what a terrain\n * uses (`index.d.ts` 2601, 6266).\n *\n * @remarks\n * Only Lite's **explicit** heightfield path is used, because the `groundMesh` path reads\n * `mesh._cpuPositions` and `worldMatrix` and therefore needs a GPU. `heights` is row-major with\n * `samplesX * samplesZ` entries.\n *\n * @public\n */\nexport class HeightfieldCollider extends Collider {\n /** The namespaced registration id. */\n static typeId = \"ignifx/HeightfieldCollider\";\n\n /** The serialized field declarations. */\n static schema: Schema = heightfieldSchema();\n\n declare heights: number[];\n\n declare samplesX: number;\n\n declare samplesZ: number;\n\n declare size: Vec3Like;\n\n /** Applies this collider's defaults on top of the shared ones. */\n constructor() {\n super();\n Object.assign(this, createDefaults(HeightfieldCollider.schema));\n }\n\n /**\n * Builds this collider's Havok shape.\n *\n * @param world - The Havok world the shape belongs to.\n * @param scale - The entity's lossy scale, applied to the authored dimensions.\n * @returns The shape handle.\n */\n createShape(world: LitePhysicsWorld, scale: Vec3Like): LitePhysicsShape {\n const expected = this.samplesX * this.samplesZ;\n if (this.samplesX < 2 || this.samplesZ < 2 || this.heights.length !== expected) {\n throw physicsError(\n PhysicsErrorCode.colliderGeometryUnavailable,\n \"The HeightfieldCollider's sample grid is invalid.\",\n {\n context: { entity: this.entity.name, expected, actual: this.heights.length },\n hint: \"heights must hold samplesX * samplesZ values, and both counts must be at least 2.\",\n },\n );\n }\n const data = new Float32Array(expected);\n for (let index = 0; index < expected; index += 1) {\n data[index] = (this.heights[index] ?? 0) * abs(scale.y);\n }\n return createHeightfieldShape(\n world,\n this.samplesX,\n this.samplesZ,\n this.size.x * abs(scale.x),\n this.size.z * abs(scale.z),\n data,\n );\n }\n\n /**\n * Writes half the size of this collider's local bounding box, scale applied.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The vector to write.\n */\n halfExtentsToRef(scale: Vec3Like, out: MutableVec3): void {\n out.set((this.size.x * abs(scale.x)) / 2, (this.size.y * abs(scale.y)) / 2, (this.size.z * abs(scale.z)) / 2);\n }\n}\n\n/**\n * Builds the `BoxCollider` schema.\n *\n * @returns The schema.\n */\nfunction boxSchema(): Schema {\n return defineSchema({ ...colliderFields(), size: vec3({ x: 1, y: 1, z: 1 }) });\n}\n\n/**\n * Builds the `SphereCollider` schema.\n *\n * @returns The schema.\n */\nfunction sphereSchema(): Schema {\n return defineSchema({ ...colliderFields(), radius: f32(0.5, { min: 0 }) });\n}\n\n/**\n * Builds the `CapsuleCollider` schema.\n *\n * @returns The schema.\n */\nfunction capsuleSchema(): Schema {\n return defineSchema({\n ...colliderFields(),\n radius: f32(0.5, { min: 0 }),\n height: f32(2, { min: 0 }),\n direction: enumOf(CAPSULE_DIRECTIONS, \"y\"),\n });\n}\n\n/**\n * Builds the `CylinderCollider` schema.\n *\n * @returns The schema.\n */\nfunction cylinderSchema(): Schema {\n return defineSchema({ ...colliderFields(), radius: f32(0.5, { min: 0 }), height: f32(2, { min: 0 }) });\n}\n\n/**\n * Builds the `MeshCollider` schema.\n *\n * @returns The schema.\n */\nfunction meshSchema(): Schema {\n return defineSchema({\n ...colliderFields(),\n mesh: asset(MeshAsset),\n convex: bool(false),\n includeChildren: bool(true),\n });\n}\n\n/**\n * Builds the `HeightfieldCollider` schema.\n *\n * @returns The schema.\n */\nfunction heightfieldSchema(): Schema {\n return defineSchema({\n ...colliderFields(),\n heights: array(f32()),\n samplesX: u32(2, { min: 2 }),\n samplesZ: u32(2, { min: 2 }),\n size: vec3({ x: 1, y: 1, z: 1 }),\n });\n}\n\n/**\n * The absolute value of a scale component; a negative scale mirrors geometry, which Havok cannot\n * represent, so the shape uses the magnitude (`09-physics.md` §2.2).\n *\n * @param value - The scale component.\n * @returns Its magnitude.\n */\nfunction abs(value: number): number {\n return Math.abs(value);\n}\n\n/**\n * The largest scale magnitude, used by shapes that have one radius.\n *\n * @param scale - The lossy scale.\n * @returns The largest magnitude.\n */\nfunction maxAxis(scale: Vec3Like): number {\n return Math.max(abs(scale.x), abs(scale.y), abs(scale.z));\n}\n\n/**\n * Scales a local offset into shape space.\n *\n * @param center - The authored offset.\n * @param scale - The lossy scale.\n * @returns A fresh vector; shape construction is not a per-frame path.\n */\nfunction scaled(center: Vec3Like, scale: Vec3Like): Vec3 {\n return new Vec3(center.x * scale.x, center.y * scale.y, center.z * scale.z);\n}\n\n/**\n * The scale along a capsule's own axis.\n *\n * @param direction - The capsule axis.\n * @param scale - The lossy scale.\n * @returns The magnitude along that axis.\n */\nfunction axisScale(direction: CapsuleDirection, scale: Vec3Like): number {\n if (direction === \"x\") {\n return abs(scale.x);\n }\n return direction === \"y\" ? abs(scale.y) : abs(scale.z);\n}\n\n/**\n * The scale across a capsule's axis, which drives its radius.\n *\n * @param direction - The capsule axis.\n * @param scale - The lossy scale.\n * @returns The larger of the two perpendicular magnitudes.\n */\nfunction radialScale(direction: CapsuleDirection, scale: Vec3Like): number {\n if (direction === \"x\") {\n return Math.max(abs(scale.y), abs(scale.z));\n }\n return direction === \"y\" ? Math.max(abs(scale.x), abs(scale.z)) : Math.max(abs(scale.x), abs(scale.y));\n}\n\n/**\n * Offsets a point along one axis.\n *\n * @param center - The starting point.\n * @param direction - Which axis to move along.\n * @param distance - How far to move.\n * @returns A fresh vector.\n */\nfunction offsetAlong(center: Vec3Like, direction: CapsuleDirection, distance: number): Vec3 {\n return new Vec3(\n center.x + (direction === \"x\" ? distance : 0),\n center.y + (direction === \"y\" ? distance : 0),\n center.z + (direction === \"z\" ? distance : 0),\n );\n}\n","import HavokPhysics from \"@babylonjs/havok\";\nimport { PhysicsErrorCode, physicsError } from \"../errors.js\";\n\n/**\n * Loading the Havok WebAssembly module (`docs/architecture/09-physics.md` §7, ADR-0003 Validation).\n *\n * `@babylonjs/havok@1.3.14`'s ESM build hard-codes `ENVIRONMENT_IS_WEB = true` and fetches its\n * `.wasm` with `fetch(scriptDirectory + path)`, so `locateFile` cannot help under Node — Node's\n * `fetch` refuses `file:` URLs. Emscripten's `wasmBinary` option is the supported escape and is what\n * this module always uses: the bytes are obtained first (from the caller, from `fetch`, or from\n * `node:fs`) and handed to the factory. `app.isHeadless` therefore only changes *where the bytes\n * come from*, exactly as the Phase 4 brief requires.\n *\n * The `@babylonjs/havok` import lives here because this file is under `src/lite/`, the only place\n * `ignifx/no-lite-outside-adapter` and dependency-cruiser allow a native backend.\n *\n * Everything here is `@internal`.\n */\n\n/**\n * The unhashed file name the Vite plugin copies into the public asset path, and therefore the\n * address `app.assets.resolveUrl` answers for.\n *\n * @remarks\n * Extension public assets are copied by **base name** (`packages/vite-plugin/src/plugin.ts`,\n * `generateBundle`), into the same directory the default asset root points at, so the address is the\n * bare file name and not a package-scoped path.\n *\n * @internal\n */\nexport const HAVOK_WASM_FILE_NAME = \"HavokPhysics.wasm\";\n\n/** Where the Havok bytes come from. */\nexport interface HavokSource {\n /** An already-instantiated module, which wins over everything else. */\n readonly module?: unknown;\n /** The `.wasm` bytes, for a caller that read them itself. */\n readonly wasmBinary?: ArrayBuffer;\n /** The URL or file path to read the bytes from. */\n readonly url?: string;\n}\n\n/**\n * Instantiates Havok.\n *\n * @param source - An instantiated module, explicit bytes, or a URL to read them from.\n * @returns The module, typed as `unknown` because Lite types its own parameter as `any`.\n * @throws IgnifxError with code `IGX-0903` when the bytes cannot be obtained or the module fails to\n * instantiate.\n *\n * @example\n * ```ts\n * const havok = await loadHavok({ url: app.assets.resolveUrl(HAVOK_WASM_FILE_NAME) });\n * ```\n *\n * @internal\n */\nexport async function loadHavok(source: HavokSource): Promise<unknown> {\n if (source.module !== undefined && source.module !== null) {\n return source.module;\n }\n const url = source.url ?? HAVOK_WASM_FILE_NAME;\n const wasmBinary = source.wasmBinary ?? (await readWasmBytes(url));\n try {\n return await HavokPhysics({ wasmBinary });\n } catch (cause: unknown) {\n throw physicsError(PhysicsErrorCode.havokUnavailable, \"Havok failed to instantiate from the supplied bytes.\", {\n context: { url },\n hint: \"Check that HavokPhysics.wasm matches the installed @babylonjs/havok version.\",\n cause,\n });\n }\n}\n\n/**\n * Reads the `.wasm` bytes, preferring `fetch` and falling back to the file system under Node.\n *\n * @param url - The URL or path.\n * @returns The bytes as a plain `ArrayBuffer`, which is what Emscripten wants.\n * @throws IgnifxError with code `IGX-0903` when neither route produces bytes.\n */\nasync function readWasmBytes(url: string): Promise<ArrayBuffer> {\n let fetchFailure: unknown = null;\n if (typeof globalThis.fetch === \"function\") {\n try {\n const response = await globalThis.fetch(url);\n if (response.ok) {\n return await response.arrayBuffer();\n }\n fetchFailure = new Error(`${String(response.status)} ${response.statusText}`);\n } catch (cause: unknown) {\n fetchFailure = cause;\n }\n }\n const fromDisk = await readFromDisk(url);\n if (fromDisk !== null) {\n return fromDisk;\n }\n const fromPackage = await readFromPackage();\n if (fromPackage !== null) {\n return fromPackage;\n }\n throw physicsError(PhysicsErrorCode.havokUnavailable, \"The Havok WebAssembly bytes could not be read.\", {\n context: { url },\n hint: 'Set physics({ havokWasm: \"<url>\" }) or hand physics({ wasmBinary }) the bytes yourself.',\n ...(fetchFailure === null ? {} : { cause: fetchFailure }),\n });\n}\n\n/**\n * Reads a file through `node:fs` when the host is Node, and reports `null` everywhere else.\n *\n * @remarks\n * The specifier is held in a constant so that browser bundlers leave the import alone: a bundler\n * only rewrites a `import(\"…\")` whose argument is a string literal, and this branch is unreachable\n * in a browser anyway.\n *\n * @param path - The file path.\n * @returns The bytes, or `null` when there is no file system to read from, or the file is\n * unreadable. A browser fails the import itself, which is the same answer.\n */\nasync function readFromDisk(path: string): Promise<ArrayBuffer | null> {\n try {\n const specifier = NODE_FS_SPECIFIER;\n // A dynamic import with a non-literal specifier is\n // typed `any`, and {@link NodeFileSystem} is the one method of it this branch calls.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const fs = (await import(/* @vite-ignore */ specifier)) as NodeFileSystem;\n const bytes = await fs.readFile(path);\n // A Node `Buffer` is a view into a pooled `ArrayBuffer`, so copy out exactly this file's bytes\n // rather than handing Emscripten a window onto the pool.\n const copy = new ArrayBuffer(bytes.byteLength);\n new Uint8Array(copy).set(bytes);\n return copy;\n } catch {\n return null;\n }\n}\n\n/** The one `node:fs/promises` member this module calls. */\ninterface NodeFileSystem {\n /**\n * Reads a whole file.\n *\n * @param file - The path.\n * @returns Its bytes.\n */\n readFile(file: string): Promise<Uint8Array>;\n}\n\n/** The `node:fs/promises` specifier, held in a constant so bundlers do not follow it. */\nconst NODE_FS_SPECIFIER = \"node:fs/promises\";\n\n/** Where `@babylonjs/havok@1.3.14` keeps the binary its ESM build would otherwise `fetch`. */\nconst HAVOK_PACKAGE_WASM = \"@babylonjs/havok/lib/esm/HavokPhysics.wasm\";\n\n/**\n * Reads the binary straight out of the installed `@babylonjs/havok` package, which is what makes a\n * headless Node app work with no configuration at all: `app.isHeadless` only changes *where the\n * bytes come from* (Phase 4 brief), and under Node the answer is the package itself.\n *\n * @returns The bytes, or `null` when `import.meta.resolve` is unavailable or the package cannot be\n * resolved.\n */\nasync function readFromPackage(): Promise<ArrayBuffer | null> {\n try {\n const resolved = import.meta.resolve(HAVOK_PACKAGE_WASM);\n return await readFromDisk(resolved.startsWith(\"file://\") ? fileUrlToPath(resolved) : resolved);\n } catch {\n return null;\n }\n}\n\n/**\n * Turns a `file:` URL into a path `node:fs` accepts.\n *\n * @param url - The `file:` URL.\n * @returns The decoded path.\n */\nfunction fileUrlToPath(url: string): string {\n return decodeURIComponent(new URL(url).pathname);\n}\n","import type { PhysicsRuntime } from \"./runtime.js\";\n\n/**\n * The one mutable cell between `register` and `onStart`.\n *\n * `Extension.register` runs **before** `createApp` builds the Lite engine and the world\n * (`packages/core/src/app/app.ts`, `initialize`), and the Havok world needs both. So the extension\n * declares its systems and its service in `register` — which is where `04-extensions.md` §1 says\n * everything is declared — and they all read the runtime through this holder, which `onStart` fills\n * in once Havok has loaded.\n *\n * @internal\n */\nexport class PhysicsHost {\n /** The runtime, or `null` until `onStart` has built it. */\n runtime: PhysicsRuntime | null = null;\n}\n","import { createPhysicsCharacterController } from \"@babylonjs/lite\";\nimport type { LitePhysicsBody, LitePhysicsWorld } from \"./havok.js\";\nimport type { PhysicsCharacterController } from \"@babylonjs/lite\";\nimport type { LiteSceneNode, MutableVec3, Vec3Like } from \"@ignifx/core\";\n\n/**\n * The character-controller half of this package's Babylon Lite adapter\n * (`docs/architecture/09-physics.md` §2.3).\n *\n * Verified against `@babylonjs/lite@1.27.0`: `createPhysicsCharacterController` (`index.d.ts` 2887)\n * builds a kinematic capsule with collide-and-slide; the class (8300) exposes `keepDistance`,\n * `maxSlopeCosine`, `characterStrength`, `moveWithCollisions` (8389), `integrate` (8398),\n * `checkSupport` (8404), `getPosition`/`setPosition`, `getVelocity`/`setVelocity`,\n * `setShapeOptions` (8379) and `onTriggerCollisionObservable` (8332). Its options carry only\n * `capsuleHeight` and `capsuleRadius` (8447) — there is no centre offset, so the component applies\n * its own `center` when it writes the entity transform.\n *\n * Everything here is `@internal`.\n */\n\n/**\n * Lite's character controller handle.\n *\n * @internal\n */\nexport type LiteCharacterController = PhysicsCharacterController;\n\n/**\n * How the character is supported by whatever is under it; Lite's `CharacterSupportedState` (1615).\n *\n * @internal\n */\nexport const SupportState = {\n /** Nothing within reach. */\n unsupported: 0,\n /** Touching a surface too steep to stand on. */\n sliding: 1,\n /** Standing on a walkable surface. */\n supported: 2,\n} as const;\n\n/**\n * The union of {@link SupportState} values.\n *\n * @internal\n */\nexport type SupportState = (typeof SupportState)[keyof typeof SupportState];\n\n/** What one dynamic body the character pushed looks like. */\nexport interface CharacterPush {\n /** The node of the body that was pushed. */\n readonly node: LiteSceneNode;\n /** The world-space impulse the character applied. */\n readonly impulse: Vec3Like;\n /** Where the impulse was applied. */\n readonly point: Vec3Like;\n}\n\n/**\n * Creates a controller.\n *\n * @param world - The Havok world.\n * @param position - The starting world position of the capsule centre.\n * @param height - Total capsule height, tip to tip.\n * @param radius - Capsule radius.\n * @returns The controller.\n *\n * @internal\n */\nexport function createController(\n world: LitePhysicsWorld,\n position: Vec3Like,\n height: number,\n radius: number,\n): LiteCharacterController {\n return createPhysicsCharacterController(\n world,\n { x: position.x, y: position.y, z: position.z },\n { capsuleHeight: height, capsuleRadius: radius },\n );\n}\n\n/**\n * Applies the tuning fields `CharacterController` exposes.\n *\n * @param controller - The controller.\n * @param slopeCosine - The cosine of the steepest walkable slope.\n * @param skinWidth - The separation kept from surfaces, in metres.\n * @param strength - The push strength applied to dynamic bodies.\n *\n * @internal\n */\nexport function tuneController(\n controller: LiteCharacterController,\n slopeCosine: number,\n skinWidth: number,\n strength: number,\n): void {\n controller.maxSlopeCosine = slopeCosine;\n controller.keepDistance = skinWidth;\n controller.characterStrength = strength;\n}\n\n/**\n * Rebuilds the capsule without losing the controller's position, velocity, or subscriptions.\n *\n * @param controller - The controller.\n * @param height - The new total height.\n * @param radius - The new radius.\n * @param preserveFeet - Whether the foot position stays fixed as the height changes.\n *\n * @internal\n */\nexport function resizeController(\n controller: LiteCharacterController,\n height: number,\n radius: number,\n preserveFeet: boolean,\n): void {\n controller.setShapeOptions({ capsuleHeight: height, capsuleRadius: radius }, preserveFeet);\n}\n\n/**\n * Moves the character by a displacement, sliding along whatever it meets.\n *\n * @param controller - The controller.\n * @param displacement - The requested world-space displacement for this step.\n *\n * @internal\n */\nexport function moveController(controller: LiteCharacterController, displacement: Vec3Like): void {\n controller.moveWithCollisions({ x: displacement.x, y: displacement.y, z: displacement.z });\n}\n\n/**\n * Probes the surface under the character without moving it.\n *\n * @remarks\n * `checkSupport` wants a **unit** direction. It classifies by `1 - dot(slide, direction)²` against\n * `maxSlopeCosine²` (`lib/physics/character-controller.js`, `checkSupport`), which is `cos²` of the\n * slope only when `direction` has length 1. Passed raw gravity (length 9.81), the term fell below\n * the limit on any incline steeper than 4° to 5°, so every walkable slope read as `SLIDING` and\n * `isGrounded` was false on it (fixed 2026-10-14). Zero gravity probes straight down.\n *\n * @param controller - The controller.\n * @param deltaSeconds - The fixed step.\n * @param gravity - The probe direction, normally gravity; only its direction is used.\n * @param groundNormal - Written with the averaged supporting normal.\n * @returns The support classification.\n *\n * @internal\n */\nexport function probeSupport(\n controller: LiteCharacterController,\n deltaSeconds: number,\n gravity: Vec3Like,\n groundNormal: MutableVec3,\n): SupportState {\n const length = Math.hypot(gravity.x, gravity.y, gravity.z);\n const direction =\n length > 0 ? { x: gravity.x / length, y: gravity.y / length, z: gravity.z / length } : { x: 0, y: -1, z: 0 };\n const surface = controller.checkSupport(deltaSeconds, direction);\n const normal = surface.averageSurfaceNormal;\n groundNormal.set(normal.x, normal.y, normal.z);\n return toSupportState(surface.supportedState);\n}\n\n/**\n * The Havok body a controller's capsule is, which is what a query names to sweep *past* the\n * character rather than into it (`ShapeCastOptions.ignore`).\n *\n * @param controller - The controller.\n * @returns Its body handle.\n *\n * @internal\n */\nexport function controllerBody(controller: LiteCharacterController): LitePhysicsBody {\n return controller.getBody();\n}\n\n/**\n * The node of a controller's capsule body. Lite creates it for the controller, separate from the\n * entity's node, so it is what a ray hit on the capsule reports (`RaycastResult.body.node`).\n *\n * @param controller - The controller.\n * @returns The capsule body's node.\n *\n * @internal\n */\nexport function controllerNode(controller: LiteCharacterController): LiteSceneNode {\n return controller.getBody().node;\n}\n\n/**\n * Reads the controller's resolved position.\n *\n * @param controller - The controller.\n * @param out - The vector to write.\n *\n * @internal\n */\nexport function readControllerPosition(controller: LiteCharacterController, out: MutableVec3): void {\n const position = controller.getPosition();\n out.set(position.x, position.y, position.z);\n}\n\n/**\n * Teleports the controller, clearing any swept motion.\n *\n * @param controller - The controller.\n * @param position - The new world position.\n *\n * @internal\n */\nexport function writeControllerPosition(controller: LiteCharacterController, position: Vec3Like): void {\n controller.setPosition({ x: position.x, y: position.y, z: position.z });\n}\n\n/**\n * Reads the controller's velocity.\n *\n * @param controller - The controller.\n * @param out - The vector to write.\n *\n * @internal\n */\nexport function readControllerVelocity(controller: LiteCharacterController, out: MutableVec3): void {\n const velocity = controller.getVelocity();\n out.set(velocity.x, velocity.y, velocity.z);\n}\n\n/**\n * Sets the controller's velocity.\n *\n * @param controller - The controller.\n * @param velocity - The new world-space velocity.\n *\n * @internal\n */\nexport function writeControllerVelocity(controller: LiteCharacterController, velocity: Vec3Like): void {\n controller.setVelocity({ x: velocity.x, y: velocity.y, z: velocity.z });\n}\n\n/**\n * Subscribes to the dynamic bodies the character pushes.\n *\n * @param controller - The controller.\n * @param sink - Called once per pushed body, during the step.\n * @returns A disposer that removes the subscription.\n *\n * @internal\n */\nexport function onControllerPush(controller: LiteCharacterController, sink: (push: CharacterPush) => void): () => void {\n return controller.onTriggerCollisionObservable.add((event): void => {\n sink({ node: event.collider.node, impulse: event.impulse, point: event.impulsePosition });\n });\n}\n\n/**\n * Releases the controller's body, shape, and query collectors.\n *\n * @param controller - The controller.\n *\n * @internal\n */\nexport function disposeController(controller: LiteCharacterController): void {\n controller.dispose();\n}\n\n/**\n * Narrows Lite's support enum to {@link SupportState}.\n *\n * @param value - Lite's value.\n * @returns The matching state, defaulting to `unsupported`.\n */\nfunction toSupportState(value: number): SupportState {\n if (value === SupportState.supported) {\n return SupportState.supported;\n }\n return value === SupportState.sliding ? SupportState.sliding : SupportState.unsupported;\n}\n","import { Quat, Vec3, lerp } from \"@ignifx/core\";\nimport { Collider } from \"../components/collider.js\";\nimport { Rigidbody } from \"../components/rigidbody.js\";\nimport { PhysicsErrorCode, physicsError } from \"../errors.js\";\nimport {\n SupportState,\n controllerBody,\n controllerNode,\n createController,\n disposeController,\n moveController,\n onControllerPush,\n probeSupport,\n readControllerPosition,\n readControllerVelocity,\n resizeController as resizeLiteController,\n tuneController,\n writeControllerPosition,\n writeControllerVelocity,\n} from \"../lite/character.js\";\nimport {\n addContainerChild,\n afterStep,\n applyForce,\n applyImpulse,\n BodyMotion,\n CONTACT_FINISHED,\n CONTACT_STARTED,\n createBody,\n createContainer,\n destroyBody,\n destroyShape,\n destroyWorld,\n disposeSimulation,\n onCollisionEvents,\n onTriggerEvents,\n PrestepMode,\n readAngularVelocity,\n readLinearVelocity,\n readNodePose,\n setBodyCollisionEvents,\n setBodyMass,\n setBodyPrestep,\n setBodyShape,\n setBodyTransform,\n setGravity,\n setRotationLocks,\n setShapeFilter,\n setShapeMaterial,\n setShapeTrigger,\n setTimestep,\n setVelocityLimits,\n stepSimulation,\n writeAngularVelocity,\n writeLinearVelocity,\n writeNodePose,\n} from \"../lite/havok.js\";\nimport type { BodyRecord, QueryTarget } from \"./body-record.js\";\nimport type { CharacterController, SupportStateName } from \"../components/character-controller.js\";\nimport type { ContactPoint } from \"../events.js\";\nimport type { CharacterPush, LiteCharacterController } from \"../lite/character.js\";\nimport type {\n ContactRecord,\n LitePhysicsBody,\n LitePhysicsShape,\n LitePhysicsWorld,\n SimulationHandles,\n TriggerRecord,\n} from \"../lite/havok.js\";\nimport type { PhysicsMaterialValues, PhysicsSettings } from \"../settings.js\";\nimport type {\n Component,\n DiagnosticsGroup,\n Entity,\n ExtensionContext,\n LiteSceneNode,\n MutableVec3,\n PhysicsCallbackName,\n QuatLike,\n Vec3Like,\n} from \"@ignifx/core\";\n\n/**\n * The per-app physics runtime: the Havok world, the bodies, the character controllers, the event\n * drains, and the three things the systems ask it to do each frame — restore, step, interpolate\n * (`docs/architecture/09-physics.md` §1).\n *\n * Everything here is `@internal`; the public surface is `PhysicsService`, `Rigidbody`, the\n * colliders, and `CharacterController`.\n */\n\n/** What the extension hands the runtime. */\nexport interface PhysicsRuntimeOptions {\n /** The extension registration surface; the physics kernel hooks live on it. */\n readonly ctx: ExtensionContext;\n /** The resolved `physics` settings section. */\n readonly settings: PhysicsSettings;\n /** The null-engine scene the world is hosted on. */\n readonly simulation: SimulationHandles;\n /** The Havok world. */\n readonly world: LitePhysicsWorld;\n /** The `physics` diagnostics group. */\n readonly counters: DiagnosticsGroup;\n}\n\n/** One buffered trigger event, resolved to records during the step. */\ninterface TriggerSlot {\n /** `true` for an enter, `false` for an exit. */\n entered: boolean;\n /** The first participant, or `null`. */\n first: BodyRecord | null;\n /** The second participant, or `null`. */\n second: BodyRecord | null;\n}\n\n/** One buffered collision event. */\ninterface ContactSlot {\n /** `0` started, `1` continued, `2` finished. */\n phase: number;\n /** The contact point. */\n readonly point: Vec3;\n /** The contact normal. */\n readonly normal: Vec3;\n /** The resolving impulse. */\n impulse: number;\n /** The first participant, or `null` when its body is not an entity's (a character capsule). */\n first: BodyRecord | null;\n /** The second participant, or `null`. */\n second: BodyRecord | null;\n}\n\n/**\n * One character controller's runtime state. It is also the capsule's entry in the query index, so\n * `currentPosition` is the capsule centre and `halfExtents` its bounding box.\n */\ninterface ControllerRecord extends QueryTarget {\n /** The component. */\n readonly component: CharacterController;\n /** Lite's controller. */\n readonly controller: LiteCharacterController;\n /** The node of the capsule's Havok body, which a ray hit reports. */\n readonly node: LiteSceneNode;\n /** The entity's layer as of the last fixed step. */\n layer: number;\n /** The pose at the end of the previous step. */\n readonly previousPosition: Vec3;\n /** The authoritative pose at the end of the last step. */\n readonly currentPosition: Vec3;\n /** Whether the display position is interpolated. */\n interpolate: boolean;\n /** The subscription to Lite's push observable. */\n disconnect: () => void;\n}\n\n/** The pooled `TriggerEvent`, whose fields the dispatcher rewrites for each delivery. */\ninterface MutableTriggerEvent {\n /** The other participant. */\n other: Entity | null;\n /** The other participant's first collider. */\n otherCollider: Collider | null;\n /** The entity being called. */\n self: Entity;\n}\n\n/** The pooled `Collision`. */\ninterface MutableCollision {\n /** The other participant. */\n other: Entity | null;\n /** The other participant's first collider. */\n otherCollider: Collider | null;\n /** The entity being called. */\n self: Entity;\n /** The one-element pooled contact list. */\n readonly contacts: readonly ContactPoint[];\n /** The relative velocity, or `null` when the other participant is not an entity's body. */\n relativeVelocity: Vec3Like | null;\n}\n\n/**\n * The counters `09-physics.md` §9 and the plan's diagnostics deliverable name.\n *\n * @public\n */\nexport const PHYSICS_DIAGNOSTICS_COUNTERS: readonly string[] = Object.freeze([\n \"bodies\",\n \"activeBodies\",\n \"stepsThisFrame\",\n \"collisionEvents\",\n \"triggerEvents\",\n \"queries\",\n \"stepMs\",\n]);\n\n/**\n * The diagnostics group name.\n *\n * @public\n */\nexport const PHYSICS_DIAGNOSTICS_GROUP = \"physics\";\n\n/** How many layers a project can declare, and therefore how wide a filter mask is. */\nconst LAYER_COUNT = 32;\n\n/** Milliseconds in one second. */\nconst MILLISECONDS_PER_SECOND = 1000;\n\n/** How far a body may move before the implicit-static diagnostic considers it moved. */\nconst STATIC_MOVE_EPSILON = 1e-6;\n\n/**\n * The per-app physics runtime.\n *\n * @internal\n */\nexport class PhysicsRuntime {\n readonly #ctx: ExtensionContext;\n\n readonly #settings: PhysicsSettings;\n\n readonly #simulation: SimulationHandles;\n\n readonly #world: LitePhysicsWorld;\n\n readonly #counters: DiagnosticsGroup;\n\n readonly #records: BodyRecord[] = [];\n\n readonly #byEntity = new Map<Entity, BodyRecord>();\n\n readonly #byNode = new Map<LiteSceneNode, BodyRecord>();\n\n readonly #dirty = new Set<Entity>();\n\n readonly #controllers: ControllerRecord[] = [];\n\n readonly #controllersByNode = new Map<LiteSceneNode, ControllerRecord>();\n\n readonly #dirtyControllers = new Set<CharacterController>();\n\n readonly #collideMasks = new Int32Array(LAYER_COUNT).fill(~0);\n\n readonly #triggerSlots: TriggerSlot[] = [];\n\n readonly #contactSlots: ContactSlot[] = [];\n\n #triggerEvent: MutableTriggerEvent | null = null;\n\n readonly #contactPoint: { point: Vec3; normal: Vec3; impulse: number } = {\n point: new Vec3(),\n normal: new Vec3(),\n impulse: 0,\n };\n\n readonly #contacts: ContactPoint[] = [];\n\n #collision: MutableCollision | null = null;\n\n readonly #scratchPosition = new Vec3();\n\n readonly #scratchRotation = new Quat();\n\n readonly #scratchVector = new Vec3();\n\n readonly #scratchOther = new Vec3();\n\n readonly #relativeVelocity = new Vec3();\n\n readonly #gravityDirection = new Vec3(0, -1, 0);\n\n #triggerCount = 0;\n\n #contactCount = 0;\n\n #stepped = false;\n\n #disposed = false;\n\n #queries = 0;\n\n #stepsThisFrame = 0;\n\n #stepMs = 0;\n\n #collisionEventCount = 0;\n\n #triggerEventCount = 0;\n\n #activeBodies = 0;\n\n /**\n * Builds the runtime, applies the world settings, and registers the event drains.\n *\n * @param options - The context, settings, scene, world, and counters.\n * @throws IgnifxError with code `IGX-0905` when the collision matrix names an unknown layer.\n */\n constructor(options: PhysicsRuntimeOptions) {\n this.#ctx = options.ctx;\n this.#settings = options.settings;\n this.#simulation = options.simulation;\n this.#world = options.world;\n this.#counters = options.counters;\n this.#contacts.push(this.#contactPoint);\n\n setGravity(this.#world, this.#settings.gravity);\n const gravity = this.#settings.gravity;\n const magnitude = Math.hypot(gravity.x, gravity.y, gravity.z);\n if (magnitude > 0) {\n this.#gravityDirection.set(gravity.x / magnitude, gravity.y / magnitude, gravity.z / magnitude);\n }\n const limits = this.#settings.velocityLimits;\n if (limits.linear > 0 || limits.angular > 0) {\n setVelocityLimits(this.#world, limits.linear, limits.angular);\n }\n this.#buildCollideMasks();\n onTriggerEvents(this.#world, (record): void => {\n this.#bufferTrigger(record);\n });\n onCollisionEvents(this.#world, (record): void => {\n this.#bufferContact(record);\n });\n afterStep(this.#world, (): void => {\n // Registered last, so it runs after both drains have filled the buffers.\n });\n }\n\n /**\n * The Havok world, for the query and viewer paths.\n *\n * @returns The world handle.\n */\n get world(): LitePhysicsWorld {\n return this.#world;\n }\n\n /**\n * Whether at least one fixed step has run, which is what Havok's broadphase needs before a query\n * can answer (`09-physics.md` §5).\n *\n * @returns `true` once a step has completed.\n */\n get hasStepped(): boolean {\n return this.#stepped;\n }\n\n /**\n * Every body, in creation order.\n *\n * @returns The records.\n */\n get records(): readonly BodyRecord[] {\n return this.#records;\n }\n\n /**\n * The resolved settings.\n *\n * @returns The `physics` section.\n */\n get settings(): PhysicsSettings {\n return this.#settings;\n }\n\n /**\n * Replaces world gravity.\n *\n * @param gravity - The new acceleration vector.\n */\n setGravity(gravity: Vec3Like): void {\n setGravity(this.#world, gravity);\n }\n\n /**\n * Marks an entity's body for a rebuild at the start of the next fixed step.\n *\n * @param entity - The entity whose colliders or `Rigidbody` changed.\n */\n markDirty(entity: Entity): void {\n if (!this.#disposed && !entity.isDestroyed) {\n this.#dirty.add(entity);\n }\n }\n\n /**\n * Marks a character controller for a rebuild at the start of the next fixed step.\n *\n * @param component - The controller component.\n */\n markControllerDirty(component: CharacterController): void {\n if (!this.#disposed) {\n this.#dirtyControllers.add(component);\n }\n }\n\n /**\n * Restores the authoritative pose of every interpolated body and controller, undoing the display\n * pose the `Update` system wrote at the top of the previous frame's `Update`\n * (`09-physics.md` §1, spike S4.3).\n */\n restorePoses(): void {\n for (let index = 0; index < this.#records.length; index += 1) {\n const record = this.#records[index];\n if (record !== undefined && record.interpolate) {\n writeNodePose(record.node, record.currentPosition, record.currentRotation);\n }\n }\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record !== undefined && record.interpolate) {\n this.#writeControllerTransform(record, record.currentPosition);\n }\n }\n }\n\n /**\n * Runs one fixed step: reconcile, step Havok, snapshot poses, dispatch events.\n *\n * @param fixedDeltaSeconds - The fixed step in seconds.\n */\n step(fixedDeltaSeconds: number): void {\n this.#syncLayers();\n this.#reconcile();\n this.#applyControllerMoves(fixedDeltaSeconds);\n setTimestep(this.#world, fixedDeltaSeconds);\n this.#triggerCount = 0;\n this.#contactCount = 0;\n const started = now();\n stepSimulation(this.#simulation, fixedDeltaSeconds * MILLISECONDS_PER_SECOND);\n this.#stepMs += now() - started;\n this.#stepsThisFrame += 1;\n this.#stepped = true;\n this.#snapshot(fixedDeltaSeconds);\n this.#dispatchTriggers();\n this.#dispatchContacts();\n }\n\n /**\n * Writes the interpolated display pose of every interpolated body and controller.\n *\n * @param alpha - `time.fixedStepAlpha`, in `[0, 1)`.\n */\n interpolate(alpha: number): void {\n this.#publishCounters();\n for (let index = 0; index < this.#records.length; index += 1) {\n const record = this.#records[index];\n if (record === undefined || !record.interpolate) {\n continue;\n }\n const position = this.#scratchPosition;\n position.set(\n lerp(record.previousPosition.x, record.currentPosition.x, alpha),\n lerp(record.previousPosition.y, record.currentPosition.y, alpha),\n lerp(record.previousPosition.z, record.currentPosition.z, alpha),\n );\n Quat.slerpToRef(record.previousRotation, record.currentRotation, alpha, this.#scratchRotation);\n writeNodePose(record.node, position, this.#scratchRotation);\n }\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record === undefined || !record.interpolate) {\n continue;\n }\n this.#scratchPosition.set(\n lerp(record.previousPosition.x, record.currentPosition.x, alpha),\n lerp(record.previousPosition.y, record.currentPosition.y, alpha),\n lerp(record.previousPosition.z, record.currentPosition.z, alpha),\n );\n this.#writeControllerTransform(record, this.#scratchPosition);\n }\n }\n\n /**\n * The Havok body of an entity, for the `.lite` escape hatch and the debug viewer.\n *\n * @param entity - The entity.\n * @returns The body handle, or `null`.\n */\n bodyHandleOf(entity: Entity): BodyRecord[\"body\"] | null {\n return this.#byEntity.get(entity)?.body ?? null;\n }\n\n /**\n * The record an entity owns.\n *\n * @param entity - The entity.\n * @returns The record, or `null`.\n */\n recordOf(entity: Entity): BodyRecord | null {\n return this.#byEntity.get(entity) ?? null;\n }\n\n /**\n * The Havok body an entity's physics is, whether that is a `Rigidbody`, a collider-only static, or\n * a `CharacterController`'s capsule — which is what a sweep names to pass through it\n * (`ShapeCastOptions.ignore`).\n *\n * @param entity - The entity.\n * @returns The body, or `null` when the entity has none yet: a body is built on the fixed step\n * after its components attach, so a query in the same frame finds nothing to ignore.\n */\n bodyOf(entity: Entity): LitePhysicsBody | null {\n const record = this.#byEntity.get(entity);\n if (record !== undefined) {\n return record.body;\n }\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const controller = this.#controllers[index];\n if (controller !== undefined && controller.component.entity === entity) {\n return controllerBody(controller.controller);\n }\n }\n return null;\n }\n\n /**\n * The record a Lite node belongs to, which is how a Havok event or query result becomes an entity.\n *\n * @param node - The node.\n * @returns The record, or `null`.\n */\n recordOfNode(node: LiteSceneNode | null): BodyRecord | null {\n return node === null ? null : (this.#byNode.get(node) ?? null);\n }\n\n /**\n * What a query hit on a Lite node: a body record, or a character controller's capsule.\n *\n * @param node - The node of the body that was hit.\n * @returns The target, or `null` when the node belongs to neither.\n */\n targetOfNode(node: LiteSceneNode | null): QueryTarget | null {\n if (node === null) {\n return null;\n }\n return this.#byNode.get(node) ?? this.#controllersByNode.get(node) ?? null;\n }\n\n /**\n * How many entries the query index holds: every body record, then every character controller.\n *\n * @returns The count.\n */\n get queryTargetCount(): number {\n return this.#records.length + this.#controllers.length;\n }\n\n /**\n * One entry of the query index. Bodies come first and controllers after, each in creation order,\n * so `overlap` lists them in a stable order (`09-physics.md` §8).\n *\n * @param index - An index below {@link PhysicsRuntime.queryTargetCount}.\n * @returns The target, or `undefined` past the end.\n */\n queryTargetAt(index: number): QueryTarget | undefined {\n const bodies = this.#records.length;\n return index < bodies ? this.#records[index] : this.#controllers[index - bodies];\n }\n\n /** Counts one query for the diagnostics group. */\n countQuery(): void {\n this.#queries += 1;\n }\n\n /**\n * Reads a body's linear velocity.\n *\n * @param entity - The entity.\n * @param out - The vector to write; left untouched when there is no body.\n */\n readLinear(entity: Entity, out: MutableVec3): void {\n const record = this.#byEntity.get(entity);\n if (record !== undefined) {\n readLinearVelocity(this.#world, record.body, out);\n }\n }\n\n /**\n * Reads a body's angular velocity.\n *\n * @param entity - The entity.\n * @param out - The vector to write.\n */\n readAngular(entity: Entity, out: MutableVec3): void {\n const record = this.#byEntity.get(entity);\n if (record !== undefined) {\n readAngularVelocity(this.#world, record.body, out);\n }\n }\n\n /**\n * Sets a body's linear velocity.\n *\n * @param entity - The entity.\n * @param velocity - Metres per second, world space.\n */\n setLinearVelocity(entity: Entity, velocity: Vec3Like): void {\n const record = this.#byEntity.get(entity);\n if (record !== undefined) {\n writeLinearVelocity(this.#world, record.body, velocity);\n }\n }\n\n /**\n * Sets a body's angular velocity.\n *\n * @param entity - The entity.\n * @param velocity - Radians per second, world space.\n */\n setAngularVelocity(entity: Entity, velocity: Vec3Like): void {\n const record = this.#byEntity.get(entity);\n if (record !== undefined) {\n writeAngularVelocity(this.#world, record.body, velocity);\n }\n }\n\n /**\n * Applies a force for one fixed step.\n *\n * @param entity - The entity.\n * @param force - Newtons, world space.\n * @param point - The application point.\n */\n addForce(entity: Entity, force: Vec3Like, point: Vec3Like): void {\n const record = this.#byEntity.get(entity);\n if (record !== undefined) {\n applyForce(this.#world, record.body, force, point);\n }\n }\n\n /**\n * Applies an impulse.\n *\n * @param entity - The entity.\n * @param impulse - Newton-seconds, world space.\n * @param point - The application point.\n */\n addImpulse(entity: Entity, impulse: Vec3Like, point: Vec3Like): void {\n const record = this.#byEntity.get(entity);\n if (record !== undefined) {\n applyImpulse(record.body, impulse, point);\n }\n }\n\n /**\n * Teleports a body and resets its interpolation history.\n *\n * @param entity - The entity.\n * @param position - The new world position.\n * @param rotation - The new world rotation.\n */\n teleport(entity: Entity, position: Vec3Like, rotation: QuatLike): void {\n const record = this.#byEntity.get(entity);\n if (record === undefined) {\n writeNodePose(entity.transform.lite, position, rotation);\n return;\n }\n setBodyTransform(this.#world, record.body, position, rotation);\n writeNodePose(record.node, position, rotation);\n record.currentPosition.set(position.x, position.y, position.z);\n record.currentRotation.set(rotation.x, rotation.y, rotation.z, rotation.w);\n record.previousPosition.set(position.x, position.y, position.z);\n record.previousRotation.set(rotation.x, rotation.y, rotation.z, rotation.w);\n }\n\n /**\n * Sets a character controller's velocity.\n *\n * @param component - The controller component.\n * @param velocity - Metres per second, world space.\n */\n setControllerVelocity(component: CharacterController, velocity: Vec3Like): void {\n const record = this.#controllerOf(component);\n if (record !== null) {\n writeControllerVelocity(record.controller, velocity);\n }\n }\n\n /**\n * Reads a character controller's velocity.\n *\n * @param component - The controller component.\n * @param out - The vector to write.\n */\n readControllerVelocity(component: CharacterController, out: MutableVec3): void {\n const record = this.#controllerOf(component);\n if (record !== null) {\n readControllerVelocity(record.controller, out);\n }\n }\n\n /**\n * Reads a character controller's world position.\n *\n * @param component - The controller component.\n * @param out - The vector to write.\n */\n readControllerPosition(component: CharacterController, out: MutableVec3): void {\n const record = this.#controllerOf(component);\n if (record !== null) {\n readControllerPosition(record.controller, out);\n }\n }\n\n /**\n * Rebuilds a controller's capsule in place.\n *\n * @param component - The controller component.\n * @param preserveFeet - Whether the foot position stays fixed.\n */\n resizeController(component: CharacterController, preserveFeet: boolean): void {\n const record = this.#controllerOf(component);\n if (record !== null) {\n resizeLiteController(record.controller, component.height, component.radius, preserveFeet);\n // The centre catches up on the next fixed step, which is also when Havok moves the body.\n capsuleHalfExtents(component.height, component.radius, record.halfExtents);\n }\n }\n\n /**\n * Teleports a controller and resets its interpolation history.\n *\n * @param component - The controller component.\n * @param position - The new entity world position.\n */\n teleportController(component: CharacterController, position: Vec3Like): void {\n const record = this.#controllerOf(component);\n if (record === null) {\n component.transform.position = position;\n return;\n }\n const centre = this.#scratchVector;\n centre.set(position.x + component.center.x, position.y + component.center.y, position.z + component.center.z);\n writeControllerPosition(record.controller, centre);\n record.currentPosition.set(centre.x, centre.y, centre.z);\n record.previousPosition.set(centre.x, centre.y, centre.z);\n this.#writeControllerTransform(record, centre);\n }\n\n /**\n * Releases a controller's Lite resources.\n *\n * @param component - The controller component.\n */\n releaseController(component: CharacterController): void {\n this.#dirtyControllers.delete(component);\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record?.component === component) {\n record.disconnect();\n disposeController(record.controller);\n this.#controllers.splice(index, 1);\n this.#controllersByNode.delete(record.node);\n return;\n }\n }\n }\n\n /**\n * Tears every body and controller down, then releases the Havok world **before** the simulation\n * scene, which is the order `docs/architecture/07-rendering.md` §7 requires.\n */\n dispose(): void {\n if (this.#disposed) {\n return;\n }\n this.#disposed = true;\n for (let index = this.#controllers.length - 1; index >= 0; index -= 1) {\n const record = this.#controllers[index];\n if (record !== undefined) {\n record.disconnect();\n disposeController(record.controller);\n }\n }\n this.#controllers.length = 0;\n this.#controllersByNode.clear();\n for (let index = this.#records.length - 1; index >= 0; index -= 1) {\n const record = this.#records[index];\n if (record !== undefined) {\n this.#teardown(record);\n }\n }\n this.#records.length = 0;\n this.#byEntity.clear();\n this.#byNode.clear();\n destroyWorld(this.#world);\n disposeSimulation(this.#simulation);\n }\n\n /**\n * Publishes the frame's counters and zeroes the accumulators. The kernel resets `FrameSample` each\n * frame but not diagnostics **groups** (`Diagnostics.beginFrame`), so a group that reports\n * per-frame totals resets itself — and the top of `Update`, where the display pose is written, is\n * the first point in a frame at which every fixed step of that frame is done.\n */\n #publishCounters(): void {\n this.#counters.set(this.#index(\"bodies\"), this.#records.length);\n this.#counters.set(this.#index(\"activeBodies\"), this.#activeBodies);\n this.#counters.set(this.#index(\"stepsThisFrame\"), this.#stepsThisFrame);\n this.#counters.set(this.#index(\"collisionEvents\"), this.#collisionEventCount);\n this.#counters.set(this.#index(\"triggerEvents\"), this.#triggerEventCount);\n this.#counters.set(this.#index(\"queries\"), this.#queries);\n this.#counters.set(this.#index(\"stepMs\"), this.#stepMs);\n this.#stepsThisFrame = 0;\n this.#collisionEventCount = 0;\n this.#triggerEventCount = 0;\n this.#queries = 0;\n this.#stepMs = 0;\n }\n\n /**\n * Resolves a counter name to its index. Called with literal names only, from paths that run once\n * per step rather than once per body.\n *\n * @param counter - The counter name.\n * @returns Its index.\n */\n #index(counter: string): number {\n return this.#counters.index(counter);\n }\n\n /**\n * Builds the per-layer collide masks from `physics.collisionMatrix` (`09-physics.md` §3).\n *\n * @remarks\n * A layer the matrix does not mention keeps `~0`, so a default project needs no matrix at all.\n * Havok tests the pair in both directions, so one side listing the other is enough to *allow* the\n * pair and one side omitting it is enough to *block* it.\n *\n * @throws IgnifxError with code `IGX-0905` when a name is not a declared layer.\n */\n #buildCollideMasks(): void {\n const layers = this.#ctx.app.world.layers;\n for (const [name, others] of Object.entries(this.#settings.collisionMatrix)) {\n const index = layers.indexOf(name);\n if (index < 0) {\n throw unknownLayer(name);\n }\n let mask = 0;\n for (const other of others) {\n const otherIndex = layers.indexOf(other);\n if (otherIndex < 0) {\n throw unknownLayer(other);\n }\n mask |= 1 << otherIndex;\n }\n this.#collideMasks[index] = mask;\n }\n }\n\n /**\n * Rebuilds every body marked dirty, and every controller.\n */\n #reconcile(): void {\n if (this.#dirty.size > 0) {\n const pending = [...this.#dirty];\n this.#dirty.clear();\n for (const entity of pending) {\n this.#rebuildEntity(entity);\n }\n }\n if (this.#dirtyControllers.size > 0) {\n const pending = [...this.#dirtyControllers];\n this.#dirtyControllers.clear();\n for (const component of pending) {\n this.#rebuildController(component);\n }\n }\n }\n\n /**\n * Tears an entity's body down and builds a new one from its current colliders.\n *\n * @param entity - The entity to rebuild.\n */\n #rebuildEntity(entity: Entity): void {\n const existing = this.#byEntity.get(entity);\n let carriedLinear: Vec3 | null = null;\n let carriedAngular: Vec3 | null = null;\n if (existing !== undefined) {\n if (existing.motion === BodyMotion.dynamic) {\n carriedLinear = new Vec3();\n carriedAngular = new Vec3();\n readLinearVelocity(this.#world, existing.body, carriedLinear);\n readAngularVelocity(this.#world, existing.body, carriedAngular);\n }\n this.#teardown(existing);\n const index = this.#records.indexOf(existing);\n if (index >= 0) {\n this.#records.splice(index, 1);\n }\n this.#byEntity.delete(entity);\n this.#byNode.delete(existing.node);\n }\n if (entity.isDestroyed || !entity.activeInHierarchy) {\n return;\n }\n const colliders = collidersOf(entity);\n if (colliders.length === 0) {\n return;\n }\n const rigidbody = entity.getComponent(Rigidbody);\n if (entity.parent !== null) {\n this.#ctx.log.warn(\n `${PhysicsErrorCode.bodyOnChildEntity}: {entity} carries a physics body but is not a root entity; Havok writes its local pose.`,\n entity.name,\n );\n }\n const record = this.#build(entity, rigidbody, colliders);\n this.#records.push(record);\n if (record.motion === BodyMotion.dynamic && carriedLinear !== null && carriedAngular !== null) {\n writeLinearVelocity(this.#world, record.body, carriedLinear);\n writeAngularVelocity(this.#world, record.body, carriedAngular);\n }\n }\n\n /**\n * Drops an entity's body immediately. `markDirty` refuses a destroyed entity — by the time\n * `onDestroyed` fires the entity is already gone — so destruction takes this path instead.\n *\n * @param entity - The entity whose body goes away.\n */\n #removeRecord(entity: Entity): void {\n const record = this.#byEntity.get(entity);\n if (record === undefined) {\n return;\n }\n this.#teardown(record);\n const index = this.#records.indexOf(record);\n if (index >= 0) {\n this.#records.splice(index, 1);\n }\n this.#byEntity.delete(entity);\n this.#byNode.delete(record.node);\n this.#dirty.delete(entity);\n }\n\n /**\n * Builds one body from an entity's colliders.\n *\n * @param entity - The entity.\n * @param rigidbody - Its `Rigidbody`, or `null` for an implicit static body.\n * @param colliders - Its colliders, in component order.\n * @returns The new record.\n */\n #build(entity: Entity, rigidbody: Rigidbody | null, colliders: readonly Collider[]): BodyRecord {\n const node = entity.transform.lite;\n const scale = entity.transform.lossyScale;\n const layer = entity.layer;\n const shapes = this.#buildShapeTree(colliders, scale, node, layer);\n const root = shapes.at(-1);\n if (root === undefined) {\n throw new Error(\"a body needs at least one collider\");\n }\n const motion = motionOf(rigidbody);\n const body = this.#createBody(node, root, rigidbody, motion);\n\n const record: BodyRecord = {\n entity,\n node,\n rigidbody,\n colliders: [...colliders],\n body,\n shapes,\n motion,\n interpolate: this.#shouldInterpolate(rigidbody, motion),\n layer,\n collisionEvents: false,\n previousPosition: new Vec3(),\n previousRotation: new Quat(),\n currentPosition: new Vec3(),\n currentRotation: new Quat(),\n halfExtents: boundsOf(colliders, scale),\n staticVersion: entity.transform.worldMatrixVersion,\n reportedMove: false,\n disconnects: [],\n };\n readNodePose(node, record.currentPosition, record.currentRotation);\n record.previousPosition.copyFrom(record.currentPosition);\n record.previousRotation.copyFrom(record.currentRotation);\n\n this.#byEntity.set(entity, record);\n this.#byNode.set(node, record);\n this.#applyCollisionEvents(record);\n this.#watchEntity(record);\n return record;\n }\n\n /**\n * Keeps a record in step with its entity: component changes rebuild, destruction removes.\n *\n * @param record - The record to watch.\n */\n #watchEntity(record: BodyRecord): void {\n const entity = record.entity;\n record.disconnects.push(\n entity.onComponentAdded.connect((component: Component): void => {\n this.#onComponentChanged(record, component);\n }),\n entity.onComponentRemoved.connect((component: Component): void => {\n this.#onComponentChanged(record, component);\n }),\n entity.onDestroyed.connect((): void => {\n this.#removeRecord(entity);\n }),\n );\n }\n\n /**\n * Builds the shapes for a body: one shape for a single collider, or a container holding a child\n * per collider. The root shape is the **last** entry.\n *\n * @param colliders - The colliders, in component order.\n * @param scale - The entity's lossy scale.\n * @param node - The entity's Lite node.\n * @param layer - The entity's layer.\n * @returns Every shape created, root last, for release when the body goes.\n */\n #buildShapeTree(colliders: readonly Collider[], scale: Vec3, node: LiteSceneNode, layer: number): LitePhysicsShape[] {\n const defaults = this.#settings.defaultMaterial;\n const shapes: LitePhysicsShape[] = [];\n const only = colliders.length === 1 ? colliders[0] : undefined;\n if (only !== undefined) {\n shapes.push(this.#buildShape(only, scale, node, layer, defaults));\n return shapes;\n }\n const root = createContainer(this.#world);\n for (const collider of colliders) {\n const child = this.#buildShape(collider, scale, node, layer, defaults);\n shapes.push(child);\n addContainerChild(this.#world, root, child, Vec3.zero(), Quat.identity());\n }\n setShapeFilter(this.#world, root, membershipOf(layer), this.#collideMaskOf(layer));\n shapes.push(root);\n return shapes;\n }\n\n /**\n * Creates the Havok body for a record and applies its motion-dependent settings.\n *\n * @param node - The entity's Lite node.\n * @param root - The root shape.\n * @param rigidbody - The `Rigidbody`, or `null` for an implicit static body.\n * @param motion - The motion type derived from the rigidbody.\n * @returns The body.\n */\n #createBody(\n node: LiteSceneNode,\n root: LitePhysicsShape,\n rigidbody: Rigidbody | null,\n motion: BodyMotion,\n ): LitePhysicsBody {\n const body = createBody(this.#world, node, motion, rigidbody?.startAsleep ?? false);\n setBodyShape(this.#world, body, root);\n if (motion === BodyMotion.dynamic) {\n setBodyMass(this.#world, body, rigidbody?.mass ?? 1);\n }\n if (motion === BodyMotion.kinematic) {\n setBodyPrestep(body, rigidbody?.kinematicSync === \"velocity\" ? PrestepMode.velocity : PrestepMode.teleport);\n }\n if (rigidbody !== null) {\n setRotationLocks(this.#world, body, lockedAxes(rigidbody));\n }\n return body;\n }\n\n /**\n * Builds one collider's shape and applies its filter, material, and trigger flag.\n *\n * @param collider - The collider.\n * @param scale - The entity's lossy scale.\n * @param node - The entity's node.\n * @param layer - The entity's layer.\n * @param defaults - The world's default material.\n * @returns The shape.\n */\n #buildShape(\n collider: Collider,\n scale: Vec3Like,\n node: LiteSceneNode,\n layer: number,\n defaults: PhysicsMaterialValues,\n ): LitePhysicsShape {\n const shape = collider.createShape(this.#world, scale, node);\n const effective = this.#layerOf(collider, layer);\n setShapeFilter(this.#world, shape, membershipOf(effective), this.#collideMaskOf(effective));\n const material = collider.resolveMaterial(defaults);\n setShapeMaterial(this.#world, shape, material.friction, material.restitution, material.staticFriction);\n if (collider.isTrigger) {\n setShapeTrigger(this.#world, shape, true);\n }\n return shape;\n }\n\n /**\n * The layer a collider filters as: its override, or its entity's.\n *\n * @param collider - The collider.\n * @param fallback - The entity's layer.\n * @returns The layer index.\n * @throws IgnifxError with code `IGX-0905` when the override names an undeclared layer.\n */\n #layerOf(collider: Collider, fallback: number): number {\n if (collider.layerOverride === \"\") {\n return fallback;\n }\n const index = this.#ctx.app.world.layers.indexOf(collider.layerOverride);\n if (index < 0) {\n throw unknownLayer(collider.layerOverride);\n }\n return index;\n }\n\n /**\n * The collide mask of a layer.\n *\n * @param layer - The layer index.\n * @returns The 32-bit mask.\n */\n #collideMaskOf(layer: number): number {\n return this.#collideMasks[layer] ?? ~0;\n }\n\n /**\n * Whether a body's display pose is interpolated.\n *\n * @param rigidbody - The `Rigidbody`, or `null`.\n * @param motion - The motion type.\n * @returns `true` when interpolation applies.\n */\n #shouldInterpolate(rigidbody: Rigidbody | null, motion: BodyMotion): boolean {\n if (!this.#settings.interpolation || motion === BodyMotion.static || rigidbody === null) {\n return false;\n }\n return rigidbody.interpolation === \"interpolate\";\n }\n\n /**\n * Recomputes `collisionEvents` when a component joins or leaves the entity (`09-physics.md` §2.1).\n *\n * @param record - The body record.\n * @param component - The component that changed.\n */\n #onComponentChanged(record: BodyRecord, component: Component): void {\n if (component instanceof Collider || component instanceof Rigidbody) {\n this.markDirty(record.entity);\n return;\n }\n this.#applyCollisionEvents(record);\n }\n\n /**\n * Pushes the effective `collisionEvents` value to Havok.\n *\n * @param record - The body record.\n */\n #applyCollisionEvents(record: BodyRecord): void {\n const mode = record.rigidbody?.collisionEvents ?? \"auto\";\n const enabled = mode === \"on\" ? true : mode === \"off\" ? false : this.#entityWantsCollisions(record.entity);\n if (enabled !== record.collisionEvents) {\n record.collisionEvents = enabled;\n setBodyCollisionEvents(this.#world, record.body, enabled);\n }\n }\n\n /**\n * Whether any script on an entity implements a collision callback.\n *\n * @param entity - The entity.\n * @returns `true` when at least one does.\n */\n #entityWantsCollisions(entity: Entity): boolean {\n return (\n this.#ctx.entityImplements(entity, \"onCollisionEnter\") ||\n this.#ctx.entityImplements(entity, \"onCollisionStay\") ||\n this.#ctx.entityImplements(entity, \"onCollisionExit\")\n );\n }\n\n /**\n * Applies a runtime `entity.layer` change to the filter masks, which `09-physics.md` §3 says\n * happens on the next fixed step.\n */\n #syncLayers(): void {\n for (let index = 0; index < this.#records.length; index += 1) {\n const record = this.#records[index];\n if (record === undefined || record.entity.layer === record.layer) {\n continue;\n }\n // Rewriting a shape's filter masks in place does **not** move a body between broadphase\n // groups in @babylonjs/havok@1.3.14 — neither on its own nor with the shape re-attached\n // (measured: a resting body kept colliding with a layer its new mask excludes). The body is\n // therefore rebuilt, which is still \"on the next fixed step\" as `09-physics.md` §3 promises;\n // `#rebuildEntity` carries the velocities across so the change is not felt as a teleport.\n this.markDirty(record.entity);\n }\n // A capsule's layer only steers queries: Lite builds its shape with every filter bit set and\n // gives no access to it, so there is nothing to rebuild.\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record !== undefined) {\n record.layer = record.entity.layer;\n }\n }\n }\n\n /**\n * Snapshots every body's authoritative pose and reports implicit-static bodies that moved.\n *\n * @param fixedDeltaSeconds - The fixed step, used to probe controller support.\n */\n #snapshot(fixedDeltaSeconds: number): void {\n let active = 0;\n for (let index = 0; index < this.#records.length; index += 1) {\n const record = this.#records[index];\n if (record === undefined) {\n continue;\n }\n record.previousPosition.copyFrom(record.currentPosition);\n record.previousRotation.copyFrom(record.currentRotation);\n readNodePose(record.node, record.currentPosition, record.currentRotation);\n if (record.motion === BodyMotion.dynamic && !nearlyEqual(record.previousPosition, record.currentPosition)) {\n active += 1;\n }\n if (record.rigidbody === null) {\n this.#checkStaticMove(record);\n }\n }\n this.#activeBodies = active;\n this.#snapshotControllers(fixedDeltaSeconds);\n }\n\n /**\n * Reports `IGX-0901` once for an implicit static body whose transform moved.\n *\n * @param record - The body record.\n */\n #checkStaticMove(record: BodyRecord): void {\n const version = record.entity.transform.worldMatrixVersion;\n if (version === record.staticVersion || record.reportedMove) {\n return;\n }\n record.staticVersion = version;\n record.reportedMove = true;\n this.#ctx.log.warn(\n `${PhysicsErrorCode.movedStaticBody}: {entity} has colliders but no Rigidbody, and it moved after its static body was placed.`,\n record.entity.name,\n );\n }\n\n /**\n * Reads every controller's resolved position into the entity transform and probes its support.\n *\n * @param fixedDeltaSeconds - The fixed step.\n */\n #snapshotControllers(fixedDeltaSeconds: number): void {\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record === undefined) {\n continue;\n }\n record.previousPosition.copyFrom(record.currentPosition);\n readControllerPosition(record.controller, record.currentPosition);\n const state = probeSupport(record.controller, fixedDeltaSeconds, this.#settings.gravity, this.#scratchVector);\n record.component.applyStepResult(supportName(state), this.#scratchVector);\n this.#writeControllerTransform(record, record.currentPosition);\n }\n }\n\n /**\n * Hands every controller its accumulated displacement.\n *\n * @param fixedDeltaSeconds - The fixed step, unused by `moveWithCollisions` but kept for symmetry.\n */\n #applyControllerMoves(fixedDeltaSeconds: number): void {\n void fixedDeltaSeconds;\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record === undefined) {\n continue;\n }\n moveController(record.controller, record.component.takePendingMove());\n }\n }\n\n /**\n * Writes a controller's capsule centre back onto its entity, undoing the component's `center`.\n *\n * @param record - The controller record.\n * @param centre - The capsule centre in world space.\n */\n #writeControllerTransform(record: ControllerRecord, centre: Vec3Like): void {\n const component = record.component;\n this.#scratchOther.set(centre.x - component.center.x, centre.y - component.center.y, centre.z - component.center.z);\n component.transform.position = this.#scratchOther;\n }\n\n /**\n * Builds or rebuilds one controller.\n *\n * @param component - The controller component.\n */\n #rebuildController(component: CharacterController): void {\n this.releaseController(component);\n if (component.isDestroyed || !component.isEnabledInHierarchy) {\n return;\n }\n const position = component.transform.position;\n const centre = new Vec3(\n position.x + component.center.x,\n position.y + component.center.y,\n position.z + component.center.z,\n );\n const controller = createController(this.#world, centre, component.height, component.radius);\n tuneController(\n controller,\n Math.cos((component.slopeLimit * Math.PI) / 180),\n component.skinWidth,\n component.pushStrength * DEFAULT_CHARACTER_STRENGTH,\n );\n const record: ControllerRecord = {\n component,\n controller,\n node: controllerNode(controller),\n entity: component.entity,\n colliders: NO_COLLIDERS,\n layer: component.entity.layer,\n halfExtents: capsuleHalfExtents(component.height, component.radius, new Vec3()),\n previousPosition: centre.clone(),\n currentPosition: centre.clone(),\n interpolate: this.#settings.interpolation && component.interpolation === \"interpolate\",\n disconnect: (): void => {\n // Replaced immediately below; a record is never observed with this placeholder.\n },\n };\n record.disconnect = onControllerPush(controller, (push: CharacterPush): void => {\n this.#reportPush(record, push);\n });\n this.#controllers.push(record);\n this.#controllersByNode.set(record.node, record);\n }\n\n /**\n * Turns one Lite push event into a `CharacterCollision`.\n *\n * @param record - The controller record.\n * @param push - What Lite reported.\n */\n #reportPush(record: ControllerRecord, push: CharacterPush): void {\n record.component.reportPush({\n other: this.recordOfNode(push.node)?.entity ?? null,\n impulse: push.impulse,\n point: push.point,\n });\n }\n\n /**\n * The runtime state of a controller component.\n *\n * @param component - The component.\n * @returns The record, or `null`.\n */\n #controllerOf(component: CharacterController): ControllerRecord | null {\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record?.component === component) {\n return record;\n }\n }\n return null;\n }\n\n /**\n * Buffers a trigger event. It runs inside `stepScene`, so it only records.\n *\n * @param event - What Lite reported.\n */\n #bufferTrigger(event: TriggerRecord): void {\n const slot = this.#triggerSlot(this.#triggerCount);\n slot.entered = event.entered;\n slot.first = this.recordOfNode(event.nodeA);\n slot.second = this.recordOfNode(event.nodeB);\n this.#triggerCount += 1;\n }\n\n /**\n * Buffers a collision event.\n *\n * @param event - What the collision drain reported.\n */\n #bufferContact(event: ContactRecord): void {\n const slot = this.#contactSlot(this.#contactCount);\n slot.phase = event.phase;\n slot.point.set(event.point.x, event.point.y, event.point.z);\n slot.normal.set(event.normal.x, event.normal.y, event.normal.z);\n slot.impulse = event.impulse;\n slot.first = this.recordOfNode(event.nodeA);\n slot.second = this.recordOfNode(event.nodeB);\n this.#contactCount += 1;\n }\n\n /**\n * Grows the trigger pool on demand and returns one slot.\n *\n * @param index - The slot index.\n * @returns The slot.\n */\n #triggerSlot(index: number): TriggerSlot {\n let slot = this.#triggerSlots[index];\n if (slot === undefined) {\n slot = { entered: false, first: null, second: null };\n this.#triggerSlots.push(slot);\n }\n return slot;\n }\n\n /**\n * Grows the contact pool on demand and returns one slot.\n *\n * @param index - The slot index.\n * @returns The slot.\n */\n #contactSlot(index: number): ContactSlot {\n let slot = this.#contactSlots[index];\n if (slot === undefined) {\n slot = { phase: 0, point: new Vec3(), normal: new Vec3(), impulse: 0, first: null, second: null };\n this.#contactSlots.push(slot);\n }\n return slot;\n }\n\n /** Delivers the buffered trigger events to both participants' scripts. */\n #dispatchTriggers(): void {\n this.#triggerEventCount += this.#triggerCount;\n for (let index = 0; index < this.#triggerCount; index += 1) {\n const slot = this.#triggerSlots[index];\n if (slot === undefined) {\n continue;\n }\n const kind: PhysicsCallbackName = slot.entered ? \"onTriggerEnter\" : \"onTriggerExit\";\n this.#deliverTrigger(slot.first, slot.second, kind);\n this.#deliverTrigger(slot.second, slot.first, kind);\n }\n }\n\n /**\n * Delivers one trigger event to one entity.\n *\n * @param target - The record whose scripts receive it, or `null`.\n * @param other - The other participant, or `null`.\n * @param kind - Which callback to deliver.\n */\n #deliverTrigger(target: BodyRecord | null, other: BodyRecord | null, kind: PhysicsCallbackName): void {\n if (target === null || target.entity.isDestroyed) {\n return;\n }\n const event: MutableTriggerEvent = (this.#triggerEvent ??= {\n other: null,\n otherCollider: null,\n self: target.entity,\n });\n event.self = target.entity;\n event.other = other?.entity ?? null;\n event.otherCollider = other?.colliders[0] ?? null;\n this.#ctx.dispatchScriptCallback(target.entity, kind, event);\n }\n\n /** Delivers the buffered collision events. */\n #dispatchContacts(): void {\n this.#collisionEventCount += this.#contactCount;\n for (let index = 0; index < this.#contactCount; index += 1) {\n const slot = this.#contactSlots[index];\n if (slot === undefined) {\n continue;\n }\n const kind = contactCallback(slot.phase);\n this.#deliverContact(slot, slot.first, slot.second, kind);\n this.#deliverContact(slot, slot.second, slot.first, kind);\n }\n }\n\n /**\n * Delivers one collision to one entity.\n *\n * @param slot - The buffered contact.\n * @param target - The record whose scripts receive it, or `null`.\n * @param other - The other participant, or `null`.\n * @param kind - Which callback to deliver.\n */\n #deliverContact(\n slot: ContactSlot,\n target: BodyRecord | null,\n other: BodyRecord | null,\n kind: PhysicsCallbackName,\n ): void {\n if (target === null || target.entity.isDestroyed || !target.collisionEvents) {\n return;\n }\n this.#contactPoint.point.copyFrom(slot.point);\n this.#contactPoint.normal.copyFrom(slot.normal);\n this.#contactPoint.impulse = slot.impulse;\n const collision: MutableCollision = (this.#collision ??= {\n other: null,\n otherCollider: null,\n self: target.entity,\n contacts: this.#contacts,\n relativeVelocity: null,\n });\n collision.self = target.entity;\n collision.other = other?.entity ?? null;\n collision.otherCollider = other?.colliders[0] ?? null;\n collision.relativeVelocity = other === null ? null : this.#relativeVelocityOf(target, other);\n this.#ctx.dispatchScriptCallback(target.entity, kind, collision);\n }\n\n /**\n * The relative velocity of two bodies at the moment of a contact.\n *\n * @param target - The receiving body.\n * @param other - The other body.\n * @returns A pooled vector.\n */\n #relativeVelocityOf(target: BodyRecord, other: BodyRecord): Vec3Like {\n readLinearVelocity(this.#world, target.body, this.#scratchVector);\n readLinearVelocity(this.#world, other.body, this.#scratchOther);\n this.#relativeVelocity.set(\n this.#scratchVector.x - this.#scratchOther.x,\n this.#scratchVector.y - this.#scratchOther.y,\n this.#scratchVector.z - this.#scratchOther.z,\n );\n return this.#relativeVelocity;\n }\n\n /**\n * Releases one record's Lite resources and signal connections.\n *\n * @param record - The record to tear down.\n */\n #teardown(record: BodyRecord): void {\n for (const disconnect of record.disconnects) {\n disconnect();\n }\n record.disconnects = [];\n destroyBody(this.#world, record.body);\n for (let index = record.shapes.length - 1; index >= 0; index -= 1) {\n const shape = record.shapes[index];\n if (shape !== undefined) {\n destroyShape(this.#world, shape);\n }\n }\n record.shapes = [];\n }\n}\n\n/** Lite's own `characterStrength` default, which `pushStrength: 1` reproduces (`index.d.ts` 8320). */\nconst DEFAULT_CHARACTER_STRENGTH = 1e38;\n\n/** The collider list of a character capsule, which is built from the controller, not from colliders. */\nconst NO_COLLIDERS: readonly Collider[] = Object.freeze([]);\n\n/**\n * The half-extents of a controller capsule's bounding box. Lite places the capsule's segment ends at\n * `±(height / 2 - radius)` (`createPhysicsCharacterController`), and the capsule does not scale with\n * the entity.\n *\n * @param height - The capsule's total height.\n * @param radius - Its radius.\n * @param out - The vector to write.\n * @returns `out`.\n */\nfunction capsuleHalfExtents(height: number, radius: number, out: Vec3): Vec3 {\n return out.set(radius, Math.abs(height / 2 - radius) + radius, radius);\n}\n\n/**\n * The colliders that make up an entity's body: every enabled `Collider` on the entity itself.\n *\n * @param entity - The entity.\n * @returns The colliders, in component order.\n */\nfunction collidersOf(entity: Entity): readonly Collider[] {\n const found: Collider[] = [];\n const components = entity.components;\n for (let index = 0; index < components.length; index += 1) {\n const component = components[index];\n if (component instanceof Collider && component.enabled && !component.isDestroyed) {\n found.push(component);\n }\n }\n return found;\n}\n\n/**\n * The motion type a `Rigidbody` asks for.\n *\n * @param rigidbody - The component, or `null` for the implicit static body.\n * @returns The Lite motion type.\n */\nfunction motionOf(rigidbody: Rigidbody | null): BodyMotion {\n if (rigidbody === null || rigidbody.bodyType === \"static\") {\n return BodyMotion.static;\n }\n return rigidbody.bodyType === \"kinematic\" ? BodyMotion.kinematic : BodyMotion.dynamic;\n}\n\n/**\n * The rotation axes a `Rigidbody` freezes.\n *\n * @param rigidbody - The component.\n * @returns The locked axes, in a stable order.\n */\nfunction lockedAxes(rigidbody: Rigidbody): readonly (\"x\" | \"y\" | \"z\")[] {\n const locked: (\"x\" | \"y\" | \"z\")[] = [];\n if (rigidbody.freezeRotation.x) {\n locked.push(\"x\");\n }\n if (rigidbody.freezeRotation.y) {\n locked.push(\"y\");\n }\n if (rigidbody.freezeRotation.z) {\n locked.push(\"z\");\n }\n return locked;\n}\n\n/**\n * The membership mask of a layer (`09-physics.md` §3).\n *\n * @param layer - The layer index.\n * @returns `1 << layer`.\n */\nfunction membershipOf(layer: number): number {\n return 1 << layer;\n}\n\n/**\n * The half-extents of the union of an entity's colliders, for the bounds index.\n *\n * @param colliders - The colliders.\n * @param scale - The entity's lossy scale.\n * @returns A fresh vector.\n */\nfunction boundsOf(colliders: readonly Collider[], scale: Vec3Like): Vec3 {\n const bounds = new Vec3();\n const scratch = new Vec3();\n for (let index = 0; index < colliders.length; index += 1) {\n const collider = colliders[index];\n if (collider === undefined) {\n continue;\n }\n collider.halfExtentsToRef(scale, scratch);\n bounds.set(\n Math.max(bounds.x, Math.abs(collider.center.x * scale.x) + scratch.x),\n Math.max(bounds.y, Math.abs(collider.center.y * scale.y) + scratch.y),\n Math.max(bounds.z, Math.abs(collider.center.z * scale.z) + scratch.z),\n );\n }\n return bounds;\n}\n\n/**\n * Which callback a contact phase maps to.\n *\n * @param phase - `0` started, `1` continued, `2` finished.\n * @returns The callback name.\n */\nfunction contactCallback(phase: number): PhysicsCallbackName {\n if (phase === CONTACT_STARTED) {\n return \"onCollisionEnter\";\n }\n return phase === CONTACT_FINISHED ? \"onCollisionExit\" : \"onCollisionStay\";\n}\n\n/**\n * The name of a Lite support state.\n *\n * @param state - Lite's value.\n * @returns The ignifx name.\n */\nfunction supportName(state: number): SupportStateName {\n if (state === SupportState.supported) {\n return \"supported\";\n }\n return state === SupportState.sliding ? \"sliding\" : \"unsupported\";\n}\n\n/**\n * Whether two positions are the same to within the static-move epsilon.\n *\n * @param first - The first position.\n * @param second - The second position.\n * @returns `true` when they match.\n */\nfunction nearlyEqual(first: Vec3Like, second: Vec3Like): boolean {\n return (\n Math.abs(first.x - second.x) < STATIC_MOVE_EPSILON &&\n Math.abs(first.y - second.y) < STATIC_MOVE_EPSILON &&\n Math.abs(first.z - second.z) < STATIC_MOVE_EPSILON\n );\n}\n\n/**\n * A monotonic millisecond reading for the `stepMs` counter. It never feeds the simulation, so it\n * does not break the \"no wall-clock reads\" rule of `09-physics.md` §8.\n *\n * @returns Milliseconds since the process started.\n */\nfunction now(): number {\n return performance.now();\n}\n\n/**\n * Builds the \"that is not a layer\" failure.\n *\n * @param name - The offending layer name.\n * @returns The error to throw.\n */\nfunction unknownLayer(name: string): ReturnType<typeof physicsError> {\n return physicsError(PhysicsErrorCode.unknownLayer, `${name} is not a layer this project declares.`, {\n context: { layer: name },\n hint: \"Add the layer to the layers settings section, or fix the name in physics.collisionMatrix.\",\n });\n}\n","import type { PhysicsHost } from \"./host.js\";\nimport type { System, SystemContext } from \"@ignifx/core\";\n\n/**\n * The three systems `docs/architecture/01-lifecycle-and-time.md` §3 and `09-physics.md` §1 put\n * physics in the frame with:\n *\n * ```\n * Systems(FixedUpdate, -100) restore the authoritative pose of interpolated bodies\n * scripts.fixedUpdate(dt) forces, velocities, CharacterController.move()\n * Systems(FixedUpdate, 100) step Havok, snapshot poses, dispatch collision and trigger events\n * ── the fixed loop ends; time.fixedStepAlpha is final ──\n * Systems(Update, -900) write lerp(prev, cur, time.fixedStepAlpha)\n * scripts.update / lateUpdate, animation, rendering — all read the display pose\n * ```\n *\n * **Why the display pose is written at the top of `Update` and not in `PreRender`** (2026-09-08).\n * It used to be written in `PreRender`, after `lateUpdate`. Camera rigs run in `lateUpdate`, so they\n * framed the character where the last fixed step left it while the renderer drew it at\n * `lerp(prev, cur, alpha)`: up to one fixed step of motion of relative judder every frame, which is\n * exactly what a follow camera makes visible. Writing the pose before `scripts.update` means every\n * consumer of a transform outside the fixed loop — scripts, animation, camera rigs, the render sync\n * — sees the same pose the frame presents, which is Unity's model. The simulation is unaffected:\n * the restore system at `FixedUpdate −100` runs before `scripts.fixedUpdate`, so `fixedUpdate` and\n * Havok still see the authoritative pose.\n *\n * Everything here is `@internal`.\n */\n\n/** The `FixedUpdate` order the restore system runs at. */\nexport const PHYSICS_RESTORE_ORDER = -100;\n\n/** The `FixedUpdate` order the step system runs at. */\nexport const PHYSICS_STEP_ORDER = 100;\n\n/**\n * The `Update` order the interpolation system runs at. Negative, so it lands in\n * `Systems(Update, order < 0)` — after the fixed loop and lifecycle flush B, before\n * `scripts.update` — and low enough that a game's own `Update` systems can still be ordered in\n * front of it if they must see the authoritative pose.\n */\nexport const PHYSICS_INTERPOLATE_ORDER = -900;\n\n/**\n * Undoes the display pose the interpolation system wrote at the top of the previous `Update`, so\n * `fixedUpdate` and Havok both see the authoritative pose (spike S4.3).\n *\n * @internal\n */\nexport class PhysicsRestoreSystem implements System {\n /** The name diagnostics and error reports use. */\n readonly name = \"physics-restore\";\n\n readonly #host: PhysicsHost;\n\n /**\n * Binds the system to the runtime holder.\n *\n * @param host - The holder the runtime lands in.\n */\n constructor(host: PhysicsHost) {\n this.#host = host;\n }\n\n /** Restores every interpolated body's authoritative pose. */\n update(): void {\n this.#host.runtime?.restorePoses();\n }\n}\n\n/**\n * Steps Havok once, snapshots the poses, and dispatches the step's events.\n *\n * @internal\n */\nexport class PhysicsStepSystem implements System {\n /** The name diagnostics and error reports use. */\n readonly name = \"physics-step\";\n\n readonly #host: PhysicsHost;\n\n /**\n * Binds the system to the runtime holder.\n *\n * @param host - The holder the runtime lands in.\n */\n constructor(host: PhysicsHost) {\n this.#host = host;\n }\n\n /**\n * Runs one fixed step.\n *\n * @param ctx - The world, clock, phase, and fixed delta.\n */\n update(ctx: SystemContext): void {\n this.#host.runtime?.step(ctx.dt);\n }\n}\n\n/**\n * Writes the interpolated display pose once per frame.\n *\n * @internal\n */\nexport class PhysicsInterpolationSystem implements System {\n /** The name diagnostics and error reports use. */\n readonly name = \"physics-interpolate\";\n\n readonly #host: PhysicsHost;\n\n /**\n * Binds the system to the runtime holder.\n *\n * @param host - The holder the runtime lands in.\n */\n constructor(host: PhysicsHost) {\n this.#host = host;\n }\n\n /**\n * Writes `lerp(prev, cur, alpha)` into every interpolated body's node.\n *\n * @param ctx - The world, clock, phase, and frame delta.\n */\n update(ctx: SystemContext): void {\n this.#host.runtime?.interpolate(ctx.time.fixedStepAlpha);\n }\n}\n","import { createPhysicsViewer, disposePhysicsViewer, showPhysicsBody } from \"@babylonjs/lite\";\nimport type { LitePhysicsBody, LitePhysicsWorld } from \"../havok.js\";\nimport type { PhysicsViewer } from \"@babylonjs/lite\";\nimport type { LiteScene } from \"@ignifx/core\";\n\n/**\n * The debug-viewer half of this package's Babylon Lite adapter\n * (`docs/architecture/09-physics.md` §9).\n *\n * `createPhysicsViewer(scene, world)` (`index.d.ts` 2909) draws wireframe bodies **into the scene it\n * is given**, and `showPhysicsBody` (11580) builds a `Mesh` per body — which needs a GPU device, so\n * the viewer targets the **render** scene and is refused on a headless app.\n *\n * The module sits under `src/lite/gpu/` for the same reason `@ignifx/core`'s does: every line of it\n * needs `engine._device`, so it is unreachable from the Vitest `node` project and is covered by the\n * browser one instead. `vitest.config.ts` already excludes every package's `src/lite/gpu`\n * directory from the unit-run coverage report.\n *\n * Everything here is `@internal`.\n */\n\n/**\n * Lite's viewer handle.\n *\n * @internal\n */\nexport type LitePhysicsViewer = PhysicsViewer;\n\n/**\n * Creates a viewer on the render scene.\n *\n * @param scene - The render scene the wireframes are drawn into.\n * @param world - The Havok world being visualised.\n * @returns The viewer handle.\n *\n * @internal\n */\nexport function createViewer(scene: LiteScene, world: LitePhysicsWorld): LitePhysicsViewer {\n return createPhysicsViewer(scene, world);\n}\n\n/**\n * Starts drawing one body.\n *\n * @param viewer - The viewer.\n * @param body - The body to show.\n *\n * @internal\n */\nexport function showBody(viewer: LitePhysicsViewer, body: LitePhysicsBody): void {\n showPhysicsBody(viewer, body);\n}\n\n/**\n * Disposes every debug mesh and unregisters the viewer's update hook.\n *\n * @param viewer - The viewer.\n *\n * @internal\n */\nexport function destroyViewer(viewer: LitePhysicsViewer): void {\n disposePhysicsViewer(viewer);\n}\n","import { physicsRaycast, shapeCast, shapeProximity } from \"@babylonjs/lite\";\nimport type { LitePhysicsBody, LitePhysicsShape, LitePhysicsWorld } from \"./havok.js\";\nimport type { LiteSceneNode, MutableVec3, QuatLike, Vec3Like } from \"@ignifx/core\";\n\n/**\n * The query half of this package's Babylon Lite adapter (`docs/architecture/09-physics.md` §5).\n *\n * ## What Lite 1.27.0 actually returns (verified in `lib/physics/havok-queries.js`)\n *\n * - `physicsRaycast` (`index.d.ts` 8577) is the **only** query that reports a body: it resolves the\n * native id through `findBodyById` and returns `RaycastResult.body` (9388).\n * - `shapeCast` (11479) returns `fraction`, two contact points, and two normals — and **no body**\n * (`ShapeCastResult`, 11497).\n * - `shapeProximity` (11524) returns the single **closest** hit within `maxDistance`, also with no\n * body (`ShapeProximityResult`, 11540); the collector it uses is created with capacity `1`\n * (`getCollector`, `havok-queries.js:7`), so it can never report more than one hit.\n *\n * `09-physics.md` §5 promises `shapeCast(...) : ShapeCastHit` and `overlap(...) : Entity[]`. Neither\n * identity is available upstream, so `PhysicsService` resolves those two against its own body index\n * (bounds-accurate) and the doc correction is recorded in the Phase 4 report. Everything here stays\n * a thin, typed pass-through.\n *\n * Everything here is `@internal`.\n */\n\n/** What a ray query answered. */\nexport interface RayQueryResult {\n /** Whether the ray hit anything. */\n hit: boolean;\n /** The node of the body that was hit, or `null`. */\n node: LiteSceneNode | null;\n /** Distance from the origin to the contact, in metres. */\n distance: number;\n /** The triangle index on a `MESH` shape, or `-1`. */\n triangleIndex: number;\n}\n\n/**\n * Casts a ray and writes the contact into out parameters (coding standards §7: no allocation on a\n * query path beyond Lite's own result object).\n *\n * @param world - The world handle.\n * @param from - The world-space origin.\n * @param to - The world-space end point.\n * @param membership - The querying mask; `~0` for \"belongs to everything\".\n * @param collideWith - The mask of layers the ray may hit.\n * @param hitTriggers - Whether trigger volumes count as hits.\n * @param point - Written with the contact point.\n * @param normal - Written with the contact normal.\n * @param out - Written with the hit flag, node, distance, and triangle index.\n *\n * @internal\n */\nexport function castRay(\n world: LitePhysicsWorld,\n from: Vec3Like,\n to: Vec3Like,\n membership: number,\n collideWith: number,\n hitTriggers: boolean,\n point: MutableVec3,\n normal: MutableVec3,\n out: RayQueryResult,\n): void {\n const result = physicsRaycast(\n world,\n { x: from.x, y: from.y, z: from.z },\n { x: to.x, y: to.y, z: to.z },\n { membership, collideWith, shouldHitTriggers: hitTriggers },\n );\n out.hit = result.hasHit;\n out.node = bodyNodeOf(result.body);\n out.distance = result.hitDistance;\n out.triangleIndex = result.triangleIndex;\n point.set(result.hitPoint.x, result.hitPoint.y, result.hitPoint.z);\n normal.set(result.hitNormal.x, result.hitNormal.y, result.hitNormal.z);\n}\n\n/** What a shape sweep answered. */\nexport interface SweepQueryResult {\n /** Whether the swept shape hit anything. */\n hit: boolean;\n /** The fraction along the sweep where contact first occurs, in `[0, 1]`. */\n fraction: number;\n}\n\n/**\n * Sweeps a shape from one position to another.\n *\n * @param world - The world handle.\n * @param shape - The shape to sweep.\n * @param rotation - The orientation held constant during the sweep.\n * @param from - The start position.\n * @param to - The end position.\n * @param hitTriggers - Whether trigger volumes count as hits.\n * @param ignoreBody - One body the sweep passes through, or `null`. Lite's `ShapeCastQuery` takes\n * exactly one (`ignoreBody`, `index.d.ts` 11494) and — unlike `physicsRaycast` — no\n * `membership`/`collideWith` pair, so this is the only filtering a sweep can do inside Havok; a\n * layer mask is applied to the *attribution* of the hit by the service, never to the sweep.\n * @param point - Written with the contact point on the hit body.\n * @param normal - Written with the contact normal on the hit body.\n * @param out - Written with the hit flag and the sweep fraction.\n *\n * @internal\n */\nexport function sweepShape(\n world: LitePhysicsWorld,\n shape: LitePhysicsShape,\n rotation: QuatLike,\n from: Vec3Like,\n to: Vec3Like,\n hitTriggers: boolean,\n ignoreBody: LitePhysicsBody | null,\n point: MutableVec3,\n normal: MutableVec3,\n out: SweepQueryResult,\n): void {\n const result = shapeCast(world, {\n shape,\n rotation: { x: rotation.x, y: rotation.y, z: rotation.z, w: rotation.w },\n startPosition: { x: from.x, y: from.y, z: from.z },\n endPosition: { x: to.x, y: to.y, z: to.z },\n shouldHitTriggers: hitTriggers,\n ...(ignoreBody === null ? {} : { ignoreBody }),\n });\n out.hit = result.hasHit;\n out.fraction = result.fraction;\n point.set(result.hitPoint.x, result.hitPoint.y, result.hitPoint.z);\n normal.set(result.hitNormal.x, result.hitNormal.y, result.hitNormal.z);\n}\n\n/**\n * Finds the distance from a positioned shape to the nearest body, which is what Lite's\n * `shapeProximity` reports. It is used as a cheap \"is anything in range at all\" test; the entities\n * themselves come from the service's own body index.\n *\n * @param world - The world handle.\n * @param shape - The query shape.\n * @param position - Its world position.\n * @param rotation - Its world rotation.\n * @param maxDistance - How far to search.\n * @param hitTriggers - Whether trigger volumes count.\n * @returns The distance to the nearest body, or `Number.POSITIVE_INFINITY` when nothing is in range.\n *\n * @internal\n */\nexport function nearestDistance(\n world: LitePhysicsWorld,\n shape: LitePhysicsShape,\n position: Vec3Like,\n rotation: QuatLike,\n maxDistance: number,\n hitTriggers: boolean,\n): number {\n const result = shapeProximity(world, {\n shape,\n position: { x: position.x, y: position.y, z: position.z },\n rotation: { x: rotation.x, y: rotation.y, z: rotation.z, w: rotation.w },\n maxDistance,\n shouldHitTriggers: hitTriggers,\n });\n return result.hasHit ? result.distance : Number.POSITIVE_INFINITY;\n}\n\n/**\n * Reads the node off an optional body handle.\n *\n * @param body - The body Lite reported, or `null`.\n * @returns The node, or `null`.\n */\nfunction bodyNodeOf(body: LitePhysicsBody | null): LiteSceneNode | null {\n return body === null ? null : body.node;\n}\n","import { Quat, Vec3 } from \"@ignifx/core\";\nimport { PhysicsErrorCode, physicsError } from \"./errors.js\";\nimport { createViewer, destroyViewer, showBody } from \"./lite/gpu/viewer.js\";\nimport { createShape, destroyShape, ShapeGeometry } from \"./lite/havok.js\";\nimport { castRay, nearestDistance, sweepShape } from \"./lite/queries.js\";\nimport type { Collider } from \"./components/collider.js\";\nimport type { LitePhysicsViewer } from \"./lite/gpu/viewer.js\";\nimport type { LitePhysicsShape, LitePhysicsWorld } from \"./lite/havok.js\";\nimport type { RayQueryResult, SweepQueryResult } from \"./lite/queries.js\";\nimport type { QueryOptions, QueryShape, RaycastHit, ShapeCastHit, ShapeCastOptions } from \"./queries.js\";\nimport type { QueryTarget } from \"./runtime/body-record.js\";\nimport type { PhysicsHost } from \"./runtime/host.js\";\nimport type { PhysicsRuntime } from \"./runtime/runtime.js\";\nimport type { PhysicsSettings } from \"./settings.js\";\nimport type { App, Entity, LiteScene, Vec3Like } from \"@ignifx/core\";\n\n/**\n * `app.physics` (`docs/architecture/09-physics.md` §5, §6, §9): gravity, the queries, the debug\n * viewer, and the Babylon Lite escape hatch.\n */\n\n/** How far a ray travels when the caller names no distance, in metres. */\nconst DEFAULT_RAY_DISTANCE = 1e4;\n\n/** How far past a skipped character capsule's surface a ray resumes, in metres. */\nconst RAY_RESUME_DISTANCE = 1e-3;\n\n/** How much slack the bounds index allows when it resolves a sweep contact to an entity. */\nconst BOUNDS_EPSILON = 1e-3;\n\n/** Every bit set: the mask a query uses when the caller names no layers. */\nconst ALL_LAYERS = ~0;\n\n/**\n * The Babylon Lite objects the physics extension owns. Unstable escape hatch\n * (`docs/architecture/00-overview.md` §3).\n *\n * @public\n */\nexport interface PhysicsLiteHandles {\n /** Lite's Havok world handle. */\n readonly world: LitePhysicsWorld;\n /** The null-engine scene the world is stepped on; also `world.lite.simulationScene`. */\n readonly simulationScene: LiteScene;\n}\n\n/**\n * The wireframe overlay `@ignifx/devtools` toggles (`09-physics.md` §9).\n *\n * @public\n */\nexport interface PhysicsDebugViewer {\n /**\n * Whether Lite's physics viewer is drawing the bodies into the **render** scene. It needs a GPU\n * device, so switching it on in a headless app is a no-op that logs a warning.\n */\n enabled: boolean;\n}\n\n/**\n * The service behind `app.physics`.\n *\n * @example\n * ```ts\n * const hit = app.physics.raycast({ x: 0, y: 10, z: 0 }, { x: 0, y: -1, z: 0 }, 20);\n * if (hit !== null) {\n * app.log.info(`ray hit ${hit.entity.name} at ${String(hit.point.y)}`);\n * }\n * ```\n *\n * @public\n */\nexport class PhysicsService {\n readonly #app: App;\n\n readonly #host: PhysicsHost;\n\n readonly #gravity = new Vec3();\n\n readonly #rayResult: RayQueryResult = { hit: false, node: null, distance: 0, triangleIndex: -1 };\n\n readonly #sweepResult: SweepQueryResult = { hit: false, fraction: 0 };\n\n readonly #point = new Vec3();\n\n readonly #normal = new Vec3();\n\n readonly #rayFrom = new Vec3();\n\n readonly #overlapExtents = new Vec3();\n\n readonly #overlapResults: Entity[] = [];\n\n readonly #debugViewer: PhysicsDebugViewer;\n\n #viewer: LitePhysicsViewer | null = null;\n\n /**\n * Wraps the holder the extension fills in from `onStart`.\n *\n * @param app - The app the service belongs to.\n * @param host - The holder the runtime lands in.\n * @param settings - The resolved `physics` settings section.\n *\n * @internal\n */\n constructor(app: App, host: PhysicsHost, settings: PhysicsSettings) {\n this.#app = app;\n this.#host = host;\n const gravity = settings.gravity;\n this.#gravity.set(gravity.x, gravity.y, gravity.z);\n this.#debugViewer = new DebugViewerToggle(this);\n }\n\n /**\n * World gravity in metres per second squared.\n *\n * @returns A live view; writing to it does nothing, assign the property instead.\n */\n get gravity(): Vec3 {\n return this.#gravity;\n }\n\n /**\n * Replaces world gravity, which every body feels from the next fixed step.\n *\n * @param value - The new acceleration vector, in metres per second squared.\n */\n set gravity(value: Vec3Like) {\n this.#gravity.set(value.x, value.y, value.z);\n this.#rt().setGravity(this.#gravity);\n }\n\n /**\n * The wireframe overlay.\n *\n * @returns The viewer toggle.\n */\n get debugViewer(): PhysicsDebugViewer {\n return this.#debugViewer;\n }\n\n /**\n * The Babylon Lite handles.\n *\n * @returns The Havok world and the simulation scene.\n */\n get lite(): PhysicsLiteHandles {\n return { world: this.#rt().world, simulationScene: this.#app.world.lite.simulationScene ?? this.#app.lite.scene };\n }\n\n /**\n * Casts a ray and returns the first entity it hits (`09-physics.md` §5).\n *\n * @remarks\n * The ray hits `Rigidbody` and collider-only bodies and `CharacterController` capsules. A capsule\n * hit reports the character's entity with `collider: null`. A ray passes through a capsule when\n * `layerMask` leaves out the character's layer, or when the ray starts inside it.\n *\n * @param origin - The world-space origin.\n * @param direction - The direction; it is normalised for you.\n * @param maxDistance - How far to travel; defaults to 10 km.\n * @param options - Layer mask and trigger behaviour.\n * @returns The hit, or `null` when the ray clears everything.\n * @throws IgnifxError with code `IGX-0902` in development when no fixed step has run yet.\n */\n raycast(\n origin: Vec3Like,\n direction: Vec3Like,\n maxDistance: number = DEFAULT_RAY_DISTANCE,\n options?: QueryOptions,\n ): RaycastHit | null {\n this.#requireStep(\"raycast\");\n const runtime = this.#rt();\n runtime.countQuery();\n const length = Math.hypot(direction.x, direction.y, direction.z);\n if (length === 0) {\n return null;\n }\n const scale = maxDistance / length;\n const to = {\n x: origin.x + direction.x * scale,\n y: origin.y + direction.y * scale,\n z: origin.z + direction.z * scale,\n };\n const from = this.#rayFrom.set(origin.x, origin.y, origin.z);\n let travelled = 0;\n // Havok filters bodies by layer itself, but a character capsule is in every layer: Lite builds\n // its shape with all filter bits set and gives no access to it. So a ray whose mask excludes a\n // character resumes just inside the capsule, where Havok does not report it again. Each pass\n // skips at least one capsule, which bounds the loop.\n for (let pass = 0; pass <= runtime.queryTargetCount; pass += 1) {\n castRay(\n runtime.world,\n from,\n to,\n ALL_LAYERS,\n maskOf(options),\n options?.hitTriggers === true,\n this.#point,\n this.#normal,\n this.#rayResult,\n );\n if (!this.#rayResult.hit) {\n return null;\n }\n const target = runtime.targetOfNode(this.#rayResult.node);\n if (target === null) {\n return null;\n }\n if (this.#accepts(target, options)) {\n return {\n entity: target.entity,\n collider: target.colliders[0] ?? null,\n point: this.#point.clone(),\n normal: this.#normal.clone(),\n distance: travelled + this.#rayResult.distance,\n triangleIndex: this.#rayResult.triangleIndex,\n };\n }\n travelled += this.#rayResult.distance + RAY_RESUME_DISTANCE;\n if (travelled >= maxDistance) {\n return null;\n }\n const step = RAY_RESUME_DISTANCE / length;\n from.set(\n this.#point.x + direction.x * step,\n this.#point.y + direction.y * step,\n this.#point.z + direction.z * step,\n );\n }\n return null;\n }\n\n /**\n * Sweeps a shape and returns the first contact (`09-physics.md` §5).\n *\n * @remarks\n * Lite's `shapeCast` reports no body (`index.d.ts` 11497), so `entity` is resolved against the\n * extension's body-bounds index and is bounds-accurate rather than shape-accurate. The index holds\n * every `Rigidbody` and collider-only body and every `CharacterController` capsule; a capsule\n * contact reports the character's entity with `collider: null`.\n *\n * The sweep itself cannot be filtered by layer — Lite's `ShapeCastQuery` carries no collision\n * masks — so a body outside `layerMask` still stops the sweep; it is merely reported with\n * `entity: null`. What the sweep *can* do is pass through one body, `options.ignore`, which is\n * how a camera boom leaves its target's capsule and a step probe leaves the character's own feet\n * without reporting them at fraction zero (2026-09-08).\n *\n * @param shape - The shape to sweep.\n * @param from - The start position.\n * @param to - The end position.\n * @param options - Layer mask, trigger behaviour, and the one entity to sweep through.\n * @returns The hit, or `null`.\n * @throws IgnifxError with code `IGX-0902` in development when no fixed step has run yet.\n */\n shapeCast(shape: QueryShape, from: Vec3Like, to: Vec3Like, options?: ShapeCastOptions): ShapeCastHit | null {\n this.#requireStep(\"shapeCast\");\n this.#rt().countQuery();\n const ignored = options?.ignore ?? null;\n const ignoredBody = ignored === null ? null : this.#rt().bodyOf(ignored);\n const handle = this.#buildQueryShape(shape);\n try {\n sweepShape(\n this.#rt().world,\n handle,\n Quat.identity(),\n from,\n to,\n options?.hitTriggers === true,\n ignoredBody,\n this.#point,\n this.#normal,\n this.#sweepResult,\n );\n } finally {\n destroyShape(this.#rt().world, handle);\n }\n if (!this.#sweepResult.hit) {\n return null;\n }\n const target = this.#targetAt(this.#point, options, ignored);\n const distance = Math.hypot(to.x - from.x, to.y - from.y, to.z - from.z) * this.#sweepResult.fraction;\n return {\n entity: target?.entity ?? null,\n collider: target?.colliders[0] ?? null,\n point: this.#point.clone(),\n normal: this.#normal.clone(),\n fraction: this.#sweepResult.fraction,\n distance,\n };\n }\n\n /**\n * Lists the entities a positioned shape overlaps (`09-physics.md` §5).\n *\n * @remarks\n * Lite's `shapeProximity` reports one hit and no identity (`index.d.ts` 11540,\n * `lib/physics/havok-queries.js:7`), so this is answered from the extension's own bounds index:\n * every `Rigidbody`, collider-only body and `CharacterController` capsule whose world bounding box\n * intersects the query shape's. It is conservative — a body whose box overlaps but whose shape\n * does not is listed.\n *\n * @param shape - The query shape.\n * @param position - Its world position.\n * @param rotation - Its world rotation; accepted for forward compatibility and currently unused,\n * because the bounds test is axis-aligned.\n * @param options - Layer mask and trigger behaviour.\n * @returns The overlapping entities, each once: bodies in creation order, then characters in\n * creation order. The array is reused between calls.\n * @throws IgnifxError with code `IGX-0902` in development when no fixed step has run yet.\n */\n overlap(shape: QueryShape, position: Vec3Like, rotation?: Quat, options?: QueryOptions): readonly Entity[] {\n void rotation;\n this.#requireStep(\"overlap\");\n const runtime = this.#rt();\n runtime.countQuery();\n queryHalfExtents(shape, this.#overlapExtents);\n const results = this.#overlapResults;\n results.length = 0;\n const count = runtime.queryTargetCount;\n for (let index = 0; index < count; index += 1) {\n const target = runtime.queryTargetAt(index);\n if (target === undefined || !this.#accepts(target, options)) {\n continue;\n }\n if (\n boxesOverlap(position, this.#overlapExtents, target.currentPosition, target.halfExtents) &&\n // An entity can carry both a body and a character controller.\n !results.includes(target.entity)\n ) {\n results.push(target.entity);\n }\n }\n return results;\n }\n\n /**\n * How far the nearest body is from a positioned shape, which is the one thing Lite's\n * `shapeProximity` answers exactly.\n *\n * @param shape - The query shape.\n * @param position - Its world position.\n * @param maxDistance - How far to search.\n * @param options - Trigger behaviour.\n * @returns The distance, or `Number.POSITIVE_INFINITY` when nothing is in range.\n * @throws IgnifxError with code `IGX-0902` in development when no fixed step has run yet.\n */\n distanceToNearest(shape: QueryShape, position: Vec3Like, maxDistance: number, options?: QueryOptions): number {\n this.#requireStep(\"distanceToNearest\");\n this.#rt().countQuery();\n const handle = this.#buildQueryShape(shape);\n try {\n return nearestDistance(\n this.#rt().world,\n handle,\n position,\n Quat.identity(),\n maxDistance,\n options?.hitTriggers === true,\n );\n } finally {\n destroyShape(this.#rt().world, handle);\n }\n }\n\n /**\n * Shows or hides Lite's wireframe bodies.\n *\n * @param enabled - Whether the viewer draws.\n */\n setDebugViewerEnabled(enabled: boolean): void {\n if (enabled === (this.#viewer !== null) || (enabled && this.#host.runtime === null)) {\n return;\n }\n if (!enabled) {\n if (this.#viewer !== null) {\n destroyViewer(this.#viewer);\n this.#viewer = null;\n }\n return;\n }\n if (this.#app.isHeadless) {\n this.#app.log.warn(\"The physics debug viewer needs a GPU device; a headless app has none.\");\n return;\n }\n const viewer = createViewer(this.#app.lite.scene, this.#rt().world);\n this.#viewer = viewer;\n const records = this.#rt().records;\n for (let index = 0; index < records.length; index += 1) {\n const record = records[index];\n if (record !== undefined) {\n showBody(viewer, record.body);\n }\n }\n }\n\n /**\n * Whether the viewer is currently drawing.\n *\n * @returns `true` when a viewer exists.\n */\n isDebugViewerEnabled(): boolean {\n return this.#viewer !== null;\n }\n\n /** Releases the viewer, if one is up. Called from the extension's `dispose`. */\n dispose(): void {\n this.setDebugViewerEnabled(false);\n }\n\n /**\n * The runtime, once `onStart` has built it.\n *\n * @returns The runtime.\n * @throws IgnifxError with code `IGX-0903` when Havok has not finished loading, which is only\n * reachable from an extension `onStart` that runs before this one.\n */\n #rt(): PhysicsRuntime {\n const runtime = this.#host.runtime;\n if (runtime === null) {\n throw physicsError(PhysicsErrorCode.havokUnavailable, \"The physics world does not exist yet.\", {\n hint: \"app.physics is usable from the first frame onwards; await app.start() first.\",\n });\n }\n return runtime;\n }\n\n /**\n * Whether at least one fixed step has completed, which is when Havok has built its broadphase and\n * queries become legal (`09-physics.md` §5). A script that queries from `lateUpdate` or `update`\n * checks this on the first frame, where the fixed loop may not have run yet, instead of catching\n * `IGX-0902`.\n *\n * @returns `true` once the first step has run.\n */\n get hasStepped(): boolean {\n return this.#rt().hasStepped;\n }\n\n /**\n * Refuses a query that ran before Havok built its broadphase (`09-physics.md` §5).\n *\n * @param query - The query name, for the diagnostic.\n * @throws IgnifxError with code `IGX-0902` when no step has completed.\n */\n #requireStep(query: string): void {\n if (this.#rt().hasStepped) {\n return;\n }\n throw physicsError(PhysicsErrorCode.queryBeforeStep, `${query}() ran before the first fixed step.`, {\n context: { query },\n hint: \"Step the app at least once (app.step(1 / 60)) before querying; Havok builds its broadphase in the first step.\",\n });\n }\n\n /**\n * Builds a temporary Havok shape for one query. Query shapes are not a per-frame path, so the\n * allocation is deliberate and the shape is released in a `finally`.\n *\n * @param shape - The description.\n * @returns The shape handle.\n */\n #buildQueryShape(shape: QueryShape): LitePhysicsShape {\n const world = this.#rt().world;\n if (shape.kind === \"sphere\") {\n return createShape(world, ShapeGeometry.sphere, { radius: shape.radius });\n }\n if (shape.kind === \"box\") {\n return createShape(world, ShapeGeometry.box, {\n extents: shape.size,\n center: { x: 0, y: 0, z: 0 },\n rotation: Quat.identity(),\n });\n }\n const half = Math.max(0, shape.height / 2 - shape.radius);\n return createShape(world, ShapeGeometry.capsule, {\n radius: shape.radius,\n pointA: { x: 0, y: -half, z: 0 },\n pointB: { x: 0, y: half, z: 0 },\n });\n }\n\n /**\n * Resolves a world-space point to the body whose bounds contain it.\n *\n * @param point - The point.\n * @param options - Layer mask and trigger behaviour.\n * @param ignored - The entity the sweep was told to pass through, which can therefore not be the\n * one it hit.\n * @returns The body or capsule, or `null`.\n */\n #targetAt(point: Vec3Like, options: QueryOptions | undefined, ignored: Entity | null = null): QueryTarget | null {\n const runtime = this.#rt();\n const count = runtime.queryTargetCount;\n let best: QueryTarget | null = null;\n let bestDistance = Number.POSITIVE_INFINITY;\n for (let index = 0; index < count; index += 1) {\n const target = runtime.queryTargetAt(index);\n if (target === undefined || target.entity === ignored || !this.#accepts(target, options)) {\n continue;\n }\n const centre = target.currentPosition;\n const extents = target.halfExtents;\n if (\n Math.abs(point.x - centre.x) > extents.x + BOUNDS_EPSILON ||\n Math.abs(point.y - centre.y) > extents.y + BOUNDS_EPSILON ||\n Math.abs(point.z - centre.z) > extents.z + BOUNDS_EPSILON\n ) {\n continue;\n }\n const distance = Math.hypot(point.x - centre.x, point.y - centre.y, point.z - centre.z);\n if (distance < bestDistance) {\n bestDistance = distance;\n best = target;\n }\n }\n return best;\n }\n\n /**\n * Whether a body or capsule passes a query's layer and trigger filters.\n *\n * @param target - The body or capsule.\n * @param options - The query options.\n * @returns `true` when it may be reported.\n */\n #accepts(target: QueryTarget, options: QueryOptions | undefined): boolean {\n if ((maskOf(options) & (1 << target.layer)) === 0) {\n return false;\n }\n return options?.hitTriggers === true || !allTriggers(target.colliders);\n }\n}\n\n/**\n * The `{ enabled }` object `app.physics.debugViewer` hands out: a property pair rather than two\n * methods, because that is how `09-physics.md` §9 and `@ignifx/devtools` name it.\n */\nclass DebugViewerToggle implements PhysicsDebugViewer {\n readonly #service: PhysicsService;\n\n /**\n * Binds the toggle to its service.\n *\n * @param service - The service that owns the viewer.\n */\n constructor(service: PhysicsService) {\n this.#service = service;\n }\n\n /**\n * Whether the viewer is drawing.\n *\n * @returns `true` when a viewer is up.\n */\n get enabled(): boolean {\n return this.#service.isDebugViewerEnabled();\n }\n\n set enabled(value: boolean) {\n this.#service.setDebugViewerEnabled(value);\n }\n}\n\n/**\n * The 32-bit layer mask a query filters with.\n *\n * @param options - The query options.\n * @returns The mask; every bit when the caller named none.\n */\nfunction maskOf(options: QueryOptions | undefined): number {\n return options?.layerMask?.bits ?? ALL_LAYERS;\n}\n\n/**\n * Whether every collider of a body is a trigger, which is what makes the body a trigger volume.\n *\n * @param colliders - The body's colliders.\n * @returns `true` when they are all triggers.\n */\nfunction allTriggers(colliders: readonly Collider[]): boolean {\n if (colliders.length === 0) {\n return false;\n }\n for (let index = 0; index < colliders.length; index += 1) {\n if (colliders[index]?.isTrigger !== true) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * The half-extents of a query shape's bounding box.\n *\n * @param shape - The description.\n * @param out - The vector to write.\n */\nfunction queryHalfExtents(shape: QueryShape, out: Vec3): void {\n if (shape.kind === \"sphere\") {\n out.set(shape.radius, shape.radius, shape.radius);\n return;\n }\n if (shape.kind === \"box\") {\n out.set(shape.size.x / 2, shape.size.y / 2, shape.size.z / 2);\n return;\n }\n out.set(shape.radius, Math.max(shape.radius, shape.height / 2), shape.radius);\n}\n\n/**\n * Whether two axis-aligned boxes overlap.\n *\n * @param firstCentre - The first box's centre.\n * @param firstExtents - The first box's half-extents.\n * @param secondCentre - The second box's centre.\n * @param secondExtents - The second box's half-extents.\n * @returns `true` when they intersect.\n */\nfunction boxesOverlap(\n firstCentre: Vec3Like,\n firstExtents: Vec3Like,\n secondCentre: Vec3Like,\n secondExtents: Vec3Like,\n): boolean {\n return (\n Math.abs(firstCentre.x - secondCentre.x) <= firstExtents.x + secondExtents.x &&\n Math.abs(firstCentre.y - secondCentre.y) <= firstExtents.y + secondExtents.y &&\n Math.abs(firstCentre.z - secondCentre.z) <= firstExtents.z + secondExtents.z\n );\n}\n","import { array, bool, defineSchema, f32, map, record, str, vec3 } from \"@ignifx/core\";\nimport type { Schema, Vec3Like } from \"@ignifx/core\";\n\n/**\n * The `physics` project settings section (`docs/architecture/09-physics.md` §6). `fixedDeltaTime` is\n * **not** here: the fixed step is shared with the core `time` section, and the extension reads it\n * from `app.time.fixedDeltaTime` on every step so a game that changes it at runtime keeps Lite's\n * per-step delta in sync.\n */\n\n/**\n * The section name as it appears in `ignifx.config.ts`.\n *\n * @public\n */\nexport const PHYSICS_SETTINGS_SECTION = \"physics\";\n\n/**\n * The value {@link PhysicsSettings.havokWasm} carries when the address comes from the manifest.\n *\n * @public\n */\nexport const HAVOK_WASM_AUTO = \"auto\";\n\n/**\n * A surface material, either as the `physics.defaultMaterial` setting or inline on a collider\n * (`09-physics.md` §2.2, §2.4).\n *\n * @public\n */\nexport interface PhysicsMaterialValues {\n /** The dynamic friction coefficient. */\n readonly friction: number;\n /** The static friction coefficient. */\n readonly staticFriction: number;\n /** How much of the approach speed is returned, `0` to `1`. */\n readonly restitution: number;\n}\n\n/**\n * The world-wide speed clamps Havok applies (`setPhysicsVelocityLimits`, `index.d.ts` 10880). A\n * value of `0` means \"leave Havok's own default alone\".\n *\n * @public\n */\nexport interface VelocityLimitSettings {\n /** Maximum linear speed in metres per second, or `0` for Havok's default. */\n readonly linear: number;\n /** Maximum angular speed in radians per second, or `0` for Havok's default. */\n readonly angular: number;\n}\n\n/**\n * The resolved `physics` settings section.\n *\n * @example\n * ```ts\n * // ignifx.config.ts\n * export default {\n * layers: { layers: [\"Default\", \"Player\", \"Enemy\"] },\n * physics: {\n * gravity: { x: 0, y: -9.81, z: 0 },\n * collisionMatrix: { Player: [\"Default\", \"Enemy\"], Enemy: [\"Default\"] },\n * },\n * };\n * ```\n *\n * @public\n */\nexport interface PhysicsSettings {\n /** World gravity in metres per second squared. */\n readonly gravity: Vec3Like;\n /**\n * Which layers each layer collides with. A layer the map does not mention collides with\n * everything, which is what makes the default project need no matrix at all.\n */\n readonly collisionMatrix: Readonly<Record<string, readonly string[]>>;\n /** The material a collider with no material of its own uses. */\n readonly defaultMaterial: PhysicsMaterialValues;\n /** The world speed clamps. */\n readonly velocityLimits: VelocityLimitSettings;\n /** Whether dynamic bodies and character controllers interpolate between fixed steps. */\n readonly interpolation: boolean;\n /** `\"auto\"` to resolve `HavokPhysics.wasm` through the asset manifest, or an explicit URL. */\n readonly havokWasm: string;\n}\n\n/** Standard gravity, matching Lite's own Havok default. */\nconst DEFAULT_GRAVITY: Vec3Like = Object.freeze({ x: 0, y: -9.81, z: 0 });\n\n/** The default surface: ordinary friction, no bounce. */\nconst DEFAULT_MATERIAL: PhysicsMaterialValues = Object.freeze({\n friction: 0.6,\n staticFriction: 0.6,\n restitution: 0,\n});\n\n/** No clamps beyond Havok's own. */\nconst DEFAULT_VELOCITY_LIMITS: VelocityLimitSettings = Object.freeze({ linear: 0, angular: 0 });\n\n/** An empty matrix, which means \"everything collides with everything\". */\nconst DEFAULT_COLLISION_MATRIX: Readonly<Record<string, readonly string[]>> = Object.freeze({});\n\n/**\n * Builds the schema the `physics` section is validated against.\n *\n * @remarks\n * It is a function, not a module-level constant: every field kind is a function call, and module\n * scope holds declarations and immutable constants only (`CONSTITUTION.md` §3.5).\n *\n * @returns The schema.\n *\n * @public\n */\nexport function physicsSettingsSchema(): Schema {\n return defineSchema({\n gravity: vec3(DEFAULT_GRAVITY),\n collisionMatrix: map(array(str())),\n defaultMaterial: record({\n friction: f32(DEFAULT_MATERIAL.friction, { min: 0 }),\n staticFriction: f32(DEFAULT_MATERIAL.staticFriction, { min: 0 }),\n restitution: f32(DEFAULT_MATERIAL.restitution, { min: 0, max: 1 }),\n }),\n velocityLimits: record({\n linear: f32(DEFAULT_VELOCITY_LIMITS.linear, { min: 0 }),\n angular: f32(DEFAULT_VELOCITY_LIMITS.angular, { min: 0 }),\n }),\n interpolation: bool(true),\n havokWasm: str(HAVOK_WASM_AUTO),\n });\n}\n\n/**\n * The values used when a project omits the `physics` section.\n *\n * @returns A fresh defaults object.\n *\n * @public\n */\nexport function defaultPhysicsSettings(): PhysicsSettings {\n return {\n gravity: DEFAULT_GRAVITY,\n collisionMatrix: DEFAULT_COLLISION_MATRIX,\n defaultMaterial: DEFAULT_MATERIAL,\n velocityLimits: DEFAULT_VELOCITY_LIMITS,\n interpolation: true,\n havokWasm: HAVOK_WASM_AUTO,\n };\n}\n","import { defineExtension, Phase } from \"@ignifx/core\";\nimport { CharacterController } from \"./components/character-controller.js\";\nimport {\n BoxCollider,\n CapsuleCollider,\n CylinderCollider,\n HeightfieldCollider,\n MeshCollider,\n SphereCollider,\n} from \"./components/colliders.js\";\nimport { Rigidbody } from \"./components/rigidbody.js\";\nimport { PHYSICS_ERROR_MESSAGES } from \"./errors.js\";\nimport { HAVOK_WASM_FILE_NAME, loadHavok } from \"./lite/havok-module.js\";\nimport { createSimulation, createWorld, disposeSimulation } from \"./lite/havok.js\";\nimport { createPhysicsMaterialLoader } from \"./material.js\";\nimport { PhysicsHost } from \"./runtime/host.js\";\nimport { PhysicsHostKey } from \"./runtime/runtime-key.js\";\nimport { PhysicsRuntime, PHYSICS_DIAGNOSTICS_COUNTERS, PHYSICS_DIAGNOSTICS_GROUP } from \"./runtime/runtime.js\";\nimport {\n PHYSICS_INTERPOLATE_ORDER,\n PHYSICS_RESTORE_ORDER,\n PHYSICS_STEP_ORDER,\n PhysicsInterpolationSystem,\n PhysicsRestoreSystem,\n PhysicsStepSystem,\n} from \"./runtime/systems.js\";\nimport { PhysicsService } from \"./service.js\";\nimport {\n defaultPhysicsSettings,\n HAVOK_WASM_AUTO,\n PHYSICS_SETTINGS_SECTION,\n physicsSettingsSchema,\n} from \"./settings.js\";\nimport type { Collider } from \"./components/collider.js\";\nimport type { PhysicsSettings } from \"./settings.js\";\nimport type { App, ComponentType, ConcreteComponentType, Extension, ExtensionContext } from \"@ignifx/core\";\n\n/**\n * Create the physics runtime in `onStart`, after the world and its layer table exist.\n * The Vite plugin copies `HavokPhysics.wasm` into public assets under its base name.\n * Headless loading falls back to the installed Havok package.\n */\n\n/**\n * What `physics()` accepts.\n *\n * @public\n */\nexport interface PhysicsOptions {\n /** An already-instantiated Havok module, which skips loading entirely. */\n readonly havok?: unknown;\n /** The `HavokPhysics.wasm` bytes, for a host that reads them itself. */\n readonly wasmBinary?: ArrayBuffer;\n}\n\ndeclare module \"@ignifx/core\" {\n interface App {\n /** 3D physics: gravity, queries, the debug viewer, and the Lite escape hatch. */\n readonly physics: PhysicsService;\n }\n}\n\n/**\n * Builds the physics extension.\n *\n * @param options - The collision-identity mode and, optionally, where Havok comes from.\n * @returns The extension descriptor.\n *\n * @example\n * ```ts\n * const app = await createApp({ headless: true, extensions: [physics()] });\n * ```\n *\n * @public\n */\n// `defineExtension` calls the factory with `undefined` when a game writes `physics()`, so the\n// default parameter is load-bearing even though the declared type is not nullish\n// (`packages/core/src/extension/define-extension.ts`).\n// oxlint-disable-next-line typescript/no-useless-default-assignment\nexport const physics: (options?: PhysicsOptions) => Extension = defineExtension<PhysicsOptions>((options = {}) => {\n const host = new PhysicsHost();\n let context: ExtensionContext | null = null;\n let service: PhysicsService | null = null;\n\n return {\n name: \"@ignifx/physics\",\n version: \"0.0.0\",\n engine: \">=0.0.0 <1.0.0\",\n requires: [],\n optional: [\"@ignifx/devtools\"],\n\n register(ctx: ExtensionContext): void {\n context = ctx;\n ctx.registerErrorCodes(PHYSICS_ERROR_MESSAGES);\n ctx.registerSettings<PhysicsSettings>(\n PHYSICS_SETTINGS_SECTION,\n physicsSettingsSchema(),\n defaultPhysicsSettings(),\n );\n ctx.registerComponents(PHYSICS_COMPONENTS);\n ctx.registerAssetLoader(createPhysicsMaterialLoader());\n const settings = ctx.settings<PhysicsSettings>(PHYSICS_SETTINGS_SECTION);\n service = new PhysicsService(ctx.app, host, settings);\n ctx.registerService(PhysicsHostKey, host);\n ctx.registerService(PhysicsService, service);\n ctx.defineAppProperty(\"physics\", (): unknown => service);\n // None of the three runs in edit mode: an editor's scene view never simulates, and the\n // interpolation would overwrite a transform the editor just moved (ADR-0028).\n ctx.registerSystem(new PhysicsRestoreSystem(host), {\n phase: Phase.FixedUpdate,\n order: PHYSICS_RESTORE_ORDER,\n editMode: \"skip\",\n });\n ctx.registerSystem(new PhysicsStepSystem(host), {\n phase: Phase.FixedUpdate,\n order: PHYSICS_STEP_ORDER,\n editMode: \"skip\",\n });\n // `Update`, not `PreRender`: camera rigs and scripts must read the same pose the renderer\n // draws (`runtime/systems.ts`, `docs/architecture/01-lifecycle-and-time.md` §3).\n ctx.registerSystem(new PhysicsInterpolationSystem(host), {\n phase: Phase.Update,\n order: PHYSICS_INTERPOLATE_ORDER,\n editMode: \"skip\",\n });\n },\n\n async onStart(app: App): Promise<void> {\n const ctx = context;\n if (ctx === null) {\n return;\n }\n const settings = ctx.settings<PhysicsSettings>(PHYSICS_SETTINGS_SECTION);\n const havok = await loadHavok({\n ...(options.havok === undefined ? {} : { module: options.havok }),\n ...(options.wasmBinary === undefined ? {} : { wasmBinary: options.wasmBinary }),\n url: settings.havokWasm === HAVOK_WASM_AUTO ? app.assets.resolveUrl(HAVOK_WASM_FILE_NAME) : settings.havokWasm,\n });\n const simulation = createSimulation();\n let world;\n try {\n world = createWorld(simulation.scene, havok, settings.gravity);\n } catch (cause: unknown) {\n disposeSimulation(simulation);\n throw cause;\n }\n const counters = app.diagnostics.registerGroup(PHYSICS_DIAGNOSTICS_GROUP, PHYSICS_DIAGNOSTICS_COUNTERS);\n host.runtime = new PhysicsRuntime({\n ctx,\n settings,\n simulation,\n world,\n counters,\n });\n ctx.setSimulationScene(simulation.scene);\n seedExistingBodies(app, host);\n },\n\n dispose(): void {\n // The world is disposed before the extensions and has already dropped the scene; the kernel\n // treats a clear at this point as a no-op (`ExtensionContext.setSimulationScene`).\n context?.setSimulationScene(null);\n service?.dispose();\n host.runtime?.dispose();\n host.runtime = null;\n context = null;\n service = null;\n },\n };\n});\n\n/** Every component this extension registers, in a stable order. */\nconst PHYSICS_COMPONENTS: readonly ConcreteComponentType[] = Object.freeze([\n Rigidbody,\n BoxCollider,\n SphereCollider,\n CapsuleCollider,\n CylinderCollider,\n MeshCollider,\n HeightfieldCollider,\n CharacterController,\n]);\n\n/** The collider classes the seed pass walks, in registration order. */\nconst COLLIDER_TYPES: readonly ComponentType<Collider>[] = Object.freeze([\n BoxCollider,\n SphereCollider,\n CapsuleCollider,\n CylinderCollider,\n MeshCollider,\n HeightfieldCollider,\n]);\n\n/**\n * Marks every collider and controller that already exists when the runtime is built.\n *\n * @remarks\n * A component attached before `onStart` — from a scene the `assets.preload` list pulled in, say —\n * called `markDirty` while `app.services.tryGet(PhysicsRuntimeKey)` was still `null`. This is the\n * catch-up pass that makes those bodies exist, and it walks the component store in registration\n * order so body creation order stays deterministic (`09-physics.md` §8).\n *\n * @param app - The app being started.\n * @param host - The holder the runtime landed in.\n */\nfunction seedExistingBodies(app: App, host: PhysicsHost): void {\n const runtime = host.runtime;\n if (runtime === null) {\n return;\n }\n for (const type of COLLIDER_TYPES) {\n const components = app.world.components(type);\n for (let index = 0; index < components.length; index += 1) {\n const collider = components[index];\n if (collider !== undefined) {\n runtime.markDirty(collider.entity);\n }\n }\n }\n const controllers = app.world.components(CharacterController);\n for (let index = 0; index < controllers.length; index += 1) {\n const controller = controllers[index];\n if (controller !== undefined) {\n runtime.markControllerDirty(controller);\n }\n }\n}\n","import { describeSchema } from \"@ignifx/core\";\nimport { CharacterController } from \"./components/character-controller.js\";\nimport {\n BoxCollider,\n CapsuleCollider,\n CylinderCollider,\n HeightfieldCollider,\n MeshCollider,\n SphereCollider,\n} from \"./components/colliders.js\";\nimport { Rigidbody } from \"./components/rigidbody.js\";\nimport { describePhysicsMaterialFileFormat } from \"./material.js\";\nimport type { SchemaDescription } from \"@ignifx/core\";\n\n/**\n * The documentation harness's view of everything `@ignifx/physics` declares\n * (`docs/architecture/16-docs-harness-and-skill.md` §3, `scripts/README.md`).\n *\n * `pnpm docs:schemas` imports the built entry point, calls {@link describeSchemas}, and turns the\n * result into `skills/ignifx/references/formats/<format>.md`. Keys are namespaced `<package>/<Name>`\n * type ids; the file format is keyed `ignifx/physicsmaterial-file` for the same reason `@ignifx/core`\n * keys its file formats that way — the harness rejects a key with no `/` and groups pages by\n * `format`.\n */\n\n/**\n * Describes every component and file format this package declares.\n *\n * @returns The records, keyed by namespaced type id.\n *\n * @example\n * ```ts\n * const schemas = describeSchemas();\n * schemas[\"ignifx/Rigidbody\"].fields[\"mass\"].default; // 1\n * ```\n *\n * @public\n */\nexport function describeSchemas(): Readonly<Record<string, SchemaDescription>> {\n return {\n \"ignifx/Rigidbody\": describeSchema(\"ignifx/Rigidbody\", Rigidbody.schema, {\n description: \"Makes an entity's colliders a dynamic, kinematic, or static Havok body.\",\n }),\n \"ignifx/BoxCollider\": describeSchema(\"ignifx/BoxCollider\", BoxCollider.schema, {\n description: \"A box collision shape, sized in local units and scaled by the entity.\",\n }),\n \"ignifx/SphereCollider\": describeSchema(\"ignifx/SphereCollider\", SphereCollider.schema, {\n description: \"A sphere collision shape; the largest scale axis wins.\",\n }),\n \"ignifx/CapsuleCollider\": describeSchema(\"ignifx/CapsuleCollider\", CapsuleCollider.schema, {\n description: \"A capsule collision shape standing along X, Y, or Z.\",\n }),\n \"ignifx/CylinderCollider\": describeSchema(\"ignifx/CylinderCollider\", CylinderCollider.schema, {\n description: \"A cylinder collision shape standing along Y.\",\n }),\n \"ignifx/MeshCollider\": describeSchema(\"ignifx/MeshCollider\", MeshCollider.schema, {\n description: \"A triangle-mesh or convex-hull shape built from real geometry; needs a GPU app.\",\n }),\n \"ignifx/HeightfieldCollider\": describeSchema(\"ignifx/HeightfieldCollider\", HeightfieldCollider.schema, {\n description: \"A terrain collision shape built from a regular grid of height samples.\",\n }),\n \"ignifx/CharacterController\": describeSchema(\"ignifx/CharacterController\", CharacterController.schema, {\n description: \"A kinematic capsule with collide-and-slide, support detection, and body pushing.\",\n }),\n \"ignifx/physicsmaterial-file\": describePhysicsMaterialFileFormat(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,iBAA8C,iBAA8B,sBAAsB;;;;;;;;;;;;;;ACG/G,MAAa,aAAa;CAAC;CAAW;CAAa;AAAQ;;;;;;AAc3D,MAAa,sBAAsB,CAAC,QAAQ,aAAa;;;;;;AAczD,MAAa,wBAAwB;CAAC;CAAQ;CAAM;AAAK;;;;;;AAczD,MAAa,uBAAuB,CAAC,YAAY,UAAU;;;;;;;;;;;;;;AA+C3D,IAAa,YAAb,MAAa,kBAAkB,UAAoC;;CAEjE,OAAO,SAAS;;CAGhB,OAAO,gBAAgB;;CAGvB,OAAO,SAAiB,gBAAgB;;CAiBxC,cAAc;EACZ,MAAM;EACN,OAAO,OAAO,MAAM,eAAe,UAAU,MAAM,CAAC;CACtD;;CAGA,WAAiB;EACf,KAAK,QAAQ;CACf;;CAGA,WAAiB;EACf,KAAK,QAAQ;CACf;;;;;CAMA,UAAgB;EACd,KAAK,SAAS,CAAC,EAAE,UAAU,KAAK,MAAM;CACxC;;;;;;CAOA,IAAI,OAA6B;EAC/B,OAAO,EAAE,MAAM,KAAK,SAAS,CAAC,EAAE,aAAa,KAAK,MAAM,KAAK,KAAK;CACpE;;;;;;CAOA,IAAI,iBAAuB;EACzB,MAAM,MAAM,IAAI,KAAK;EACrB,KAAK,oBAAoB,GAAG;EAC5B,OAAO;CACT;;;;;;CAOA,IAAI,eAAe,OAAiB;EAClC,KAAK,SAAS,CAAC,EAAE,kBAAkB,KAAK,QAAQ,KAAK;CACvD;;;;;;;CAQA,oBAAoB,KAA+B;EACjD,KAAK,SAAS,CAAC,EAAE,WAAW,KAAK,QAAQ,GAAG;EAC5C,OAAO;CACT;;;;;;CAO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Ae,8BAA8B,oBAAoB,QAAQ,EACrG,aAAa,mFACf,CAAC;EACD,+BAA+B,kCAAkC;CACnE;AACF"}
1
+ {"version":3,"file":"index.js","names":["specifier"],"sources":["../src/runtime/runtime-key.ts","../src/components/rigidbody.ts","../src/components/character-controller.ts","../src/errors.ts","../src/material.ts","../src/components/collider.ts","../src/lite/havok.ts","../src/runtime/outline.ts","../src/components/colliders.ts","../src/lite/havok-module.ts","../src/runtime/host.ts","../src/lite/character.ts","../src/runtime/runtime.ts","../src/runtime/systems.ts","../src/lite/gpu/viewer.ts","../src/lite/queries.ts","../src/service.ts","../src/settings.ts","../src/extension.ts","../src/schemas.ts"],"sourcesContent":["import { createServiceKey } from \"@ignifx/core\";\nimport type { PhysicsHost } from \"./host.js\";\nimport type { ServiceNameKey } from \"@ignifx/core\";\n\n/**\n * The key the extension registers its runtime holder under, so that `Rigidbody`, the colliders, and\n * `CharacterController` can reach the runtime from `this.app.services` without a module-level\n * singleton (`CONSTITUTION.md` §3.6: no globals, two apps in one process).\n *\n * The **holder** is registered rather than the runtime itself, because everything an extension\n * contributes is declared in `register` (`docs/architecture/04-extensions.md` §1) and the runtime\n * does not exist until `onStart`.\n *\n * @internal\n */\nexport const PhysicsHostKey: ServiceNameKey<PhysicsHost> = createServiceKey<PhysicsHost>(\"@ignifx/physics:host\");\n","import { bool, Component, createDefaults, defineSchema, enumOf, f32, record, Vec3 } from \"@ignifx/core\";\nimport { PhysicsHostKey } from \"../runtime/runtime-key.js\";\nimport type { LitePhysicsBody } from \"../lite/havok.js\";\nimport type { PhysicsRuntime } from \"../runtime/runtime.js\";\nimport type { ComponentHooks, MutableVec3, QuatLike, Schema, Vec3Like } from \"@ignifx/core\";\n\n/**\n * Simulate colliders on a root entity; parented bodies log `IGX-0907` because backend pose writes\n * are local. Collision events default to `auto`, following attached callbacks.\n * Velocity limits are world settings; per-body damping, gravity factors, sleep thresholds, and\n * explicit wake-up are unavailable in the pinned Lite adapter.\n */\n\n/**\n * How a body moves.\n *\n * @public\n */\nexport const BODY_TYPES = [\"dynamic\", \"kinematic\", \"static\"] as const;\n\n/**\n * The union of {@link BODY_TYPES}.\n *\n * @public\n */\nexport type BodyType = (typeof BODY_TYPES)[number];\n\n/**\n * Whether a body's display pose is interpolated between fixed steps.\n *\n * @public\n */\nexport const INTERPOLATION_MODES = [\"none\", \"interpolate\"] as const;\n\n/**\n * The union of {@link INTERPOLATION_MODES}.\n *\n * @public\n */\nexport type InterpolationMode = (typeof INTERPOLATION_MODES)[number];\n\n/**\n * Whether collision callbacks are delivered for this body.\n *\n * @public\n */\nexport const COLLISION_EVENT_MODES = [\"auto\", \"on\", \"off\"] as const;\n\n/**\n * The union of {@link COLLISION_EVENT_MODES}.\n *\n * @public\n */\nexport type CollisionEventMode = (typeof COLLISION_EVENT_MODES)[number];\n\n/**\n * How a moved kinematic node reaches Havok.\n *\n * @public\n */\nexport const KINEMATIC_SYNC_MODES = [\"teleport\", \"velocity\"] as const;\n\n/**\n * The union of {@link KINEMATIC_SYNC_MODES}.\n *\n * @public\n */\nexport type KinematicSyncMode = (typeof KINEMATIC_SYNC_MODES)[number];\n\n/**\n * Whether each rotation axis is frozen.\n *\n * @public\n */\nexport interface FreezeRotation {\n /** Freeze rotation about X. */\n readonly x: boolean;\n /** Freeze rotation about Y. */\n readonly y: boolean;\n /** Freeze rotation about Z. */\n readonly z: boolean;\n}\n\n/**\n * The Babylon Lite objects a `Rigidbody` owns. Unstable escape hatch\n * (`docs/architecture/00-overview.md` §3).\n *\n * @public\n */\nexport interface RigidbodyLiteHandles {\n /** The Havok body, or `null` before the first fixed step has built it. */\n readonly body: LitePhysicsBody | null;\n}\n\n/**\n * Makes an entity's colliders a Havok body (`09-physics.md` §2.1).\n *\n * @example\n * ```ts\n * const crate = world.createEntity(\"Crate\");\n * crate.transform.position = { x: 0, y: 5, z: 0 };\n * crate.addComponent(BoxCollider, { size: { x: 1, y: 1, z: 1 } });\n * crate.addComponent(Rigidbody, { mass: 2 });\n * ```\n *\n * @public\n */\nexport class Rigidbody extends Component implements ComponentHooks {\n /** The namespaced registration id. */\n static typeId = \"ignifx/Rigidbody\";\n\n /** One body per entity. */\n static allowMultiple = false;\n\n /** The serialized field declarations (ADR-0004). */\n static schema: Schema = rigidbodySchema();\n\n declare bodyType: BodyType;\n\n declare mass: number;\n\n declare startAsleep: boolean;\n\n declare freezeRotation: FreezeRotation;\n\n declare interpolation: InterpolationMode;\n\n declare collisionEvents: CollisionEventMode;\n\n declare kinematicSync: KinematicSyncMode;\n\n /** Applies the schema defaults, exactly as `Component.define` would. */\n constructor() {\n super();\n Object.assign(this, createDefaults(Rigidbody.schema));\n }\n\n /** Marks the entity's body for a rebuild at the start of the next fixed step. */\n onAttach(): void {\n this.rebuild();\n }\n\n /** Marks the entity's body for a rebuild, which turns it back into an implicit static body. */\n onDetach(): void {\n this.rebuild();\n }\n\n /**\n * Rebuilds the body after a tool changed fields from outside: an editor's inspector, or a hot\n * reload's new default (`ComponentHooks.onValidate`).\n *\n * @param fields - The fields that changed.\n */\n onValidate(fields: readonly string[]): void {\n void fields;\n this.rebuild();\n }\n\n /**\n * Rebuilds the body at the start of the next fixed step. Call it after changing `bodyType`,\n * `mass`, `freezeRotation`, or the entity's scale.\n */\n rebuild(): void {\n this.#runtime()?.markDirty(this.entity);\n }\n\n /**\n * The Babylon Lite handles this component owns.\n *\n * @returns The Havok body, or `null` before the first fixed step built it.\n */\n get lite(): RigidbodyLiteHandles {\n return { body: this.#runtime()?.bodyHandleOf(this.entity) ?? null };\n }\n\n /**\n * The body's linear velocity in metres per second.\n *\n * @returns A freshly allocated vector; use {@link Rigidbody.linearVelocityToRef} in hot code.\n */\n get linearVelocity(): Vec3 {\n const out = new Vec3();\n this.linearVelocityToRef(out);\n return out;\n }\n\n /**\n * Replaces the body's linear velocity.\n *\n * @param value - Metres per second, world space.\n */\n set linearVelocity(value: Vec3Like) {\n this.#runtime()?.setLinearVelocity(this.entity, value);\n }\n\n /**\n * Reads the linear velocity without allocating.\n *\n * @param out - The vector to write.\n * @returns `out`.\n */\n linearVelocityToRef(out: MutableVec3): MutableVec3 {\n this.#runtime()?.readLinear(this.entity, out);\n return out;\n }\n\n /**\n * The body's angular velocity in radians per second.\n *\n * @returns A freshly allocated vector; use {@link Rigidbody.angularVelocityToRef} in hot code.\n */\n get angularVelocity(): Vec3 {\n const out = new Vec3();\n this.angularVelocityToRef(out);\n return out;\n }\n\n /**\n * Replaces the body's angular velocity.\n *\n * @param value - Radians per second, world space.\n */\n set angularVelocity(value: Vec3Like) {\n this.#runtime()?.setAngularVelocity(this.entity, value);\n }\n\n /**\n * Reads the angular velocity without allocating.\n *\n * @param out - The vector to write.\n * @returns `out`.\n */\n angularVelocityToRef(out: MutableVec3): MutableVec3 {\n this.#runtime()?.readAngular(this.entity, out);\n return out;\n }\n\n /**\n * Applies a force for one fixed step. Call it from `fixedUpdate`.\n *\n * @param force - Newtons, world space.\n * @param point - Where to apply it; defaults to the entity's world position.\n *\n * @example\n * ```ts\n * fixedUpdate(): void {\n * this.body.addForce({ x: 0, y: 20, z: 0 });\n * }\n * ```\n */\n addForce(force: Vec3Like, point?: Vec3Like): void {\n this.#runtime()?.addForce(this.entity, force, point ?? this.transform.position);\n }\n\n /**\n * Applies an instantaneous impulse.\n *\n * @param impulse - Newton-seconds, world space.\n * @param point - Where to apply it; defaults to the entity's world position.\n */\n addImpulse(impulse: Vec3Like, point?: Vec3Like): void {\n this.#runtime()?.addImpulse(this.entity, impulse, point ?? this.transform.position);\n }\n\n /**\n * Moves the body without integrating a velocity, and resets the interpolation history so the\n * display pose does not slide across the gap.\n *\n * @param position - The new world position.\n * @param rotation - The new world rotation; defaults to the current one.\n */\n teleport(position: Vec3Like, rotation?: QuatLike): void {\n this.#runtime()?.teleport(this.entity, position, rotation ?? this.transform.rotation);\n }\n\n /**\n * The runtime, or `null` when the extension is not registered on this app.\n *\n * @returns The runtime.\n */\n #runtime(): PhysicsRuntime | null {\n return this.app.services.tryGet(PhysicsHostKey)?.runtime ?? null;\n }\n}\n\n/**\n * Builds the `Rigidbody` schema.\n *\n * @returns The schema.\n */\nfunction rigidbodySchema(): Schema {\n return defineSchema({\n bodyType: enumOf(BODY_TYPES, \"dynamic\"),\n mass: f32(1, { min: 0 }),\n startAsleep: bool(false),\n freezeRotation: record({ x: bool(false), y: bool(false), z: bool(false) }),\n interpolation: enumOf(INTERPOLATION_MODES, \"interpolate\"),\n collisionEvents: enumOf(COLLISION_EVENT_MODES, \"auto\"),\n kinematicSync: enumOf(KINEMATIC_SYNC_MODES, \"teleport\"),\n });\n}\n","import { Component, createDefaults, defineSchema, enumOf, f32, Signal, Vec3, vec3 } from \"@ignifx/core\";\nimport { PhysicsHostKey } from \"../runtime/runtime-key.js\";\nimport { INTERPOLATION_MODES } from \"./rigidbody.js\";\nimport type { CharacterCollision } from \"../events.js\";\nimport type { InterpolationMode } from \"./rigidbody.js\";\nimport type { PhysicsRuntime } from \"../runtime/runtime.js\";\nimport type { ComponentHooks, Schema, Vec3Like } from \"@ignifx/core\";\n\n/**\n * Sum `move` displacements during `fixedUpdate` and apply them in the physics step.\n * The controller owns world position after the step; game code owns rotation and gravity.\n * `supportState` is the last step's result. `pushStrength` scales Lite's default strength, not newtons.\n */\n\n/**\n * How the character is supported by whatever is under it.\n *\n * @public\n */\nexport const SUPPORT_STATES = [\"unsupported\", \"sliding\", \"supported\"] as const;\n\n/**\n * The union of {@link SUPPORT_STATES}.\n *\n * @public\n */\nexport type SupportStateName = (typeof SUPPORT_STATES)[number];\n\n/**\n * A kinematic capsule that walks, slides, and pushes (`09-physics.md` §2.3).\n *\n * @example\n * ```ts\n * class Walk extends Script implements ScriptCallbacks {\n * static typeId = \"mygame/Walk\";\n * fixedUpdate(dt: number): void {\n * const controller = this.entity.requireComponent(CharacterController);\n * controller.move({ x: 2 * dt, y: 0, z: 0 });\n * }\n * }\n * ```\n *\n * @public\n */\nexport class CharacterController extends Component implements ComponentHooks {\n /** The namespaced registration id. */\n static typeId = \"ignifx/CharacterController\";\n\n /** One controller per entity. */\n static allowMultiple = false;\n\n /** The serialized field declarations (ADR-0004). */\n static schema: Schema = characterSchema();\n\n declare radius: number;\n\n declare height: number;\n\n declare center: Vec3Like;\n\n declare slopeLimit: number;\n\n declare skinWidth: number;\n\n declare pushStrength: number;\n\n declare interpolation: InterpolationMode;\n\n /** The displacement requested so far this fixed step. */\n readonly #pendingMove = new Vec3();\n\n /** The averaged normal of the supporting surface, written by the step system. */\n readonly #groundNormal = new Vec3(0, 1, 0);\n\n /** How the character was supported at the end of the last step. */\n #supportState: SupportStateName = \"unsupported\";\n\n /** Emitted for every dynamic body the character pushed; created on first access. */\n #onCollided: Signal<CharacterCollision> | null = null;\n\n /** Applies the schema defaults. */\n constructor() {\n super();\n Object.assign(this, createDefaults(CharacterController.schema));\n }\n\n /** Creates the Lite controller at the start of the next fixed step. */\n onAttach(): void {\n this.rebuild();\n }\n\n /** Releases the Lite controller. */\n onDetach(): void {\n this.#runtime()?.releaseController(this);\n }\n\n /**\n * Rebuilds the body after a tool changed fields from outside: an editor's inspector, or a hot\n * reload's new default (`ComponentHooks.onValidate`).\n *\n * @param fields - The fields that changed.\n */\n onValidate(fields: readonly string[]): void {\n void fields;\n this.rebuild();\n }\n\n /** Rebuilds the capsule at the start of the next fixed step. */\n rebuild(): void {\n this.#runtime()?.markControllerDirty(this);\n }\n\n /**\n * Requests a displacement for this fixed step. Displacements accumulate until the step runs.\n *\n * @param displacement - The world-space displacement to attempt.\n */\n move(displacement: Vec3Like): void {\n this.#pendingMove.set(\n this.#pendingMove.x + displacement.x,\n this.#pendingMove.y + displacement.y,\n this.#pendingMove.z + displacement.z,\n );\n }\n\n /**\n * Sets the controller's velocity, which is what `integrate` advances.\n *\n * @param velocity - Metres per second, world space.\n */\n setVelocity(velocity: Vec3Like): void {\n this.#runtime()?.setControllerVelocity(this, velocity);\n }\n\n /**\n * The controller's current velocity.\n *\n * @returns A freshly allocated vector.\n */\n get velocity(): Vec3 {\n const out = new Vec3();\n this.#runtime()?.readControllerVelocity(this, out);\n return out;\n }\n\n /**\n * Whether the character is standing on a walkable surface.\n *\n * @returns `true` when the last step's probe reported `supported`.\n */\n get isGrounded(): boolean {\n return this.#supportState === \"supported\";\n }\n\n /**\n * How the character was supported at the end of the last step.\n *\n * @returns `\"unsupported\"`, `\"sliding\"`, or `\"supported\"`.\n */\n get supportState(): SupportStateName {\n return this.#supportState;\n }\n\n /**\n * The averaged normal of the supporting surface.\n *\n * @returns A live view; copy it if you keep it.\n */\n get groundNormal(): Vec3 {\n return this.#groundNormal;\n }\n\n /**\n * Emitted once per dynamic body the character pushed during a step.\n *\n * @returns The signal, created on first access.\n */\n get onCollided(): Signal<CharacterCollision> {\n this.#onCollided ??= new Signal<CharacterCollision>();\n return this.#onCollided;\n }\n\n /**\n * Changes the capsule height without losing the controller's state — the crouch primitive.\n *\n * @param height - The new total height, tip to tip.\n * @param preserveFeet - Whether the foot position stays fixed; defaults to `true`.\n */\n setHeight(height: number, preserveFeet: boolean = true): void {\n this.height = height;\n this.#runtime()?.resizeController(this, preserveFeet);\n }\n\n /**\n * Teleports the character, clearing any swept motion and the interpolation history.\n *\n * @param position - The new world position of the entity.\n */\n teleport(position: Vec3Like): void {\n this.#runtime()?.teleportController(this, position);\n }\n\n /**\n * The displacement requested so far this step, consumed by the step system.\n *\n * @returns A live view of the accumulator.\n *\n * @internal\n */\n takePendingMove(): Vec3 {\n return this.#pendingMove;\n }\n\n /**\n * Records the outcome of a step.\n *\n * @param state - The support classification.\n * @param normal - The averaged supporting normal.\n *\n * @internal\n */\n applyStepResult(state: SupportStateName, normal: Vec3Like): void {\n this.#supportState = state;\n this.#groundNormal.set(normal.x, normal.y, normal.z);\n this.#pendingMove.set(0, 0, 0);\n }\n\n /**\n * Emits `onCollided` if anything is listening.\n *\n * @param collision - The push to report.\n *\n * @internal\n */\n reportPush(collision: CharacterCollision): void {\n this.#onCollided?.emit(collision);\n }\n\n /**\n * The runtime, or `null` when the extension is not registered on this app.\n *\n * @returns The runtime.\n */\n #runtime(): PhysicsRuntime | null {\n return this.app.services.tryGet(PhysicsHostKey)?.runtime ?? null;\n }\n}\n\n/**\n * Builds the `CharacterController` schema.\n *\n * @returns The schema.\n */\nfunction characterSchema(): Schema {\n return defineSchema({\n radius: f32(0.4, { min: 0 }),\n height: f32(1.8, { min: 0 }),\n center: vec3(),\n slopeLimit: f32(45, { min: 0, max: 90 }),\n skinWidth: f32(0.05, { min: 0 }),\n pushStrength: f32(1, { min: 0 }),\n interpolation: enumOf(INTERPOLATION_MODES, \"interpolate\"),\n });\n}\n","import { IgnifxError } from \"@ignifx/core\";\nimport type { ErrorContext } from \"@ignifx/core\";\n\n/**\n * The diagnostic codes `@ignifx/physics` owns. The package sits in the `09` subsystem range of\n * `docs/architecture/15-devtools-and-diagnostics.md` §1, so every code reads `IGX-09##`.\n *\n * The table lives here rather than in `@ignifx/core`'s `CoreErrorCode`: an extension owns its own\n * codes and hands them to the app through `ExtensionContext.registerErrorCodes`\n * (`docs/architecture/04-extensions.md` §3).\n */\n\n/**\n * Every diagnostic code `@ignifx/physics` can throw or report, keyed by an intention-revealing name\n * so call sites read as prose and the compiler catches typos (coding standards §5.2).\n *\n * @example\n * ```ts\n * throw physicsError(PhysicsErrorCode.queryBeforeStep, \"raycast() ran before the first step.\", {\n * context: { query: \"raycast\" },\n * });\n * ```\n *\n * @public\n */\nexport const PhysicsErrorCode = {\n /** An entity with colliders but no `Rigidbody` moved after its implicit static body was placed. */\n movedStaticBody: \"IGX-0901\",\n /** A query ran before the first completed fixed step, so Havok has no broadphase yet. */\n queryBeforeStep: \"IGX-0902\",\n /** The Havok WebAssembly module could not be loaded. */\n havokUnavailable: \"IGX-0903\",\n /** A `.physicsmaterial.json` file is not an `ignifx.physicsmaterial` document this build reads. */\n invalidMaterialFile: \"IGX-0904\",\n /** The `physics.collisionMatrix` setting names a layer the project does not declare. */\n unknownLayer: \"IGX-0905\",\n /** A `MeshCollider` has no geometry to build a shape from. */\n colliderGeometryUnavailable: \"IGX-0906\",\n /** A physics body was built for an entity that has a parent, whose node pose is not world space. */\n bodyOnChildEntity: \"IGX-0907\",\n // IGX-0908 is retired: it was the ADR-0013 collision drain's guard, removed with the drain.\n // Do not reuse it, so an old log or bug report never points at the wrong failure.\n} as const;\n\n/**\n * The union of the codes the `PhysicsErrorCode` table declares.\n *\n * @public\n */\nexport type PhysicsErrorCode = (typeof PhysicsErrorCode)[keyof typeof PhysicsErrorCode];\n\n/**\n * The one-line message template of every code, as `ExtensionContext.registerErrorCodes` wants it.\n * Context keys appear in braces, matching the core table's convention.\n *\n * @public\n */\nexport const PHYSICS_ERROR_MESSAGES: Readonly<Record<string, string>> = Object.freeze({\n \"IGX-0901\": \"{entity} has colliders but no Rigidbody, and it moved after its static body was placed.\",\n \"IGX-0902\": \"{query} needs at least one completed fixed step before Havok can answer it.\",\n \"IGX-0903\": \"The Havok WebAssembly module could not be loaded from {url}.\",\n \"IGX-0904\": \"{file} is not an ignifx.physicsmaterial document this build can read.\",\n \"IGX-0905\": \"physics.collisionMatrix names the layer {layer}, which the project does not declare.\",\n \"IGX-0906\": \"{entity} has a MeshCollider with no geometry to build a shape from.\",\n \"IGX-0907\": \"{entity} carries a physics body but is not a root entity; Havok writes its local pose.\",\n});\n\n/**\n * Options accepted by {@link physicsError}: the same subset of `IgnifxErrorOptions` this package\n * uses.\n *\n * @public\n */\nexport interface PhysicsErrorOptions {\n /** Identifiers that locate the failure. */\n readonly context?: ErrorContext;\n /** One sentence telling the developer what to do about it. */\n readonly hint?: string;\n /** The failure being wrapped, when there is one. */\n readonly cause?: unknown;\n}\n\n/**\n * Builds an `IgnifxError` carrying one of this package's codes.\n *\n * @param code - The code from the `PhysicsErrorCode` table.\n * @param message - The actionable development sentence.\n * @param options - Context identifiers, a remedy hint, and the wrapped cause.\n * @returns The error to throw or to reject with.\n *\n * @example\n * ```ts\n * throw physicsError(PhysicsErrorCode.unknownLayer, \"physics.collisionMatrix names Enemy.\", {\n * context: { layer: \"Enemy\" },\n * });\n * ```\n *\n * @public\n */\nexport function physicsError(code: PhysicsErrorCode, message: string, options?: PhysicsErrorOptions): IgnifxError {\n return new IgnifxError(code, message, {\n ...(options?.context === undefined ? {} : { context: options.context }),\n ...(options?.hint === undefined ? {} : { hint: options.hint }),\n ...(options?.cause === undefined ? {} : { cause: options.cause }),\n });\n}\n","import { PhysicsErrorCode, physicsError } from \"./errors.js\";\nimport type { PhysicsMaterialValues } from \"./settings.js\";\nimport type { AssetLoader, JsonObject, JsonValue, LoaderContext, SchemaDescription } from \"@ignifx/core\";\n\n/**\n * The `ignifx.physicsmaterial` asset (`docs/architecture/09-physics.md` §2.4,\n * `05-assets-and-loading.md` §5): a surface's friction and bounciness, saved next to the scene that\n * uses it so an artist can retune a floor without touching code.\n */\n\n/**\n * The asset type name `.physicsmaterial.json` addresses resolve to.\n *\n * @public\n */\nexport const PHYSICS_MATERIAL_ASSET_TYPE = \"physicsmaterial\";\n\n/**\n * The address suffix that selects the loader.\n *\n * @public\n */\nexport const PHYSICS_MATERIAL_FILE_EXTENSION = \".physicsmaterial.json\";\n\n/**\n * The `format` string every physics-material document declares.\n *\n * @public\n */\nexport const PHYSICS_MATERIAL_FILE_FORMAT = \"ignifx.physicsmaterial\";\n\n/**\n * The file format version; `1` before ignifx 1.0.\n *\n * @public\n */\nexport const PHYSICS_MATERIAL_FORMAT_VERSION = 1;\n\n/**\n * A loaded surface material. The values are the ones Havok's `setPhysicsShapeMaterial` takes\n * (`index.d.ts` 10853).\n *\n * @example\n * ```ts\n * const ice = await app.assets.load<PhysicsMaterial>(\"materials/ice.physicsmaterial.json\");\n * floor.addComponent(BoxCollider, { size: { x: 10, y: 1, z: 10 }, material: ice });\n * ```\n *\n * @public\n */\nexport class PhysicsMaterial implements PhysicsMaterialValues {\n /** The asset type token, so `asset(PhysicsMaterial)` fields resolve. */\n static assetType: string = PHYSICS_MATERIAL_ASSET_TYPE;\n\n /** A human-readable name, used in diagnostics. */\n readonly name: string;\n\n /** The dynamic friction coefficient. */\n readonly friction: number;\n\n /** The static friction coefficient. */\n readonly staticFriction: number;\n\n /** How much of the approach speed is returned, `0` to `1`. */\n readonly restitution: number;\n\n /**\n * Wraps parsed values. The loader constructs these; game code uses\n * {@link PhysicsMaterial.fromValues} when it wants one in code.\n *\n * @param name - A human-readable name.\n * @param values - Friction, static friction, and restitution.\n */\n constructor(name: string, values: PhysicsMaterialValues) {\n this.name = name;\n this.friction = values.friction;\n this.staticFriction = values.staticFriction;\n this.restitution = values.restitution;\n }\n\n /**\n * Builds a material in code, filling in the fields the caller omitted.\n *\n * @param name - A human-readable name.\n * @param values - Any subset of the three coefficients.\n * @returns The material.\n *\n * @example\n * ```ts\n * const bouncy = PhysicsMaterial.fromValues(\"bouncy\", { restitution: 0.9 });\n * ```\n */\n static fromValues(name: string, values: Partial<PhysicsMaterialValues>): PhysicsMaterial {\n const friction = values.friction ?? 0.6;\n return new PhysicsMaterial(name, {\n friction,\n staticFriction: values.staticFriction ?? friction,\n restitution: values.restitution ?? 0,\n });\n }\n}\n\n/**\n * Builds the loader for `.physicsmaterial.json` files.\n *\n * @returns The loader, ready for `ctx.registerAssetLoader`.\n *\n * @public\n */\nexport function createPhysicsMaterialLoader(): AssetLoader<PhysicsMaterial> {\n return {\n type: PHYSICS_MATERIAL_ASSET_TYPE,\n extensions: [PHYSICS_MATERIAL_FILE_EXTENSION],\n load: async (ctx: LoaderContext): Promise<PhysicsMaterial> => {\n const document = await ctx.fetchJson<JsonValue>();\n return parsePhysicsMaterial(ctx.address, document);\n },\n };\n}\n\n/**\n * Parses one `ignifx.physicsmaterial` document.\n *\n * @param address - The address it came from, for the diagnostic.\n * @param document - The parsed JSON.\n * @returns The material.\n * @throws IgnifxError with code `IGX-0904` when the document is not one this build can read.\n *\n * @public\n */\nexport function parsePhysicsMaterial(address: string, document: JsonValue): PhysicsMaterial {\n const object = asObject(document);\n if (object === null || object[\"format\"] !== PHYSICS_MATERIAL_FILE_FORMAT) {\n throw physicsError(PhysicsErrorCode.invalidMaterialFile, `${address} is not an ${PHYSICS_MATERIAL_FILE_FORMAT}.`, {\n context: { file: address },\n hint: `Add \"format\": \"${PHYSICS_MATERIAL_FILE_FORMAT}\" to the document.`,\n });\n }\n const version = numberAt(object, \"formatVersion\", PHYSICS_MATERIAL_FORMAT_VERSION);\n if (version > PHYSICS_MATERIAL_FORMAT_VERSION) {\n throw physicsError(PhysicsErrorCode.invalidMaterialFile, `${address} is version ${String(version)}.`, {\n context: { file: address, version },\n hint: \"Upgrade @ignifx/physics, or re-save the material from this version of the editor.\",\n });\n }\n const friction = numberAt(object, \"friction\", 0.6);\n const name = typeof object[\"name\"] === \"string\" ? object[\"name\"] : address;\n return new PhysicsMaterial(name, {\n friction,\n staticFriction: numberAt(object, \"staticFriction\", friction),\n restitution: numberAt(object, \"restitution\", 0),\n });\n}\n\n/**\n * Describes the `ignifx.physicsmaterial` file format for the documentation harness\n * (`docs/architecture/16-docs-harness-and-skill.md` §3).\n *\n * @returns The description of the top-level file fields.\n *\n * @public\n */\nexport function describePhysicsMaterialFileFormat(): SchemaDescription {\n return {\n title: \"Physics material file\",\n format: PHYSICS_MATERIAL_FILE_FORMAT,\n description: \"A surface's friction and bounciness, referenced by a collider's material field.\",\n fields: {\n format: {\n kind: \"str\",\n default: PHYSICS_MATERIAL_FILE_FORMAT,\n description: `Always \"${PHYSICS_MATERIAL_FILE_FORMAT}\".`,\n },\n formatVersion: {\n kind: \"u32\",\n default: PHYSICS_MATERIAL_FORMAT_VERSION,\n description: \"The file format version; 1 before ignifx 1.0.\",\n },\n name: { kind: \"str\", default: \"\", description: \"A human-readable name; defaults to the address.\" },\n friction: { kind: \"f32\", default: 0.6, description: \"The dynamic friction coefficient.\" },\n staticFriction: {\n kind: \"f32\",\n default: 0.6,\n description: \"The static friction coefficient; defaults to friction.\",\n },\n restitution: { kind: \"f32\", default: 0, description: \"How much approach speed is returned, 0 to 1.\" },\n },\n };\n}\n\n/**\n * Views a JSON value as an object.\n *\n * @param value - The parsed JSON.\n * @returns The object, or `null` when the value is not one.\n */\nfunction asObject(value: JsonValue): JsonObject | null {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return null;\n }\n // The guard above is exactly `JsonObject` — an object\n // that is neither `null` nor an array — which is what `JsonValue` leaves in the union.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return value as JsonObject;\n}\n\n/**\n * Reads a numeric property, tolerating its absence.\n *\n * @param object - The document.\n * @param key - The property name.\n * @param fallback - What to use when the property is missing or not a number.\n * @returns The value.\n */\nfunction numberAt(object: JsonObject, key: string, fallback: number): number {\n const value = object[key];\n return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n","import { asset, bool, Component, createDefaults, optional, record, str, vec3, f32 } from \"@ignifx/core\";\nimport { PhysicsMaterial } from \"../material.js\";\nimport { PhysicsHostKey } from \"../runtime/runtime-key.js\";\nimport type { LitePhysicsShape, LitePhysicsWorld } from \"../lite/havok.js\";\nimport type { PhysicsMaterialValues } from \"../settings.js\";\nimport type { AssetHandle, ComponentHooks, LiteSceneNode, MutableVec3, Schema, Vec3Like } from \"@ignifx/core\";\n\n/**\n * Collider dimensions use local units and the entity's scale at build time; call `rebuild` after\n * changing scale. Material assets take precedence over inline material, then project defaults.\n */\n\n/**\n * The fields every collider declares. It is a function because a field kind is a function call and\n * module scope holds declarations only (`CONSTITUTION.md` §3.5).\n *\n * @returns The shared field declarations, ready to spread into a collider's own schema.\n *\n * @public\n */\nexport function colliderFields(): Schema {\n return {\n center: vec3(),\n isTrigger: bool(false),\n material: asset(PhysicsMaterial),\n inlineMaterial: optional(\n record({\n friction: f32(0.6, { min: 0 }),\n staticFriction: f32(0.6, { min: 0 }),\n restitution: f32(0, { min: 0, max: 1 }),\n }),\n ),\n layerOverride: str(\"\"),\n };\n}\n\n/**\n * The base class of every collider. It is never registered on its own; `entity.getComponents` and\n * `world.components` accept it because the concrete colliders extend it.\n *\n * @public\n */\nexport abstract class Collider extends Component implements ComponentHooks {\n /** Several colliders on one entity form one compound body (`09-physics.md` §2.2). */\n static allowMultiple = true;\n\n /** The shape's offset from the entity origin, in local units. */\n declare center: Vec3Like;\n\n /** When `true` the shape reports overlaps and resolves no contacts. */\n declare isTrigger: boolean;\n\n /** A `.physicsmaterial.json` reference; wins over {@link Collider.inlineMaterial}. */\n declare material: AssetHandle<PhysicsMaterial> | null;\n\n /** An inline surface, used when {@link Collider.material} is `null`. */\n declare inlineMaterial: PhysicsMaterialValues | null;\n\n /** The name of the layer this collider filters as, or `\"\"` to use `entity.layer`. */\n declare layerOverride: string;\n\n /**\n * Applies the shared defaults. A concrete collider calls `super()` and then applies its own.\n */\n constructor() {\n super();\n Object.assign(this, createDefaults(colliderFields()));\n }\n\n /** Marks the entity's body for a rebuild at the start of the next fixed step. */\n onAttach(): void {\n this.rebuild();\n }\n\n /** Marks the entity's body for a rebuild, which removes this collider from it. */\n onDetach(): void {\n this.rebuild();\n }\n\n /**\n * Rebuilds the body after a tool changed fields from outside: an editor's inspector, or a hot\n * reload's new default (`ComponentHooks.onValidate`).\n *\n * @param fields - The fields that changed.\n */\n onValidate(fields: readonly string[]): void {\n void fields;\n this.rebuild();\n }\n\n /**\n * Rebuilds the entity's body and shapes at the start of the next fixed step. Call it after\n * changing a size, a `center`, `isTrigger`, or the entity's scale.\n *\n * @example\n * ```ts\n * box.size = { x: 2, y: 2, z: 2 };\n * box.rebuild();\n * ```\n */\n rebuild(): void {\n this.app.services.tryGet(PhysicsHostKey)?.runtime?.markDirty(this.entity);\n }\n\n /**\n * Resolves the surface this collider presents to Havok.\n *\n * @param fallback - The world's `physics.defaultMaterial`.\n * @returns The asset's values, the inline values, or the fallback.\n */\n resolveMaterial(fallback: PhysicsMaterialValues): PhysicsMaterialValues {\n return this.material?.value ?? this.inlineMaterial ?? fallback;\n }\n\n /**\n * Builds the Havok shape this collider stands for.\n *\n * @param world - The Havok world.\n * @param scale - The entity's lossy scale.\n * @param node - The entity's Lite node, for the colliders that read geometry from it.\n * @returns The shape handle.\n *\n * @internal\n */\n abstract createShape(world: LitePhysicsWorld, scale: Vec3Like, node: LiteSceneNode): LitePhysicsShape;\n\n /**\n * Writes the half-extents of this collider's local bounding box, scale applied. The service's\n * `overlap` and `shapeCast` use it to resolve entities that Lite's queries do not identify.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The vector to write.\n *\n * @internal\n */\n abstract halfExtentsToRef(scale: Vec3Like, out: MutableVec3): void;\n\n /**\n * Appends this collider's outline, as line segments in the body's space with the scale applied,\n * for `PhysicsService.colliderOutlines`. A collider whose shape cannot be outlined without its\n * geometry appends nothing.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The segment list: six numbers per segment.\n *\n * @internal\n */\n outlineToRef(scale: Vec3Like, out: number[]): void {\n void scale;\n void out;\n }\n}\n","import {\n addPhysicsShapeChild,\n applyPhysicsBodyForce,\n applyPhysicsBodyImpulse,\n createHavokWorld,\n createHeightFieldShape,\n createNullEngine,\n createPhysicsBody,\n createPhysicsShape,\n createSceneContext,\n disposePhysics,\n disposeScene,\n getPhysicsBodyAngularVelocity,\n getPhysicsBodyLinearVelocity,\n lockPhysicsBodyRotationAxes,\n onPhysicsAfterStep,\n onPhysicsCollision,\n onPhysicsTriggerBodies,\n releasePhysicsShape,\n removePhysicsBody,\n setPhysicsBodyAngularVelocity,\n setPhysicsBodyCollisionEventsEnabled,\n setPhysicsBodyLinearVelocity,\n setPhysicsBodyMass,\n setPhysicsBodyPrestepType,\n setPhysicsBodyShape,\n setPhysicsBodyTransform,\n setPhysicsGravity,\n setPhysicsShapeFilterCollideMask,\n setPhysicsShapeFilterMembershipMask,\n setPhysicsShapeIsTrigger,\n setPhysicsShapeMaterial,\n setPhysicsTimestep,\n setPhysicsVelocityLimits,\n stepScene,\n unlockPhysicsBodyRotationAxes,\n} from \"@babylonjs/lite\";\nimport type { PhysicsBody, PhysicsRotationAxis, PhysicsShape, PhysicsWorld } from \"@babylonjs/lite\";\nimport type { LiteEngine, LiteScene, LiteSceneNode, MutableQuat, MutableVec3, QuatLike, Vec3Like } from \"@ignifx/core\";\n\n/**\n * The Havok half of this package's Babylon Lite adapter (ADR-0002, ADR-0003,\n * `docs/architecture/09-physics.md` §1). Every `@babylonjs/lite` symbol the extension uses is named\n * here once, so the rest of `src/` never imports Lite (`ignifx/no-lite-outside-adapter`).\n *\n * ## Facts verified against `@babylonjs/lite@1.27.0`\n *\n * - `createHavokWorld(scene, hknp, gravity)` (`index.d.ts` 2592, `lib/physics/havok.js:44`) unshifts\n * one step callback onto `scene._beforeRender`. Hosting it on a **null-engine** scene and driving\n * that scene with `stepScene` (12438) is what gives ignifx the accumulator ADR-0003 requires.\n * - `_stepWorld` (`lib/physics/havok.js:73-107`) pre-syncs node→body only for `ANIMATED` bodies and\n * for bodies with `_preStep` set, then steps once, then syncs body→node for `DYNAMIC` bodies. A\n * `DYNAMIC` body therefore never reads its node, which is what makes the interpolated display\n * pose of `09-physics.md` §1 safe (spike S4.3).\n * - `_syncBodyToNode` writes `node.position` / `node.rotationQuaternion` — the node's **local** TRS.\n * A body's node must therefore be a root node for its pose to be world space; the extension\n * reports `IGX-0907` otherwise.\n * - `setPhysicsTimestep(world, dt)` (10863) stores `dt * 1000` in `world._fixedDeltaMs`, and the\n * step clamps at 100 ms (`MAX_STEP_MS`), so the fixed step and Lite's step agree exactly.\n *\n * Everything here is `@internal`.\n */\n\n/**\n * Lite's opaque Havok world handle.\n *\n * @internal\n */\nexport type LitePhysicsWorld = PhysicsWorld;\n\n/**\n * Lite's opaque Havok body handle. It carries the node it is bound to, which is how the extension\n * resolves a body back to an entity.\n *\n * @internal\n */\nexport type LitePhysicsBody = PhysicsBody;\n\n/**\n * Lite's opaque Havok collision-shape handle.\n *\n * @internal\n */\nexport type LitePhysicsShape = PhysicsShape;\n\n/**\n * How a body moves, in ignifx's vocabulary. The numbers are Lite's `PhysicsMotionType` values\n * (`index.d.ts` 8543) so no translation table is needed on a per-body path.\n *\n * @internal\n */\nexport const BodyMotion = {\n /** Immovable; `PhysicsMotionType.STATIC`. */\n static: 0,\n /** Driven by the node transform; `PhysicsMotionType.ANIMATED`. */\n kinematic: 1,\n /** Simulated; `PhysicsMotionType.DYNAMIC`. */\n dynamic: 2,\n} as const;\n\n/**\n * The union of {@link BodyMotion} values.\n *\n * @internal\n */\nexport type BodyMotion = (typeof BodyMotion)[keyof typeof BodyMotion];\n\n/**\n * How a moved node reaches its body before a step; Lite's `PhysicsPrestepType` (8557).\n *\n * @internal\n */\nexport const PrestepMode = {\n /** No sync at all. */\n disabled: 0,\n /** Snap the body onto the node. */\n teleport: 1,\n /** Give the body the velocity that reaches the node, so resting bodies are dragged along. */\n velocity: 2,\n} as const;\n\n/**\n * The union of {@link PrestepMode} values.\n *\n * @internal\n */\nexport type PrestepMode = (typeof PrestepMode)[keyof typeof PrestepMode];\n\n/**\n * The shape geometries this package builds; Lite's `PhysicsShapeType` (8606).\n *\n * @internal\n */\nexport const ShapeGeometry = {\n /** A sphere. */\n sphere: 0,\n /** A capsule between two points. */\n capsule: 1,\n /** A cylinder between two points. */\n cylinder: 2,\n /** An axis-aligned box in shape space. */\n box: 3,\n /** The convex hull of a node's meshes. */\n convexHull: 4,\n /** A compound of child shapes. */\n container: 5,\n /** A triangle mesh built from a node's meshes. */\n mesh: 6,\n} as const;\n\n/**\n * The union of {@link ShapeGeometry} values.\n *\n * @internal\n */\nexport type ShapeGeometry = (typeof ShapeGeometry)[keyof typeof ShapeGeometry];\n\n/**\n * Geometry parameters for {@link createShape}; the subset of Lite's `PhysicsShapeParameters` (8596)\n * this package writes.\n *\n * @internal\n */\nexport interface ShapeParameters {\n /** The shape's centre in shape space. */\n readonly center?: Vec3Like;\n /** The radius of a sphere, capsule, or cylinder. */\n readonly radius?: number;\n /** The first end point of a capsule or cylinder. */\n readonly pointA?: Vec3Like;\n /** The second end point of a capsule or cylinder. */\n readonly pointB?: Vec3Like;\n /** The full extents of a box. */\n readonly extents?: Vec3Like;\n /** The rotation of a box in shape space. */\n readonly rotation?: QuatLike;\n}\n\n/** The engine and scene the simulation runs on. */\nexport interface SimulationHandles {\n /** Lite's null engine — no device, no surface. */\n readonly engine: LiteEngine;\n /** A scene with no default render task, advanced only by {@link stepSimulation}. */\n readonly scene: LiteScene;\n}\n\n/**\n * Creates the null-engine scene the Havok world is hosted on (`09-physics.md` §1, spike S4.1).\n *\n * @returns The engine and scene. Release with {@link disposeSimulation}.\n *\n * @internal\n */\nexport function createSimulation(): SimulationHandles {\n const engine = createNullEngine();\n return { engine, scene: createSceneContext(engine, { defaultRenderTask: false }) };\n}\n\n/**\n * Releases the simulation scene. The null engine owns no GPU resource and must not be handed to\n * Lite's `disposeEngine` (ADR-0009 Validation).\n *\n * @param handles - What {@link createSimulation} returned.\n *\n * @internal\n */\nexport function disposeSimulation(handles: SimulationHandles): void {\n disposeScene(handles.scene);\n}\n\n/**\n * Advances the simulation scene by exactly one Havok step.\n *\n * @param handles - The engine and scene.\n * @param deltaMs - The fixed step in milliseconds.\n *\n * @internal\n */\nexport function stepSimulation(handles: SimulationHandles, deltaMs: number): void {\n stepScene(handles.engine, handles.scene, deltaMs);\n}\n\n/**\n * Creates the Havok world on a simulation scene.\n *\n * @param scene - The simulation scene.\n * @param havok - The instantiated Havok WebAssembly module; Lite types it as `any`.\n * @param gravity - The world gravity.\n * @returns The world handle.\n *\n * @internal\n */\nexport function createWorld(scene: LiteScene, havok: unknown, gravity: Vec3Like): LitePhysicsWorld {\n return createHavokWorld(scene, havok, { x: gravity.x, y: gravity.y, z: gravity.z });\n}\n\n/**\n * Releases every body and the native world. Call it before the simulation scene is disposed\n * (`docs/architecture/07-rendering.md` §7 ordering).\n *\n * @param world - The world handle.\n *\n * @internal\n */\nexport function destroyWorld(world: LitePhysicsWorld): void {\n disposePhysics(world);\n}\n\n/**\n * Pins Lite's per-step delta to ignifx's fixed step, so the two never disagree.\n *\n * @param world - The world handle.\n * @param seconds - The fixed step in seconds.\n *\n * @internal\n */\nexport function setTimestep(world: LitePhysicsWorld, seconds: number): void {\n setPhysicsTimestep(world, seconds);\n}\n\n/**\n * Sets world gravity.\n *\n * @param world - The world handle.\n * @param gravity - The acceleration vector, in metres per second squared.\n *\n * @internal\n */\nexport function setGravity(world: LitePhysicsWorld, gravity: Vec3Like): void {\n setPhysicsGravity(world, { x: gravity.x, y: gravity.y, z: gravity.z });\n}\n\n/**\n * Sets the world-wide speed limits.\n *\n * @param world - The world handle.\n * @param linear - Maximum linear speed, in metres per second.\n * @param angular - Maximum angular speed, in radians per second.\n *\n * @internal\n */\nexport function setVelocityLimits(world: LitePhysicsWorld, linear: number, angular: number): void {\n setPhysicsVelocityLimits(world, linear, angular);\n}\n\n/**\n * Creates a body bound to a scene node.\n *\n * @param world - The world handle.\n * @param node - The node whose local pose is the body pose.\n * @param motion - How the body moves.\n * @param startsAsleep - Whether the body starts asleep.\n * @returns The body handle.\n *\n * @internal\n */\nexport function createBody(\n world: LitePhysicsWorld,\n node: LiteSceneNode,\n motion: BodyMotion,\n startsAsleep: boolean,\n): LitePhysicsBody {\n return createPhysicsBody(world, node, motion, startsAsleep);\n}\n\n/**\n * Removes a body from the world.\n *\n * @param world - The world handle.\n * @param body - The body to remove.\n *\n * @internal\n */\nexport function destroyBody(world: LitePhysicsWorld, body: LitePhysicsBody): void {\n removePhysicsBody(world, body);\n}\n\n/**\n * Attaches a shape to a body.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param shape - The shape.\n *\n * @internal\n */\nexport function setBodyShape(world: LitePhysicsWorld, body: LitePhysicsBody, shape: LitePhysicsShape): void {\n setPhysicsBodyShape(world, body, shape);\n}\n\n/**\n * Sets a body's mass. Havok recomputes the shape-derived inertia around it.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param mass - The mass in kilograms; `0` for an infinite-mass body.\n *\n * @internal\n */\nexport function setBodyMass(world: LitePhysicsWorld, body: LitePhysicsBody, mass: number): void {\n setPhysicsBodyMass(world, body, mass);\n}\n\n/**\n * Chooses how a moved node reaches the body before the next step.\n *\n * @param body - The body.\n * @param mode - The prestep mode.\n *\n * @internal\n */\nexport function setBodyPrestep(body: LitePhysicsBody, mode: PrestepMode): void {\n setPhysicsBodyPrestepType(body, mode);\n}\n\n/**\n * Turns collision-event reporting on or off for one body.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param enabled - Whether the body contributes to the collision stream.\n *\n * @internal\n */\nexport function setBodyCollisionEvents(world: LitePhysicsWorld, body: LitePhysicsBody, enabled: boolean): void {\n setPhysicsBodyCollisionEventsEnabled(world, body, enabled);\n}\n\n/**\n * Teleports a body, keeping the node it drives consistent.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param position - The world position.\n * @param rotation - The world rotation.\n *\n * @internal\n */\nexport function setBodyTransform(\n world: LitePhysicsWorld,\n body: LitePhysicsBody,\n position: Vec3Like,\n rotation: QuatLike,\n): void {\n setPhysicsBodyTransform(\n world,\n body,\n { x: position.x, y: position.y, z: position.z },\n { x: rotation.x, y: rotation.y, z: rotation.z, w: rotation.w },\n );\n}\n\n/**\n * Reads a body's linear velocity into an out parameter (coding standards §7).\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param out - The vector to write.\n *\n * @internal\n */\nexport function readLinearVelocity(world: LitePhysicsWorld, body: LitePhysicsBody, out: MutableVec3): void {\n const value = getPhysicsBodyLinearVelocity(world, body);\n out.set(value.x, value.y, value.z);\n}\n\n/**\n * Reads a body's angular velocity into an out parameter.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param out - The vector to write.\n *\n * @internal\n */\nexport function readAngularVelocity(world: LitePhysicsWorld, body: LitePhysicsBody, out: MutableVec3): void {\n const value = getPhysicsBodyAngularVelocity(world, body);\n out.set(value.x, value.y, value.z);\n}\n\n/**\n * Sets a body's linear velocity.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param velocity - Metres per second, world space.\n *\n * @internal\n */\nexport function writeLinearVelocity(world: LitePhysicsWorld, body: LitePhysicsBody, velocity: Vec3Like): void {\n setPhysicsBodyLinearVelocity(world, body, { x: velocity.x, y: velocity.y, z: velocity.z });\n}\n\n/**\n * Sets a body's angular velocity.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param velocity - Radians per second, world space.\n *\n * @internal\n */\nexport function writeAngularVelocity(world: LitePhysicsWorld, body: LitePhysicsBody, velocity: Vec3Like): void {\n setPhysicsBodyAngularVelocity(world, body, { x: velocity.x, y: velocity.y, z: velocity.z });\n}\n\n/**\n * Applies a force for one fixed step.\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param force - Newtons, world space.\n * @param point - The world-space application point.\n *\n * @internal\n */\nexport function applyForce(world: LitePhysicsWorld, body: LitePhysicsBody, force: Vec3Like, point: Vec3Like): void {\n applyPhysicsBodyForce(world, body, { x: force.x, y: force.y, z: force.z }, { x: point.x, y: point.y, z: point.z });\n}\n\n/**\n * Applies an instantaneous impulse.\n *\n * @param body - The body.\n * @param impulse - Newton-seconds, world space.\n * @param point - The world-space application point.\n *\n * @internal\n */\nexport function applyImpulse(body: LitePhysicsBody, impulse: Vec3Like, point: Vec3Like): void {\n applyPhysicsBodyImpulse(body, { x: impulse.x, y: impulse.y, z: impulse.z }, { x: point.x, y: point.y, z: point.z });\n}\n\n/**\n * Locks or unlocks a body's rotation axes. Havok expresses a locked degree of freedom as zero\n * inertia (`index.d.ts` 6956).\n *\n * @param world - The world handle.\n * @param body - The body.\n * @param locked - The axes to lock; every other axis is unlocked.\n *\n * @internal\n */\nexport function setRotationLocks(\n world: LitePhysicsWorld,\n body: LitePhysicsBody,\n locked: readonly PhysicsRotationAxis[],\n): void {\n const free: PhysicsRotationAxis[] = [];\n for (const axis of ROTATION_AXES) {\n if (!locked.includes(axis)) {\n free.push(axis);\n }\n }\n if (free.length > 0) {\n unlockPhysicsBodyRotationAxes(world, body, free);\n }\n if (locked.length > 0) {\n lockPhysicsBodyRotationAxes(world, body, locked);\n }\n}\n\n/** The three rotation axes Lite names, in a stable order. */\nconst ROTATION_AXES: readonly PhysicsRotationAxis[] = Object.freeze([\"x\", \"y\", \"z\"]);\n\n/**\n * Creates a primitive collision shape.\n *\n * @param world - The world handle.\n * @param geometry - Which primitive to build.\n * @param parameters - Its geometry parameters.\n * @returns The shape handle.\n *\n * @internal\n */\nexport function createShape(\n world: LitePhysicsWorld,\n geometry: ShapeGeometry,\n parameters: ShapeParameters,\n): LitePhysicsShape {\n return createPhysicsShape(world, { type: geometry, parameters: { ...parameters } });\n}\n\n/**\n * Creates a triangle-mesh or convex-hull shape from a node's meshes.\n *\n * @remarks\n * Lite documents this as unsupported on the null engine (`index.d.ts` 2781: \"Mesh/convex-hull\n * colliders that require `node.worldMatrix`\"), and a headless `MeshAsset` uploads no geometry at\n * all, so the extension refuses with `IGX-0906` rather than building an empty shape.\n *\n * @param world - The world handle.\n * @param node - The node whose meshes supply the geometry.\n * @param convex - `true` for a convex hull, `false` for a triangle mesh.\n * @param includeChildren - Whether descendant meshes are accumulated.\n * @returns The shape handle.\n *\n * @internal\n */\nexport function createMeshShape(\n world: LitePhysicsWorld,\n node: LiteSceneNode,\n convex: boolean,\n includeChildren: boolean,\n): LitePhysicsShape {\n return createPhysicsShape(world, {\n type: convex ? ShapeGeometry.convexHull : ShapeGeometry.mesh,\n mesh: node,\n includeChildMeshes: includeChildren,\n });\n}\n\n/**\n * Creates a heightfield shape from an explicit sample grid (`index.d.ts` 2601, 6266).\n *\n * @remarks\n * The explicit path only calls `hknp._malloc` and `HP_Shape_CreateHeightField`\n * (`lib/physics/havok-heightfield.js:4-22`), so it works on the null engine; the `groundMesh` path\n * reads `mesh._cpuPositions` and `worldMatrix` and does not.\n *\n * @param world - The world handle.\n * @param samplesX - How many samples along X.\n * @param samplesZ - How many samples along Z.\n * @param sizeX - The world-space size along X.\n * @param sizeZ - The world-space size along Z.\n * @param heights - `samplesX * samplesZ` row-major height samples.\n * @returns The shape handle.\n *\n * @internal\n */\nexport function createHeightfieldShape(\n world: LitePhysicsWorld,\n samplesX: number,\n samplesZ: number,\n sizeX: number,\n sizeZ: number,\n heights: Float32Array,\n): LitePhysicsShape {\n return createHeightFieldShape(world, {\n numHeightFieldSamplesX: samplesX,\n numHeightFieldSamplesZ: samplesZ,\n heightFieldSizeX: sizeX,\n heightFieldSizeZ: sizeZ,\n heightFieldData: heights,\n });\n}\n\n/**\n * Creates the empty compound shape several colliders on one entity are added to.\n *\n * @param world - The world handle.\n * @returns The container shape.\n *\n * @internal\n */\nexport function createContainer(world: LitePhysicsWorld): LitePhysicsShape {\n return createPhysicsShape(world, { type: ShapeGeometry.container });\n}\n\n/**\n * Adds a child shape to a container at a local offset.\n *\n * @param world - The world handle.\n * @param container - The container shape.\n * @param child - The child shape.\n * @param translation - The child's offset inside the container.\n * @param rotation - The child's rotation inside the container.\n *\n * @internal\n */\nexport function addContainerChild(\n world: LitePhysicsWorld,\n container: LitePhysicsShape,\n child: LitePhysicsShape,\n translation: Vec3Like,\n rotation: QuatLike,\n): void {\n addPhysicsShapeChild(\n world,\n container,\n child,\n { x: translation.x, y: translation.y, z: translation.z },\n { x: rotation.x, y: rotation.y, z: rotation.z, w: rotation.w },\n );\n}\n\n/**\n * Releases a shape no body references any more.\n *\n * @param world - The world handle.\n * @param shape - The shape.\n *\n * @internal\n */\nexport function destroyShape(world: LitePhysicsWorld, shape: LitePhysicsShape): void {\n releasePhysicsShape(world, shape);\n}\n\n/**\n * Marks a shape as a trigger volume: it reports overlaps and resolves no contacts.\n *\n * @param world - The world handle.\n * @param shape - The shape.\n * @param isTrigger - Whether the shape is a trigger.\n *\n * @internal\n */\nexport function setShapeTrigger(world: LitePhysicsWorld, shape: LitePhysicsShape, isTrigger: boolean): void {\n setPhysicsShapeIsTrigger(world, shape, isTrigger);\n}\n\n/**\n * Sets a shape's surface material.\n *\n * @param world - The world handle.\n * @param shape - The shape.\n * @param friction - The dynamic friction coefficient.\n * @param restitution - The bounciness, `0` to `1`.\n * @param staticFriction - The static friction coefficient.\n *\n * @internal\n */\nexport function setShapeMaterial(\n world: LitePhysicsWorld,\n shape: LitePhysicsShape,\n friction: number,\n restitution: number,\n staticFriction: number,\n): void {\n setPhysicsShapeMaterial(world, shape, friction, restitution, staticFriction);\n}\n\n/**\n * Sets a shape's collision filter masks (`09-physics.md` §3).\n *\n * @param world - The world handle.\n * @param shape - The shape.\n * @param membership - The 32-bit membership mask, `1 << entity.layer`.\n * @param collideWith - The 32-bit mask of layers the shape collides with.\n *\n * @internal\n */\nexport function setShapeFilter(\n world: LitePhysicsWorld,\n shape: LitePhysicsShape,\n membership: number,\n collideWith: number,\n): void {\n setPhysicsShapeFilterMembershipMask(world, shape, membership);\n setPhysicsShapeFilterCollideMask(world, shape, collideWith);\n}\n\n/**\n * Reads a node's local pose into out parameters.\n *\n * @param node - The node.\n * @param position - The vector to write the position into.\n * @param rotation - The quaternion to write the rotation into.\n *\n * @internal\n */\nexport function readNodePose(node: LiteSceneNode, position: MutableVec3, rotation: MutableQuat): void {\n const local = node.position;\n const quaternion = node.rotationQuaternion;\n position.set(local.x, local.y, local.z);\n rotation.set(quaternion.x, quaternion.y, quaternion.z, quaternion.w);\n}\n\n/**\n * Writes a node's local pose.\n *\n * @param node - The node.\n * @param position - The position to write.\n * @param rotation - The rotation to write.\n *\n * @internal\n */\nexport function writeNodePose(node: LiteSceneNode, position: Vec3Like, rotation: QuatLike): void {\n node.position.set(position.x, position.y, position.z);\n node.rotationQuaternion.set(rotation.x, rotation.y, rotation.z, rotation.w);\n}\n\n/**\n * What the trigger drain reports for one overlap.\n *\n * @internal\n */\nexport interface TriggerRecord {\n /** `true` for `ENTERED`, `false` for `EXITED`. */\n readonly entered: boolean;\n /** The first node, or `null` when Lite no longer tracks the body. */\n readonly nodeA: LiteSceneNode | null;\n /** The second node, or `null`. */\n readonly nodeB: LiteSceneNode | null;\n}\n\n/**\n * Registers the trigger drain (`index.d.ts` 7787). It runs inside `stepScene`, from Lite's\n * post-step hook, so the callback must only buffer.\n *\n * @param world - The world handle.\n * @param sink - Called once per trigger event.\n * @returns A disposer that removes the drain.\n *\n * @internal\n */\nexport function onTriggerEvents(world: LitePhysicsWorld, sink: (record: TriggerRecord) => void): () => void {\n return onPhysicsTriggerBodies(world, (info): void => {\n sink({\n entered: info.type === \"ENTERED\",\n nodeA: info.bodyA === null ? null : info.bodyA.node,\n nodeB: info.bodyB === null ? null : info.bodyB.node,\n });\n });\n}\n\n/**\n * What the collision drain reports for one contact.\n *\n * @internal\n */\nexport interface ContactRecord {\n /** `0` for `STARTED`, `1` for `CONTINUED`, `2` for `FINISHED`. */\n readonly phase: number;\n /** The world-space contact point. */\n readonly point: Vec3Like;\n /** The world-space contact normal. */\n readonly normal: Vec3Like;\n /** The magnitude of the resolving impulse; `0` for a contact that just ended. */\n readonly impulse: number;\n /** The node of the first body (Lite's `collider`). */\n readonly nodeA: LiteSceneNode;\n /** The node of the second body (Lite's `collidedAgainst`). */\n readonly nodeB: LiteSceneNode;\n}\n\n/** `ContactRecord.phase` for a contact that just started. */\nexport const CONTACT_STARTED: number = 0;\n\n/** `ContactRecord.phase` for a contact that persists. */\nexport const CONTACT_CONTINUED: number = 1;\n\n/** `ContactRecord.phase` for a contact that just ended. */\nexport const CONTACT_FINISHED: number = 2;\n\n/**\n * Registers the collision drain (`onPhysicsCollision`, `index.d.ts` 9315). Each\n * `PhysicsCollisionInfo` (10030) names both bodies as `collider` and `collidedAgainst`, and they are\n * resolved to nodes the same way the trigger drain resolves `bodyA`/`bodyB`. Lite skips an event\n * whose bodies it no longer tracks (`lib/physics/havok-collision.js:47-52`), so both are present.\n *\n * @remarks\n * `colliderIndex` and `collidedAgainstIndex` are thin-instance indices. ignifx never creates\n * thin-instance bodies, so they are always `0` and are ignored.\n *\n * @param world - The world handle.\n * @param sink - Called once per collision event.\n *\n * @internal\n */\nexport function onCollisionEvents(world: LitePhysicsWorld, sink: (record: ContactRecord) => void): void {\n onPhysicsCollision(world, (info): void => {\n sink({\n phase:\n info.type === \"STARTED\" ? CONTACT_STARTED : info.type === \"CONTINUED\" ? CONTACT_CONTINUED : CONTACT_FINISHED,\n point: info.point,\n normal: info.normal,\n impulse: info.impulse,\n nodeA: info.collider.node,\n nodeB: info.collidedAgainst.node,\n });\n });\n}\n\n/**\n * Registers a callback that runs after every Havok step (`index.d.ts` 7753). Lite's own drains use\n * the same hook, and the hooks run in registration order, so the extension's buffer flush is\n * registered last and sees everything the drains produced.\n *\n * @param world - The world handle.\n * @param callback - What to run after each step.\n *\n * @internal\n */\nexport function afterStep(world: LitePhysicsWorld, callback: () => void): void {\n onPhysicsAfterStep(world, (): void => {\n callback();\n });\n}\n","import type { QuatLike, Vec3Like } from \"@ignifx/core\";\n\n/**\n * Line-segment builders for collider outlines (`PhysicsService.colliderOutlines`): what an editor\n * draws as a collider gizmo (ADR-0028, amendment of 2026-10-20). Every builder appends segments to\n * a flat `number[]`, six numbers per segment (`x, y, z` of each end), in the body's own space with\n * the entity's scale applied; {@link placeOutline} moves them into world space.\n *\n * Everything here is `@internal`.\n */\n\n/** How many straight segments approximate a full circle. */\nexport const OUTLINE_CIRCLE_SEGMENTS = 32;\n\n/** A full turn in radians. */\nconst TURN = Math.PI * 2;\n\n/** A unit axis, as three numbers. */\ntype Axis = readonly [number, number, number];\n\n/** The world axes. */\nconst X_AXIS: Axis = [1, 0, 0];\nconst Y_AXIS: Axis = [0, 1, 0];\nconst Z_AXIS: Axis = [0, 0, 1];\n\n/**\n * The axis a capsule stands along, and the two axes across it.\n *\n * @param direction - `\"x\"`, `\"y\"`, or `\"z\"`.\n * @returns `[along, across, across]`.\n *\n * @internal\n */\nexport function capsuleAxes(direction: \"x\" | \"y\" | \"z\"): readonly [Axis, Axis, Axis] {\n if (direction === \"x\") {\n return [X_AXIS, Y_AXIS, Z_AXIS];\n }\n return direction === \"y\" ? [Y_AXIS, X_AXIS, Z_AXIS] : [Z_AXIS, X_AXIS, Y_AXIS];\n}\n\n/**\n * Appends one segment.\n *\n * @param out - The segment list.\n * @param a - The first end.\n * @param b - The second end.\n *\n * @internal\n */\nexport function pushSegment(out: number[], a: Vec3Like, b: Vec3Like): void {\n out.push(a.x, a.y, a.z, b.x, b.y, b.z);\n}\n\n/**\n * Appends the twelve edges of an axis-aligned box.\n *\n * @param out - The segment list.\n * @param center - The box centre.\n * @param half - Half its size along each axis.\n *\n * @internal\n */\nexport function pushBox(out: number[], center: Vec3Like, half: Vec3Like): void {\n const x0 = center.x - half.x;\n const x1 = center.x + half.x;\n const y0 = center.y - half.y;\n const y1 = center.y + half.y;\n const z0 = center.z - half.z;\n const z1 = center.z + half.z;\n for (const [y, z] of [\n [y0, z0],\n [y0, z1],\n [y1, z0],\n [y1, z1],\n ] as const) {\n out.push(x0, y, z, x1, y, z);\n }\n for (const [x, z] of [\n [x0, z0],\n [x0, z1],\n [x1, z0],\n [x1, z1],\n ] as const) {\n out.push(x, y0, z, x, y1, z);\n }\n for (const [x, y] of [\n [x0, y0],\n [x0, y1],\n [x1, y0],\n [x1, y1],\n ] as const) {\n out.push(x, y, z0, x, y, z1);\n }\n}\n\n/**\n * Appends an arc of a circle in the plane of two axes.\n *\n * @param out - The segment list.\n * @param center - The circle's centre.\n * @param u - The axis angle `0` points along.\n * @param v - The axis angle `π / 2` points along.\n * @param radius - The radius.\n * @param from - The start angle, in radians.\n * @param to - The end angle, in radians.\n *\n * @internal\n */\nexport function pushArc(\n out: number[],\n center: Vec3Like,\n u: Axis,\n v: Axis,\n radius: number,\n from: number = 0,\n to: number = TURN,\n): void {\n const steps = Math.max(1, Math.round((OUTLINE_CIRCLE_SEGMENTS * Math.abs(to - from)) / TURN));\n let previousCos = Math.cos(from);\n let previousSin = Math.sin(from);\n for (let step = 1; step <= steps; step += 1) {\n const angle = from + ((to - from) * step) / steps;\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n out.push(\n center.x + radius * (u[0] * previousCos + v[0] * previousSin),\n center.y + radius * (u[1] * previousCos + v[1] * previousSin),\n center.z + radius * (u[2] * previousCos + v[2] * previousSin),\n center.x + radius * (u[0] * cos + v[0] * sin),\n center.y + radius * (u[1] * cos + v[1] * sin),\n center.z + radius * (u[2] * cos + v[2] * sin),\n );\n previousCos = cos;\n previousSin = sin;\n }\n}\n\n/**\n * Appends a sphere's three great circles.\n *\n * @param out - The segment list.\n * @param center - The centre.\n * @param radius - The radius.\n *\n * @internal\n */\nexport function pushSphere(out: number[], center: Vec3Like, radius: number): void {\n pushArc(out, center, X_AXIS, Y_AXIS, radius);\n pushArc(out, center, Y_AXIS, Z_AXIS, radius);\n pushArc(out, center, Z_AXIS, X_AXIS, radius);\n}\n\n/**\n * Appends a capsule: a ring at each end of its segment, four lines joining them, and the two\n * half-circle profiles of each cap.\n *\n * @param out - The segment list.\n * @param center - The capsule's centre.\n * @param direction - The axis it stands along.\n * @param radius - Its radius.\n * @param halfSegment - Half the length of the segment between the cap centres.\n *\n * @internal\n */\nexport function pushCapsule(\n out: number[],\n center: Vec3Like,\n direction: \"x\" | \"y\" | \"z\",\n radius: number,\n halfSegment: number,\n): void {\n const [along, u, v] = capsuleAxes(direction);\n const top = offset(center, along, halfSegment);\n const bottom = offset(center, along, -halfSegment);\n pushTube(out, top, bottom, u, v, radius);\n for (const across of [u, v]) {\n pushArc(out, top, across, along, radius, 0, Math.PI);\n pushArc(out, bottom, across, along, radius, Math.PI, TURN);\n }\n}\n\n/**\n * Appends a cylinder standing along the Y axis: a ring at each end and four lines joining them.\n *\n * @param out - The segment list.\n * @param center - The cylinder's centre.\n * @param radius - Its radius.\n * @param halfHeight - Half its height.\n *\n * @internal\n */\nexport function pushCylinder(out: number[], center: Vec3Like, radius: number, halfHeight: number): void {\n pushTube(out, offset(center, Y_AXIS, halfHeight), offset(center, Y_AXIS, -halfHeight), X_AXIS, Z_AXIS, radius);\n}\n\n/**\n * Moves an outline from body space into world space, in place, and packs it.\n *\n * @param local - The segments in body space, scale applied.\n * @param position - The body's world position.\n * @param rotation - The body's world rotation.\n * @returns The segments in world space.\n *\n * @internal\n */\nexport function placeOutline(local: readonly number[], position: Vec3Like, rotation: QuatLike): Float32Array {\n const out = new Float32Array(local.length);\n const { x: qx, y: qy, z: qz, w: qw } = rotation;\n for (let index = 0; index + 2 < local.length; index += 3) {\n const x = local[index] ?? 0;\n const y = local[index + 1] ?? 0;\n const z = local[index + 2] ?? 0;\n // v' = v + 2w(q × v) + 2(q × (q × v)), the usual quaternion rotation without a matrix.\n const tx = 2 * (qy * z - qz * y);\n const ty = 2 * (qz * x - qx * z);\n const tz = 2 * (qx * y - qy * x);\n out[index] = x + qw * tx + (qy * tz - qz * ty) + position.x;\n out[index + 1] = y + qw * ty + (qz * tx - qx * tz) + position.y;\n out[index + 2] = z + qw * tz + (qx * ty - qy * tx) + position.z;\n }\n return out;\n}\n\n/**\n * Appends two rings and the four lines joining them.\n *\n * @param out - The segment list.\n * @param top - The centre of one ring.\n * @param bottom - The centre of the other.\n * @param u - One axis across the tube.\n * @param v - The other.\n * @param radius - The radius.\n */\nfunction pushTube(out: number[], top: Vec3Like, bottom: Vec3Like, u: Axis, v: Axis, radius: number): void {\n pushArc(out, top, u, v, radius);\n pushArc(out, bottom, u, v, radius);\n for (const [axis, sign] of [\n [u, 1],\n [u, -1],\n [v, 1],\n [v, -1],\n ] as const) {\n pushSegment(out, offset(top, axis, sign * radius), offset(bottom, axis, sign * radius));\n }\n}\n\n/**\n * A point moved along an axis.\n *\n * @param point - The start.\n * @param axis - The unit axis.\n * @param distance - How far.\n * @returns A fresh point.\n */\nfunction offset(point: Vec3Like, axis: Axis, distance: number): Vec3Like {\n return { x: point.x + axis[0] * distance, y: point.y + axis[1] * distance, z: point.z + axis[2] * distance };\n}\n","import {\n createDefaults,\n defineSchema,\n MeshAsset,\n Quat,\n Vec3,\n array,\n bool,\n asset,\n enumOf,\n f32,\n u32,\n vec3,\n} from \"@ignifx/core\";\nimport { PhysicsErrorCode, physicsError } from \"../errors.js\";\nimport { createHeightfieldShape, createMeshShape, createShape, ShapeGeometry } from \"../lite/havok.js\";\nimport { pushBox, pushCapsule, pushCylinder, pushSphere } from \"../runtime/outline.js\";\nimport { Collider, colliderFields } from \"./collider.js\";\nimport type { LitePhysicsShape, LitePhysicsWorld } from \"../lite/havok.js\";\nimport type { AssetHandle, LiteSceneNode, MutableVec3, Schema, Vec3Like } from \"@ignifx/core\";\n\n/**\n * The concrete colliders (`docs/architecture/09-physics.md` §2.2). Each one maps to exactly one\n * Havok shape type (`index.d.ts` 8606) and bakes its `center` into the shape's own parameters, so a\n * single collider needs no compound wrapper.\n *\n * Sizes are authored in local units and multiplied by the entity's lossy scale when the shape is\n * built; Havok cannot rescale a built shape, so a later scale change needs `collider.rebuild()`.\n */\n\n/**\n * The axis a capsule stands along.\n *\n * @public\n */\nexport const CAPSULE_DIRECTIONS = [\"x\", \"y\", \"z\"] as const;\n\n/**\n * The union of {@link CAPSULE_DIRECTIONS}.\n *\n * @public\n */\nexport type CapsuleDirection = (typeof CAPSULE_DIRECTIONS)[number];\n\n/**\n * A box collider, sized in local units (`09-physics.md` §2.2).\n *\n * @example\n * ```ts\n * const floor = world.createEntity(\"Floor\");\n * floor.addComponent(BoxCollider, { size: { x: 20, y: 1, z: 20 } });\n * ```\n *\n * @public\n */\nexport class BoxCollider extends Collider {\n /** The namespaced registration id. */\n static typeId = \"ignifx/BoxCollider\";\n\n /** The serialized field declarations (ADR-0004). */\n static schema: Schema = boxSchema();\n\n declare size: Vec3Like;\n\n /** Applies this collider's defaults on top of the shared ones. */\n constructor() {\n super();\n Object.assign(this, createDefaults(BoxCollider.schema));\n }\n\n /**\n * Builds this collider's Havok shape.\n *\n * @param world - The Havok world the shape belongs to.\n * @param scale - The entity's lossy scale, applied to the authored dimensions.\n * @returns The shape handle.\n */\n createShape(world: LitePhysicsWorld, scale: Vec3Like): LitePhysicsShape {\n return createShape(world, ShapeGeometry.box, {\n extents: { x: this.size.x * abs(scale.x), y: this.size.y * abs(scale.y), z: this.size.z * abs(scale.z) },\n center: scaled(this.center, scale),\n rotation: new Quat(),\n });\n }\n\n /**\n * Writes half the size of this collider's local bounding box, scale applied.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The vector to write.\n */\n halfExtentsToRef(scale: Vec3Like, out: MutableVec3): void {\n out.set((this.size.x * abs(scale.x)) / 2, (this.size.y * abs(scale.y)) / 2, (this.size.z * abs(scale.z)) / 2);\n }\n\n /**\n * Appends the box's twelve edges.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The segment list.\n *\n * @internal\n */\n override outlineToRef(scale: Vec3Like, out: number[]): void {\n const half = new Vec3();\n this.halfExtentsToRef(scale, half);\n pushBox(out, scaled(this.center, scale), half);\n }\n}\n\n/**\n * A sphere collider. Non-uniform scale is not representable as a sphere, so the largest scale axis\n * wins — the same rule Unity applies.\n *\n * @public\n */\nexport class SphereCollider extends Collider {\n /** The namespaced registration id. */\n static typeId = \"ignifx/SphereCollider\";\n\n /** The serialized field declarations. */\n static schema: Schema = sphereSchema();\n\n declare radius: number;\n\n /** Applies this collider's defaults on top of the shared ones. */\n constructor() {\n super();\n Object.assign(this, createDefaults(SphereCollider.schema));\n }\n\n /**\n * Builds this collider's Havok shape.\n *\n * @param world - The Havok world the shape belongs to.\n * @param scale - The entity's lossy scale, applied to the authored dimensions.\n * @returns The shape handle.\n */\n createShape(world: LitePhysicsWorld, scale: Vec3Like): LitePhysicsShape {\n return createShape(world, ShapeGeometry.sphere, {\n radius: this.radius * maxAxis(scale),\n center: scaled(this.center, scale),\n });\n }\n\n /**\n * Writes half the size of this collider's local bounding box, scale applied.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The vector to write.\n */\n halfExtentsToRef(scale: Vec3Like, out: MutableVec3): void {\n const radius = this.radius * maxAxis(scale);\n out.set(radius, radius, radius);\n }\n\n /**\n * Appends the sphere's three great circles.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The segment list.\n *\n * @internal\n */\n override outlineToRef(scale: Vec3Like, out: number[]): void {\n pushSphere(out, scaled(this.center, scale), this.radius * maxAxis(scale));\n }\n}\n\n/**\n * A capsule collider: a cylinder with hemispherical caps, standing along one axis.\n *\n * @remarks\n * `height` is the **total** tip-to-tip height, so a capsule shorter than `2 * radius` degenerates to\n * a sphere of that radius rather than inverting.\n *\n * @public\n */\nexport class CapsuleCollider extends Collider {\n /** The namespaced registration id. */\n static typeId = \"ignifx/CapsuleCollider\";\n\n /** The serialized field declarations. */\n static schema: Schema = capsuleSchema();\n\n declare radius: number;\n\n declare height: number;\n\n declare direction: CapsuleDirection;\n\n /** Applies this collider's defaults on top of the shared ones. */\n constructor() {\n super();\n Object.assign(this, createDefaults(CapsuleCollider.schema));\n }\n\n /**\n * Builds this collider's Havok shape.\n *\n * @param world - The Havok world the shape belongs to.\n * @param scale - The entity's lossy scale, applied to the authored dimensions.\n * @returns The shape handle.\n */\n createShape(world: LitePhysicsWorld, scale: Vec3Like): LitePhysicsShape {\n const radius = this.radius * radialScale(this.direction, scale);\n const half = Math.max(0, (this.height * axisScale(this.direction, scale)) / 2 - radius);\n const center = scaled(this.center, scale);\n return createShape(world, ShapeGeometry.capsule, {\n radius,\n pointA: offsetAlong(center, this.direction, -half),\n pointB: offsetAlong(center, this.direction, half),\n });\n }\n\n /**\n * Writes half the size of this collider's local bounding box, scale applied.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The vector to write.\n */\n halfExtentsToRef(scale: Vec3Like, out: MutableVec3): void {\n const radius = this.radius * radialScale(this.direction, scale);\n const half = Math.max(radius, (this.height * axisScale(this.direction, scale)) / 2);\n out.set(\n this.direction === \"x\" ? half : radius,\n this.direction === \"y\" ? half : radius,\n this.direction === \"z\" ? half : radius,\n );\n }\n\n /**\n * Appends the capsule's end rings, its sides, and its caps.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The segment list.\n *\n * @internal\n */\n override outlineToRef(scale: Vec3Like, out: number[]): void {\n const radius = this.radius * radialScale(this.direction, scale);\n const half = Math.max(0, (this.height * axisScale(this.direction, scale)) / 2 - radius);\n pushCapsule(out, scaled(this.center, scale), this.direction, radius, half);\n }\n}\n\n/**\n * A cylinder collider standing along Y.\n *\n * @public\n */\nexport class CylinderCollider extends Collider {\n /** The namespaced registration id. */\n static typeId = \"ignifx/CylinderCollider\";\n\n /** The serialized field declarations. */\n static schema: Schema = cylinderSchema();\n\n declare radius: number;\n\n declare height: number;\n\n /** Applies this collider's defaults on top of the shared ones. */\n constructor() {\n super();\n Object.assign(this, createDefaults(CylinderCollider.schema));\n }\n\n /**\n * Builds this collider's Havok shape.\n *\n * @param world - The Havok world the shape belongs to.\n * @param scale - The entity's lossy scale, applied to the authored dimensions.\n * @returns The shape handle.\n */\n createShape(world: LitePhysicsWorld, scale: Vec3Like): LitePhysicsShape {\n const radius = this.radius * Math.max(abs(scale.x), abs(scale.z));\n const half = (this.height * abs(scale.y)) / 2;\n const center = scaled(this.center, scale);\n return createShape(world, ShapeGeometry.cylinder, {\n radius,\n pointA: { x: center.x, y: center.y - half, z: center.z },\n pointB: { x: center.x, y: center.y + half, z: center.z },\n });\n }\n\n /**\n * Writes half the size of this collider's local bounding box, scale applied.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The vector to write.\n */\n halfExtentsToRef(scale: Vec3Like, out: MutableVec3): void {\n const radius = this.radius * Math.max(abs(scale.x), abs(scale.z));\n out.set(radius, (this.height * abs(scale.y)) / 2, radius);\n }\n\n /**\n * Appends the cylinder's end rings and its sides.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The segment list.\n *\n * @internal\n */\n override outlineToRef(scale: Vec3Like, out: number[]): void {\n const radius = this.radius * Math.max(abs(scale.x), abs(scale.z));\n pushCylinder(out, scaled(this.center, scale), radius, (this.height * abs(scale.y)) / 2);\n }\n}\n\n/**\n * A collider built from real geometry: either an explicit `MeshAsset` or, when `mesh` is\n * `null`, whatever the entity's `MeshRenderer`/`Model` put under its node.\n *\n * @remarks\n * **Headless is not supported.** `@babylonjs/lite@1.27.0` documents mesh and convex-hull colliders\n * as unavailable on the null engine (`index.d.ts` 2781), and a headless `MeshAsset` uploads no\n * geometry at all (`MeshAsset.lite.mesh` is `null`), so building one reports `IGX-0906` instead of\n * producing an empty shape. Use a primitive collider in headless tests.\n *\n * @public\n */\nexport class MeshCollider extends Collider {\n /** The namespaced registration id. */\n static typeId = \"ignifx/MeshCollider\";\n\n /** The serialized field declarations. */\n static schema: Schema = meshSchema();\n\n declare mesh: AssetHandle<MeshAsset> | null;\n\n declare convex: boolean;\n\n declare includeChildren: boolean;\n\n /** Applies this collider's defaults on top of the shared ones. */\n constructor() {\n super();\n Object.assign(this, createDefaults(MeshCollider.schema));\n }\n\n /**\n * Builds this collider's Havok shape from real geometry.\n *\n * @param world - The Havok world the shape belongs to.\n * @param _scale - Unused: a mesh shape carries the geometry's own world scale.\n * @param node - The entity's node, whose meshes supply the vertices when `mesh` is `null`.\n * @returns The shape handle.\n */\n createShape(world: LitePhysicsWorld, _scale: Vec3Like, node: LiteSceneNode): LitePhysicsShape {\n const source = this.#sourceNode(node);\n return createMeshShape(world, source, this.convex, this.includeChildren);\n }\n\n /**\n * Writes half the size of this collider's local bounding box — zero, because measuring a triangle\n * soup means reading its vertices, which is GPU territory.\n *\n * @param _scale - Unused.\n * @param out - The vector to write.\n */\n halfExtentsToRef(_scale: Vec3Like, out: MutableVec3): void {\n // The bounds index cannot measure a triangle soup without reading its vertices, which is GPU\n // territory. A mesh collider therefore contributes a point to `overlap`/`shapeCast` resolution\n // and is documented as such.\n out.set(0, 0, 0);\n }\n\n /**\n * The node whose meshes supply the geometry.\n *\n * @param entityNode - The entity's own node.\n * @returns The node to hand Lite.\n * @throws IgnifxError with code `IGX-0906` when there is no geometry to read.\n */\n #sourceNode(entityNode: LiteSceneNode): LiteSceneNode {\n const explicit = this.mesh?.value.lite.mesh ?? null;\n if (explicit !== null) {\n return explicit;\n }\n if (this.mesh !== null) {\n throw physicsError(\n PhysicsErrorCode.colliderGeometryUnavailable,\n \"The MeshCollider's mesh asset has no geometry.\",\n {\n context: { entity: this.entity.name },\n hint: \"Mesh colliders need a GPU app; a headless MeshAsset uploads nothing to build a shape from.\",\n },\n );\n }\n if (entityNode.children.length === 0) {\n throw physicsError(PhysicsErrorCode.colliderGeometryUnavailable, \"The MeshCollider has no mesh to read.\", {\n context: { entity: this.entity.name },\n hint: \"Add a MeshRenderer or Model to the entity, or set the collider's mesh field.\",\n });\n }\n return entityNode;\n }\n}\n\n/**\n * A heightfield collider: a regular grid of height samples in the XZ plane, which is what a terrain\n * uses (`index.d.ts` 2601, 6266).\n *\n * @remarks\n * Only Lite's **explicit** heightfield path is used, because the `groundMesh` path reads\n * `mesh._cpuPositions` and `worldMatrix` and therefore needs a GPU. `heights` is row-major with\n * `samplesX * samplesZ` entries.\n *\n * @public\n */\nexport class HeightfieldCollider extends Collider {\n /** The namespaced registration id. */\n static typeId = \"ignifx/HeightfieldCollider\";\n\n /** The serialized field declarations. */\n static schema: Schema = heightfieldSchema();\n\n declare heights: number[];\n\n declare samplesX: number;\n\n declare samplesZ: number;\n\n declare size: Vec3Like;\n\n /** Applies this collider's defaults on top of the shared ones. */\n constructor() {\n super();\n Object.assign(this, createDefaults(HeightfieldCollider.schema));\n }\n\n /**\n * Builds this collider's Havok shape.\n *\n * @param world - The Havok world the shape belongs to.\n * @param scale - The entity's lossy scale, applied to the authored dimensions.\n * @returns The shape handle.\n */\n createShape(world: LitePhysicsWorld, scale: Vec3Like): LitePhysicsShape {\n const expected = this.samplesX * this.samplesZ;\n if (this.samplesX < 2 || this.samplesZ < 2 || this.heights.length !== expected) {\n throw physicsError(\n PhysicsErrorCode.colliderGeometryUnavailable,\n \"The HeightfieldCollider's sample grid is invalid.\",\n {\n context: { entity: this.entity.name, expected, actual: this.heights.length },\n hint: \"heights must hold samplesX * samplesZ values, and both counts must be at least 2.\",\n },\n );\n }\n const data = new Float32Array(expected);\n for (let index = 0; index < expected; index += 1) {\n data[index] = (this.heights[index] ?? 0) * abs(scale.y);\n }\n return createHeightfieldShape(\n world,\n this.samplesX,\n this.samplesZ,\n this.size.x * abs(scale.x),\n this.size.z * abs(scale.z),\n data,\n );\n }\n\n /**\n * Writes half the size of this collider's local bounding box, scale applied.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The vector to write.\n */\n halfExtentsToRef(scale: Vec3Like, out: MutableVec3): void {\n out.set((this.size.x * abs(scale.x)) / 2, (this.size.y * abs(scale.y)) / 2, (this.size.z * abs(scale.z)) / 2);\n }\n\n /**\n * Appends the bounding box of the samples: the field's extent across, centred on the entity as\n * Havok places it, and from its lowest to its highest sample in height. `center` does not apply\n * to a heightfield.\n *\n * @param scale - The entity's lossy scale.\n * @param out - The segment list.\n *\n * @internal\n */\n override outlineToRef(scale: Vec3Like, out: number[]): void {\n let low = Number.POSITIVE_INFINITY;\n let high = Number.NEGATIVE_INFINITY;\n for (const height of this.heights) {\n low = Math.min(low, height);\n high = Math.max(high, height);\n }\n if (low > high) {\n return;\n }\n const y = abs(scale.y);\n pushBox(\n out,\n { x: 0, y: ((low + high) / 2) * y, z: 0 },\n { x: (this.size.x * abs(scale.x)) / 2, y: ((high - low) / 2) * y, z: (this.size.z * abs(scale.z)) / 2 },\n );\n }\n}\n\n/**\n * Builds the `BoxCollider` schema.\n *\n * @returns The schema.\n */\nfunction boxSchema(): Schema {\n return defineSchema({ ...colliderFields(), size: vec3({ x: 1, y: 1, z: 1 }) });\n}\n\n/**\n * Builds the `SphereCollider` schema.\n *\n * @returns The schema.\n */\nfunction sphereSchema(): Schema {\n return defineSchema({ ...colliderFields(), radius: f32(0.5, { min: 0 }) });\n}\n\n/**\n * Builds the `CapsuleCollider` schema.\n *\n * @returns The schema.\n */\nfunction capsuleSchema(): Schema {\n return defineSchema({\n ...colliderFields(),\n radius: f32(0.5, { min: 0 }),\n height: f32(2, { min: 0 }),\n direction: enumOf(CAPSULE_DIRECTIONS, \"y\"),\n });\n}\n\n/**\n * Builds the `CylinderCollider` schema.\n *\n * @returns The schema.\n */\nfunction cylinderSchema(): Schema {\n return defineSchema({ ...colliderFields(), radius: f32(0.5, { min: 0 }), height: f32(2, { min: 0 }) });\n}\n\n/**\n * Builds the `MeshCollider` schema.\n *\n * @returns The schema.\n */\nfunction meshSchema(): Schema {\n return defineSchema({\n ...colliderFields(),\n mesh: asset(MeshAsset),\n convex: bool(false),\n includeChildren: bool(true),\n });\n}\n\n/**\n * Builds the `HeightfieldCollider` schema.\n *\n * @returns The schema.\n */\nfunction heightfieldSchema(): Schema {\n return defineSchema({\n ...colliderFields(),\n heights: array(f32()),\n samplesX: u32(2, { min: 2 }),\n samplesZ: u32(2, { min: 2 }),\n size: vec3({ x: 1, y: 1, z: 1 }),\n });\n}\n\n/**\n * The absolute value of a scale component; a negative scale mirrors geometry, which Havok cannot\n * represent, so the shape uses the magnitude (`09-physics.md` §2.2).\n *\n * @param value - The scale component.\n * @returns Its magnitude.\n */\nfunction abs(value: number): number {\n return Math.abs(value);\n}\n\n/**\n * The largest scale magnitude, used by shapes that have one radius.\n *\n * @param scale - The lossy scale.\n * @returns The largest magnitude.\n */\nfunction maxAxis(scale: Vec3Like): number {\n return Math.max(abs(scale.x), abs(scale.y), abs(scale.z));\n}\n\n/**\n * Scales a local offset into shape space.\n *\n * @param center - The authored offset.\n * @param scale - The lossy scale.\n * @returns A fresh vector; shape construction is not a per-frame path.\n */\nfunction scaled(center: Vec3Like, scale: Vec3Like): Vec3 {\n return new Vec3(center.x * scale.x, center.y * scale.y, center.z * scale.z);\n}\n\n/**\n * The scale along a capsule's own axis.\n *\n * @param direction - The capsule axis.\n * @param scale - The lossy scale.\n * @returns The magnitude along that axis.\n */\nfunction axisScale(direction: CapsuleDirection, scale: Vec3Like): number {\n if (direction === \"x\") {\n return abs(scale.x);\n }\n return direction === \"y\" ? abs(scale.y) : abs(scale.z);\n}\n\n/**\n * The scale across a capsule's axis, which drives its radius.\n *\n * @param direction - The capsule axis.\n * @param scale - The lossy scale.\n * @returns The larger of the two perpendicular magnitudes.\n */\nfunction radialScale(direction: CapsuleDirection, scale: Vec3Like): number {\n if (direction === \"x\") {\n return Math.max(abs(scale.y), abs(scale.z));\n }\n return direction === \"y\" ? Math.max(abs(scale.x), abs(scale.z)) : Math.max(abs(scale.x), abs(scale.y));\n}\n\n/**\n * Offsets a point along one axis.\n *\n * @param center - The starting point.\n * @param direction - Which axis to move along.\n * @param distance - How far to move.\n * @returns A fresh vector.\n */\nfunction offsetAlong(center: Vec3Like, direction: CapsuleDirection, distance: number): Vec3 {\n return new Vec3(\n center.x + (direction === \"x\" ? distance : 0),\n center.y + (direction === \"y\" ? distance : 0),\n center.z + (direction === \"z\" ? distance : 0),\n );\n}\n","import HavokPhysics from \"@babylonjs/havok\";\nimport { PhysicsErrorCode, physicsError } from \"../errors.js\";\n\n/**\n * Loading the Havok WebAssembly module (`docs/architecture/09-physics.md` §7, ADR-0003 Validation).\n *\n * `@babylonjs/havok@1.3.14`'s ESM build hard-codes `ENVIRONMENT_IS_WEB = true` and fetches its\n * `.wasm` with `fetch(scriptDirectory + path)`, so `locateFile` cannot help under Node — Node's\n * `fetch` refuses `file:` URLs. Emscripten's `wasmBinary` option is the supported escape and is what\n * this module always uses: the bytes are obtained first (from the caller, from `fetch`, or from\n * `node:fs`) and handed to the factory. `app.isHeadless` therefore only changes *where the bytes\n * come from*, exactly as the Phase 4 brief requires.\n *\n * The `@babylonjs/havok` import lives here because this file is under `src/lite/`, the only place\n * `ignifx/no-lite-outside-adapter` and dependency-cruiser allow a native backend.\n *\n * Everything here is `@internal`.\n */\n\n/**\n * The unhashed file name the Vite plugin copies into the public asset path, and therefore the\n * address `app.assets.resolveUrl` answers for.\n *\n * @remarks\n * Extension public assets are copied by **base name** (`packages/vite-plugin/src/plugin.ts`,\n * `generateBundle`), into the same directory the default asset root points at, so the address is the\n * bare file name and not a package-scoped path.\n *\n * @internal\n */\nexport const HAVOK_WASM_FILE_NAME = \"HavokPhysics.wasm\";\n\n/** Where the Havok bytes come from. */\nexport interface HavokSource {\n /** An already-instantiated module, which wins over everything else. */\n readonly module?: unknown;\n /** The `.wasm` bytes, for a caller that read them itself. */\n readonly wasmBinary?: ArrayBuffer;\n /** The URL or file path to read the bytes from. */\n readonly url?: string;\n}\n\n/**\n * Instantiates Havok.\n *\n * @param source - An instantiated module, explicit bytes, or a URL to read them from.\n * @returns The module, typed as `unknown` because Lite types its own parameter as `any`.\n * @throws IgnifxError with code `IGX-0903` when the bytes cannot be obtained or the module fails to\n * instantiate.\n *\n * @example\n * ```ts\n * const havok = await loadHavok({ url: app.assets.resolveUrl(HAVOK_WASM_FILE_NAME) });\n * ```\n *\n * @internal\n */\nexport async function loadHavok(source: HavokSource): Promise<unknown> {\n if (source.module !== undefined && source.module !== null) {\n return source.module;\n }\n const url = source.url ?? HAVOK_WASM_FILE_NAME;\n const wasmBinary = source.wasmBinary ?? (await readWasmBytes(url));\n try {\n return await HavokPhysics({ wasmBinary });\n } catch (cause: unknown) {\n throw physicsError(PhysicsErrorCode.havokUnavailable, \"Havok failed to instantiate from the supplied bytes.\", {\n context: { url },\n hint: \"Check that HavokPhysics.wasm matches the installed @babylonjs/havok version.\",\n cause,\n });\n }\n}\n\n/**\n * Reads the `.wasm` bytes, preferring `fetch` and falling back to the file system under Node.\n *\n * @param url - The URL or path.\n * @returns The bytes as a plain `ArrayBuffer`, which is what Emscripten wants.\n * @throws IgnifxError with code `IGX-0903` when neither route produces bytes.\n */\nasync function readWasmBytes(url: string): Promise<ArrayBuffer> {\n let fetchFailure: unknown = null;\n if (typeof globalThis.fetch === \"function\") {\n try {\n const response = await globalThis.fetch(url);\n if (response.ok) {\n return await response.arrayBuffer();\n }\n fetchFailure = new Error(`${String(response.status)} ${response.statusText}`);\n } catch (cause: unknown) {\n fetchFailure = cause;\n }\n }\n const fromDisk = await readFromDisk(url);\n if (fromDisk !== null) {\n return fromDisk;\n }\n const fromPackage = await readFromPackage();\n if (fromPackage !== null) {\n return fromPackage;\n }\n throw physicsError(PhysicsErrorCode.havokUnavailable, \"The Havok WebAssembly bytes could not be read.\", {\n context: { url },\n hint: 'Set physics({ havokWasm: \"<url>\" }) or hand physics({ wasmBinary }) the bytes yourself.',\n ...(fetchFailure === null ? {} : { cause: fetchFailure }),\n });\n}\n\n/**\n * Reads a file through `node:fs` when the host is Node, and reports `null` everywhere else.\n *\n * @remarks\n * The specifier is held in a constant so that browser bundlers leave the import alone: a bundler\n * only rewrites a `import(\"…\")` whose argument is a string literal, and this branch is unreachable\n * in a browser anyway.\n *\n * @param path - The file path.\n * @returns The bytes, or `null` when there is no file system to read from, or the file is\n * unreadable. A browser fails the import itself, which is the same answer.\n */\nasync function readFromDisk(path: string): Promise<ArrayBuffer | null> {\n try {\n const specifier = NODE_FS_SPECIFIER;\n // A dynamic import with a non-literal specifier is\n // typed `any`, and {@link NodeFileSystem} is the one method of it this branch calls.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const fs = (await import(/* @vite-ignore */ specifier)) as NodeFileSystem;\n const bytes = await fs.readFile(path);\n // A Node `Buffer` is a view into a pooled `ArrayBuffer`, so copy out exactly this file's bytes\n // rather than handing Emscripten a window onto the pool.\n const copy = new ArrayBuffer(bytes.byteLength);\n new Uint8Array(copy).set(bytes);\n return copy;\n } catch {\n return null;\n }\n}\n\n/** The one `node:fs/promises` member this module calls. */\ninterface NodeFileSystem {\n /**\n * Reads a whole file.\n *\n * @param file - The path.\n * @returns Its bytes.\n */\n readFile(file: string): Promise<Uint8Array>;\n}\n\n/** The `node:fs/promises` specifier, held in a constant so bundlers do not follow it. */\nconst NODE_FS_SPECIFIER = \"node:fs/promises\";\n\n/** Where `@babylonjs/havok@1.3.14` keeps the binary its ESM build would otherwise `fetch`. */\nconst HAVOK_PACKAGE_WASM = \"@babylonjs/havok/lib/esm/HavokPhysics.wasm\";\n\n/**\n * Reads the binary straight out of the installed `@babylonjs/havok` package, which is what makes a\n * headless Node app work with no configuration at all: `app.isHeadless` only changes *where the\n * bytes come from* (Phase 4 brief), and under Node the answer is the package itself.\n *\n * @returns The bytes, or `null` when `import.meta.resolve` is unavailable or the package cannot be\n * resolved.\n */\nasync function readFromPackage(): Promise<ArrayBuffer | null> {\n try {\n const resolved = import.meta.resolve(HAVOK_PACKAGE_WASM);\n return await readFromDisk(resolved.startsWith(\"file://\") ? fileUrlToPath(resolved) : resolved);\n } catch {\n return null;\n }\n}\n\n/**\n * Turns a `file:` URL into a path `node:fs` accepts.\n *\n * @param url - The `file:` URL.\n * @returns The decoded path.\n */\nfunction fileUrlToPath(url: string): string {\n return decodeURIComponent(new URL(url).pathname);\n}\n","import type { PhysicsRuntime } from \"./runtime.js\";\n\n/**\n * The one mutable cell between `register` and `onStart`.\n *\n * `Extension.register` runs **before** `createApp` builds the Lite engine and the world\n * (`packages/core/src/app/app.ts`, `initialize`), and the Havok world needs both. So the extension\n * declares its systems and its service in `register` — which is where `04-extensions.md` §1 says\n * everything is declared — and they all read the runtime through this holder, which `onStart` fills\n * in once Havok has loaded.\n *\n * @internal\n */\nexport class PhysicsHost {\n /** The runtime, or `null` until `onStart` has built it. */\n runtime: PhysicsRuntime | null = null;\n}\n","import { createPhysicsCharacterController } from \"@babylonjs/lite\";\nimport type { LitePhysicsBody, LitePhysicsWorld } from \"./havok.js\";\nimport type { PhysicsCharacterController } from \"@babylonjs/lite\";\nimport type { LiteSceneNode, MutableVec3, Vec3Like } from \"@ignifx/core\";\n\n/**\n * The character-controller half of this package's Babylon Lite adapter\n * (`docs/architecture/09-physics.md` §2.3).\n *\n * Verified against `@babylonjs/lite@1.27.0`: `createPhysicsCharacterController` (`index.d.ts` 2887)\n * builds a kinematic capsule with collide-and-slide; the class (8300) exposes `keepDistance`,\n * `maxSlopeCosine`, `characterStrength`, `moveWithCollisions` (8389), `integrate` (8398),\n * `checkSupport` (8404), `getPosition`/`setPosition`, `getVelocity`/`setVelocity`,\n * `setShapeOptions` (8379) and `onTriggerCollisionObservable` (8332). Its options carry only\n * `capsuleHeight` and `capsuleRadius` (8447) — there is no centre offset, so the component applies\n * its own `center` when it writes the entity transform.\n *\n * Everything here is `@internal`.\n */\n\n/**\n * Lite's character controller handle.\n *\n * @internal\n */\nexport type LiteCharacterController = PhysicsCharacterController;\n\n/**\n * How the character is supported by whatever is under it; Lite's `CharacterSupportedState` (1615).\n *\n * @internal\n */\nexport const SupportState = {\n /** Nothing within reach. */\n unsupported: 0,\n /** Touching a surface too steep to stand on. */\n sliding: 1,\n /** Standing on a walkable surface. */\n supported: 2,\n} as const;\n\n/**\n * The union of {@link SupportState} values.\n *\n * @internal\n */\nexport type SupportState = (typeof SupportState)[keyof typeof SupportState];\n\n/** What one dynamic body the character pushed looks like. */\nexport interface CharacterPush {\n /** The node of the body that was pushed. */\n readonly node: LiteSceneNode;\n /** The world-space impulse the character applied. */\n readonly impulse: Vec3Like;\n /** Where the impulse was applied. */\n readonly point: Vec3Like;\n}\n\n/**\n * Creates a controller.\n *\n * @param world - The Havok world.\n * @param position - The starting world position of the capsule centre.\n * @param height - Total capsule height, tip to tip.\n * @param radius - Capsule radius.\n * @returns The controller.\n *\n * @internal\n */\nexport function createController(\n world: LitePhysicsWorld,\n position: Vec3Like,\n height: number,\n radius: number,\n): LiteCharacterController {\n return createPhysicsCharacterController(\n world,\n { x: position.x, y: position.y, z: position.z },\n { capsuleHeight: height, capsuleRadius: radius },\n );\n}\n\n/**\n * Applies the tuning fields `CharacterController` exposes.\n *\n * @param controller - The controller.\n * @param slopeCosine - The cosine of the steepest walkable slope.\n * @param skinWidth - The separation kept from surfaces, in metres.\n * @param strength - The push strength applied to dynamic bodies.\n *\n * @internal\n */\nexport function tuneController(\n controller: LiteCharacterController,\n slopeCosine: number,\n skinWidth: number,\n strength: number,\n): void {\n controller.maxSlopeCosine = slopeCosine;\n controller.keepDistance = skinWidth;\n controller.characterStrength = strength;\n}\n\n/**\n * Rebuilds the capsule without losing the controller's position, velocity, or subscriptions.\n *\n * @param controller - The controller.\n * @param height - The new total height.\n * @param radius - The new radius.\n * @param preserveFeet - Whether the foot position stays fixed as the height changes.\n *\n * @internal\n */\nexport function resizeController(\n controller: LiteCharacterController,\n height: number,\n radius: number,\n preserveFeet: boolean,\n): void {\n controller.setShapeOptions({ capsuleHeight: height, capsuleRadius: radius }, preserveFeet);\n}\n\n/**\n * Moves the character by a displacement, sliding along whatever it meets.\n *\n * @param controller - The controller.\n * @param displacement - The requested world-space displacement for this step.\n *\n * @internal\n */\nexport function moveController(controller: LiteCharacterController, displacement: Vec3Like): void {\n controller.moveWithCollisions({ x: displacement.x, y: displacement.y, z: displacement.z });\n}\n\n/**\n * Probes the surface under the character without moving it.\n *\n * @remarks\n * `checkSupport` wants a **unit** direction. It classifies by `1 - dot(slide, direction)²` against\n * `maxSlopeCosine²` (`lib/physics/character-controller.js`, `checkSupport`), which is `cos²` of the\n * slope only when `direction` has length 1. Passed raw gravity (length 9.81), the term fell below\n * the limit on any incline steeper than 4° to 5°, so every walkable slope read as `SLIDING` and\n * `isGrounded` was false on it (fixed 2026-10-14). Zero gravity probes straight down.\n *\n * @param controller - The controller.\n * @param deltaSeconds - The fixed step.\n * @param gravity - The probe direction, normally gravity; only its direction is used.\n * @param groundNormal - Written with the averaged supporting normal.\n * @returns The support classification.\n *\n * @internal\n */\nexport function probeSupport(\n controller: LiteCharacterController,\n deltaSeconds: number,\n gravity: Vec3Like,\n groundNormal: MutableVec3,\n): SupportState {\n const length = Math.hypot(gravity.x, gravity.y, gravity.z);\n const direction =\n length > 0 ? { x: gravity.x / length, y: gravity.y / length, z: gravity.z / length } : { x: 0, y: -1, z: 0 };\n const surface = controller.checkSupport(deltaSeconds, direction);\n const normal = surface.averageSurfaceNormal;\n groundNormal.set(normal.x, normal.y, normal.z);\n return toSupportState(surface.supportedState);\n}\n\n/**\n * The Havok body a controller's capsule is, which is what a query names to sweep *past* the\n * character rather than into it (`ShapeCastOptions.ignore`).\n *\n * @param controller - The controller.\n * @returns Its body handle.\n *\n * @internal\n */\nexport function controllerBody(controller: LiteCharacterController): LitePhysicsBody {\n return controller.getBody();\n}\n\n/**\n * The node of a controller's capsule body. Lite creates it for the controller, separate from the\n * entity's node, so it is what a ray hit on the capsule reports (`RaycastResult.body.node`).\n *\n * @param controller - The controller.\n * @returns The capsule body's node.\n *\n * @internal\n */\nexport function controllerNode(controller: LiteCharacterController): LiteSceneNode {\n return controller.getBody().node;\n}\n\n/**\n * Reads the controller's resolved position.\n *\n * @param controller - The controller.\n * @param out - The vector to write.\n *\n * @internal\n */\nexport function readControllerPosition(controller: LiteCharacterController, out: MutableVec3): void {\n const position = controller.getPosition();\n out.set(position.x, position.y, position.z);\n}\n\n/**\n * Teleports the controller, clearing any swept motion.\n *\n * @param controller - The controller.\n * @param position - The new world position.\n *\n * @internal\n */\nexport function writeControllerPosition(controller: LiteCharacterController, position: Vec3Like): void {\n controller.setPosition({ x: position.x, y: position.y, z: position.z });\n}\n\n/**\n * Reads the controller's velocity.\n *\n * @param controller - The controller.\n * @param out - The vector to write.\n *\n * @internal\n */\nexport function readControllerVelocity(controller: LiteCharacterController, out: MutableVec3): void {\n const velocity = controller.getVelocity();\n out.set(velocity.x, velocity.y, velocity.z);\n}\n\n/**\n * Sets the controller's velocity.\n *\n * @param controller - The controller.\n * @param velocity - The new world-space velocity.\n *\n * @internal\n */\nexport function writeControllerVelocity(controller: LiteCharacterController, velocity: Vec3Like): void {\n controller.setVelocity({ x: velocity.x, y: velocity.y, z: velocity.z });\n}\n\n/**\n * Subscribes to the dynamic bodies the character pushes.\n *\n * @param controller - The controller.\n * @param sink - Called once per pushed body, during the step.\n * @returns A disposer that removes the subscription.\n *\n * @internal\n */\nexport function onControllerPush(controller: LiteCharacterController, sink: (push: CharacterPush) => void): () => void {\n return controller.onTriggerCollisionObservable.add((event): void => {\n sink({ node: event.collider.node, impulse: event.impulse, point: event.impulsePosition });\n });\n}\n\n/**\n * Releases the controller's body, shape, and query collectors.\n *\n * @param controller - The controller.\n *\n * @internal\n */\nexport function disposeController(controller: LiteCharacterController): void {\n controller.dispose();\n}\n\n/**\n * Narrows Lite's support enum to {@link SupportState}.\n *\n * @param value - Lite's value.\n * @returns The matching state, defaulting to `unsupported`.\n */\nfunction toSupportState(value: number): SupportState {\n if (value === SupportState.supported) {\n return SupportState.supported;\n }\n return value === SupportState.sliding ? SupportState.sliding : SupportState.unsupported;\n}\n","import { Quat, Vec3, lerp } from \"@ignifx/core\";\nimport { Collider } from \"../components/collider.js\";\nimport { Rigidbody } from \"../components/rigidbody.js\";\nimport { PhysicsErrorCode, physicsError } from \"../errors.js\";\nimport {\n SupportState,\n controllerBody,\n controllerNode,\n createController,\n disposeController,\n moveController,\n onControllerPush,\n probeSupport,\n readControllerPosition,\n readControllerVelocity,\n resizeController as resizeLiteController,\n tuneController,\n writeControllerPosition,\n writeControllerVelocity,\n} from \"../lite/character.js\";\nimport {\n addContainerChild,\n afterStep,\n applyForce,\n applyImpulse,\n BodyMotion,\n CONTACT_FINISHED,\n CONTACT_STARTED,\n createBody,\n createContainer,\n destroyBody,\n destroyShape,\n destroyWorld,\n disposeSimulation,\n onCollisionEvents,\n onTriggerEvents,\n PrestepMode,\n readAngularVelocity,\n readLinearVelocity,\n readNodePose,\n setBodyCollisionEvents,\n setBodyMass,\n setBodyPrestep,\n setBodyShape,\n setBodyTransform,\n setGravity,\n setRotationLocks,\n setShapeFilter,\n setShapeMaterial,\n setShapeTrigger,\n setTimestep,\n setVelocityLimits,\n stepSimulation,\n writeAngularVelocity,\n writeLinearVelocity,\n writeNodePose,\n} from \"../lite/havok.js\";\nimport type { BodyRecord, QueryTarget } from \"./body-record.js\";\nimport type { CharacterController, SupportStateName } from \"../components/character-controller.js\";\nimport type { ContactPoint } from \"../events.js\";\nimport type { CharacterPush, LiteCharacterController } from \"../lite/character.js\";\nimport type {\n ContactRecord,\n LitePhysicsBody,\n LitePhysicsShape,\n LitePhysicsWorld,\n SimulationHandles,\n TriggerRecord,\n} from \"../lite/havok.js\";\nimport type { PhysicsMaterialValues, PhysicsSettings } from \"../settings.js\";\nimport type {\n Component,\n DiagnosticsGroup,\n Entity,\n ExtensionContext,\n LiteSceneNode,\n MutableVec3,\n PhysicsCallbackName,\n QuatLike,\n Vec3Like,\n} from \"@ignifx/core\";\n\n/**\n * The per-app physics runtime: the Havok world, the bodies, the character controllers, the event\n * drains, and the three things the systems ask it to do each frame — restore, step, interpolate\n * (`docs/architecture/09-physics.md` §1).\n *\n * Everything here is `@internal`; the public surface is `PhysicsService`, `Rigidbody`, the\n * colliders, and `CharacterController`.\n */\n\n/** What the extension hands the runtime. */\nexport interface PhysicsRuntimeOptions {\n /** The extension registration surface; the physics kernel hooks live on it. */\n readonly ctx: ExtensionContext;\n /** The resolved `physics` settings section. */\n readonly settings: PhysicsSettings;\n /** The null-engine scene the world is hosted on. */\n readonly simulation: SimulationHandles;\n /** The Havok world. */\n readonly world: LitePhysicsWorld;\n /** The `physics` diagnostics group. */\n readonly counters: DiagnosticsGroup;\n}\n\n/** One buffered trigger event, resolved to records during the step. */\ninterface TriggerSlot {\n /** `true` for an enter, `false` for an exit. */\n entered: boolean;\n /** The first participant, or `null`. */\n first: BodyRecord | null;\n /** The second participant, or `null`. */\n second: BodyRecord | null;\n}\n\n/** One buffered collision event. */\ninterface ContactSlot {\n /** `0` started, `1` continued, `2` finished. */\n phase: number;\n /** The contact point. */\n readonly point: Vec3;\n /** The contact normal. */\n readonly normal: Vec3;\n /** The resolving impulse. */\n impulse: number;\n /** The first participant, or `null` when its body is not an entity's (a character capsule). */\n first: BodyRecord | null;\n /** The second participant, or `null`. */\n second: BodyRecord | null;\n}\n\n/**\n * One character controller's runtime state. It is also the capsule's entry in the query index, so\n * `currentPosition` is the capsule centre and `halfExtents` its bounding box.\n */\ninterface ControllerRecord extends QueryTarget {\n /** The component. */\n readonly component: CharacterController;\n /** Lite's controller. */\n readonly controller: LiteCharacterController;\n /** The node of the capsule's Havok body, which a ray hit reports. */\n readonly node: LiteSceneNode;\n /** The entity's layer as of the last fixed step. */\n layer: number;\n /** The pose at the end of the previous step. */\n readonly previousPosition: Vec3;\n /** The authoritative pose at the end of the last step. */\n readonly currentPosition: Vec3;\n /** Whether the display position is interpolated. */\n interpolate: boolean;\n /** `Transform.worldMatrixVersion` when the capsule was placed; edit mode follows a move. */\n placedVersion: number;\n /** The subscription to Lite's push observable. */\n disconnect: () => void;\n}\n\n/**\n * Who hears about bodies coming and going: the debug viewer, which draws each one.\n *\n * @internal\n */\nexport interface BodyObserver {\n /** A body was added to the world. */\n added(body: LitePhysicsBody): void;\n /** A body is about to leave the world. */\n removed(body: LitePhysicsBody): void;\n /**\n * A body was re-placed: `next` stands in for `previous` on the same node with the same shapes, so\n * whatever was drawn for `previous` still fits and follows the node.\n */\n replaced(previous: LitePhysicsBody, next: LitePhysicsBody): void;\n}\n\n/** The pooled `TriggerEvent`, whose fields the dispatcher rewrites for each delivery. */\ninterface MutableTriggerEvent {\n /** The other participant. */\n other: Entity | null;\n /** The other participant's first collider. */\n otherCollider: Collider | null;\n /** The entity being called. */\n self: Entity;\n}\n\n/** The pooled `Collision`. */\ninterface MutableCollision {\n /** The other participant. */\n other: Entity | null;\n /** The other participant's first collider. */\n otherCollider: Collider | null;\n /** The entity being called. */\n self: Entity;\n /** The one-element pooled contact list. */\n readonly contacts: readonly ContactPoint[];\n /** The relative velocity, or `null` when the other participant is not an entity's body. */\n relativeVelocity: Vec3Like | null;\n}\n\n/**\n * The counters `09-physics.md` §9 and the plan's diagnostics deliverable name.\n *\n * @public\n */\nexport const PHYSICS_DIAGNOSTICS_COUNTERS: readonly string[] = Object.freeze([\n \"bodies\",\n \"activeBodies\",\n \"stepsThisFrame\",\n \"collisionEvents\",\n \"triggerEvents\",\n \"queries\",\n \"stepMs\",\n]);\n\n/**\n * The diagnostics group name.\n *\n * @public\n */\nexport const PHYSICS_DIAGNOSTICS_GROUP = \"physics\";\n\n/** How many layers a project can declare, and therefore how wide a filter mask is. */\nconst LAYER_COUNT = 32;\n\n/** Milliseconds in one second. */\nconst MILLISECONDS_PER_SECOND = 1000;\n\n/** How far a body may move before the implicit-static diagnostic considers it moved. */\nconst STATIC_MOVE_EPSILON = 1e-6;\n\n/**\n * The per-app physics runtime.\n *\n * @internal\n */\nexport class PhysicsRuntime {\n readonly #ctx: ExtensionContext;\n\n readonly #settings: PhysicsSettings;\n\n readonly #simulation: SimulationHandles;\n\n readonly #world: LitePhysicsWorld;\n\n readonly #counters: DiagnosticsGroup;\n\n readonly #records: BodyRecord[] = [];\n\n readonly #byEntity = new Map<Entity, BodyRecord>();\n\n readonly #byNode = new Map<LiteSceneNode, BodyRecord>();\n\n readonly #dirty = new Set<Entity>();\n\n readonly #controllers: ControllerRecord[] = [];\n\n readonly #controllersByNode = new Map<LiteSceneNode, ControllerRecord>();\n\n readonly #dirtyControllers = new Set<CharacterController>();\n\n readonly #collideMasks = new Int32Array(LAYER_COUNT).fill(~0);\n\n readonly #triggerSlots: TriggerSlot[] = [];\n\n readonly #contactSlots: ContactSlot[] = [];\n\n #triggerEvent: MutableTriggerEvent | null = null;\n\n readonly #contactPoint: { point: Vec3; normal: Vec3; impulse: number } = {\n point: new Vec3(),\n normal: new Vec3(),\n impulse: 0,\n };\n\n readonly #contacts: ContactPoint[] = [];\n\n #collision: MutableCollision | null = null;\n\n readonly #scratchPosition = new Vec3();\n\n readonly #scratchRotation = new Quat();\n\n readonly #scratchVector = new Vec3();\n\n readonly #scratchOther = new Vec3();\n\n readonly #relativeVelocity = new Vec3();\n\n readonly #gravityDirection = new Vec3(0, -1, 0);\n\n #triggerCount = 0;\n\n #contactCount = 0;\n\n #stepped = false;\n\n /** Whether the app is an editor's scene view, where bodies exist and nothing steps (ADR-0028). */\n readonly #isEditMode: boolean;\n\n #observer: BodyObserver | null = null;\n\n /** The last failure reported for each entity whose body could not be built, in edit mode. */\n readonly #failures = new WeakMap<Entity, string>();\n\n /** The entities `IGX-0907` (a body on a child entity) has been logged for, once each. */\n readonly #warnedChildren = new WeakSet<Entity>();\n\n #disposed = false;\n\n #queries = 0;\n\n #stepsThisFrame = 0;\n\n #stepMs = 0;\n\n #collisionEventCount = 0;\n\n #triggerEventCount = 0;\n\n #activeBodies = 0;\n\n /**\n * Builds the runtime, applies the world settings, and registers the event drains.\n *\n * @param options - The context, settings, scene, world, and counters.\n * @throws IgnifxError with code `IGX-0905` when the collision matrix names an unknown layer.\n */\n constructor(options: PhysicsRuntimeOptions) {\n this.#ctx = options.ctx;\n this.#settings = options.settings;\n this.#simulation = options.simulation;\n this.#world = options.world;\n this.#counters = options.counters;\n this.#isEditMode = options.ctx.app.isEditMode;\n this.#contacts.push(this.#contactPoint);\n\n setGravity(this.#world, this.#settings.gravity);\n const gravity = this.#settings.gravity;\n const magnitude = Math.hypot(gravity.x, gravity.y, gravity.z);\n if (magnitude > 0) {\n this.#gravityDirection.set(gravity.x / magnitude, gravity.y / magnitude, gravity.z / magnitude);\n }\n const limits = this.#settings.velocityLimits;\n if (limits.linear > 0 || limits.angular > 0) {\n setVelocityLimits(this.#world, limits.linear, limits.angular);\n }\n this.#buildCollideMasks();\n onTriggerEvents(this.#world, (record): void => {\n this.#bufferTrigger(record);\n });\n onCollisionEvents(this.#world, (record): void => {\n this.#bufferContact(record);\n });\n afterStep(this.#world, (): void => {\n // Registered last, so it runs after both drains have filled the buffers.\n });\n }\n\n /**\n * The Havok world, for the query and viewer paths.\n *\n * @returns The world handle.\n */\n get world(): LitePhysicsWorld {\n return this.#world;\n }\n\n /**\n * Whether at least one fixed step has run, which is what Havok's broadphase needs before a query\n * can answer (`09-physics.md` §5).\n *\n * @returns `true` once a step has completed.\n */\n get hasStepped(): boolean {\n return this.#stepped;\n }\n\n /**\n * Whether this runtime belongs to an edit-mode app, where bodies are kept in sync with the world\n * by {@link PhysicsRuntime.syncEditMode} and never stepped (ADR-0028, amendment of 2026-10-20).\n *\n * @returns `true` in an editor's scene view.\n */\n get isEditMode(): boolean {\n return this.#isEditMode;\n }\n\n /**\n * Sets who hears about bodies coming and going.\n *\n * @param observer - The observer, or `null` to stop.\n */\n setBodyObserver(observer: BodyObserver | null): void {\n this.#observer = observer;\n }\n\n /**\n * Every body, in creation order.\n *\n * @returns The records.\n */\n get records(): readonly BodyRecord[] {\n return this.#records;\n }\n\n /**\n * The resolved settings.\n *\n * @returns The `physics` section.\n */\n get settings(): PhysicsSettings {\n return this.#settings;\n }\n\n /**\n * Replaces world gravity.\n *\n * @param gravity - The new acceleration vector.\n */\n setGravity(gravity: Vec3Like): void {\n setGravity(this.#world, gravity);\n }\n\n /**\n * Marks an entity's body for a rebuild at the start of the next fixed step.\n *\n * @param entity - The entity whose colliders or `Rigidbody` changed.\n */\n markDirty(entity: Entity): void {\n if (!this.#disposed && !entity.isDestroyed) {\n this.#dirty.add(entity);\n }\n }\n\n /**\n * Marks a character controller for a rebuild at the start of the next fixed step.\n *\n * @param component - The controller component.\n */\n markControllerDirty(component: CharacterController): void {\n if (!this.#disposed) {\n this.#dirtyControllers.add(component);\n }\n }\n\n /**\n * Restores the authoritative pose of every interpolated body and controller, undoing the display\n * pose the `Update` system wrote at the top of the previous frame's `Update`\n * (`09-physics.md` §1, spike S4.3).\n */\n restorePoses(): void {\n for (let index = 0; index < this.#records.length; index += 1) {\n const record = this.#records[index];\n if (record !== undefined && record.interpolate) {\n writeNodePose(record.node, record.currentPosition, record.currentRotation);\n }\n }\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record !== undefined && record.interpolate) {\n this.#writeControllerTransform(record, record.currentPosition);\n }\n }\n }\n\n /**\n * Runs one fixed step: reconcile, step Havok, snapshot poses, dispatch events.\n *\n * @param fixedDeltaSeconds - The fixed step in seconds.\n */\n step(fixedDeltaSeconds: number): void {\n this.#syncLayers();\n this.#reconcile();\n this.#applyControllerMoves(fixedDeltaSeconds);\n setTimestep(this.#world, fixedDeltaSeconds);\n this.#triggerCount = 0;\n this.#contactCount = 0;\n const started = now();\n stepSimulation(this.#simulation, fixedDeltaSeconds * MILLISECONDS_PER_SECOND);\n this.#stepMs += now() - started;\n this.#stepsThisFrame += 1;\n this.#stepped = true;\n this.#snapshot(fixedDeltaSeconds);\n this.#dispatchTriggers();\n this.#dispatchContacts();\n }\n\n /**\n * Brings the bodies in line with the world without stepping, which is all an edit-mode app ever\n * does with them (ADR-0028, amendment of 2026-10-20): it builds, rebuilds, and removes bodies for\n * component and layer changes, and re-places every body and capsule whose transform moved, so a\n * query sees what the editor shows. Havok is never stepped, so nothing falls, no contact or\n * trigger event is produced, and no pose is written back to a transform.\n *\n * @remarks\n * A moved body is removed and added again with the shapes it has: a teleport alone leaves Havok's\n * broadphase where the body was, so a ray at the new place would miss it until a step. A changed\n * scale rebuilds the shapes too.\n */\n syncEditMode(): void {\n if (this.#disposed) {\n return;\n }\n this.#syncLayers();\n this.#followTransforms();\n this.#reconcile();\n this.#publishCounters();\n }\n\n /**\n * Writes the interpolated display pose of every interpolated body and controller.\n *\n * @param alpha - `time.fixedStepAlpha`, in `[0, 1)`.\n */\n interpolate(alpha: number): void {\n this.#publishCounters();\n for (let index = 0; index < this.#records.length; index += 1) {\n const record = this.#records[index];\n if (record === undefined || !record.interpolate) {\n continue;\n }\n const position = this.#scratchPosition;\n position.set(\n lerp(record.previousPosition.x, record.currentPosition.x, alpha),\n lerp(record.previousPosition.y, record.currentPosition.y, alpha),\n lerp(record.previousPosition.z, record.currentPosition.z, alpha),\n );\n Quat.slerpToRef(record.previousRotation, record.currentRotation, alpha, this.#scratchRotation);\n writeNodePose(record.node, position, this.#scratchRotation);\n }\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record === undefined || !record.interpolate) {\n continue;\n }\n this.#scratchPosition.set(\n lerp(record.previousPosition.x, record.currentPosition.x, alpha),\n lerp(record.previousPosition.y, record.currentPosition.y, alpha),\n lerp(record.previousPosition.z, record.currentPosition.z, alpha),\n );\n this.#writeControllerTransform(record, this.#scratchPosition);\n }\n }\n\n /**\n * The Havok body of an entity, for the `.lite` escape hatch and the debug viewer.\n *\n * @param entity - The entity.\n * @returns The body handle, or `null`.\n */\n bodyHandleOf(entity: Entity): BodyRecord[\"body\"] | null {\n return this.#byEntity.get(entity)?.body ?? null;\n }\n\n /**\n * The record an entity owns.\n *\n * @param entity - The entity.\n * @returns The record, or `null`.\n */\n recordOf(entity: Entity): BodyRecord | null {\n return this.#byEntity.get(entity) ?? null;\n }\n\n /**\n * The Havok body an entity's physics is, whether that is a `Rigidbody`, a collider-only static, or\n * a `CharacterController`'s capsule — which is what a sweep names to pass through it\n * (`ShapeCastOptions.ignore`).\n *\n * @param entity - The entity.\n * @returns The body, or `null` when the entity has none yet: a body is built on the fixed step\n * after its components attach, so a query in the same frame finds nothing to ignore.\n */\n bodyOf(entity: Entity): LitePhysicsBody | null {\n const record = this.#byEntity.get(entity);\n if (record !== undefined) {\n return record.body;\n }\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const controller = this.#controllers[index];\n if (controller !== undefined && controller.component.entity === entity) {\n return controllerBody(controller.controller);\n }\n }\n return null;\n }\n\n /**\n * The record a Lite node belongs to, which is how a Havok event or query result becomes an entity.\n *\n * @param node - The node.\n * @returns The record, or `null`.\n */\n recordOfNode(node: LiteSceneNode | null): BodyRecord | null {\n return node === null ? null : (this.#byNode.get(node) ?? null);\n }\n\n /**\n * What a query hit on a Lite node: a body record, or a character controller's capsule.\n *\n * @param node - The node of the body that was hit.\n * @returns The target, or `null` when the node belongs to neither.\n */\n targetOfNode(node: LiteSceneNode | null): QueryTarget | null {\n if (node === null) {\n return null;\n }\n return this.#byNode.get(node) ?? this.#controllersByNode.get(node) ?? null;\n }\n\n /**\n * How many entries the query index holds: every body record, then every character controller.\n *\n * @returns The count.\n */\n get queryTargetCount(): number {\n return this.#records.length + this.#controllers.length;\n }\n\n /**\n * One entry of the query index. Bodies come first and controllers after, each in creation order,\n * so `overlap` lists them in a stable order (`09-physics.md` §8).\n *\n * @param index - An index below {@link PhysicsRuntime.queryTargetCount}.\n * @returns The target, or `undefined` past the end.\n */\n queryTargetAt(index: number): QueryTarget | undefined {\n const bodies = this.#records.length;\n return index < bodies ? this.#records[index] : this.#controllers[index - bodies];\n }\n\n /** Counts one query for the diagnostics group. */\n countQuery(): void {\n this.#queries += 1;\n }\n\n /**\n * Reads a body's linear velocity.\n *\n * @param entity - The entity.\n * @param out - The vector to write; left untouched when there is no body.\n */\n readLinear(entity: Entity, out: MutableVec3): void {\n const record = this.#byEntity.get(entity);\n if (record !== undefined) {\n readLinearVelocity(this.#world, record.body, out);\n }\n }\n\n /**\n * Reads a body's angular velocity.\n *\n * @param entity - The entity.\n * @param out - The vector to write.\n */\n readAngular(entity: Entity, out: MutableVec3): void {\n const record = this.#byEntity.get(entity);\n if (record !== undefined) {\n readAngularVelocity(this.#world, record.body, out);\n }\n }\n\n /**\n * Sets a body's linear velocity.\n *\n * @param entity - The entity.\n * @param velocity - Metres per second, world space.\n */\n setLinearVelocity(entity: Entity, velocity: Vec3Like): void {\n const record = this.#byEntity.get(entity);\n if (record !== undefined) {\n writeLinearVelocity(this.#world, record.body, velocity);\n }\n }\n\n /**\n * Sets a body's angular velocity.\n *\n * @param entity - The entity.\n * @param velocity - Radians per second, world space.\n */\n setAngularVelocity(entity: Entity, velocity: Vec3Like): void {\n const record = this.#byEntity.get(entity);\n if (record !== undefined) {\n writeAngularVelocity(this.#world, record.body, velocity);\n }\n }\n\n /**\n * Applies a force for one fixed step.\n *\n * @param entity - The entity.\n * @param force - Newtons, world space.\n * @param point - The application point.\n */\n addForce(entity: Entity, force: Vec3Like, point: Vec3Like): void {\n const record = this.#byEntity.get(entity);\n if (record !== undefined) {\n applyForce(this.#world, record.body, force, point);\n }\n }\n\n /**\n * Applies an impulse.\n *\n * @param entity - The entity.\n * @param impulse - Newton-seconds, world space.\n * @param point - The application point.\n */\n addImpulse(entity: Entity, impulse: Vec3Like, point: Vec3Like): void {\n const record = this.#byEntity.get(entity);\n if (record !== undefined) {\n applyImpulse(record.body, impulse, point);\n }\n }\n\n /**\n * Teleports a body and resets its interpolation history.\n *\n * @param entity - The entity.\n * @param position - The new world position.\n * @param rotation - The new world rotation.\n */\n teleport(entity: Entity, position: Vec3Like, rotation: QuatLike): void {\n const record = this.#byEntity.get(entity);\n if (record === undefined) {\n writeNodePose(entity.transform.lite, position, rotation);\n return;\n }\n setBodyTransform(this.#world, record.body, position, rotation);\n writeNodePose(record.node, position, rotation);\n record.currentPosition.set(position.x, position.y, position.z);\n record.currentRotation.set(rotation.x, rotation.y, rotation.z, rotation.w);\n record.previousPosition.set(position.x, position.y, position.z);\n record.previousRotation.set(rotation.x, rotation.y, rotation.z, rotation.w);\n }\n\n /**\n * Sets a character controller's velocity.\n *\n * @param component - The controller component.\n * @param velocity - Metres per second, world space.\n */\n setControllerVelocity(component: CharacterController, velocity: Vec3Like): void {\n const record = this.#controllerOf(component);\n if (record !== null) {\n writeControllerVelocity(record.controller, velocity);\n }\n }\n\n /**\n * Reads a character controller's velocity.\n *\n * @param component - The controller component.\n * @param out - The vector to write.\n */\n readControllerVelocity(component: CharacterController, out: MutableVec3): void {\n const record = this.#controllerOf(component);\n if (record !== null) {\n readControllerVelocity(record.controller, out);\n }\n }\n\n /**\n * Reads a character controller's world position.\n *\n * @param component - The controller component.\n * @param out - The vector to write.\n */\n readControllerPosition(component: CharacterController, out: MutableVec3): void {\n const record = this.#controllerOf(component);\n if (record !== null) {\n readControllerPosition(record.controller, out);\n }\n }\n\n /**\n * Rebuilds a controller's capsule in place.\n *\n * @param component - The controller component.\n * @param preserveFeet - Whether the foot position stays fixed.\n */\n resizeController(component: CharacterController, preserveFeet: boolean): void {\n const record = this.#controllerOf(component);\n if (record !== null) {\n resizeLiteController(record.controller, component.height, component.radius, preserveFeet);\n // The centre catches up on the next fixed step, which is also when Havok moves the body.\n capsuleHalfExtents(component.height, component.radius, record.halfExtents);\n }\n }\n\n /**\n * Teleports a controller and resets its interpolation history.\n *\n * @param component - The controller component.\n * @param position - The new entity world position.\n */\n teleportController(component: CharacterController, position: Vec3Like): void {\n const record = this.#controllerOf(component);\n if (record === null) {\n component.transform.position = position;\n return;\n }\n const centre = this.#scratchVector;\n centre.set(position.x + component.center.x, position.y + component.center.y, position.z + component.center.z);\n writeControllerPosition(record.controller, centre);\n record.currentPosition.set(centre.x, centre.y, centre.z);\n record.previousPosition.set(centre.x, centre.y, centre.z);\n this.#writeControllerTransform(record, centre);\n }\n\n /**\n * Releases a controller's Lite resources.\n *\n * @param component - The controller component.\n */\n releaseController(component: CharacterController): void {\n this.#dirtyControllers.delete(component);\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record?.component === component) {\n record.disconnect();\n disposeController(record.controller);\n this.#controllers.splice(index, 1);\n this.#controllersByNode.delete(record.node);\n return;\n }\n }\n }\n\n /**\n * Tears every body and controller down, then releases the Havok world **before** the simulation\n * scene, which is the order `docs/architecture/07-rendering.md` §7 requires.\n */\n dispose(): void {\n if (this.#disposed) {\n return;\n }\n this.#disposed = true;\n for (let index = this.#controllers.length - 1; index >= 0; index -= 1) {\n const record = this.#controllers[index];\n if (record !== undefined) {\n record.disconnect();\n disposeController(record.controller);\n }\n }\n this.#controllers.length = 0;\n this.#controllersByNode.clear();\n for (let index = this.#records.length - 1; index >= 0; index -= 1) {\n const record = this.#records[index];\n if (record !== undefined) {\n this.#teardown(record);\n }\n }\n this.#records.length = 0;\n this.#byEntity.clear();\n this.#byNode.clear();\n destroyWorld(this.#world);\n disposeSimulation(this.#simulation);\n }\n\n /**\n * Publishes the frame's counters and zeroes the accumulators. The kernel resets `FrameSample` each\n * frame but not diagnostics **groups** (`Diagnostics.beginFrame`), so a group that reports\n * per-frame totals resets itself — and the top of `Update`, where the display pose is written, is\n * the first point in a frame at which every fixed step of that frame is done.\n */\n #publishCounters(): void {\n this.#counters.set(this.#index(\"bodies\"), this.#records.length);\n this.#counters.set(this.#index(\"activeBodies\"), this.#activeBodies);\n this.#counters.set(this.#index(\"stepsThisFrame\"), this.#stepsThisFrame);\n this.#counters.set(this.#index(\"collisionEvents\"), this.#collisionEventCount);\n this.#counters.set(this.#index(\"triggerEvents\"), this.#triggerEventCount);\n this.#counters.set(this.#index(\"queries\"), this.#queries);\n this.#counters.set(this.#index(\"stepMs\"), this.#stepMs);\n this.#stepsThisFrame = 0;\n this.#collisionEventCount = 0;\n this.#triggerEventCount = 0;\n this.#queries = 0;\n this.#stepMs = 0;\n }\n\n /**\n * Resolves a counter name to its index. Called with literal names only, from paths that run once\n * per step rather than once per body.\n *\n * @param counter - The counter name.\n * @returns Its index.\n */\n #index(counter: string): number {\n return this.#counters.index(counter);\n }\n\n /**\n * Builds the per-layer collide masks from `physics.collisionMatrix` (`09-physics.md` §3).\n *\n * @remarks\n * A layer the matrix does not mention keeps `~0`, so a default project needs no matrix at all.\n * Havok tests the pair in both directions, so one side listing the other is enough to *allow* the\n * pair and one side omitting it is enough to *block* it.\n *\n * @throws IgnifxError with code `IGX-0905` when a name is not a declared layer.\n */\n #buildCollideMasks(): void {\n const layers = this.#ctx.app.world.layers;\n for (const [name, others] of Object.entries(this.#settings.collisionMatrix)) {\n const index = layers.indexOf(name);\n if (index < 0) {\n throw unknownLayer(name);\n }\n let mask = 0;\n for (const other of others) {\n const otherIndex = layers.indexOf(other);\n if (otherIndex < 0) {\n throw unknownLayer(other);\n }\n mask |= 1 << otherIndex;\n }\n this.#collideMasks[index] = mask;\n }\n }\n\n /**\n * Re-places every body and capsule whose transform changed since it was placed, for\n * {@link PhysicsRuntime.syncEditMode}. A body whose lossy scale changed is rebuilt instead.\n */\n #followTransforms(): void {\n for (let index = 0; index < this.#records.length; index += 1) {\n const record = this.#records[index];\n if (record === undefined || this.#dirty.has(record.entity)) {\n continue;\n }\n const transform = record.entity.transform;\n if (transform.worldMatrixVersion === record.placedVersion) {\n continue;\n }\n if (nearlyEqual(transform.lossyScale, record.placedScale)) {\n this.#replace(record);\n } else {\n this.markDirty(record.entity);\n }\n }\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record !== undefined && record.entity.transform.worldMatrixVersion !== record.placedVersion) {\n this.markControllerDirty(record.component);\n }\n }\n }\n\n /**\n * Removes a body and adds it again where its node now is, keeping its shapes.\n *\n * @param record - The record whose entity moved.\n */\n #replace(record: BodyRecord): void {\n const root = record.shapes.at(-1);\n if (root === undefined) {\n this.markDirty(record.entity);\n return;\n }\n const previous = record.body;\n destroyBody(this.#world, previous);\n record.body = this.#createBody(record.node, root, record.rigidbody, record.motion);\n record.collisionEvents = false;\n this.#applyCollisionEvents(record);\n readNodePose(record.node, record.currentPosition, record.currentRotation);\n record.previousPosition.copyFrom(record.currentPosition);\n record.previousRotation.copyFrom(record.currentRotation);\n record.placedVersion = record.entity.transform.worldMatrixVersion;\n this.#observer?.replaced(previous, record.body);\n }\n\n /**\n * Rebuilds every body marked dirty, and every controller.\n */\n #reconcile(): void {\n if (this.#dirty.size > 0) {\n const pending = [...this.#dirty];\n this.#dirty.clear();\n for (const entity of pending) {\n this.#guarded(entity, null, (): void => {\n this.#rebuildEntity(entity);\n });\n }\n }\n if (this.#dirtyControllers.size > 0) {\n const pending = [...this.#dirtyControllers];\n this.#dirtyControllers.clear();\n for (const component of pending) {\n this.#guarded(component.entity, component, (): void => {\n this.#rebuildController(component);\n });\n }\n }\n }\n\n /**\n * Runs one entity's rebuild. In an edit-mode app a failure (a collider naming an undeclared\n * layer, say) is reported through `app.onError` once per entity and message and the other\n * entities still build, so one broken entity never stops the editor's queries; the entity\n * builds again when its components change. A game rethrows, as before.\n *\n * @param entity - The entity being rebuilt.\n * @param component - The controller being rebuilt, or `null` for a body.\n * @param rebuild - The work.\n */\n #guarded(entity: Entity, component: Component | null, rebuild: () => void): void {\n if (!this.#isEditMode) {\n rebuild();\n return;\n }\n try {\n rebuild();\n this.#failures.delete(entity);\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n if (this.#failures.get(entity) !== message) {\n this.#failures.set(entity, message);\n this.#ctx.app.onError.emit({ error, source: \"extension\", phase: null, entity, component });\n }\n }\n }\n\n /**\n * Tears an entity's body down and builds a new one from its current colliders.\n *\n * @param entity - The entity to rebuild.\n */\n #rebuildEntity(entity: Entity): void {\n const existing = this.#byEntity.get(entity);\n let carriedLinear: Vec3 | null = null;\n let carriedAngular: Vec3 | null = null;\n if (existing !== undefined) {\n if (existing.motion === BodyMotion.dynamic) {\n carriedLinear = new Vec3();\n carriedAngular = new Vec3();\n readLinearVelocity(this.#world, existing.body, carriedLinear);\n readAngularVelocity(this.#world, existing.body, carriedAngular);\n }\n this.#teardown(existing);\n const index = this.#records.indexOf(existing);\n if (index >= 0) {\n this.#records.splice(index, 1);\n }\n this.#byEntity.delete(entity);\n this.#byNode.delete(existing.node);\n }\n if (entity.isDestroyed || !entity.activeInHierarchy) {\n return;\n }\n const colliders = collidersOf(entity);\n if (colliders.length === 0) {\n return;\n }\n const rigidbody = entity.getComponent(Rigidbody);\n if (entity.parent !== null && !this.#warnedChildren.has(entity)) {\n this.#warnedChildren.add(entity);\n this.#ctx.log.warn(\n `${PhysicsErrorCode.bodyOnChildEntity}: {entity} carries a physics body but is not a root entity; Havok writes its local pose.`,\n entity.name,\n );\n }\n const record = this.#build(entity, rigidbody, colliders);\n this.#records.push(record);\n if (record.motion === BodyMotion.dynamic && carriedLinear !== null && carriedAngular !== null) {\n writeLinearVelocity(this.#world, record.body, carriedLinear);\n writeAngularVelocity(this.#world, record.body, carriedAngular);\n }\n }\n\n /**\n * Drops an entity's body immediately. `markDirty` refuses a destroyed entity — by the time\n * `onDestroyed` fires the entity is already gone — so destruction takes this path instead.\n *\n * @param entity - The entity whose body goes away.\n */\n #removeRecord(entity: Entity): void {\n const record = this.#byEntity.get(entity);\n if (record === undefined) {\n return;\n }\n this.#teardown(record);\n const index = this.#records.indexOf(record);\n if (index >= 0) {\n this.#records.splice(index, 1);\n }\n this.#byEntity.delete(entity);\n this.#byNode.delete(record.node);\n this.#dirty.delete(entity);\n }\n\n /**\n * Builds one body from an entity's colliders.\n *\n * @param entity - The entity.\n * @param rigidbody - Its `Rigidbody`, or `null` for an implicit static body.\n * @param colliders - Its colliders, in component order.\n * @returns The new record.\n */\n #build(entity: Entity, rigidbody: Rigidbody | null, colliders: readonly Collider[]): BodyRecord {\n const node = entity.transform.lite;\n const scale = entity.transform.lossyScale;\n const layer = entity.layer;\n const shapes = this.#buildShapeTree(colliders, scale, node, layer);\n const root = shapes.at(-1);\n if (root === undefined) {\n throw new Error(\"a body needs at least one collider\");\n }\n const motion = motionOf(rigidbody);\n const body = this.#createBody(node, root, rigidbody, motion);\n\n const record: BodyRecord = {\n entity,\n node,\n rigidbody,\n colliders: [...colliders],\n body,\n shapes,\n motion,\n interpolate: this.#shouldInterpolate(rigidbody, motion),\n layer,\n collisionEvents: false,\n previousPosition: new Vec3(),\n previousRotation: new Quat(),\n currentPosition: new Vec3(),\n currentRotation: new Quat(),\n halfExtents: boundsOf(colliders, scale),\n staticVersion: entity.transform.worldMatrixVersion,\n reportedMove: false,\n placedVersion: entity.transform.worldMatrixVersion,\n placedScale: scale.clone(),\n disconnects: [],\n };\n readNodePose(node, record.currentPosition, record.currentRotation);\n record.previousPosition.copyFrom(record.currentPosition);\n record.previousRotation.copyFrom(record.currentRotation);\n\n this.#byEntity.set(entity, record);\n this.#byNode.set(node, record);\n this.#applyCollisionEvents(record);\n this.#watchEntity(record);\n this.#observer?.added(body);\n return record;\n }\n\n /**\n * Keeps a record in step with its entity: component changes rebuild, destruction removes.\n *\n * @param record - The record to watch.\n */\n #watchEntity(record: BodyRecord): void {\n const entity = record.entity;\n record.disconnects.push(\n entity.onComponentAdded.connect((component: Component): void => {\n this.#onComponentChanged(record, component);\n }),\n entity.onComponentRemoved.connect((component: Component): void => {\n this.#onComponentChanged(record, component);\n }),\n entity.onDestroyed.connect((): void => {\n this.#removeRecord(entity);\n }),\n );\n }\n\n /**\n * Builds the shapes for a body: one shape for a single collider, or a container holding a child\n * per collider. The root shape is the **last** entry.\n *\n * @param colliders - The colliders, in component order.\n * @param scale - The entity's lossy scale.\n * @param node - The entity's Lite node.\n * @param layer - The entity's layer.\n * @returns Every shape created, root last, for release when the body goes.\n */\n #buildShapeTree(colliders: readonly Collider[], scale: Vec3, node: LiteSceneNode, layer: number): LitePhysicsShape[] {\n const defaults = this.#settings.defaultMaterial;\n const shapes: LitePhysicsShape[] = [];\n const only = colliders.length === 1 ? colliders[0] : undefined;\n if (only !== undefined) {\n shapes.push(this.#buildShape(only, scale, node, layer, defaults));\n return shapes;\n }\n const root = createContainer(this.#world);\n try {\n for (const collider of colliders) {\n const child = this.#buildShape(collider, scale, node, layer, defaults);\n shapes.push(child);\n addContainerChild(this.#world, root, child, Vec3.zero(), Quat.identity());\n }\n } catch (error: unknown) {\n // A collider that cannot be built releases the shapes its siblings already made.\n destroyShape(this.#world, root);\n for (const shape of shapes) {\n destroyShape(this.#world, shape);\n }\n throw error;\n }\n setShapeFilter(this.#world, root, membershipOf(layer), this.#collideMaskOf(layer));\n shapes.push(root);\n return shapes;\n }\n\n /**\n * Creates the Havok body for a record and applies its motion-dependent settings.\n *\n * @param node - The entity's Lite node.\n * @param root - The root shape.\n * @param rigidbody - The `Rigidbody`, or `null` for an implicit static body.\n * @param motion - The motion type derived from the rigidbody.\n * @returns The body.\n */\n #createBody(\n node: LiteSceneNode,\n root: LitePhysicsShape,\n rigidbody: Rigidbody | null,\n motion: BodyMotion,\n ): LitePhysicsBody {\n const body = createBody(this.#world, node, motion, rigidbody?.startAsleep ?? false);\n setBodyShape(this.#world, body, root);\n if (motion === BodyMotion.dynamic) {\n setBodyMass(this.#world, body, rigidbody?.mass ?? 1);\n }\n if (motion === BodyMotion.kinematic) {\n setBodyPrestep(body, rigidbody?.kinematicSync === \"velocity\" ? PrestepMode.velocity : PrestepMode.teleport);\n }\n if (rigidbody !== null) {\n setRotationLocks(this.#world, body, lockedAxes(rigidbody));\n }\n return body;\n }\n\n /**\n * Builds one collider's shape and applies its filter, material, and trigger flag.\n *\n * @param collider - The collider.\n * @param scale - The entity's lossy scale.\n * @param node - The entity's node.\n * @param layer - The entity's layer.\n * @param defaults - The world's default material.\n * @returns The shape.\n */\n #buildShape(\n collider: Collider,\n scale: Vec3Like,\n node: LiteSceneNode,\n layer: number,\n defaults: PhysicsMaterialValues,\n ): LitePhysicsShape {\n // The layer is resolved first, so an undeclared one throws before a shape exists to leak.\n const effective = this.#layerOf(collider, layer);\n const shape = collider.createShape(this.#world, scale, node);\n setShapeFilter(this.#world, shape, membershipOf(effective), this.#collideMaskOf(effective));\n const material = collider.resolveMaterial(defaults);\n setShapeMaterial(this.#world, shape, material.friction, material.restitution, material.staticFriction);\n if (collider.isTrigger) {\n setShapeTrigger(this.#world, shape, true);\n }\n return shape;\n }\n\n /**\n * The layer a collider filters as: its override, or its entity's.\n *\n * @param collider - The collider.\n * @param fallback - The entity's layer.\n * @returns The layer index.\n * @throws IgnifxError with code `IGX-0905` when the override names an undeclared layer.\n */\n #layerOf(collider: Collider, fallback: number): number {\n if (collider.layerOverride === \"\") {\n return fallback;\n }\n const index = this.#ctx.app.world.layers.indexOf(collider.layerOverride);\n if (index < 0) {\n throw unknownLayer(collider.layerOverride);\n }\n return index;\n }\n\n /**\n * The collide mask of a layer.\n *\n * @param layer - The layer index.\n * @returns The 32-bit mask.\n */\n #collideMaskOf(layer: number): number {\n return this.#collideMasks[layer] ?? ~0;\n }\n\n /**\n * Whether a body's display pose is interpolated.\n *\n * @param rigidbody - The `Rigidbody`, or `null`.\n * @param motion - The motion type.\n * @returns `true` when interpolation applies.\n */\n #shouldInterpolate(rigidbody: Rigidbody | null, motion: BodyMotion): boolean {\n if (this.#isEditMode || !this.#settings.interpolation || motion === BodyMotion.static || rigidbody === null) {\n return false;\n }\n return rigidbody.interpolation === \"interpolate\";\n }\n\n /**\n * Recomputes `collisionEvents` when a component joins or leaves the entity (`09-physics.md` §2.1).\n *\n * @param record - The body record.\n * @param component - The component that changed.\n */\n #onComponentChanged(record: BodyRecord, component: Component): void {\n if (component instanceof Collider || component instanceof Rigidbody) {\n this.markDirty(record.entity);\n return;\n }\n this.#applyCollisionEvents(record);\n }\n\n /**\n * Pushes the effective `collisionEvents` value to Havok.\n *\n * @param record - The body record.\n */\n #applyCollisionEvents(record: BodyRecord): void {\n const mode = record.rigidbody?.collisionEvents ?? \"auto\";\n const enabled = mode === \"on\" ? true : mode === \"off\" ? false : this.#entityWantsCollisions(record.entity);\n if (enabled !== record.collisionEvents) {\n record.collisionEvents = enabled;\n setBodyCollisionEvents(this.#world, record.body, enabled);\n }\n }\n\n /**\n * Whether any script on an entity implements a collision callback.\n *\n * @param entity - The entity.\n * @returns `true` when at least one does.\n */\n #entityWantsCollisions(entity: Entity): boolean {\n return (\n this.#ctx.entityImplements(entity, \"onCollisionEnter\") ||\n this.#ctx.entityImplements(entity, \"onCollisionStay\") ||\n this.#ctx.entityImplements(entity, \"onCollisionExit\")\n );\n }\n\n /**\n * Applies a runtime `entity.layer` change to the filter masks, which `09-physics.md` §3 says\n * happens on the next fixed step.\n */\n #syncLayers(): void {\n for (let index = 0; index < this.#records.length; index += 1) {\n const record = this.#records[index];\n if (record === undefined || record.entity.layer === record.layer) {\n continue;\n }\n // Rewriting a shape's filter masks in place does **not** move a body between broadphase\n // groups in @babylonjs/havok@1.3.14 — neither on its own nor with the shape re-attached\n // (measured: a resting body kept colliding with a layer its new mask excludes). The body is\n // therefore rebuilt, which is still \"on the next fixed step\" as `09-physics.md` §3 promises;\n // `#rebuildEntity` carries the velocities across so the change is not felt as a teleport.\n this.markDirty(record.entity);\n }\n // A capsule's layer only steers queries: Lite builds its shape with every filter bit set and\n // gives no access to it, so there is nothing to rebuild.\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record !== undefined) {\n record.layer = record.entity.layer;\n }\n }\n }\n\n /**\n * Snapshots every body's authoritative pose and reports implicit-static bodies that moved.\n *\n * @param fixedDeltaSeconds - The fixed step, used to probe controller support.\n */\n #snapshot(fixedDeltaSeconds: number): void {\n let active = 0;\n for (let index = 0; index < this.#records.length; index += 1) {\n const record = this.#records[index];\n if (record === undefined) {\n continue;\n }\n record.previousPosition.copyFrom(record.currentPosition);\n record.previousRotation.copyFrom(record.currentRotation);\n readNodePose(record.node, record.currentPosition, record.currentRotation);\n if (record.motion === BodyMotion.dynamic && !nearlyEqual(record.previousPosition, record.currentPosition)) {\n active += 1;\n }\n if (record.rigidbody === null) {\n this.#checkStaticMove(record);\n }\n }\n this.#activeBodies = active;\n this.#snapshotControllers(fixedDeltaSeconds);\n }\n\n /**\n * Reports `IGX-0901` once for an implicit static body whose transform moved.\n *\n * @param record - The body record.\n */\n #checkStaticMove(record: BodyRecord): void {\n const version = record.entity.transform.worldMatrixVersion;\n if (version === record.staticVersion || record.reportedMove) {\n return;\n }\n record.staticVersion = version;\n record.reportedMove = true;\n this.#ctx.log.warn(\n `${PhysicsErrorCode.movedStaticBody}: {entity} has colliders but no Rigidbody, and it moved after its static body was placed.`,\n record.entity.name,\n );\n }\n\n /**\n * Reads every controller's resolved position into the entity transform and probes its support.\n *\n * @param fixedDeltaSeconds - The fixed step.\n */\n #snapshotControllers(fixedDeltaSeconds: number): void {\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record === undefined) {\n continue;\n }\n record.previousPosition.copyFrom(record.currentPosition);\n readControllerPosition(record.controller, record.currentPosition);\n const state = probeSupport(record.controller, fixedDeltaSeconds, this.#settings.gravity, this.#scratchVector);\n record.component.applyStepResult(supportName(state), this.#scratchVector);\n this.#writeControllerTransform(record, record.currentPosition);\n }\n }\n\n /**\n * Hands every controller its accumulated displacement.\n *\n * @param fixedDeltaSeconds - The fixed step, unused by `moveWithCollisions` but kept for symmetry.\n */\n #applyControllerMoves(fixedDeltaSeconds: number): void {\n void fixedDeltaSeconds;\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record === undefined) {\n continue;\n }\n moveController(record.controller, record.component.takePendingMove());\n }\n }\n\n /**\n * Writes a controller's capsule centre back onto its entity, undoing the component's `center`.\n *\n * @param record - The controller record.\n * @param centre - The capsule centre in world space.\n */\n #writeControllerTransform(record: ControllerRecord, centre: Vec3Like): void {\n const component = record.component;\n this.#scratchOther.set(centre.x - component.center.x, centre.y - component.center.y, centre.z - component.center.z);\n component.transform.position = this.#scratchOther;\n }\n\n /**\n * Builds or rebuilds one controller.\n *\n * @param component - The controller component.\n */\n #rebuildController(component: CharacterController): void {\n this.releaseController(component);\n if (component.isDestroyed || !component.isEnabledInHierarchy) {\n return;\n }\n const position = component.transform.position;\n const centre = new Vec3(\n position.x + component.center.x,\n position.y + component.center.y,\n position.z + component.center.z,\n );\n const controller = createController(this.#world, centre, component.height, component.radius);\n tuneController(\n controller,\n Math.cos((component.slopeLimit * Math.PI) / 180),\n component.skinWidth,\n component.pushStrength * DEFAULT_CHARACTER_STRENGTH,\n );\n const record: ControllerRecord = {\n component,\n controller,\n node: controllerNode(controller),\n entity: component.entity,\n colliders: NO_COLLIDERS,\n layer: component.entity.layer,\n halfExtents: capsuleHalfExtents(component.height, component.radius, new Vec3()),\n previousPosition: centre.clone(),\n currentPosition: centre.clone(),\n interpolate: !this.#isEditMode && this.#settings.interpolation && component.interpolation === \"interpolate\",\n placedVersion: component.transform.worldMatrixVersion,\n disconnect: (): void => {\n // Replaced immediately below; a record is never observed with this placeholder.\n },\n };\n record.disconnect = onControllerPush(controller, (push: CharacterPush): void => {\n this.#reportPush(record, push);\n });\n this.#controllers.push(record);\n this.#controllersByNode.set(record.node, record);\n }\n\n /**\n * Turns one Lite push event into a `CharacterCollision`.\n *\n * @param record - The controller record.\n * @param push - What Lite reported.\n */\n #reportPush(record: ControllerRecord, push: CharacterPush): void {\n record.component.reportPush({\n other: this.recordOfNode(push.node)?.entity ?? null,\n impulse: push.impulse,\n point: push.point,\n });\n }\n\n /**\n * The runtime state of a controller component.\n *\n * @param component - The component.\n * @returns The record, or `null`.\n */\n #controllerOf(component: CharacterController): ControllerRecord | null {\n for (let index = 0; index < this.#controllers.length; index += 1) {\n const record = this.#controllers[index];\n if (record?.component === component) {\n return record;\n }\n }\n return null;\n }\n\n /**\n * Buffers a trigger event. It runs inside `stepScene`, so it only records.\n *\n * @param event - What Lite reported.\n */\n #bufferTrigger(event: TriggerRecord): void {\n const slot = this.#triggerSlot(this.#triggerCount);\n slot.entered = event.entered;\n slot.first = this.recordOfNode(event.nodeA);\n slot.second = this.recordOfNode(event.nodeB);\n this.#triggerCount += 1;\n }\n\n /**\n * Buffers a collision event.\n *\n * @param event - What the collision drain reported.\n */\n #bufferContact(event: ContactRecord): void {\n const slot = this.#contactSlot(this.#contactCount);\n slot.phase = event.phase;\n slot.point.set(event.point.x, event.point.y, event.point.z);\n slot.normal.set(event.normal.x, event.normal.y, event.normal.z);\n slot.impulse = event.impulse;\n slot.first = this.recordOfNode(event.nodeA);\n slot.second = this.recordOfNode(event.nodeB);\n this.#contactCount += 1;\n }\n\n /**\n * Grows the trigger pool on demand and returns one slot.\n *\n * @param index - The slot index.\n * @returns The slot.\n */\n #triggerSlot(index: number): TriggerSlot {\n let slot = this.#triggerSlots[index];\n if (slot === undefined) {\n slot = { entered: false, first: null, second: null };\n this.#triggerSlots.push(slot);\n }\n return slot;\n }\n\n /**\n * Grows the contact pool on demand and returns one slot.\n *\n * @param index - The slot index.\n * @returns The slot.\n */\n #contactSlot(index: number): ContactSlot {\n let slot = this.#contactSlots[index];\n if (slot === undefined) {\n slot = { phase: 0, point: new Vec3(), normal: new Vec3(), impulse: 0, first: null, second: null };\n this.#contactSlots.push(slot);\n }\n return slot;\n }\n\n /** Delivers the buffered trigger events to both participants' scripts. */\n #dispatchTriggers(): void {\n this.#triggerEventCount += this.#triggerCount;\n for (let index = 0; index < this.#triggerCount; index += 1) {\n const slot = this.#triggerSlots[index];\n if (slot === undefined) {\n continue;\n }\n const kind: PhysicsCallbackName = slot.entered ? \"onTriggerEnter\" : \"onTriggerExit\";\n this.#deliverTrigger(slot.first, slot.second, kind);\n this.#deliverTrigger(slot.second, slot.first, kind);\n }\n }\n\n /**\n * Delivers one trigger event to one entity.\n *\n * @param target - The record whose scripts receive it, or `null`.\n * @param other - The other participant, or `null`.\n * @param kind - Which callback to deliver.\n */\n #deliverTrigger(target: BodyRecord | null, other: BodyRecord | null, kind: PhysicsCallbackName): void {\n if (target === null || target.entity.isDestroyed) {\n return;\n }\n const event: MutableTriggerEvent = (this.#triggerEvent ??= {\n other: null,\n otherCollider: null,\n self: target.entity,\n });\n event.self = target.entity;\n event.other = other?.entity ?? null;\n event.otherCollider = other?.colliders[0] ?? null;\n this.#ctx.dispatchScriptCallback(target.entity, kind, event);\n }\n\n /** Delivers the buffered collision events. */\n #dispatchContacts(): void {\n this.#collisionEventCount += this.#contactCount;\n for (let index = 0; index < this.#contactCount; index += 1) {\n const slot = this.#contactSlots[index];\n if (slot === undefined) {\n continue;\n }\n const kind = contactCallback(slot.phase);\n this.#deliverContact(slot, slot.first, slot.second, kind);\n this.#deliverContact(slot, slot.second, slot.first, kind);\n }\n }\n\n /**\n * Delivers one collision to one entity.\n *\n * @param slot - The buffered contact.\n * @param target - The record whose scripts receive it, or `null`.\n * @param other - The other participant, or `null`.\n * @param kind - Which callback to deliver.\n */\n #deliverContact(\n slot: ContactSlot,\n target: BodyRecord | null,\n other: BodyRecord | null,\n kind: PhysicsCallbackName,\n ): void {\n if (target === null || target.entity.isDestroyed || !target.collisionEvents) {\n return;\n }\n this.#contactPoint.point.copyFrom(slot.point);\n this.#contactPoint.normal.copyFrom(slot.normal);\n this.#contactPoint.impulse = slot.impulse;\n const collision: MutableCollision = (this.#collision ??= {\n other: null,\n otherCollider: null,\n self: target.entity,\n contacts: this.#contacts,\n relativeVelocity: null,\n });\n collision.self = target.entity;\n collision.other = other?.entity ?? null;\n collision.otherCollider = other?.colliders[0] ?? null;\n collision.relativeVelocity = other === null ? null : this.#relativeVelocityOf(target, other);\n this.#ctx.dispatchScriptCallback(target.entity, kind, collision);\n }\n\n /**\n * The relative velocity of two bodies at the moment of a contact.\n *\n * @param target - The receiving body.\n * @param other - The other body.\n * @returns A pooled vector.\n */\n #relativeVelocityOf(target: BodyRecord, other: BodyRecord): Vec3Like {\n readLinearVelocity(this.#world, target.body, this.#scratchVector);\n readLinearVelocity(this.#world, other.body, this.#scratchOther);\n this.#relativeVelocity.set(\n this.#scratchVector.x - this.#scratchOther.x,\n this.#scratchVector.y - this.#scratchOther.y,\n this.#scratchVector.z - this.#scratchOther.z,\n );\n return this.#relativeVelocity;\n }\n\n /**\n * Releases one record's Lite resources and signal connections.\n *\n * @param record - The record to tear down.\n */\n #teardown(record: BodyRecord): void {\n for (const disconnect of record.disconnects) {\n disconnect();\n }\n record.disconnects = [];\n this.#observer?.removed(record.body);\n destroyBody(this.#world, record.body);\n for (let index = record.shapes.length - 1; index >= 0; index -= 1) {\n const shape = record.shapes[index];\n if (shape !== undefined) {\n destroyShape(this.#world, shape);\n }\n }\n record.shapes = [];\n }\n}\n\n/** Lite's own `characterStrength` default, which `pushStrength: 1` reproduces (`index.d.ts` 8320). */\nconst DEFAULT_CHARACTER_STRENGTH = 1e38;\n\n/** The collider list of a character capsule, which is built from the controller, not from colliders. */\nconst NO_COLLIDERS: readonly Collider[] = Object.freeze([]);\n\n/**\n * The half-extents of a controller capsule's bounding box. Lite places the capsule's segment ends at\n * `±(height / 2 - radius)` (`createPhysicsCharacterController`), and the capsule does not scale with\n * the entity.\n *\n * @param height - The capsule's total height.\n * @param radius - Its radius.\n * @param out - The vector to write.\n * @returns `out`.\n */\nfunction capsuleHalfExtents(height: number, radius: number, out: Vec3): Vec3 {\n return out.set(radius, Math.abs(height / 2 - radius) + radius, radius);\n}\n\n/**\n * The colliders that make up an entity's body: every enabled `Collider` on the entity itself.\n *\n * @param entity - The entity.\n * @returns The colliders, in component order.\n */\nfunction collidersOf(entity: Entity): readonly Collider[] {\n const found: Collider[] = [];\n const components = entity.components;\n for (let index = 0; index < components.length; index += 1) {\n const component = components[index];\n if (component instanceof Collider && component.enabled && !component.isDestroyed) {\n found.push(component);\n }\n }\n return found;\n}\n\n/**\n * The motion type a `Rigidbody` asks for.\n *\n * @param rigidbody - The component, or `null` for the implicit static body.\n * @returns The Lite motion type.\n */\nfunction motionOf(rigidbody: Rigidbody | null): BodyMotion {\n if (rigidbody === null || rigidbody.bodyType === \"static\") {\n return BodyMotion.static;\n }\n return rigidbody.bodyType === \"kinematic\" ? BodyMotion.kinematic : BodyMotion.dynamic;\n}\n\n/**\n * The rotation axes a `Rigidbody` freezes.\n *\n * @param rigidbody - The component.\n * @returns The locked axes, in a stable order.\n */\nfunction lockedAxes(rigidbody: Rigidbody): readonly (\"x\" | \"y\" | \"z\")[] {\n const locked: (\"x\" | \"y\" | \"z\")[] = [];\n if (rigidbody.freezeRotation.x) {\n locked.push(\"x\");\n }\n if (rigidbody.freezeRotation.y) {\n locked.push(\"y\");\n }\n if (rigidbody.freezeRotation.z) {\n locked.push(\"z\");\n }\n return locked;\n}\n\n/**\n * The membership mask of a layer (`09-physics.md` §3).\n *\n * @param layer - The layer index.\n * @returns `1 << layer`.\n */\nfunction membershipOf(layer: number): number {\n return 1 << layer;\n}\n\n/**\n * The half-extents of the union of an entity's colliders, for the bounds index.\n *\n * @param colliders - The colliders.\n * @param scale - The entity's lossy scale.\n * @returns A fresh vector.\n */\nfunction boundsOf(colliders: readonly Collider[], scale: Vec3Like): Vec3 {\n const bounds = new Vec3();\n const scratch = new Vec3();\n for (let index = 0; index < colliders.length; index += 1) {\n const collider = colliders[index];\n if (collider === undefined) {\n continue;\n }\n collider.halfExtentsToRef(scale, scratch);\n bounds.set(\n Math.max(bounds.x, Math.abs(collider.center.x * scale.x) + scratch.x),\n Math.max(bounds.y, Math.abs(collider.center.y * scale.y) + scratch.y),\n Math.max(bounds.z, Math.abs(collider.center.z * scale.z) + scratch.z),\n );\n }\n return bounds;\n}\n\n/**\n * Which callback a contact phase maps to.\n *\n * @param phase - `0` started, `1` continued, `2` finished.\n * @returns The callback name.\n */\nfunction contactCallback(phase: number): PhysicsCallbackName {\n if (phase === CONTACT_STARTED) {\n return \"onCollisionEnter\";\n }\n return phase === CONTACT_FINISHED ? \"onCollisionExit\" : \"onCollisionStay\";\n}\n\n/**\n * The name of a Lite support state.\n *\n * @param state - Lite's value.\n * @returns The ignifx name.\n */\nfunction supportName(state: number): SupportStateName {\n if (state === SupportState.supported) {\n return \"supported\";\n }\n return state === SupportState.sliding ? \"sliding\" : \"unsupported\";\n}\n\n/**\n * Whether two positions are the same to within the static-move epsilon.\n *\n * @param first - The first position.\n * @param second - The second position.\n * @returns `true` when they match.\n */\nfunction nearlyEqual(first: Vec3Like, second: Vec3Like): boolean {\n return (\n Math.abs(first.x - second.x) < STATIC_MOVE_EPSILON &&\n Math.abs(first.y - second.y) < STATIC_MOVE_EPSILON &&\n Math.abs(first.z - second.z) < STATIC_MOVE_EPSILON\n );\n}\n\n/**\n * A monotonic millisecond reading for the `stepMs` counter. It never feeds the simulation, so it\n * does not break the \"no wall-clock reads\" rule of `09-physics.md` §8.\n *\n * @returns Milliseconds since the process started.\n */\nfunction now(): number {\n return performance.now();\n}\n\n/**\n * Builds the \"that is not a layer\" failure.\n *\n * @param name - The offending layer name.\n * @returns The error to throw.\n */\nfunction unknownLayer(name: string): ReturnType<typeof physicsError> {\n return physicsError(PhysicsErrorCode.unknownLayer, `${name} is not a layer this project declares.`, {\n context: { layer: name },\n hint: \"Add the layer to the layers settings section, or fix the name in physics.collisionMatrix.\",\n });\n}\n","import type { PhysicsHost } from \"./host.js\";\nimport type { System, SystemContext } from \"@ignifx/core\";\n\n/**\n * The three systems `docs/architecture/01-lifecycle-and-time.md` §3 and `09-physics.md` §1 put\n * physics in the frame with:\n *\n * ```\n * Systems(FixedUpdate, -100) restore the authoritative pose of interpolated bodies\n * scripts.fixedUpdate(dt) forces, velocities, CharacterController.move()\n * Systems(FixedUpdate, 100) step Havok, snapshot poses, dispatch collision and trigger events\n * ── the fixed loop ends; time.fixedStepAlpha is final ──\n * Systems(Update, -900) write lerp(prev, cur, time.fixedStepAlpha)\n * scripts.update / lateUpdate, animation, rendering — all read the display pose\n * ```\n *\n * **Why the display pose is written at the top of `Update` and not in `PreRender`** (2026-09-08).\n * It used to be written in `PreRender`, after `lateUpdate`. Camera rigs run in `lateUpdate`, so they\n * framed the character where the last fixed step left it while the renderer drew it at\n * `lerp(prev, cur, alpha)`: up to one fixed step of motion of relative judder every frame, which is\n * exactly what a follow camera makes visible. Writing the pose before `scripts.update` means every\n * consumer of a transform outside the fixed loop — scripts, animation, camera rigs, the render sync\n * — sees the same pose the frame presents, which is Unity's model. The simulation is unaffected:\n * the restore system at `FixedUpdate −100` runs before `scripts.fixedUpdate`, so `fixedUpdate` and\n * Havok still see the authoritative pose.\n *\n * Everything here is `@internal`.\n */\n\n/** The `FixedUpdate` order the restore system runs at. */\nexport const PHYSICS_RESTORE_ORDER = -100;\n\n/** The `FixedUpdate` order the step system runs at. */\nexport const PHYSICS_STEP_ORDER = 100;\n\n/**\n * The `Update` order the interpolation system runs at. Negative, so it lands in\n * `Systems(Update, order < 0)` — after the fixed loop and lifecycle flush B, before\n * `scripts.update` — and low enough that a game's own `Update` systems can still be ordered in\n * front of it if they must see the authoritative pose.\n */\nexport const PHYSICS_INTERPOLATE_ORDER = -900;\n\n/**\n * Undoes the display pose the interpolation system wrote at the top of the previous `Update`, so\n * `fixedUpdate` and Havok both see the authoritative pose (spike S4.3).\n *\n * @internal\n */\nexport class PhysicsRestoreSystem implements System {\n /** The name diagnostics and error reports use. */\n readonly name = \"physics-restore\";\n\n readonly #host: PhysicsHost;\n\n /**\n * Binds the system to the runtime holder.\n *\n * @param host - The holder the runtime lands in.\n */\n constructor(host: PhysicsHost) {\n this.#host = host;\n }\n\n /** Restores every interpolated body's authoritative pose. */\n update(): void {\n this.#host.runtime?.restorePoses();\n }\n}\n\n/**\n * Steps Havok once, snapshots the poses, and dispatches the step's events.\n *\n * @internal\n */\nexport class PhysicsStepSystem implements System {\n /** The name diagnostics and error reports use. */\n readonly name = \"physics-step\";\n\n readonly #host: PhysicsHost;\n\n /**\n * Binds the system to the runtime holder.\n *\n * @param host - The holder the runtime lands in.\n */\n constructor(host: PhysicsHost) {\n this.#host = host;\n }\n\n /**\n * Runs one fixed step.\n *\n * @param ctx - The world, clock, phase, and fixed delta.\n */\n update(ctx: SystemContext): void {\n this.#host.runtime?.step(ctx.dt);\n }\n}\n\n/**\n * Writes the interpolated display pose once per frame.\n *\n * @internal\n */\nexport class PhysicsInterpolationSystem implements System {\n /** The name diagnostics and error reports use. */\n readonly name = \"physics-interpolate\";\n\n readonly #host: PhysicsHost;\n\n /**\n * Binds the system to the runtime holder.\n *\n * @param host - The holder the runtime lands in.\n */\n constructor(host: PhysicsHost) {\n this.#host = host;\n }\n\n /**\n * Writes `lerp(prev, cur, alpha)` into every interpolated body's node.\n *\n * @param ctx - The world, clock, phase, and frame delta.\n */\n update(ctx: SystemContext): void {\n this.#host.runtime?.interpolate(ctx.time.fixedStepAlpha);\n }\n}\n\n/**\n * Where the edit-mode sync system runs: in `PreRender`, after every script, tween and animation of\n * the frame has moved what it moves, and before the render sync, so the debug viewer draws bodies\n * where the frame shows their entities.\n */\nexport const PHYSICS_EDIT_SYNC_ORDER = -800;\n\n/**\n * Keeps the bodies of an edit-mode app in line with the world, without stepping\n * (ADR-0028, amendment of 2026-10-20). It is registered only in an edit-mode app, so a game never\n * pays for it.\n *\n * @internal\n */\nexport class PhysicsEditSyncSystem implements System {\n /** The name diagnostics and error reports use. */\n readonly name = \"physics-edit-sync\";\n\n readonly #host: PhysicsHost;\n\n /**\n * Binds the system to the runtime holder.\n *\n * @param host - The holder the runtime lands in.\n */\n constructor(host: PhysicsHost) {\n this.#host = host;\n }\n\n /** Builds, re-places, and removes bodies for this frame's changes. */\n update(): void {\n this.#host.runtime?.syncEditMode();\n }\n}\n","import { createPhysicsViewer, disposePhysicsViewer, hidePhysicsBody, showPhysicsBody } from \"@babylonjs/lite\";\nimport type { LitePhysicsBody, LitePhysicsWorld } from \"../havok.js\";\nimport type { PhysicsViewer } from \"@babylonjs/lite\";\nimport type { LiteScene } from \"@ignifx/core\";\n\n/**\n * The debug-viewer half of this package's Babylon Lite adapter\n * (`docs/architecture/09-physics.md` §9).\n *\n * `createPhysicsViewer(scene, world)` (`index.d.ts` 2909) draws wireframe bodies **into the scene it\n * is given**, and `showPhysicsBody` (11580) builds a `Mesh` per body — which needs a GPU device, so\n * the viewer targets the **render** scene and is refused on a headless app.\n *\n * The module sits under `src/lite/gpu/` for the same reason `@ignifx/core`'s does: every line of it\n * needs `engine._device`, so it is unreachable from the Vitest `node` project and is covered by the\n * browser one instead. `vitest.config.ts` already excludes every package's `src/lite/gpu`\n * directory from the unit-run coverage report.\n *\n * Everything here is `@internal`.\n */\n\n/**\n * Lite's viewer handle.\n *\n * @internal\n */\nexport type LitePhysicsViewer = PhysicsViewer;\n\n/**\n * Creates a viewer on the render scene.\n *\n * @param scene - The render scene the wireframes are drawn into.\n * @param world - The Havok world being visualised.\n * @returns The viewer handle.\n *\n * @internal\n */\nexport function createViewer(scene: LiteScene, world: LitePhysicsWorld): LitePhysicsViewer {\n return createPhysicsViewer(scene, world);\n}\n\n/**\n * Starts drawing one body.\n *\n * @param viewer - The viewer.\n * @param body - The body to show.\n *\n * @internal\n */\nexport function showBody(viewer: LitePhysicsViewer, body: LitePhysicsBody): void {\n showPhysicsBody(viewer, body);\n}\n\n/**\n * Stops drawing one body and disposes its debug mesh. A body the viewer is not drawing is ignored.\n *\n * @param viewer - The viewer.\n * @param body - The body to hide.\n *\n * @internal\n */\nexport function hideBody(viewer: LitePhysicsViewer, body: LitePhysicsBody): void {\n hidePhysicsBody(viewer, body);\n}\n\n/**\n * Disposes every debug mesh and unregisters the viewer's update hook.\n *\n * @param viewer - The viewer.\n *\n * @internal\n */\nexport function destroyViewer(viewer: LitePhysicsViewer): void {\n disposePhysicsViewer(viewer);\n}\n","import { physicsRaycast, shapeCast, shapeProximity } from \"@babylonjs/lite\";\nimport type { LitePhysicsBody, LitePhysicsShape, LitePhysicsWorld } from \"./havok.js\";\nimport type { LiteSceneNode, MutableVec3, QuatLike, Vec3Like } from \"@ignifx/core\";\n\n/**\n * The query half of this package's Babylon Lite adapter (`docs/architecture/09-physics.md` §5).\n *\n * ## What Lite 1.27.0 actually returns (verified in `lib/physics/havok-queries.js`)\n *\n * - `physicsRaycast` (`index.d.ts` 8577) is the **only** query that reports a body: it resolves the\n * native id through `findBodyById` and returns `RaycastResult.body` (9388).\n * - `shapeCast` (11479) returns `fraction`, two contact points, and two normals — and **no body**\n * (`ShapeCastResult`, 11497).\n * - `shapeProximity` (11524) returns the single **closest** hit within `maxDistance`, also with no\n * body (`ShapeProximityResult`, 11540); the collector it uses is created with capacity `1`\n * (`getCollector`, `havok-queries.js:7`), so it can never report more than one hit.\n *\n * `09-physics.md` §5 promises `shapeCast(...) : ShapeCastHit` and `overlap(...) : Entity[]`. Neither\n * identity is available upstream, so `PhysicsService` resolves those two against its own body index\n * (bounds-accurate) and the doc correction is recorded in the Phase 4 report. Everything here stays\n * a thin, typed pass-through.\n *\n * Everything here is `@internal`.\n */\n\n/** What a ray query answered. */\nexport interface RayQueryResult {\n /** Whether the ray hit anything. */\n hit: boolean;\n /** The node of the body that was hit, or `null`. */\n node: LiteSceneNode | null;\n /** Distance from the origin to the contact, in metres. */\n distance: number;\n /** The triangle index on a `MESH` shape, or `-1`. */\n triangleIndex: number;\n}\n\n/**\n * Casts a ray and writes the contact into out parameters (coding standards §7: no allocation on a\n * query path beyond Lite's own result object).\n *\n * @param world - The world handle.\n * @param from - The world-space origin.\n * @param to - The world-space end point.\n * @param membership - The querying mask; `~0` for \"belongs to everything\".\n * @param collideWith - The mask of layers the ray may hit.\n * @param hitTriggers - Whether trigger volumes count as hits.\n * @param point - Written with the contact point.\n * @param normal - Written with the contact normal.\n * @param out - Written with the hit flag, node, distance, and triangle index.\n *\n * @internal\n */\nexport function castRay(\n world: LitePhysicsWorld,\n from: Vec3Like,\n to: Vec3Like,\n membership: number,\n collideWith: number,\n hitTriggers: boolean,\n point: MutableVec3,\n normal: MutableVec3,\n out: RayQueryResult,\n): void {\n const result = physicsRaycast(\n world,\n { x: from.x, y: from.y, z: from.z },\n { x: to.x, y: to.y, z: to.z },\n { membership, collideWith, shouldHitTriggers: hitTriggers },\n );\n out.hit = result.hasHit;\n out.node = bodyNodeOf(result.body);\n out.distance = result.hitDistance;\n out.triangleIndex = result.triangleIndex;\n point.set(result.hitPoint.x, result.hitPoint.y, result.hitPoint.z);\n normal.set(result.hitNormal.x, result.hitNormal.y, result.hitNormal.z);\n}\n\n/** What a shape sweep answered. */\nexport interface SweepQueryResult {\n /** Whether the swept shape hit anything. */\n hit: boolean;\n /** The fraction along the sweep where contact first occurs, in `[0, 1]`. */\n fraction: number;\n}\n\n/**\n * Sweeps a shape from one position to another.\n *\n * @param world - The world handle.\n * @param shape - The shape to sweep.\n * @param rotation - The orientation held constant during the sweep.\n * @param from - The start position.\n * @param to - The end position.\n * @param hitTriggers - Whether trigger volumes count as hits.\n * @param ignoreBody - One body the sweep passes through, or `null`. Lite's `ShapeCastQuery` takes\n * exactly one (`ignoreBody`, `index.d.ts` 11494) and — unlike `physicsRaycast` — no\n * `membership`/`collideWith` pair, so this is the only filtering a sweep can do inside Havok; a\n * layer mask is applied to the *attribution* of the hit by the service, never to the sweep.\n * @param point - Written with the contact point on the hit body.\n * @param normal - Written with the contact normal on the hit body.\n * @param out - Written with the hit flag and the sweep fraction.\n *\n * @internal\n */\nexport function sweepShape(\n world: LitePhysicsWorld,\n shape: LitePhysicsShape,\n rotation: QuatLike,\n from: Vec3Like,\n to: Vec3Like,\n hitTriggers: boolean,\n ignoreBody: LitePhysicsBody | null,\n point: MutableVec3,\n normal: MutableVec3,\n out: SweepQueryResult,\n): void {\n const result = shapeCast(world, {\n shape,\n rotation: { x: rotation.x, y: rotation.y, z: rotation.z, w: rotation.w },\n startPosition: { x: from.x, y: from.y, z: from.z },\n endPosition: { x: to.x, y: to.y, z: to.z },\n shouldHitTriggers: hitTriggers,\n ...(ignoreBody === null ? {} : { ignoreBody }),\n });\n out.hit = result.hasHit;\n out.fraction = result.fraction;\n point.set(result.hitPoint.x, result.hitPoint.y, result.hitPoint.z);\n normal.set(result.hitNormal.x, result.hitNormal.y, result.hitNormal.z);\n}\n\n/**\n * Finds the distance from a positioned shape to the nearest body, which is what Lite's\n * `shapeProximity` reports. It is used as a cheap \"is anything in range at all\" test; the entities\n * themselves come from the service's own body index.\n *\n * @param world - The world handle.\n * @param shape - The query shape.\n * @param position - Its world position.\n * @param rotation - Its world rotation.\n * @param maxDistance - How far to search.\n * @param hitTriggers - Whether trigger volumes count.\n * @returns The distance to the nearest body, or `Number.POSITIVE_INFINITY` when nothing is in range.\n *\n * @internal\n */\nexport function nearestDistance(\n world: LitePhysicsWorld,\n shape: LitePhysicsShape,\n position: Vec3Like,\n rotation: QuatLike,\n maxDistance: number,\n hitTriggers: boolean,\n): number {\n const result = shapeProximity(world, {\n shape,\n position: { x: position.x, y: position.y, z: position.z },\n rotation: { x: rotation.x, y: rotation.y, z: rotation.z, w: rotation.w },\n maxDistance,\n shouldHitTriggers: hitTriggers,\n });\n return result.hasHit ? result.distance : Number.POSITIVE_INFINITY;\n}\n\n/**\n * Reads the node off an optional body handle.\n *\n * @param body - The body Lite reported, or `null`.\n * @returns The node, or `null`.\n */\nfunction bodyNodeOf(body: LitePhysicsBody | null): LiteSceneNode | null {\n return body === null ? null : body.node;\n}\n","import { Quat, Vec3 } from \"@ignifx/core\";\nimport { Collider } from \"./components/collider.js\";\nimport { PhysicsErrorCode, physicsError } from \"./errors.js\";\nimport { createViewer, destroyViewer, hideBody, showBody } from \"./lite/gpu/viewer.js\";\nimport { createShape, destroyShape, ShapeGeometry } from \"./lite/havok.js\";\nimport { castRay, nearestDistance, sweepShape } from \"./lite/queries.js\";\nimport { placeOutline } from \"./runtime/outline.js\";\nimport type { LitePhysicsViewer } from \"./lite/gpu/viewer.js\";\nimport type { LitePhysicsBody, LitePhysicsShape, LitePhysicsWorld } from \"./lite/havok.js\";\nimport type { RayQueryResult, SweepQueryResult } from \"./lite/queries.js\";\nimport type { QueryOptions, QueryShape, RaycastHit, ShapeCastHit, ShapeCastOptions } from \"./queries.js\";\nimport type { QueryTarget } from \"./runtime/body-record.js\";\nimport type { PhysicsHost } from \"./runtime/host.js\";\nimport type { PhysicsRuntime } from \"./runtime/runtime.js\";\nimport type { PhysicsSettings } from \"./settings.js\";\nimport type { App, Entity, LiteScene, Vec3Like } from \"@ignifx/core\";\n\n/**\n * `app.physics` (`docs/architecture/09-physics.md` §5, §6, §9): gravity, the queries, the debug\n * viewer, and the Babylon Lite escape hatch.\n */\n\n/** How far a ray travels when the caller names no distance, in metres. */\nconst DEFAULT_RAY_DISTANCE = 1e4;\n\n/** How far past a skipped character capsule's surface a ray resumes, in metres. */\nconst RAY_RESUME_DISTANCE = 1e-3;\n\n/** How much slack the bounds index allows when it resolves a sweep contact to an entity. */\nconst BOUNDS_EPSILON = 1e-3;\n\n/** Every bit set: the mask a query uses when the caller names no layers. */\nconst ALL_LAYERS = ~0;\n\n/**\n * The Babylon Lite objects the physics extension owns. Unstable escape hatch\n * (`docs/architecture/00-overview.md` §3).\n *\n * @public\n */\nexport interface PhysicsLiteHandles {\n /** Lite's Havok world handle. */\n readonly world: LitePhysicsWorld;\n /** The null-engine scene the world is stepped on; also `world.lite.simulationScene`. */\n readonly simulationScene: LiteScene;\n}\n\n/**\n * The wireframe overlay `@ignifx/devtools` toggles (`09-physics.md` §9).\n *\n * @public\n */\nexport interface PhysicsDebugViewer {\n /**\n * Whether Lite's physics viewer is drawing the bodies into the **render** scene. It needs a GPU\n * device, so switching it on in a headless app is a no-op that logs a warning.\n */\n enabled: boolean;\n}\n\n/**\n * One collider's outline, from `app.physics.colliderOutlines`: what an editor draws as a collider\n * gizmo (ADR-0028, amendment of 2026-10-20).\n *\n * @public\n */\nexport interface ColliderOutline {\n /** The collider the outline is of. */\n readonly collider: Collider;\n /** Whether the collider is a trigger, which an editor usually draws in another colour. */\n readonly isTrigger: boolean;\n /**\n * The outline as world-space line segments: every six numbers are one segment, the `x, y, z` of\n * its two ends, in metres.\n */\n readonly lines: Float32Array;\n}\n\n/**\n * The service behind `app.physics`.\n *\n * @example\n * ```ts\n * const hit = app.physics.raycast({ x: 0, y: 10, z: 0 }, { x: 0, y: -1, z: 0 }, 20);\n * if (hit !== null) {\n * app.log.info(`ray hit ${hit.entity.name} at ${String(hit.point.y)}`);\n * }\n * ```\n *\n * @public\n */\nexport class PhysicsService {\n readonly #app: App;\n\n readonly #host: PhysicsHost;\n\n readonly #gravity = new Vec3();\n\n readonly #rayResult: RayQueryResult = { hit: false, node: null, distance: 0, triangleIndex: -1 };\n\n readonly #sweepResult: SweepQueryResult = { hit: false, fraction: 0 };\n\n readonly #point = new Vec3();\n\n readonly #normal = new Vec3();\n\n readonly #rayFrom = new Vec3();\n\n readonly #overlapExtents = new Vec3();\n\n readonly #overlapResults: Entity[] = [];\n\n readonly #debugViewer: PhysicsDebugViewer;\n\n #viewer: LitePhysicsViewer | null = null;\n\n /**\n * Wraps the holder the extension fills in from `onStart`.\n *\n * @param app - The app the service belongs to.\n * @param host - The holder the runtime lands in.\n * @param settings - The resolved `physics` settings section.\n *\n * @internal\n */\n constructor(app: App, host: PhysicsHost, settings: PhysicsSettings) {\n this.#app = app;\n this.#host = host;\n const gravity = settings.gravity;\n this.#gravity.set(gravity.x, gravity.y, gravity.z);\n this.#debugViewer = new DebugViewerToggle(this);\n }\n\n /**\n * World gravity in metres per second squared.\n *\n * @returns A live view; writing to it does nothing, assign the property instead.\n */\n get gravity(): Vec3 {\n return this.#gravity;\n }\n\n /**\n * Replaces world gravity, which every body feels from the next fixed step.\n *\n * @param value - The new acceleration vector, in metres per second squared.\n */\n set gravity(value: Vec3Like) {\n this.#gravity.set(value.x, value.y, value.z);\n this.#rt().setGravity(this.#gravity);\n }\n\n /**\n * The wireframe overlay.\n *\n * @returns The viewer toggle.\n */\n get debugViewer(): PhysicsDebugViewer {\n return this.#debugViewer;\n }\n\n /**\n * The Babylon Lite handles.\n *\n * @returns The Havok world and the simulation scene.\n */\n get lite(): PhysicsLiteHandles {\n return { world: this.#rt().world, simulationScene: this.#app.world.lite.simulationScene ?? this.#app.lite.scene };\n }\n\n /**\n * Casts a ray and returns the first entity it hits (`09-physics.md` §5).\n *\n * @remarks\n * The ray hits `Rigidbody` and collider-only bodies and `CharacterController` capsules. A capsule\n * hit reports the character's entity with `collider: null`. A ray passes through a capsule when\n * `layerMask` leaves out the character's layer, or when the ray starts inside it.\n *\n * @param origin - The world-space origin.\n * @param direction - The direction; it is normalised for you.\n * @param maxDistance - How far to travel; defaults to 10 km.\n * @param options - Layer mask and trigger behaviour.\n * @returns The hit, or `null` when the ray clears everything.\n * @throws IgnifxError with code `IGX-0902` in development when no fixed step has run yet, outside\n * edit mode.\n */\n raycast(\n origin: Vec3Like,\n direction: Vec3Like,\n maxDistance: number = DEFAULT_RAY_DISTANCE,\n options?: QueryOptions,\n ): RaycastHit | null {\n this.#requireStep(\"raycast\");\n const runtime = this.#rt();\n runtime.countQuery();\n const length = Math.hypot(direction.x, direction.y, direction.z);\n if (length === 0) {\n return null;\n }\n const scale = maxDistance / length;\n const to = {\n x: origin.x + direction.x * scale,\n y: origin.y + direction.y * scale,\n z: origin.z + direction.z * scale,\n };\n const from = this.#rayFrom.set(origin.x, origin.y, origin.z);\n let travelled = 0;\n // Havok filters bodies by layer itself, but a character capsule is in every layer: Lite builds\n // its shape with all filter bits set and gives no access to it. So a ray whose mask excludes a\n // character resumes just inside the capsule, where Havok does not report it again. Each pass\n // skips at least one capsule, which bounds the loop.\n for (let pass = 0; pass <= runtime.queryTargetCount; pass += 1) {\n castRay(\n runtime.world,\n from,\n to,\n ALL_LAYERS,\n maskOf(options),\n options?.hitTriggers === true,\n this.#point,\n this.#normal,\n this.#rayResult,\n );\n if (!this.#rayResult.hit) {\n return null;\n }\n const target = runtime.targetOfNode(this.#rayResult.node);\n if (target === null) {\n return null;\n }\n if (this.#accepts(target, options)) {\n return {\n entity: target.entity,\n collider: target.colliders[0] ?? null,\n point: this.#point.clone(),\n normal: this.#normal.clone(),\n distance: travelled + this.#rayResult.distance,\n triangleIndex: this.#rayResult.triangleIndex,\n };\n }\n travelled += this.#rayResult.distance + RAY_RESUME_DISTANCE;\n if (travelled >= maxDistance) {\n return null;\n }\n const step = RAY_RESUME_DISTANCE / length;\n from.set(\n this.#point.x + direction.x * step,\n this.#point.y + direction.y * step,\n this.#point.z + direction.z * step,\n );\n }\n return null;\n }\n\n /**\n * Sweeps a shape and returns the first contact (`09-physics.md` §5).\n *\n * @remarks\n * Lite's `shapeCast` reports no body (`index.d.ts` 11497), so `entity` is resolved against the\n * extension's body-bounds index and is bounds-accurate rather than shape-accurate. The index holds\n * every `Rigidbody` and collider-only body and every `CharacterController` capsule; a capsule\n * contact reports the character's entity with `collider: null`.\n *\n * The sweep itself cannot be filtered by layer — Lite's `ShapeCastQuery` carries no collision\n * masks — so a body outside `layerMask` still stops the sweep; it is merely reported with\n * `entity: null`. What the sweep *can* do is pass through one body, `options.ignore`, which is\n * how a camera boom leaves its target's capsule and a step probe leaves the character's own feet\n * without reporting them at fraction zero (2026-09-08).\n *\n * @param shape - The shape to sweep.\n * @param from - The start position.\n * @param to - The end position.\n * @param options - Layer mask, trigger behaviour, and the one entity to sweep through.\n * @returns The hit, or `null`.\n * @throws IgnifxError with code `IGX-0902` in development when no fixed step has run yet, outside\n * edit mode.\n */\n shapeCast(shape: QueryShape, from: Vec3Like, to: Vec3Like, options?: ShapeCastOptions): ShapeCastHit | null {\n this.#requireStep(\"shapeCast\");\n this.#rt().countQuery();\n const ignored = options?.ignore ?? null;\n const ignoredBody = ignored === null ? null : this.#rt().bodyOf(ignored);\n const handle = this.#buildQueryShape(shape);\n try {\n sweepShape(\n this.#rt().world,\n handle,\n Quat.identity(),\n from,\n to,\n options?.hitTriggers === true,\n ignoredBody,\n this.#point,\n this.#normal,\n this.#sweepResult,\n );\n } finally {\n destroyShape(this.#rt().world, handle);\n }\n if (!this.#sweepResult.hit) {\n return null;\n }\n const target = this.#targetAt(this.#point, options, ignored);\n const distance = Math.hypot(to.x - from.x, to.y - from.y, to.z - from.z) * this.#sweepResult.fraction;\n return {\n entity: target?.entity ?? null,\n collider: target?.colliders[0] ?? null,\n point: this.#point.clone(),\n normal: this.#normal.clone(),\n fraction: this.#sweepResult.fraction,\n distance,\n };\n }\n\n /**\n * Lists the entities a positioned shape overlaps (`09-physics.md` §5).\n *\n * @remarks\n * Lite's `shapeProximity` reports one hit and no identity (`index.d.ts` 11540,\n * `lib/physics/havok-queries.js:7`), so this is answered from the extension's own bounds index:\n * every `Rigidbody`, collider-only body and `CharacterController` capsule whose world bounding box\n * intersects the query shape's. It is conservative — a body whose box overlaps but whose shape\n * does not is listed.\n *\n * @param shape - The query shape.\n * @param position - Its world position.\n * @param rotation - Its world rotation; accepted for forward compatibility and currently unused,\n * because the bounds test is axis-aligned.\n * @param options - Layer mask and trigger behaviour.\n * @returns The overlapping entities, each once: bodies in creation order, then characters in\n * creation order. The array is reused between calls.\n * @throws IgnifxError with code `IGX-0902` in development when no fixed step has run yet, outside\n * edit mode.\n */\n overlap(shape: QueryShape, position: Vec3Like, rotation?: Quat, options?: QueryOptions): readonly Entity[] {\n void rotation;\n this.#requireStep(\"overlap\");\n const runtime = this.#rt();\n runtime.countQuery();\n queryHalfExtents(shape, this.#overlapExtents);\n const results = this.#overlapResults;\n results.length = 0;\n const count = runtime.queryTargetCount;\n for (let index = 0; index < count; index += 1) {\n const target = runtime.queryTargetAt(index);\n if (target === undefined || !this.#accepts(target, options)) {\n continue;\n }\n if (\n boxesOverlap(position, this.#overlapExtents, target.currentPosition, target.halfExtents) &&\n // An entity can carry both a body and a character controller.\n !results.includes(target.entity)\n ) {\n results.push(target.entity);\n }\n }\n return results;\n }\n\n /**\n * How far the nearest body is from a positioned shape, which is the one thing Lite's\n * `shapeProximity` answers exactly.\n *\n * @param shape - The query shape.\n * @param position - Its world position.\n * @param maxDistance - How far to search.\n * @param options - Trigger behaviour.\n * @returns The distance, or `Number.POSITIVE_INFINITY` when nothing is in range.\n * @throws IgnifxError with code `IGX-0902` in development when no fixed step has run yet, outside\n * edit mode.\n */\n distanceToNearest(shape: QueryShape, position: Vec3Like, maxDistance: number, options?: QueryOptions): number {\n this.#requireStep(\"distanceToNearest\");\n this.#rt().countQuery();\n const handle = this.#buildQueryShape(shape);\n try {\n return nearestDistance(\n this.#rt().world,\n handle,\n position,\n Quat.identity(),\n maxDistance,\n options?.hitTriggers === true,\n );\n } finally {\n destroyShape(this.#rt().world, handle);\n }\n }\n\n /**\n * Shows or hides Lite's wireframe bodies.\n *\n * @param enabled - Whether the viewer draws.\n */\n setDebugViewerEnabled(enabled: boolean): void {\n if (enabled === (this.#viewer !== null) || (enabled && this.#host.runtime === null)) {\n return;\n }\n if (!enabled) {\n if (this.#viewer !== null) {\n this.#host.runtime?.setBodyObserver(null);\n destroyViewer(this.#viewer);\n this.#viewer = null;\n }\n return;\n }\n if (this.#app.isHeadless) {\n this.#app.log.warn(\"The physics debug viewer needs a GPU device; a headless app has none.\");\n return;\n }\n const runtime = this.#rt();\n const viewer = createViewer(this.#app.lite.scene, runtime.world);\n this.#viewer = viewer;\n const records = runtime.records;\n for (let index = 0; index < records.length; index += 1) {\n const record = records[index];\n if (record !== undefined) {\n showBody(viewer, record.body);\n }\n }\n // Bodies built or rebuilt later are drawn too, and removed ones stop drawing. A re-placed body\n // keeps the mesh drawn for the body it replaced, which follows the node, so dragging a body in\n // an editor rebuilds no debug mesh; `shown` maps each current body to the one the viewer knows.\n const shown = new Map<LitePhysicsBody, LitePhysicsBody>();\n runtime.setBodyObserver({\n added: (body): void => {\n showBody(viewer, body);\n },\n removed: (body): void => {\n hideBody(viewer, shown.get(body) ?? body);\n shown.delete(body);\n },\n replaced: (previous, next): void => {\n shown.set(next, shown.get(previous) ?? previous);\n shown.delete(previous);\n },\n });\n }\n\n /**\n * The outlines of an entity's enabled colliders, as world-space line segments: what an editor\n * draws as collider gizmos (ADR-0028, amendment of 2026-10-20).\n *\n * @remarks\n * Each outline is built from the collider's fields, the entity's world pose, and its lossy scale,\n * the same inputs Havok's shape is built from, so it works in any app, headless included, and\n * before the first step. A box draws its edges; a sphere its three great circles; a capsule and a\n * cylinder their end rings, sides, and (for a capsule) caps; a `HeightfieldCollider` the bounding\n * box of its samples. A `MeshCollider` has no outline, because its triangles live on the GPU: its\n * `lines` is empty, and an editor draws the mesh's own wireframe instead.\n *\n * @param entity - The entity whose colliders to outline.\n * @returns One outline per enabled collider, in component order; empty when it has none or the\n * entity is inactive in the hierarchy, which builds no body.\n *\n * @example\n * ```ts\n * for (const outline of app.physics.colliderOutlines(selected)) {\n * drawLines(outline.lines, outline.isTrigger ? \"orange\" : \"green\");\n * }\n * ```\n */\n colliderOutlines(entity: Entity): readonly ColliderOutline[] {\n const outlines: ColliderOutline[] = [];\n if (entity.isDestroyed || !entity.activeInHierarchy) {\n return outlines;\n }\n const transform = entity.transform;\n const position = transform.position;\n const rotation = transform.rotation;\n const scale = transform.lossyScale;\n const local: number[] = [];\n for (const component of entity.components) {\n if (!(component instanceof Collider) || !component.enabled) {\n continue;\n }\n local.length = 0;\n component.outlineToRef(scale, local);\n outlines.push({\n collider: component,\n isTrigger: component.isTrigger,\n lines: placeOutline(local, position, rotation),\n });\n }\n return outlines;\n }\n\n /**\n * Whether the viewer is currently drawing.\n *\n * @returns `true` when a viewer exists.\n */\n isDebugViewerEnabled(): boolean {\n return this.#viewer !== null;\n }\n\n /** Releases the viewer, if one is up. Called from the extension's `dispose`. */\n dispose(): void {\n this.setDebugViewerEnabled(false);\n }\n\n /**\n * The runtime, once `onStart` has built it.\n *\n * @returns The runtime.\n * @throws IgnifxError with code `IGX-0903` when Havok has not finished loading, which is only\n * reachable from an extension `onStart` that runs before this one.\n */\n #rt(): PhysicsRuntime {\n const runtime = this.#host.runtime;\n if (runtime === null) {\n throw physicsError(PhysicsErrorCode.havokUnavailable, \"The physics world does not exist yet.\", {\n hint: \"app.physics is usable from the first frame onwards; await app.start() first.\",\n });\n }\n return runtime;\n }\n\n /**\n * Whether at least one fixed step has completed, which is when Havok has built its broadphase and\n * queries become legal (`09-physics.md` §5). A script that queries from `lateUpdate` or `update`\n * checks this on the first frame, where the fixed loop may not have run yet, instead of catching\n * `IGX-0902`. An edit-mode app never steps, so this stays `false` there, and its queries answer\n * anyway (ADR-0028, amendment of 2026-10-20).\n *\n * @returns `true` once the first step has run.\n */\n get hasStepped(): boolean {\n return this.#rt().hasStepped;\n }\n\n /**\n * Refuses a query that ran before Havok built its broadphase (`09-physics.md` §5). In an\n * edit-mode app, which never steps, it brings the bodies in line with the world instead, so the\n * query sees what the editor shows (ADR-0028, amendment of 2026-10-20).\n *\n * @param query - The query name, for the diagnostic.\n * @throws IgnifxError with code `IGX-0902` when no step has completed, outside edit mode.\n */\n #requireStep(query: string): void {\n const runtime = this.#rt();\n if (runtime.isEditMode) {\n runtime.syncEditMode();\n return;\n }\n if (runtime.hasStepped) {\n return;\n }\n throw physicsError(PhysicsErrorCode.queryBeforeStep, `${query}() ran before the first fixed step.`, {\n context: { query },\n hint: \"Step the app at least once (app.step(1 / 60)) before querying; Havok builds its broadphase in the first step.\",\n });\n }\n\n /**\n * Builds a temporary Havok shape for one query. Query shapes are not a per-frame path, so the\n * allocation is deliberate and the shape is released in a `finally`.\n *\n * @param shape - The description.\n * @returns The shape handle.\n */\n #buildQueryShape(shape: QueryShape): LitePhysicsShape {\n const world = this.#rt().world;\n if (shape.kind === \"sphere\") {\n return createShape(world, ShapeGeometry.sphere, { radius: shape.radius });\n }\n if (shape.kind === \"box\") {\n return createShape(world, ShapeGeometry.box, {\n extents: shape.size,\n center: { x: 0, y: 0, z: 0 },\n rotation: Quat.identity(),\n });\n }\n const half = Math.max(0, shape.height / 2 - shape.radius);\n return createShape(world, ShapeGeometry.capsule, {\n radius: shape.radius,\n pointA: { x: 0, y: -half, z: 0 },\n pointB: { x: 0, y: half, z: 0 },\n });\n }\n\n /**\n * Resolves a world-space point to the body whose bounds contain it.\n *\n * @param point - The point.\n * @param options - Layer mask and trigger behaviour.\n * @param ignored - The entity the sweep was told to pass through, which can therefore not be the\n * one it hit.\n * @returns The body or capsule, or `null`.\n */\n #targetAt(point: Vec3Like, options: QueryOptions | undefined, ignored: Entity | null = null): QueryTarget | null {\n const runtime = this.#rt();\n const count = runtime.queryTargetCount;\n let best: QueryTarget | null = null;\n let bestDistance = Number.POSITIVE_INFINITY;\n for (let index = 0; index < count; index += 1) {\n const target = runtime.queryTargetAt(index);\n if (target === undefined || target.entity === ignored || !this.#accepts(target, options)) {\n continue;\n }\n const centre = target.currentPosition;\n const extents = target.halfExtents;\n if (\n Math.abs(point.x - centre.x) > extents.x + BOUNDS_EPSILON ||\n Math.abs(point.y - centre.y) > extents.y + BOUNDS_EPSILON ||\n Math.abs(point.z - centre.z) > extents.z + BOUNDS_EPSILON\n ) {\n continue;\n }\n const distance = Math.hypot(point.x - centre.x, point.y - centre.y, point.z - centre.z);\n if (distance < bestDistance) {\n bestDistance = distance;\n best = target;\n }\n }\n return best;\n }\n\n /**\n * Whether a body or capsule passes a query's layer and trigger filters.\n *\n * @param target - The body or capsule.\n * @param options - The query options.\n * @returns `true` when it may be reported.\n */\n #accepts(target: QueryTarget, options: QueryOptions | undefined): boolean {\n if ((maskOf(options) & (1 << target.layer)) === 0) {\n return false;\n }\n return options?.hitTriggers === true || !allTriggers(target.colliders);\n }\n}\n\n/**\n * The `{ enabled }` object `app.physics.debugViewer` hands out: a property pair rather than two\n * methods, because that is how `09-physics.md` §9 and `@ignifx/devtools` name it.\n */\nclass DebugViewerToggle implements PhysicsDebugViewer {\n readonly #service: PhysicsService;\n\n /**\n * Binds the toggle to its service.\n *\n * @param service - The service that owns the viewer.\n */\n constructor(service: PhysicsService) {\n this.#service = service;\n }\n\n /**\n * Whether the viewer is drawing.\n *\n * @returns `true` when a viewer is up.\n */\n get enabled(): boolean {\n return this.#service.isDebugViewerEnabled();\n }\n\n set enabled(value: boolean) {\n this.#service.setDebugViewerEnabled(value);\n }\n}\n\n/**\n * The 32-bit layer mask a query filters with.\n *\n * @param options - The query options.\n * @returns The mask; every bit when the caller named none.\n */\nfunction maskOf(options: QueryOptions | undefined): number {\n return options?.layerMask?.bits ?? ALL_LAYERS;\n}\n\n/**\n * Whether every collider of a body is a trigger, which is what makes the body a trigger volume.\n *\n * @param colliders - The body's colliders.\n * @returns `true` when they are all triggers.\n */\nfunction allTriggers(colliders: readonly Collider[]): boolean {\n if (colliders.length === 0) {\n return false;\n }\n for (let index = 0; index < colliders.length; index += 1) {\n if (colliders[index]?.isTrigger !== true) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * The half-extents of a query shape's bounding box.\n *\n * @param shape - The description.\n * @param out - The vector to write.\n */\nfunction queryHalfExtents(shape: QueryShape, out: Vec3): void {\n if (shape.kind === \"sphere\") {\n out.set(shape.radius, shape.radius, shape.radius);\n return;\n }\n if (shape.kind === \"box\") {\n out.set(shape.size.x / 2, shape.size.y / 2, shape.size.z / 2);\n return;\n }\n out.set(shape.radius, Math.max(shape.radius, shape.height / 2), shape.radius);\n}\n\n/**\n * Whether two axis-aligned boxes overlap.\n *\n * @param firstCentre - The first box's centre.\n * @param firstExtents - The first box's half-extents.\n * @param secondCentre - The second box's centre.\n * @param secondExtents - The second box's half-extents.\n * @returns `true` when they intersect.\n */\nfunction boxesOverlap(\n firstCentre: Vec3Like,\n firstExtents: Vec3Like,\n secondCentre: Vec3Like,\n secondExtents: Vec3Like,\n): boolean {\n return (\n Math.abs(firstCentre.x - secondCentre.x) <= firstExtents.x + secondExtents.x &&\n Math.abs(firstCentre.y - secondCentre.y) <= firstExtents.y + secondExtents.y &&\n Math.abs(firstCentre.z - secondCentre.z) <= firstExtents.z + secondExtents.z\n );\n}\n","import { array, bool, defineSchema, f32, map, record, str, vec3 } from \"@ignifx/core\";\nimport type { Schema, Vec3Like } from \"@ignifx/core\";\n\n/**\n * The `physics` project settings section (`docs/architecture/09-physics.md` §6). `fixedDeltaTime` is\n * **not** here: the fixed step is shared with the core `time` section, and the extension reads it\n * from `app.time.fixedDeltaTime` on every step so a game that changes it at runtime keeps Lite's\n * per-step delta in sync.\n */\n\n/**\n * The section name as it appears in `ignifx.config.ts`.\n *\n * @public\n */\nexport const PHYSICS_SETTINGS_SECTION = \"physics\";\n\n/**\n * The value {@link PhysicsSettings.havokWasm} carries when the address comes from the manifest.\n *\n * @public\n */\nexport const HAVOK_WASM_AUTO = \"auto\";\n\n/**\n * A surface material, either as the `physics.defaultMaterial` setting or inline on a collider\n * (`09-physics.md` §2.2, §2.4).\n *\n * @public\n */\nexport interface PhysicsMaterialValues {\n /** The dynamic friction coefficient. */\n readonly friction: number;\n /** The static friction coefficient. */\n readonly staticFriction: number;\n /** How much of the approach speed is returned, `0` to `1`. */\n readonly restitution: number;\n}\n\n/**\n * The world-wide speed clamps Havok applies (`setPhysicsVelocityLimits`, `index.d.ts` 10880). A\n * value of `0` means \"leave Havok's own default alone\".\n *\n * @public\n */\nexport interface VelocityLimitSettings {\n /** Maximum linear speed in metres per second, or `0` for Havok's default. */\n readonly linear: number;\n /** Maximum angular speed in radians per second, or `0` for Havok's default. */\n readonly angular: number;\n}\n\n/**\n * The resolved `physics` settings section.\n *\n * @example\n * ```ts\n * // ignifx.config.ts\n * export default {\n * layers: { layers: [\"Default\", \"Player\", \"Enemy\"] },\n * physics: {\n * gravity: { x: 0, y: -9.81, z: 0 },\n * collisionMatrix: { Player: [\"Default\", \"Enemy\"], Enemy: [\"Default\"] },\n * },\n * };\n * ```\n *\n * @public\n */\nexport interface PhysicsSettings {\n /** World gravity in metres per second squared. */\n readonly gravity: Vec3Like;\n /**\n * Which layers each layer collides with. A layer the map does not mention collides with\n * everything, which is what makes the default project need no matrix at all.\n */\n readonly collisionMatrix: Readonly<Record<string, readonly string[]>>;\n /** The material a collider with no material of its own uses. */\n readonly defaultMaterial: PhysicsMaterialValues;\n /** The world speed clamps. */\n readonly velocityLimits: VelocityLimitSettings;\n /** Whether dynamic bodies and character controllers interpolate between fixed steps. */\n readonly interpolation: boolean;\n /** `\"auto\"` to resolve `HavokPhysics.wasm` through the asset manifest, or an explicit URL. */\n readonly havokWasm: string;\n}\n\n/** Standard gravity, matching Lite's own Havok default. */\nconst DEFAULT_GRAVITY: Vec3Like = Object.freeze({ x: 0, y: -9.81, z: 0 });\n\n/** The default surface: ordinary friction, no bounce. */\nconst DEFAULT_MATERIAL: PhysicsMaterialValues = Object.freeze({\n friction: 0.6,\n staticFriction: 0.6,\n restitution: 0,\n});\n\n/** No clamps beyond Havok's own. */\nconst DEFAULT_VELOCITY_LIMITS: VelocityLimitSettings = Object.freeze({ linear: 0, angular: 0 });\n\n/** An empty matrix, which means \"everything collides with everything\". */\nconst DEFAULT_COLLISION_MATRIX: Readonly<Record<string, readonly string[]>> = Object.freeze({});\n\n/**\n * Builds the schema the `physics` section is validated against.\n *\n * @remarks\n * It is a function, not a module-level constant: every field kind is a function call, and module\n * scope holds declarations and immutable constants only (`CONSTITUTION.md` §3.5).\n *\n * @returns The schema.\n *\n * @public\n */\nexport function physicsSettingsSchema(): Schema {\n return defineSchema({\n gravity: vec3(DEFAULT_GRAVITY),\n collisionMatrix: map(array(str())),\n defaultMaterial: record({\n friction: f32(DEFAULT_MATERIAL.friction, { min: 0 }),\n staticFriction: f32(DEFAULT_MATERIAL.staticFriction, { min: 0 }),\n restitution: f32(DEFAULT_MATERIAL.restitution, { min: 0, max: 1 }),\n }),\n velocityLimits: record({\n linear: f32(DEFAULT_VELOCITY_LIMITS.linear, { min: 0 }),\n angular: f32(DEFAULT_VELOCITY_LIMITS.angular, { min: 0 }),\n }),\n interpolation: bool(true),\n havokWasm: str(HAVOK_WASM_AUTO),\n });\n}\n\n/**\n * The values used when a project omits the `physics` section.\n *\n * @returns A fresh defaults object.\n *\n * @public\n */\nexport function defaultPhysicsSettings(): PhysicsSettings {\n return {\n gravity: DEFAULT_GRAVITY,\n collisionMatrix: DEFAULT_COLLISION_MATRIX,\n defaultMaterial: DEFAULT_MATERIAL,\n velocityLimits: DEFAULT_VELOCITY_LIMITS,\n interpolation: true,\n havokWasm: HAVOK_WASM_AUTO,\n };\n}\n","import { defineExtension, Phase } from \"@ignifx/core\";\nimport { CharacterController } from \"./components/character-controller.js\";\nimport {\n BoxCollider,\n CapsuleCollider,\n CylinderCollider,\n HeightfieldCollider,\n MeshCollider,\n SphereCollider,\n} from \"./components/colliders.js\";\nimport { Rigidbody } from \"./components/rigidbody.js\";\nimport { PHYSICS_ERROR_MESSAGES } from \"./errors.js\";\nimport { HAVOK_WASM_FILE_NAME, loadHavok } from \"./lite/havok-module.js\";\nimport { createSimulation, createWorld, disposeSimulation } from \"./lite/havok.js\";\nimport { createPhysicsMaterialLoader } from \"./material.js\";\nimport { PhysicsHost } from \"./runtime/host.js\";\nimport { PhysicsHostKey } from \"./runtime/runtime-key.js\";\nimport { PhysicsRuntime, PHYSICS_DIAGNOSTICS_COUNTERS, PHYSICS_DIAGNOSTICS_GROUP } from \"./runtime/runtime.js\";\nimport {\n PHYSICS_EDIT_SYNC_ORDER,\n PHYSICS_INTERPOLATE_ORDER,\n PHYSICS_RESTORE_ORDER,\n PHYSICS_STEP_ORDER,\n PhysicsEditSyncSystem,\n PhysicsInterpolationSystem,\n PhysicsRestoreSystem,\n PhysicsStepSystem,\n} from \"./runtime/systems.js\";\nimport { PhysicsService } from \"./service.js\";\nimport {\n defaultPhysicsSettings,\n HAVOK_WASM_AUTO,\n PHYSICS_SETTINGS_SECTION,\n physicsSettingsSchema,\n} from \"./settings.js\";\nimport type { Collider } from \"./components/collider.js\";\nimport type { PhysicsSettings } from \"./settings.js\";\nimport type { App, ComponentType, ConcreteComponentType, Extension, ExtensionContext } from \"@ignifx/core\";\n\n/**\n * Create the physics runtime in `onStart`, after the world and its layer table exist.\n * The Vite plugin copies `HavokPhysics.wasm` into public assets under its base name.\n * Headless loading falls back to the installed Havok package.\n */\n\n/**\n * What `physics()` accepts.\n *\n * @public\n */\nexport interface PhysicsOptions {\n /** An already-instantiated Havok module, which skips loading entirely. */\n readonly havok?: unknown;\n /** The `HavokPhysics.wasm` bytes, for a host that reads them itself. */\n readonly wasmBinary?: ArrayBuffer;\n}\n\ndeclare module \"@ignifx/core\" {\n interface App {\n /** 3D physics: gravity, queries, the debug viewer, and the Lite escape hatch. */\n readonly physics: PhysicsService;\n }\n}\n\n/**\n * Builds the physics extension.\n *\n * @param options - The collision-identity mode and, optionally, where Havok comes from.\n * @returns The extension descriptor.\n *\n * @example\n * ```ts\n * const app = await createApp({ headless: true, extensions: [physics()] });\n * ```\n *\n * @public\n */\n// `defineExtension` calls the factory with `undefined` when a game writes `physics()`, so the\n// default parameter is load-bearing even though the declared type is not nullish\n// (`packages/core/src/extension/define-extension.ts`).\n// oxlint-disable-next-line typescript/no-useless-default-assignment\nexport const physics: (options?: PhysicsOptions) => Extension = defineExtension<PhysicsOptions>((options = {}) => {\n const host = new PhysicsHost();\n let context: ExtensionContext | null = null;\n let service: PhysicsService | null = null;\n\n return {\n name: \"@ignifx/physics\",\n version: \"0.0.0\",\n engine: \">=0.0.0 <1.0.0\",\n requires: [],\n optional: [\"@ignifx/devtools\"],\n\n register(ctx: ExtensionContext): void {\n context = ctx;\n ctx.registerErrorCodes(PHYSICS_ERROR_MESSAGES);\n ctx.registerSettings<PhysicsSettings>(\n PHYSICS_SETTINGS_SECTION,\n physicsSettingsSchema(),\n defaultPhysicsSettings(),\n );\n ctx.registerComponents(PHYSICS_COMPONENTS);\n ctx.registerAssetLoader(createPhysicsMaterialLoader());\n const settings = ctx.settings<PhysicsSettings>(PHYSICS_SETTINGS_SECTION);\n service = new PhysicsService(ctx.app, host, settings);\n ctx.registerService(PhysicsHostKey, host);\n ctx.registerService(PhysicsService, service);\n ctx.defineAppProperty(\"physics\", (): unknown => service);\n // None of the three runs in edit mode: an editor's scene view never simulates, and the\n // interpolation would overwrite a transform the editor just moved (ADR-0028).\n ctx.registerSystem(new PhysicsRestoreSystem(host), {\n phase: Phase.FixedUpdate,\n order: PHYSICS_RESTORE_ORDER,\n editMode: \"skip\",\n });\n ctx.registerSystem(new PhysicsStepSystem(host), {\n phase: Phase.FixedUpdate,\n order: PHYSICS_STEP_ORDER,\n editMode: \"skip\",\n });\n // `Update`, not `PreRender`: camera rigs and scripts must read the same pose the renderer\n // draws (`runtime/systems.ts`, `docs/architecture/01-lifecycle-and-time.md` §3).\n ctx.registerSystem(new PhysicsInterpolationSystem(host), {\n phase: Phase.Update,\n order: PHYSICS_INTERPOLATE_ORDER,\n editMode: \"skip\",\n });\n // An edit-mode app keeps its bodies in line with the scene instead, without stepping, so an\n // editor can query them and draw them (ADR-0028, amendment of 2026-10-20). A game never\n // registers it.\n if (ctx.app.isEditMode) {\n ctx.registerSystem(new PhysicsEditSyncSystem(host), {\n phase: Phase.PreRender,\n order: PHYSICS_EDIT_SYNC_ORDER,\n });\n }\n },\n\n async onStart(app: App): Promise<void> {\n const ctx = context;\n if (ctx === null) {\n return;\n }\n const settings = ctx.settings<PhysicsSettings>(PHYSICS_SETTINGS_SECTION);\n const havok = await loadHavok({\n ...(options.havok === undefined ? {} : { module: options.havok }),\n ...(options.wasmBinary === undefined ? {} : { wasmBinary: options.wasmBinary }),\n url: settings.havokWasm === HAVOK_WASM_AUTO ? app.assets.resolveUrl(HAVOK_WASM_FILE_NAME) : settings.havokWasm,\n });\n const simulation = createSimulation();\n let world;\n try {\n world = createWorld(simulation.scene, havok, settings.gravity);\n } catch (cause: unknown) {\n disposeSimulation(simulation);\n throw cause;\n }\n const counters = app.diagnostics.registerGroup(PHYSICS_DIAGNOSTICS_GROUP, PHYSICS_DIAGNOSTICS_COUNTERS);\n host.runtime = new PhysicsRuntime({\n ctx,\n settings,\n simulation,\n world,\n counters,\n });\n ctx.setSimulationScene(simulation.scene);\n seedExistingBodies(app, host);\n },\n\n dispose(): void {\n // The world is disposed before the extensions and has already dropped the scene; the kernel\n // treats a clear at this point as a no-op (`ExtensionContext.setSimulationScene`).\n context?.setSimulationScene(null);\n service?.dispose();\n host.runtime?.dispose();\n host.runtime = null;\n context = null;\n service = null;\n },\n };\n});\n\n/** Every component this extension registers, in a stable order. */\nconst PHYSICS_COMPONENTS: readonly ConcreteComponentType[] = Object.freeze([\n Rigidbody,\n BoxCollider,\n SphereCollider,\n CapsuleCollider,\n CylinderCollider,\n MeshCollider,\n HeightfieldCollider,\n CharacterController,\n]);\n\n/** The collider classes the seed pass walks, in registration order. */\nconst COLLIDER_TYPES: readonly ComponentType<Collider>[] = Object.freeze([\n BoxCollider,\n SphereCollider,\n CapsuleCollider,\n CylinderCollider,\n MeshCollider,\n HeightfieldCollider,\n]);\n\n/**\n * Marks every collider and controller that already exists when the runtime is built.\n *\n * @remarks\n * A component attached before `onStart` — from a scene the `assets.preload` list pulled in, say —\n * called `markDirty` while `app.services.tryGet(PhysicsRuntimeKey)` was still `null`. This is the\n * catch-up pass that makes those bodies exist, and it walks the component store in registration\n * order so body creation order stays deterministic (`09-physics.md` §8).\n *\n * @param app - The app being started.\n * @param host - The holder the runtime landed in.\n */\nfunction seedExistingBodies(app: App, host: PhysicsHost): void {\n const runtime = host.runtime;\n if (runtime === null) {\n return;\n }\n for (const type of COLLIDER_TYPES) {\n const components = app.world.components(type);\n for (let index = 0; index < components.length; index += 1) {\n const collider = components[index];\n if (collider !== undefined) {\n runtime.markDirty(collider.entity);\n }\n }\n }\n const controllers = app.world.components(CharacterController);\n for (let index = 0; index < controllers.length; index += 1) {\n const controller = controllers[index];\n if (controller !== undefined) {\n runtime.markControllerDirty(controller);\n }\n }\n}\n","import { describeSchema } from \"@ignifx/core\";\nimport { CharacterController } from \"./components/character-controller.js\";\nimport {\n BoxCollider,\n CapsuleCollider,\n CylinderCollider,\n HeightfieldCollider,\n MeshCollider,\n SphereCollider,\n} from \"./components/colliders.js\";\nimport { Rigidbody } from \"./components/rigidbody.js\";\nimport { describePhysicsMaterialFileFormat } from \"./material.js\";\nimport type { SchemaDescription } from \"@ignifx/core\";\n\n/**\n * The documentation harness's view of everything `@ignifx/physics` declares\n * (`docs/architecture/16-docs-harness-and-skill.md` §3, `scripts/README.md`).\n *\n * `pnpm docs:schemas` imports the built entry point, calls {@link describeSchemas}, and turns the\n * result into `skills/ignifx/references/formats/<format>.md`. Keys are namespaced `<package>/<Name>`\n * type ids; the file format is keyed `ignifx/physicsmaterial-file` for the same reason `@ignifx/core`\n * keys its file formats that way — the harness rejects a key with no `/` and groups pages by\n * `format`.\n */\n\n/**\n * Describes every component and file format this package declares.\n *\n * @returns The records, keyed by namespaced type id.\n *\n * @example\n * ```ts\n * const schemas = describeSchemas();\n * schemas[\"ignifx/Rigidbody\"].fields[\"mass\"].default; // 1\n * ```\n *\n * @public\n */\nexport function describeSchemas(): Readonly<Record<string, SchemaDescription>> {\n return {\n \"ignifx/Rigidbody\": describeSchema(\"ignifx/Rigidbody\", Rigidbody.schema, {\n description: \"Makes an entity's colliders a dynamic, kinematic, or static Havok body.\",\n }),\n \"ignifx/BoxCollider\": describeSchema(\"ignifx/BoxCollider\", BoxCollider.schema, {\n description: \"A box collision shape, sized in local units and scaled by the entity.\",\n }),\n \"ignifx/SphereCollider\": describeSchema(\"ignifx/SphereCollider\", SphereCollider.schema, {\n description: \"A sphere collision shape; the largest scale axis wins.\",\n }),\n \"ignifx/CapsuleCollider\": describeSchema(\"ignifx/CapsuleCollider\", CapsuleCollider.schema, {\n description: \"A capsule collision shape standing along X, Y, or Z.\",\n }),\n \"ignifx/CylinderCollider\": describeSchema(\"ignifx/CylinderCollider\", CylinderCollider.schema, {\n description: \"A cylinder collision shape standing along Y.\",\n }),\n \"ignifx/MeshCollider\": describeSchema(\"ignifx/MeshCollider\", MeshCollider.schema, {\n description: \"A triangle-mesh or convex-hull shape built from real geometry; needs a GPU app.\",\n }),\n \"ignifx/HeightfieldCollider\": describeSchema(\"ignifx/HeightfieldCollider\", HeightfieldCollider.schema, {\n description: \"A terrain collision shape built from a regular grid of height samples.\",\n }),\n \"ignifx/CharacterController\": describeSchema(\"ignifx/CharacterController\", CharacterController.schema, {\n description: \"A kinematic capsule with collide-and-slide, support detection, and body pushing.\",\n }),\n \"ignifx/physicsmaterial-file\": describePhysicsMaterialFileFormat(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,iBAA8C,iBAA8B,sBAAsB;;;;;;;;;;;;;;ACG/G,MAAa,aAAa;CAAC;CAAW;CAAa;AAAQ;;;;;;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