SceneManager
Defined in: SceneManager.ts:51
Stack-based scene manager with push/pop/replace semantics.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SceneManager():
SceneManager
Returns
Section titled “Returns”SceneManager
Accessors
Section titled “Accessors”_isMutating
Section titled “_isMutating”Get Signature
Section titled “Get Signature”get _isMutating():
boolean
Defined in: SceneManager.ts:180
Internal
Whether a stack mutation (push/pop/replace/popAll) is running, including
while its lifecycle hooks execute. Lets Scene.paused detect a reentrant
write from inside a hook, which would race the transition’s pause diff.
Returns
Section titled “Returns”boolean
active
Section titled “active”Get Signature
Section titled “Get Signature”get active():
Scene|undefined
Defined in: SceneManager.ts:155
The topmost (active) scene.
Returns
Section titled “Returns”Scene | undefined
activeScenes
Section titled “activeScenes”Get Signature
Section titled “Get Signature”get activeScenes(): readonly
Scene[]
Defined in: SceneManager.ts:165
All non-paused scenes in the stack, bottom to top.
Returns
Section titled “Returns”readonly Scene[]
Get Signature
Section titled “Get Signature”get all(): readonly
Scene[]
Defined in: SceneManager.ts:160
All scenes in the stack, bottom to top.
Returns
Section titled “Returns”readonly Scene[]
autoPauseOnBlur
Section titled “autoPauseOnBlur”Get Signature
Section titled “Get Signature”get autoPauseOnBlur():
boolean
Defined in: SceneManager.ts:85
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. Blur pause goes through the paused setter,
so affected scenes get onPause on blur and onResume on focus.
Returns
Section titled “Returns”boolean
Set Signature
Section titled “Set Signature”set autoPauseOnBlur(
value):void
Defined in: SceneManager.ts:89
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”void
isTransitioning
Section titled “isTransitioning”Get Signature
Section titled “Get Signature”get isTransitioning():
boolean
Defined in: SceneManager.ts:170
Whether a scene transition is currently running.
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”_destroy()
Section titled “_destroy()”_destroy():
void
Defined in: SceneManager.ts:404
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.
One-way: the destroyed state is never cleared, matching the engine’s single-use lifecycle. Later push/pop/replace/popAll calls are ignored.
Returns
Section titled “Returns”void
_flushDestroyQueues()
Section titled “_flushDestroyQueues()”_flushDestroyQueues():
void
Defined in: SceneManager.ts:430
Internal
Flush destroy queues for all active scenes. Called by the engine during endOfFrame.
Returns
Section titled “Returns”void
_handleVisibilityChange()
Section titled “_handleVisibilityChange()”_handleVisibilityChange(
hidden):void
Defined in: SceneManager.ts:130
Internal
React to a visibility change. Parameterised on hidden so unit tests can
drive it without a real document.
Parameters
Section titled “Parameters”hidden
Section titled “hidden”boolean
Returns
Section titled “Returns”void
_mountDetached()
Section titled “_mountDetached()”_mountDetached(
scene):Promise<void>
Defined in: SceneManager.ts:374
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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<void>
_setContext()
Section titled “_setContext()”_setContext(
context):void
Defined in: SceneManager.ts:104
Internal
Set the engine context.
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”void
_tickTransition()
Section titled “_tickTransition()”_tickTransition(
dt):void
Defined in: SceneManager.ts:441
Internal
Advance the active transition by dt seconds. Called by Engine’s
earlyUpdate callback with raw (unscaled) wall-clock dt.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
_unmountDetached()
Section titled “_unmountDetached()”_unmountDetached(
scene):void
Defined in: SceneManager.ts:388
Internal
Run the scene-exit lifecycle (onExit, entity destruction, afterExit hooks, scoped-service clear) for a detached scene.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
pop(
opts?):Promise<Scene|undefined>
Defined in: SceneManager.ts:209
Pop the top scene. Scenes below may receive onResume().
Safe to call reentrantly — see push.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<Scene | undefined>
popAll()
Section titled “popAll()”popAll():
Promise<void>
Defined in: SceneManager.ts:288
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.
Safe to call reentrantly — see push.
Returns
Section titled “Returns”Promise<void>
preload()
Section titled “preload()”preload(
scene,onProgress?):Promise<void>
Defined in: SceneManager.ts:324
Load a scene’s preload manifest now, so pushing or replacing to it later
enters immediately instead of loading again. The handles are counted once:
the push consumes this load rather than acquiring its own references, and
LoadingScene uses it for exactly that.
await engine.scenes.preload(level2, (ratio) => bar.update({ value: ratio }));await engine.scenes.replace(level2);onProgress runs alongside the scene’s own onProgress hook, both
reporting 0 → 1. A call that joins one already running for the same
scene receives the ratio reached so far, then every later one.
A scene preloaded and never pushed keeps its references until
assets.clear() — nothing later releases them on its behalf. Entering a
scene claims the set waiting for it, so a preload of that same scene
from then on loads a set of its own rather than joining one the entry now
owns: the entering scene’s exit must not free a prefetch someone else is
still holding.
Parameters
Section titled “Parameters”onProgress?
Section titled “onProgress?”(ratio) => void
Returns
Section titled “Returns”Promise<void>
push()
Section titled “push()”push(
scene,opts?):Promise<void>
Defined in: SceneManager.ts:193
Push a scene onto the stack. Scenes below may receive onPause().
If the scene declares a preload array, assets are loaded before onEnter().
Safe to call reentrantly from a lifecycle hook (e.g. onEnter): the call
is queued on the internal pending chain and runs after the current
mutation finishes. The returned promise resolves once that deferred run
completes.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<void>
replace()
Section titled “replace()”replace(
scene,opts?):Promise<void>
Defined in: SceneManager.ts:251
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.
Safe to call reentrantly from a lifecycle hook (e.g. onEnter): the call
is queued on the internal pending chain and runs after the current
mutation finishes. The returned promise resolves once that deferred run
completes.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<void>
Coding agents: fetch https://yage.dev/llms.txt first and prefer the Markdown references it links over these HTML pages. This page's Markdown counterpart is /llms/packages/core.md.