2.3 KiB
2.3 KiB
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 duringnix buildby Node.js scripts inscripts/
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≈35–55, nosey≈65–85, mouthy≈90–110) so all layers composite withdrawImage(img, 0, 0, 128, 128) - Face part selection seeded from
window.__life.masterSeedvia inlinemulberry32in the Three.js script block window.__lifeexportsmasterSeed(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). Newassets/andscripts/dirs must begit add-ed beforenix buildor they are silently excluded. BoxGeometrymaterial 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/assetspicks up both committed sprites and the generatedbook.glb
Key Files
assets/sprites/eyes/eyes_{1,2}.svg— wide-open vs narrow/tired eyesassets/sprites/nose/nose_{1,2}.svg— dot vs nostrils noseassets/sprites/mouth/mouth_{1,2}.svg— smile vs neutral mouthassets/objects/book.glb— generated at build time (not committed); dark-red flat box 0.14×0.18×0.03scripts/gen-book.mjs— pure Node.js GLB writer, no npm deps;node scripts/gen-book.mjs <outpath>