Engine laws · celworld docs

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..b and weighted picks are seeded draws, once per seed per place.
  • Sub-seed by section. Body, look and gait (and each .cel let) 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@v wherever it must not move.
  • Variety is data, never special cases in mesh code: genome tables, .cel lets and seeds= 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 typecheck is 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

ThingPath
The .cel compilerpackages/engine/src/dsl/
The generation system prompt: guide, generated reference, examplespackages/engine/src/dsl/prompt/
.cel scripts by setpackages/engine/src/dsl/scripts/<set>/
The scene enginepackages/engine/src/scene/
The scene grammarSCENE_GRAMMAR in packages/engine/src/scene/director/prompt.ts
Scene scriptspackages/engine/src/scene/scripts/*.scene
People, nature, props and buildings generatorspackages/engine/src/chars/, packages/engine/src/content/
The cel CLIapps/web/scripts/cel.ts
The library storeapps/web/server/store/
The renderer lease and the Viewport componentapps/web/src/viewport/renderer.ts, apps/web/src/viewport/Viewport.tsx
The play kit: QA hook, daily seeds, share linespackages/play/
This guide, for Claude sessionsdocs/build-on-celworld.md and the celworld skill