Skip to content

API Class SceneManager

github-actions[bot] edited this page Dec 1, 2026 · 7 revisions

Class: SceneManager

Defined in: src/engine/scene/SceneManager.ts:117

Loads scene files as scene nodes under the World root (ADR 0016). Acts on the current World (ADR 0032): the one whose frame is running, else the Engine's default World. A load captures that World when called, so the swap lands there even though it happens later.

await SceneManager.load("scenes/level1.scene.json");
await SceneManager.load("scenes/hud.scene.json", { additive: true });

Constructors

Constructor

new SceneManager(): SceneManager;

Returns

SceneManager

Accessors

activeScene

Get Signature

get static activeScene(): GameObject | null;

Defined in: src/engine/scene/SceneManager.ts:119

The most recently loaded scene node.

Returns

GameObject | null


scenes

Get Signature

get static scenes(): GameObject[];

Defined in: src/engine/scene/SceneManager.ts:124

All loaded scene nodes, oldest first.

Returns

GameObject[]

Methods

load()

static load(path, options?): Promise<GameObject>;

Defined in: src/engine/scene/SceneManager.ts:132

Load a scene file. Assets are preloaded first; the swap happens at the end of the current frame (or immediately when the engine isn't mid-frame). Resolves with the new scene node.

Parameters

path

string

options?

LoadSceneOptions = {}

Returns

Promise<GameObject>


preload()

static preload(paths): Promise<void>;

Defined in: src/engine/scene/SceneManager.ts:235

Warm up prefabs and materials ahead of time (ADR 0080): their textures and models load, and the renderer draws each once, hidden, so the shader pipelines they need exist before they're spawned. For content chosen at runtime (a boss before its arena opens); scene loads already warm what their scene, its settings.preload list and the project's scripts name.

await SceneManager.preload(["prefabs/boss.prefab.json"]);

Parameters

paths

string[]

Returns

Promise<void>


unload()

static unload(scene): void;

Defined in: src/engine/scene/SceneManager.ts:243

Unload a scene node and everything in it (at the end of the frame).

Parameters

scene

GameObject

Returns

void


whenReady()

static whenReady(): Promise<void>;

Defined in: src/engine/scene/SceneManager.ts:221

Resolves when the current World has no load in flight and the latest reached readiness (ADR 0616): at once if nothing is loading; rejects if that load failed, if the newest replacing load failed (a later additive load doesn't hide it, ADR 0619), or if the World is unloaded first.

Returns

Promise<void>

Clone this wiki locally