Engine laws
The rules that keep saved seeds stable, the look consistent and the pages fast.
These are the rules every model, scene, generator and game keeps. They are why a seed saved today grows the same thing next year, and why a whole town draws in a few hundred calls.
Laws
- Seed, then versioned pure-data spec, then geometry, then a runtime instance. Specs have no three.js in them and are exact; geometry is built from them.
- No `Math.random()` in the engine. Every random draw goes through
Rng(mulberry32), seeded from the spec seed plus a sub-seed. In.cel,a..band weighted picks are seeded draws, once per seed per place. - Sub-seed by section. Body, look and gait (and each
.cellet) draw from independent streams, so retuning one never reshuffles another. - Saved seeds keep producing the same thing. Golden tests freeze a whole town's layout to the millimetre. A version is immutable: change a model by saving v2, and pin
slug@vwherever it must not move. - Variety is data, never special cases in mesh code: genome tables,
.cellets andseeds=ranges. - Vertex colours and the shared toon materials. No textures or PBR on 3D forms; light bands stay hard; ink is plum
#3b2a5e, never black; face features are never inked. - No z-fighting, ever. The compiler rejects coplanar overlaps; offset or recess every detail.
- One renderer per page. Stages lease the site's renderer and never create their own.
- Every generator gets a page on the site with a seed, a reroll, an inspector and performance stats.
- Strict TypeScript, no `any`, zod at every boundary. A change isn't done while
bun run typecheckis red.
The look
The approved look is chunky, rounded, toy-like forms in flat vertex colours, three hard light bands, a thin light rim and plum ink outlines, under warm sunlight with soft blob shadows. The full art bible is ui.md at the repo root, and the reference renders are in media/baseline/. Every ground surface carries a procedural texture; nothing ships an image file for a 3D form.
Where things live
| Thing | Path |
|---|---|
The .cel compiler | packages/engine/src/dsl/ |
| The generation system prompt: guide, generated reference, examples | packages/engine/src/dsl/prompt/ |
.cel scripts by set | packages/engine/src/dsl/scripts/<set>/ |
| The scene engine | packages/engine/src/scene/ |
| The scene grammar | SCENE_GRAMMAR in packages/engine/src/scene/director/prompt.ts |
| Scene scripts | packages/engine/src/scene/scripts/*.scene |
| People, nature, props and buildings generators | packages/engine/src/chars/, packages/engine/src/content/ |
The cel CLI | apps/web/scripts/cel.ts |
| The library store | apps/web/server/store/ |
| The renderer lease and the Viewport component | apps/web/src/viewport/renderer.ts, apps/web/src/viewport/Viewport.tsx |
| The play kit: QA hook, daily seeds, share lines | packages/play/ |
| This guide, for Claude sessions | docs/build-on-celworld.md and the celworld skill |