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, and a build declares three as its own dependency and imports it directly where it needs a three object.

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 GameDefinition the engine drives, src/levels/ holds the level definitions it registers, src/actors/ holds the actor and component classes those levels place, assets/ holds the files the game loads, and validation/ holds the vitest suites a case checks the build with.

index.html
src/main.ts
src/game.ts
src/levels/
src/actors/
assets/
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, one level with one game mode, a lit mesh that moves itself by the frame’s delta, and a screen-space readout.
Pawns and ControllersA game mode that adds a player, a pawn possessed by a player controller reading registered actions, and the same pawn driven by an AI controller.
Worlds and TransitionsTwo levels, a world.open request honored at the end of the frame, the options it carries into the incoming mode, and a value kept on the game instance across it.
Game Mode and ScoringA subclassed game state and player state, a score kept on them, and a match moved through waiting, playing, and over.
Collision and EventsColliders on channels with blocking and overlapping responses, a game applying its own response from hit, and a pickup consumed on overlap:begin.
Audio and AssetsLoading a model, a texture, and a produced audio file in a level’s load, defining a synthesized cue, playing cues from world points while the match runs, and surfacing a failed load.
Diagnostics and OverlayRegistering instance-level and world-level sources and what the overlay draws from them while the game runs.
Validating a GameA vitest suite that imports the build’s own game definition, poses scenarios through the debug surface its initialize returns, steps it with engine.advance, and checks the world, the scene, the events, and the screen layer.
Scripted ClocksOne scenario stepped under a constant, a repeating sequence, and a seeded jitter clock.