Skip to content

SceneManager

Defined in: SceneManager.ts:27

Stack-based scene manager with push/pop/replace semantics.

new SceneManager(): SceneManager

SceneManager

get active(): Scene | undefined

Defined in: SceneManager.ts:119

The topmost (active) scene.

Scene | undefined


get activeScenes(): readonly Scene[]

Defined in: SceneManager.ts:129

All non-paused scenes in the stack, bottom to top.

readonly Scene[]


get all(): readonly Scene[]

Defined in: SceneManager.ts:124

All scenes in the stack, bottom to top.

readonly Scene[]


get autoPauseOnBlur(): boolean

Defined in: SceneManager.ts:50

Pause all non-paused scenes when document.hidden becomes true; restore them on focus. Default: false. Only scenes paused by this mechanism are restored — user-paused scenes (manual scene.paused = true or pauseBelow cascade) are never touched.

boolean

set autoPauseOnBlur(value): void

Defined in: SceneManager.ts:54

boolean

void


get isTransitioning(): boolean

Defined in: SceneManager.ts:134

Whether a scene transition is currently running.

boolean

_destroy(): void

Defined in: SceneManager.ts:256

Internal

Mark the manager destroyed and synchronously tear down every scene. Called by Engine.destroy(). Any queued async work short-circuits on resume; in-flight transitions’ pending promises are resolved via _cleanupRun so they don’t leak.

void


_flushDestroyQueues(): void

Defined in: SceneManager.ts:282

Internal

Flush destroy queues for all active scenes. Called by the engine during endOfFrame.

void


_handleVisibilityChange(hidden): void

Defined in: SceneManager.ts:94

Internal

React to a visibility change. Parameterised on hidden so unit tests can drive it without a real document.

boolean

void


_mountDetached(scene): Promise<void>

Defined in: SceneManager.ts:229

Internal

Run the full scene-enter lifecycle (beforeEnter hooks, preload, onEnter) for a scene that is NOT placed on the stack. Used by infrastructure plugins like DebugPlugin that render a scene off-stack.

Scene

Promise<void>


_setContext(context): void

Defined in: SceneManager.ts:69

Internal

Set the engine context.

EngineContext

void


_tickTransition(dt): void

Defined in: SceneManager.ts:293

Internal

Advance the active transition by dt ms. Called by Engine’s earlyUpdate callback with raw (unscaled) wall-clock dt.

number

void


_unmountDetached(scene): void

Defined in: SceneManager.ts:243

Internal

Run the scene-exit lifecycle (onExit, entity destruction, afterExit hooks, scoped-service clear) for a detached scene.

Scene

void


pop(opts?): Promise<Scene | undefined>

Defined in: SceneManager.ts:156

Pop the top scene. Scenes below may receive onResume().

SceneTransitionOptions

Promise<Scene | undefined>


popAll(): Promise<void>

Defined in: SceneManager.ts:209

Pop every scene on the stack, top to bottom. Each receives onExit(). Queued like push/pop/replace — runs after any in-flight transition. Use for “restart from menu”-style flows. Does not run transitions.

Promise<void>


push(scene, opts?): Promise<void>

Defined in: SceneManager.ts:142

Push a scene onto the stack. Scenes below may receive onPause(). If the scene declares a preload array, assets are loaded before onEnter().

Scene

SceneTransitionOptions

Promise<void>


replace(scene, opts?): Promise<void>

Defined in: SceneManager.ts:180

Replace the top scene. Without a transition the old scene exits first, then the new scene enters. With a transition the new scene is pushed first, both scenes coexist for the transition duration, then the old scene is removed at the end.

Scene

SceneTransitionOptions

Promise<void>