Skip to content

Documentation / scene / Application

Class: Application

Defined in: libs/scene/src/app/app.ts:140

Application

Entry-point and lifecycle coordinator for the engine. Responsible for:

  • Creating and owning the rendering device from a chosen backend.
  • Managing the per-frame loop, including timing and viewport setup.
  • Forwarding device/DOM input events via an observable event map.
  • Hosting the runtime scripting system and input manager.

Singleton:

  • Only one instance may exist at a time. Access via {@link getApp}.

Events:

  • See appEventMap for all emitted events (resize, tick, pointer/keyboard/drag).

Usage:

  • Construct with AppOptions, await ready(), then call run() to start the loop.

Extends

  • Observable<appEventMap>

Constructors

Constructor

new Application(opt): Application

Defined in: libs/scene/src/app/app.ts:154

Construct the Application singleton with the provided options.

Throws if an instance already exists.

Parameters

opt

AppCreationOptions

Application creation options (canvas, backend, and optional runtime/device settings).

Returns

Application

Overrides

Observable<appEventMap>.constructor

Accessors

editorMode

Get Signature

get editorMode(): EditorMode

Defined in: libs/scene/src/app/app.ts:183

Editor mode

Returns

EditorMode


inputManager

Get Signature

get inputManager(): InputManager

Defined in: libs/scene/src/app/app.ts:189

The input manager instance handling pointer/keyboard event routing.

Returns

InputManager


engine

Get Signature

get engine(): Engine

Defined in: libs/scene/src/app/app.ts:195

Get the instanceof Engine.

Returns

Engine


options

Get Signature

get options(): RequireOptionals<AppOptions>

Defined in: libs/scene/src/app/app.ts:203

The (sanitized) options used to create this application.

Note: Defaults are applied for enableMSAA and pixelRatio if omitted.

Returns

RequireOptionals<AppOptions>


device

Get Signature

get device(): AbstractDevice

Defined in: libs/scene/src/app/app.ts:211

The initialized rendering device.

Available after await ready().

Returns

AbstractDevice


deviceType

Get Signature

get deviceType(): string

Defined in: libs/scene/src/app/app.ts:217

Convenience accessor for the device type name provided by the backend.

Returns

string

Methods

on()

on<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:594

IEventTarget.on

Type Parameters

K

K extends keyof appEventMap

Parameters

type

K

listener

EventListener<appEventMap, K>

context?

unknown

Returns

void

Inherited from

Observable.on


once()

once<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:598

IEventTarget.once

Type Parameters

K

K extends keyof appEventMap

Parameters

type

K

listener

EventListener<appEventMap, K>

context?

unknown

Returns

void

Inherited from

Observable.once


off()

off<K>(type, listener?, context?): void

Defined in: libs/base/dist/index.d.ts:602

IEventTarget.off

Type Parameters

K

K extends keyof appEventMap

Parameters

type

K

listener?

EventListener<appEventMap>

context?

unknown

Returns

void

Inherited from

Observable.off


dispatchEvent()

dispatchEvent<K>(type, ...args): void

Defined in: libs/base/dist/index.d.ts:606

IEventTarget.dispatchEvent

Type Parameters

K

K extends keyof appEventMap

Parameters

type

K

args

...appEventMap[K]

Returns

void

Inherited from

Observable.dispatchEvent


focus()

focus(): void

Defined in: libs/scene/src/app/app.ts:223

Set keyboard focus to the device's canvas element.

Returns

void


ready()

ready(): Promise<void>

Defined in: libs/scene/src/app/app.ts:231

Initialize the rendering device and start input processing.

Returns

Promise<void>

Throws

If device creation fails.


frame()

frame(): void

Defined in: libs/scene/src/app/app.ts:262

Render a single frame.

Steps:

  • Flushes pending disposals from the previous frame.
  • Clears device state (framebuffer, viewport, scissor).
  • Queries frame timing from the device (elapsedFrame, elapsedOverall).
  • Updates the runtime manager (scripting/behaviors).
  • Emits tick with delta/elapsed times.

Safe to call manually; also used by the run loop.

Returns

void


run()

run(): void

Defined in: libs/scene/src/app/app.ts:281

Start the application's render loop.

Uses the device's internal scheduling (device.runLoop) to repeatedly call frame().

Returns

void


stop()

stop(): void

Defined in: libs/scene/src/app/app.ts:291

Stop the application's render loop.

Uses device.exitLoop() to end the scheduling started by run().

Returns

void

Released under the MIT License.