4.2 KiB
4.2 KiB
trmn
Architecture
Static site (no backend). index.html + life.js + schedule.js + locations.js as ES modules. Three.js + onnxruntime-web from CDN.
Served by Caddy via nix run on port 8080. Built by nix build (includes model weights in $out/model/).
Domains:
- Life generation:
life.js— deterministic 36,500-day procedural simulation → trmn/life - NPC people: family tree + tracked friends/children, each with deterministic PersonRecord → trmn/people
- Daily schedule:
schedule.js— 96-slot day, 68 scenes, deterministic from (masterSeed, currentDay) → trmn/schedule - Rendering: Three.js low-poly 3D scenes, flat shading, cinematic 2.39:1 viewport
- LLM dialogue: TinyStories-8M ONNX INT8 bundled in
/model/TinyStories-8M/→ trmn/llm - Assets: SVG face sprites + GLB objects + Blender location scenes → trmn/assets
window.__life exposes {traits, buf, eventLog, people, today, currentDay, masterSeed, schedule}.
window.__sceneLoader exposes { loadAndShow(locationId, props) } for the debug panel.
Conventions
- Determinism: ALL randomness seeded from absolute time, never
Math.random(); usemakeRng(masterSeed, day) - Low-poly aesthetic:
MeshLambertMaterialwithflatShading: true, BoxGeometry for characters - Cinematic viewport:
aspect-ratio: 2.39/1, FOV 26°, vignette via CSS::after - Scene background via CSS gradient on
#stagediv; canvas isalpha: true - Static assets: copy to
$out/assets/in flake installPhase; generated assets built via Node.js/Blender in buildPhase .blendfiles are source of truth for location scenes; GLBs are build artifacts never committed
Gotchas
header Content-Type text/htmlin Caddyfile is wrong for multi-asset setups — omit itMeshFlatMaterialdoes not exist; useMeshLambertMaterial { flatShading: true }onnxruntime-webmust be a<script>tag (global), NOT an ES module importmap entry- Never spread
buf(Float32Array) in a loop — hangs browser; index directly withbuf[d * FIELDS + F.X] - Nix flake
src = ./.only includes git-tracked files →git addnew dirs beforenix build - eventLog entries are
{id, personId?, attended?}objects, not plain strings — usee.idnote - All ONNX build/inference gotchas → trmn/llm
Key Files
index.html— 4 inline module scripts: life sim bootstrap, Three.js scene (+ pack loader + debug exposure), debug panel UI, LLM inferencelife.js— full life simulation: PRNG, 31 events, 36,501-day loop, NPC people systemschedule.js— daily schedule: 68-scene catalog, 10 life stages, forced-event overrideslocations.js—generateLocationProps(locationId, masterSeed, playerState, eventLog?); wall/floor palettes + conditional mesh setsschedule-debug.mjs— CLI debug tool;nix run .#schedule -- [flags]stats.mjs— aggregate stats across 1000 lives;nix run .#statsflake.nix— build + Caddy server +tinyStoriesOnnxsub-derivation +stats+scheduleapps;pkgs.blenderin nativeBuildInputsASSETS.md— authoring guide: location ID→file mapping, mesh naming conventions, Blender setup, build/test workflow
Subnodes
- trmn/llm — ONNX build pipeline, in-browser inference, TinyStories-8M gotchas
- trmn/life — life simulation: PRNG, state schema, event catalog, packed buffer layout
- trmn/assets — location scene pipeline: Blender→GLB→scenes.pack, naming conventions, debug panel, PRNG offsets
- trmn/people — NPC system: family tree, PersonRecord, PRNG isolation, post-apply hooks
- trmn/schedule — daily schedule: slot layout, scene catalog, life stages, forced events, debug CLI