Skip to main content

Simulation

@zylem/game-lib


@zylem/game-lib / runtime / Simulation

Interface: Simulation

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:254

The behavior world. Construct via createSimulation.

Properties​

adapter​

readonly adapter: WasmStageRuntime

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:260

The low-level wasm adapter. Behavior systems receive this as their wasmStage context so descriptors can attach/query behaviors by slot; hosts should prefer the handle-based methods on the Simulation itself.


fixedTimestep​

readonly fixedTimestep: number

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:261

Accessors​

areEventsEnabled​

Get Signature​

get areEventsEnabled(): boolean

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:287

Returns​

boolean


entityCount​

Get Signature​

get entityCount(): number

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:288

Returns​

number


isDisposed​

Get Signature​

get isDisposed(): boolean

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:318

Returns​

boolean

Methods​

applyImpulse()​

applyImpulse(handle, x, y, z): boolean

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:303

Parameters​

handle​

EntityHandle

x​

number

y​

number

z​

number

Returns​

boolean


awakeDynamicCount()​

awakeDynamicCount(): number

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:311

Returns​

number


castRay()​

castRay(origin, dir, maxDistance, solidOnly?): Omit<StageRaycastHit, "slot"> & object | null

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:313

Physics raycast; the hit's slot is resolved to an entity handle.

Parameters​

origin​

readonly [number, number, number]

dir​

readonly [number, number, number]

maxDistance​

number

solidOnly?​

boolean

Returns​

Omit<StageRaycastHit, "slot"> & object | null


despawn()​

despawn(handle): boolean

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:276

Parameters​

handle​

EntityHandle

Returns​

boolean


dispose()​

dispose(): void

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:320

Destroy the wasm stage. The Simulation must not be used afterwards.

Returns​

void


getBodyInfo()​

getBodyInfo(handle): StageBodyInfo | null

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:316

Parameters​

handle​

EntityHandle

Returns​

StageBodyInfo | null


getDebugRender()​

getDebugRender(): StageDebugRender | null

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:317

Returns​

StageDebugRender | null


getLinearVelocity()​

getLinearVelocity(handle): [number, number, number] | null

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:301

Parameters​

handle​

EntityHandle

Returns​

[number, number, number] | null


getPose()​

getPose(handle, out?): StagePose | null

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:297

Parameters​

handle​

EntityHandle

out?​

StagePose

Returns​

StagePose | null


handleForSlot()​

handleForSlot(slot): EntityHandle | null

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:278

Resolve a raw runtime slot back to its public handle, if alive.

Parameters​

slot​

number

Returns​

EntityHandle | null


readPreviousRenderSlot()​

readPreviousRenderSlot(handle, out?): StageRenderSlot | null

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:306

Decode a handle's pose from the previous-step render copy.

Parameters​

handle​

EntityHandle

out?​

StageRenderSlot

Returns​

StageRenderSlot | null


readRenderSlot()​

readRenderSlot(handle, out?): StageRenderSlot | null

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:304

Parameters​

handle​

EntityHandle

out?​

StageRenderSlot

Returns​

StageRenderSlot | null


readSnapshot()​

readSnapshot(handle, out?): StageBehaviorSnapshot | null

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:307

Parameters​

handle​

EntityHandle

out?​

StageBehaviorSnapshot

Returns​

StageBehaviorSnapshot | null


setAngularVelocity()​

setAngularVelocity(handle, x, y, z): boolean

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:302

Parameters​

handle​

EntityHandle

x​

number

y​

number

z​

number

Returns​

boolean


setEventsEnabled()​

setEventsEnabled(enabled): void

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:286

Toggle collision-event collection. When disabled the wasm stage skips per-step contact-pair hashing and update() skips event draining / translation entirely (frame.events stays empty). Re-enabling emits collisionStarted for every currently overlapping pair on the next step, so late listeners observe current state.

Parameters​

enabled​

boolean

Returns​

void


setGravity()​

setGravity(x, y, z): void

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:308

Parameters​

x​

number

y​

number

z​

number

Returns​

void


setLinearVelocity()​

setLinearVelocity(handle, x, y, z): boolean

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:300

Parameters​

handle​

EntityHandle

x​

number

y​

number

z​

number

Returns​

boolean


setPosition()​

setPosition(handle, x, y, z): boolean

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:298

Parameters​

handle​

EntityHandle

x​

number

y​

number

z​

number

Returns​

boolean


setRotation()​

setRotation(handle, x, y, z, w): boolean

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:299

Parameters​

handle​

EntityHandle

x​

number

y​

number

z​

number

w​

number

Returns​

boolean


setSleepThresholds()​

setSleepThresholds(normalizedLinearThreshold, angularThreshold, timeUntilSleep): void

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:310

Parameters​

normalizedLinearThreshold​

number

angularThreshold​

number

timeUntilSleep​

number

Returns​

void


setSolverIterations()​

setSolverIterations(iterations): void

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:309

Parameters​

iterations​

number

Returns​

void


spawn()​

spawn(definition?): EntityHandle | null

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:275

Create a runtime entity from a plain definition. Returns null when the runtime rejects the allocation.

Parameters​

definition?​

EntityDefinition

Returns​

EntityHandle | null


update()​

update(deltaTime): SimulationFrame

Defined in: node_modules/.pnpm/@zylem+behaviors@0.8.9_@types+react@19.3.0_react@19.3.0_three@0.185.1/node_modules/@zylem/behaviors/dist/core.d.ts:294

Advance the simulation by deltaTime seconds using a fixed-timestep accumulator. Runs zero or more fixed steps and returns a SimulationFrame with translated events and interpolation data.

Parameters​

deltaTime​

number

Returns​

SimulationFrame