Skip to content

Inspector

Defined in: Inspector.ts:401

Programmatic runtime control and state queries for testing and debugging. Exposed on window.__yage__ in debug mode.

new Inspector(engine): Inspector

Defined in: Inspector.ts:711

EngineRef

Inspector

readonly capture: object

Defined in: Inspector.ts:687

dataURL: () => Promise<string>

Promise<string>

png: () => Promise<Uint8Array<ArrayBufferLike>>

Promise<Uint8Array<ArrayBufferLike>>

pngBase64: () => Promise<string>

Promise<string>


readonly events: object

Defined in: Inspector.ts:621

clearLog: () => void

void

getLog: () => EventLogEntry[]

EventLogEntry[]

isEnabled: () => boolean

boolean

setCapacity: (n) => void

number

void

setEnabled: (enabled) => void

Turn event-log recording on/off at runtime. Off means zero per-event allocation: the EventBus tap detaches and recordBusEvent is never called. DebugConfig.eventLog controls the startup default; this is the runtime switch for toggling mid-session.

boolean

void

waitFor: (pattern, options?) => Promise<EventLogEntry>

string | RegExp

"entity" | "bus"

number

Promise<EventLogEntry>


readonly input: object

Defined in: Inspector.ts:531

clearAll: () => void

void

fireAction: (name, frames) => void

string

number = 1

void

gamepadAxis: (side, value) => void

InspectorGamepadAxisKey

number

void

gamepadButton: (code, pressed) => void

string

boolean

void

hold: (code, frames) => void

string

number

void

keyDown: (code) => void

string

void

keyUp: (code) => void

string

void

mouseDown: (button) => void

0 | 1 | 2

void

mouseMove: (x, y) => void

number

number

void

mouseUp: (button) => void

0 | 1 | 2

void

pointerDown: (button, opts?) => void

Inject a synthetic pointer-down. With opts.id and opts.type: "touch" this drives a multi-touch contact, exercising getPointers(), per-pointer event hooks, and the any-pointer aggregate for MouseLeft.

0 | 1 | 2

InspectorPointerOpts

void

pointerMove: (x, y, opts?) => void

Inject a synthetic pointer-move with full pointer addressing. Pass opts with id / type: "touch" to drive a specific finger; defaults match the primary mouse pointer (same as mouseMove).

number

number

InspectorPointerOpts

void

pointerUp: (button, opts?) => void

0 | 1 | 2

number

void

tap: (code, frames) => void

string

number = 1

void


readonly time: object

Defined in: Inspector.ts:439

freeze: () => void

void

getFrame: () => number

number

isAdvancing: (withinMs) => boolean

True if a real GameLoop.tick() happened within the last withinMs (default 250) milliseconds of wall-clock time. Independent of isFrozen(): a frozen clock that isn’t being stepped reads false (nothing is ticking), but a manual step/stepUntil/stepAsync fires a real tick, so this reads true for withinMs after one. A stalled-but-not-frozen game — a hung await, a runaway synchronous loop — also reads false, the case this method exists to tell apart from “frozen on purpose”.

number = 250

boolean

isFrozen: () => boolean

boolean

setDelta: (ms) => void

number

void

step: (frames) => void

number = 1

void

stepAsync: (frames, opts?) => Promise<void>

Advance a fixed number of frames, yielding a real macrotask between each so the same async draining as stepUntil applies — for call sites that already know how many frames they need.

number = 1

number

Promise<void>

stepUntil: (predicate, opts?) => Promise<number>

Advance frame-by-frame until predicate() returns true, yielding a real macrotask between frames so async work parked on the microtask queue — a scene transition’s await, a dialogue runner’s promise chain — gets a chance to settle before the next frame steps. Checks predicate before the first frame (resolves 0 if already satisfied) and after each subsequent frame. Throws if predicate is still false after opts.maxFrames (default 600, i.e. 10s at 60fps).

() => boolean

number

number

Promise<number>

thaw: () => void

void

addExtension<T>(namespace, api): T

Defined in: Inspector.ts:716

