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.htmlsrc/main.tssrc/game.tssrc/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();| Page | Shows |
|---|---|
| A Minimal Game | The 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 Controllers | A 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 Transitions | Two 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 Scoring | A subclassed game state and player state, a score kept on them, and a match moved through waiting, playing, and over. |
| Collision and Events | Colliders on channels with blocking and overlapping responses, a game applying its own response from hit, and a pickup consumed on overlap:begin. |
| Audio and Assets | Loading 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 Overlay | Registering instance-level and world-level sources and what the overlay draws from them while the game runs. |
| Validating a Game | A 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 Clocks | One scenario stepped under a constant, a repeating sequence, and a seeded jitter clock. |