Skip to content

API Class Engine

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

Class: Engine

Defined in: src/engine/boot/Engine.ts:96

Owns the Worlds and drives them frame by frame (ADR 0011, 0032). A bootstrap creates the start-up Worlds; game code creates more at runtime through handles. engine.world is the default World: the first one the bootstrap made.

const engine = await Engine.create({ container, project, assets });
await SceneManager.load("scenes/main.scene.json");
engine.start();

Implements

Properties

settings

readonly settings: ProjectSettings;

Defined in: src/engine/boot/Engine.ts:97

Implementation of

BootstrapEngine.settings

Accessors

isRunning

Get Signature

get isRunning(): boolean;

Defined in: src/engine/boot/Engine.ts:438

True while the requestAnimationFrame loop is running.

Returns

boolean


world

Get Signature

get world(): World;

Defined in: src/engine/boot/Engine.ts:200

The default World: the first one the bootstrap created (the next one, if that's destroyed).

Returns

World

Methods

createWorld()

createWorld(config): WorldHandle;

Defined in: src/engine/boot/Engine.ts:228

Create a World in this Engine. See Engine.createWorld. Its scenes load in the background (Engine.create waits for the start-up Worlds'), and it steps from the next frame on.

Parameters

config

string | WorldConfig

Returns

WorldHandle

Implementation of

BootstrapEngine.createWorld


dispose()

dispose(): void;

Defined in: src/engine/boot/Engine.ts:569

Stop the loop, destroy every World's nodes (scripts get onDestroy, audio stops), release GPU resources, then release the project context (ADR 0319): the asset sources it was given go, and storage goes back to the backend of the Engine created before it that's still alive (the editor's, after Play), or the one in use before.

Returns

void


findWorld()

findWorld(name): WorldHandle | null;

Defined in: src/engine/boot/Engine.ts:305

A handle on one of this Engine's Worlds, by name, or null.

Parameters

name

string

Returns

WorldHandle | null

Implementation of

BootstrapEngine.findWorld


start()

start(): void;

Defined in: src/engine/boot/Engine.ts:446

Start the requestAnimationFrame loop. A frame that throws is logged (once per message) and the loop goes on (ADR 0635); stopping and starting again inside a frame leaves one loop, not two.

Returns

void


step()

step(dt): void;

Defined in: src/engine/boot/Engine.ts:478

Advance one frame by dt real seconds. Used by the loop; call it directly in tests. As in Unity's player loop, every unpaused World steps once, in creation order, each on its own clock (ADR 0032). Afterwards the default World is current again.

Parameters

dt

number

Returns

void


stop()

stop(): void;

Defined in: src/engine/boot/Engine.ts:467

Returns

void


worlds()

worlds(): readonly WorldHandle[];

Defined in: src/engine/boot/Engine.ts:316

Handles on every World, in creation (and step) order. For the editor and bootstraps, not game scripts.

Returns

readonly WorldHandle[]

Implementation of

WorldOwner.worlds


create()

static create(options?): Promise<Engine>;

Defined in: src/engine/boot/Engine.ts:163

Parameters

options?

EngineOptions = {}

Returns

Promise<Engine>


createWorld()

static createWorld(config): WorldHandle;

Defined in: src/engine/boot/Engine.ts:209

Create a World in the Engine that's running the current World (ADR 0032), e.g. from a menu's "Host" button. config is a WorldConfig or the name of a bootstrap template.

Parameters

config

string | WorldConfig

Returns

WorldHandle


findWorld()

static findWorld(name): WorldHandle | null;

Defined in: src/engine/boot/Engine.ts:214

A handle on a World of the current World's Engine, by name, or null.

Parameters

name

string

Returns

WorldHandle | null

Clone this wiki locally