Files
roam/trmnassets.org
T
2026-06-17 07:36:46 +03:00

2.3 KiB
Raw Blame History

trmn/assets trmn/assets

trmn — asset pipeline: SVG sprites + GLB objects

Architecture

Two asset types, both served from $out/assets/ by Caddy:

  • Sprites: SVG files in assets/sprites/{eyes,nose,mouth}/, static/committed, no build step
  • 3D objects: GLB files in assets/objects/, generated during nix build by Node.js scripts in scripts/

Face compositing at runtime: load SVG parts → draw onto OffscreenCanvas(128,128)THREE.CanvasTexture. Applied to the +z front face (index 4) of the head BoxGeometry via a material array.

Conventions

  • All sprite SVGs are 128×128; each draws its feature in the region it occupies on the face canvas (eyes y≈3555, nose y≈6585, mouth y≈90110) so all layers composite with drawImage(img, 0, 0, 128, 128)
  • Face part selection seeded from window.__life.masterSeed via inline mulberry32 in the Three.js script block
  • window.__life exports masterSeed (added alongside traits/buf/eventLog/today/currentDay)
  • GLB generators: pure Node.js stdlib only (no npm), accept output path as process.argv[2]
  • Three.js importmap includes "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/" for GLTFLoader

Gotchas

  • Critical: Nix flake src = ./. only includes git-tracked files (git ls-files). New assets/ and scripts/ dirs must be git add-ed before nix build or they are silently excluded.
  • BoxGeometry material array face order: [+x, -x, +y, -y, +z, -z] → index 4 is the front face (camera-facing)
  • GLB generator runs in Nix buildPhase and writes to the build dir; installPhase cp -r assets $out/assets picks up both committed sprites and the generated book.glb

Key Files

  • assets/sprites/eyes/eyes_{1,2}.svg — wide-open vs narrow/tired eyes
  • assets/sprites/nose/nose_{1,2}.svg — dot vs nostrils nose
  • assets/sprites/mouth/mouth_{1,2}.svg — smile vs neutral mouth
  • assets/objects/book.glb — generated at build time (not committed); dark-red flat box 0.14×0.18×0.03
  • scripts/gen-book.mjs — pure Node.js GLB writer, no npm deps; node scripts/gen-book.mjs <outpath>