Register a namespaced extension API for plugin-specific debug helpers.

T extends object

string

T

T


attachSceneEventObserver(scene): void

Defined in: Inspector.ts:963

Internal

Install entity-event observation for one scene. No-op if disabled.

Scene

void


attachTimeController(controller): void

Defined in: Inspector.ts:928

Internal

DebugPlugin attaches the frozen-time controller through this hook.

InspectorTimeController

void


createSceneRandom(): RandomService

Defined in: Inspector.ts:894

Create a new scene-scoped RNG instance using the current inspector seed policy.

RandomService


detachSceneEventObserver(scene): void

Defined in: Inspector.ts:969

Internal

Clear entity-event observation for one scene.

Scene

void


detachTimeController(controller?): void

Defined in: Inspector.ts:933

Internal

Clear a previously attached time controller.

InspectorTimeController

void


dispose(): void

Defined in: Inspector.ts:990

Internal

Engine teardown releases the event-bus tap through this hook.

void


getComponentData(entityName, componentClass): unknown

Defined in: Inspector.ts:845

Get component data (serializable subset) by class name string.

string

string

unknown


getEntities(): EntitySnapshot[]

Defined in: Inspector.ts:852

Get all entities in the active scene as lightweight snapshots.

EntitySnapshot[]


getEntityByName(name): EntitySnapshot | undefined

Defined in: Inspector.ts:824

Find entity by name in the active scene.

string

EntitySnapshot | undefined


getEntityPosition(name): { x: number; y: number; } | undefined

Defined in: Inspector.ts:831

Get entity position (from Transform component).

string

{ x: number; y: number; } | undefined


getErrors(): ErrorSnapshot

Defined in: Inspector.ts:887

Get recorded failures from the error boundary.

ErrorSnapshot


getExtension<T>(namespace): T | undefined

Defined in: Inspector.ts:734

Look up a previously registered extension API by namespace.

T extends object

string

T | undefined


getSceneStack(): SceneSnapshot[]

Defined in: Inspector.ts:865

Get scene stack info.

SceneSnapshot[]


getSystems(): SystemSnapshot[]

Defined in: Inspector.ts:875

Get active system info.

SystemSnapshot[]


hasComponent(entityName, componentClass): boolean

Defined in: Inspector.ts:840

Check if an entity has a component by class name string.

string

string

boolean


recordEntityEvent(eventName, data, entity): void

Defined in: Inspector.ts:974

Internal

Scene hooks forward entity events through this method.

string

unknown

Entity

void


registerFacetContributor(contributor): () => void

Defined in: Inspector.ts:758

Register an InspectorFacetContributor so a plugin can augment component/entity snapshots with a namespaced facet (e.g. the renderer’s render geometry). Returns an unregister function; call it on plugin teardown. Re-registering a namespace replaces the prior contributor (mirrors save’s registerSnapshotExtra).

InspectorFacetContributor

() => void


removeExtension(namespace): void

Defined in: Inspector.ts:743

Remove a previously registered extension namespace.

string

void


setDefaultSceneSeed(seed): void

Defined in: Inspector.ts:910

Internal

DebugPlugin installs a deterministic default seed through this hook.

number | undefined

void


setEventLogEnabled(enabled): void

Defined in: Inspector.ts:940

Internal

Enable or disable event log recording.

boolean

void


setSeed(seed): void

Defined in: Inspector.ts:901

Force every current and future scene RNG to the provided seed.

number

void


snapshot(): EngineSnapshot

Defined in: Inspector.ts:772

Full deterministic state snapshot (stable ordering, serializable).

EngineSnapshot


snapshotJSON(): string

Defined in: Inspector.ts:790

Stable JSON form of snapshot.

string


snapshotScene(nameOrId): WorldSceneSnapshot

Defined in: Inspector.ts:800

Snapshot one scene by its public scene.name or its inspector-assigned id (snapshot().scenes[].id). Name is tried first. If more than one active scene shares that name, throws rather than guessing — pass the id instead. Falls back to an id match when no scene has that name.

string

WorldSceneSnapshot