Skip to content

Engine

Defined in: Engine.ts:54

The top-level entry point. Owns the plugin registry, game loop, scene manager, and DI container.

new Engine(config?): Engine

Defined in: Engine.ts:96

EngineConfig

Engine

readonly assets: AssetManager

Defined in: Engine.ts:73

The asset manager.


readonly context: EngineContext

Defined in: Engine.ts:56

The dependency injection container.


readonly events: EventBus<EngineEvents>

Defined in: Engine.ts:60

The event bus.


readonly inspector: Inspector

Defined in: Engine.ts:66

The inspector (debug queries).


readonly logger: Logger

Defined in: Engine.ts:64

The logger.


readonly loop: GameLoop

Defined in: Engine.ts:62

The game loop.


readonly scenes: SceneManager

Defined in: Engine.ts:58

The scene manager.

destroy(): void

Defined in: Engine.ts:321

Stop the engine. Destroys all scenes, plugins, and the game loop. One-way: the instance cannot be started again. Repeat calls are a no-op, so a host that tears down defensively (hot reload, component unmount) can call it without tracking whether it already did.

Scene teardown, system unregistration and plugin onDestroy are independent stages: a throw in one still lets the others run, so a failing scene onExit cannot leave a plugin holding its GPU context. The first error is rethrown once teardown has finished, and the rest are reported through Logger.

void


registerSceneHooks(hooks): () => void

Defined in: Engine.ts:192

Register scene lifecycle hooks. The returned function unregisters the hooks. Infrastructure plugins (renderer, physics, debug) register hooks in their install or onStart to set up and tear down per-scene state.

SceneHooks

() => void


start(): Promise<void>

Defined in: Engine.ts:231

Start the engine. Installs plugins in topological order, starts the game loop. Calling it again while running is a no-op.

An engine instance is single-use, so start() throws once the instance has reached a terminal state — destroy() has run, or an earlier start() rejected. Plugin install() registers services into a container that rejects duplicate keys, and onDestroy() releases resources the plugin cannot rebuild, so a second pass over the same instance cannot produce a working engine.

destroy() called while startup is still awaiting a plugin abandons the rest of the sequence: the loop never starts and no further hook runs.

Promise<void>


use(plugin): this

Defined in: Engine.ts:197

Register a plugin. Must be called before start().

Plugin

this