Engine
Defined in: Engine.ts:54
The top-level entry point. Owns the plugin registry, game loop, scene manager, and DI container.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Engine(
config?):Engine
Defined in: Engine.ts:96
Parameters
Section titled “Parameters”config?
Section titled “config?”Returns
Section titled “Returns”Engine
Properties
Section titled “Properties”assets
Section titled “assets”
readonlyassets:AssetManager
Defined in: Engine.ts:73
The asset manager.
context
Section titled “context”
readonlycontext:EngineContext
Defined in: Engine.ts:56
The dependency injection container.
events
Section titled “events”
readonlyevents:EventBus<EngineEvents>
Defined in: Engine.ts:60
The event bus.
inspector
Section titled “inspector”
readonlyinspector:Inspector
Defined in: Engine.ts:66
The inspector (debug queries).
logger
Section titled “logger”
readonlylogger:Logger
Defined in: Engine.ts:64
The logger.
readonlyloop:GameLoop
Defined in: Engine.ts:62
The game loop.
scenes
Section titled “scenes”
readonlyscenes:SceneManager
Defined in: Engine.ts:58
The scene manager.
Methods
Section titled “Methods”destroy()
Section titled “destroy()”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.
Returns
Section titled “Returns”void
registerSceneHooks()
Section titled “registerSceneHooks()”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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”() => void
start()
Section titled “start()”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.
Returns
Section titled “Returns”Promise<void>
use(
plugin):this
Defined in: Engine.ts:197
Register a plugin. Must be called before start().
Parameters
Section titled “Parameters”plugin
Section titled “plugin”Returns
Section titled “Returns”this