Skip to content

Overview

This section is a set of complete programs. Each page shows every file the build it describes consists of, whole, so the engine’s surface can be judged from working code. Every file compiles against the types the APIs section declares.

Each build has the same shape. index.html is the page the build is served as, src/main.ts creates the engine and boots it, src/game.ts exports the Game<S, D> the engine drives, assets/ holds the files the game loads, and tests/ holds the build’s own vitest suites; a case’s validators are staged beside src/ at validation/, as Validating a Game shows. A build declares three beside the engine in its own package.json, and a game imports it directly wherever it needs a three object.

index.html
src/main.ts
src/game.ts
assets/
tests/
validation/

The boot sequence is the same on every page as well: construct the engine, subscribe to anything the caller wants to observe, initialize, and run.

const engine = createEngine({ canvas, width, height, game });
await engine.initialize();
await engine.run();
PageShows
A Minimal GameThe smallest complete build: a page, a boot module, and a game that moves a mesh by the frame’s delta and draws a readout on the screen layer.
Input and ActionsRegistering a dual-stick layout’s vocabulary, driving a mesh and the camera from held analog actions, reading a digital edge, and driving the same code from a key and from a test.
Audio and AssetsLoading a model and a produced audio file during initialization, placing the model’s clone in the scene, playing a synthesized cue and a positioned file-backed cue, and surfacing a failed load.
Diagnostics and OverlayRegistering overlay sources during initialization and reading them back while the game runs.
Validating a GameA vitest suite that imports the build’s own game, steps it in the page under vitest’s browser mode with engine.advance, and checks the scene, the projection, and the screen layer’s draw calls.
Scripted ClocksOne scenario stepped under a constant, a repeating sequence, and a seeded jitter clock.