A mech game prototype, pushed by Fable 5.2

agent

+0:10

[redacted: private notes read: a reflection page and a memory file]

  • Bashls -la tools kit/blocks kit/makers kit/lab public public/assets | head -150; cat package.json; cat docs/housekeeping.md; ls [redacted: private path]/ 2>/dev/null; nproc; uptime; free -g | head -2

    command

    ls -la tools kit/blocks kit/makers kit/lab public public/assets | head -150; cat package.json; cat docs/housekeeping.md; ls [redacted: private path]/ 2>/dev/null; nproc; uptime; free -g | head -2

    result, 246 lines

    kit/blocks:
    total 12
    drwx------ 2 severian severian 4096 Nov 10 18:20 .
    drwx------ 5 severian severian 4096 Nov 10 18:20 ..
    -rw------- 1 severian severian  331 Nov 10 18:20 dummy.py
    -rw------- 1 severian severian    0 Nov 10 18:20 __init__.py
    
    kit/lab:
    total 280
    drwx------ 2 severian severian  4096 Nov 10 18:20 .
    drwx------ 5 severian severian  4096 Nov 10 18:20 ..
    -rw------- 1 severian severian  9158 Nov 10 18:20 assembly.py
    -rw------- 1 severian severian  2206 Nov 10 18:20 atelier_board.py
    -rw------- 1 severian severian  1812 Nov 10 18:20 atelier_lab.py
    -rw------- 1 severian severian 22504 Nov 10 18:20 backkit.py
    -rw------- 1 severian severian 21490 Nov 10 18:20 board_heraldic.py
    -rw------- 1 severian severian 17731 Nov 10 18:20 board_plate.py
    -rw------- 1 severian severian 15740 Nov 10 18:20 board_sleek.py
    -rw------- 1 severian severian 20119 Nov 10 18:20 board_tourney.py
    -rw------- 1 severian severian 39323 Nov 10 18:20 bodykit.py
    -rw------- 1 severian severian 10357 Nov 10 18:20 chestkit.py
    -rw------- 1 severian severian 37640 Nov 10 18:20 headkit.py
    -rw------- 1 severian severian 16334 Nov 10 18:20 heads.py
    -rw------- 1 severian severian 26120 Nov 10 18:20 knightkit.py
    -rw------- 1 severian severian  2407 Nov 10 18:20 pattern_lab.py
    -rw------- 1 severian severian  1944 Nov 10 18:20 pilotlab.py
    -rw------- 1 severian severian  1662 Nov 10 18:20 sizes.py
    
    kit/makers:
    total 92
    drwx------ 2 severian severian  4096 Nov 10 18:20 .
    drwx------ 5 severian severian  4096 Nov 10 18:20 ..
    -rw------- 1 severian severian 35108 Nov 10 18:20 atelier.py
    -rw------- 1 severian severian     0 Nov 10 18:20 __init__.py
    -rw------- 1 severian severian 36676 Nov 10 18:20 pattern.py
    -rw------- 1 severian severian 12117 Nov 10 18:20 shell.py
    
    public:
    total 12
    drwx------ 3 severian severian 4096 Nov 10 18:20 .
    drwx------ 8 severian severian 4096 Nov 10 18:24 ..
    drwx------ 2 severian severian 4096 Nov 10 18:20 assets
    
    public/assets:
    total 173240
    drwx------ 2 severian severian     4096 Nov 10 18:20 .
    drwx------ 3 severian severian     4096 Nov 10 18:20 ..
    -rw------- 1 severian severian    97212 Nov 10 18:20 alien_acicular.glb
    -rw------- 1 severian severian   120312 Nov 10 18:20 alien_druse.glb
    -rw------- 1 severian severian   282936 Nov 10 18:20 alien_druse_mimic.glb
    -rw------- 1 severian severian   710368 Nov 10 18:20 alien_geode.glb
    -rw------- 1 severian severian  1484272 Nov 10 18:20 auto_ledger.glb
    -rw------- 1 severian severian  1179792 Nov 10 18:20 auto_tally.glb
    -rw------- 1 severian severian   852852 Nov 10 18:20 auto_tick.glb
    -rw------- 1 severian severian    25452 Nov 10 18:20 cannon.glb
    -rw------- 1 severian severian   245152 Nov 10 18:20 cockpit.glb
    -rw------- 1 severian severian  1438116 Nov 10 18:20 cockpit_light.glb
    -rw------- 1 severian severian    69016 Nov 10 18:20 drone.glb
    -rw------- 1 severian severian    55596 Nov 10 18:20 escape_pod.glb
    -rw------- 1 severian severian  1596768 Nov 10 18:20 heavy_B.glb
    -rw------- 1 severian severian  1512944 Nov 10 18:20 heavy_C.glb
    -rw------- 1 severian severian  1532780 Nov 10 18:20 heavy.glb
    -rw------- 1 severian severian  6729808 Nov 10 18:20 lab_alien.glb
    -rw------- 1 severian severian 14187700 Nov 10 18:20 lab_atelier_a.glb
    -rw------- 1 severian severian 10801072 Nov 10 18:20 lab_atelier_b.glb
    -rw------- 1 severian severian 11706000 Nov 10 18:20 lab_atelier_c.glb
    -rw------- 1 severian severian 11717484 Nov 10 18:20 lab_atelier_d.glb
    -rw------- 1 severian severian  6134544 Nov 10 18:20 lab_atelier.glb
    -rw------- 1 severian severian  6307036 Nov 10 18:20 lab_auto.glb
    -rw------- 1 severian severian  8216648 Nov 10 18:20 lab_backs.glb
    -rw------- 1 severian severian   277820 Nov 10 18:20 lab_chests2.glb
    -rw------- 1 severian severian   529028 Nov 10 18:20 lab_chests3.glb
    -rw------- 1 severian severian  6951676 Nov 10 18:20 lab_chests4.glb
    -rw------- 1 severian severian   283132 Nov 10 18:20 lab_chests.glb
    -rw------- 1 severian severian   148000 Nov 10 18:20 lab_feet2.glb
    -rw------- 1 severian severian   430680 Nov 10 18:20 lab_feet3.glb
    -rw------- 1 severian severian   155308 Nov 10 18:20 lab_feet.glb
    -rw------- 1 severian severian  6416784 Nov 10 18:20 lab_frames.glb
    -rw------- 1 severian severian   471472 Nov 10 18:20 lab_heads2.glb
    -rw------- 1 severian severian  1033232 Nov 10 18:20 lab_heads3.glb
    -rw------- 1 severian severian   714520 Nov 10 18:20 lab_heads4.glb
    -rw------- 1 severian severian   697628 Nov 10 18:20 lab_heads5.glb
    -rw------- 1 severian severian   900656 Nov 10 18:20 lab_heads6.glb
    -rw------- 1 severian severian   979832 Nov 10 18:20 lab_heads7.glb
    -rw------- 1 severian severian  1119580 Nov 10 18:20 lab_heads8.glb
    -rw------- 1 severian severian   163260 Nov 10 18:20 lab_heads.glb
    -rw------- 1 severian severian  5656964 Nov 10 18:20 lab_heavy.glb
    -rw------- 1 severian severian  6683852 Nov 10 18:20 lab_light.glb
    -rw------- 1 severian severian  6240172 Nov 10 18:20 lab_pattern.glb
    -rw------- 1 severian severian  2391752 Nov 10 18:20 lab_pilot.glb
    -rw------- 1 severian severian  8038888 Nov 10 18:20 lab_raider.glb
    -rw------- 1 severian severian  7861896 Nov 10 18:20 lab_show.glb
    -rw------- 1 severian severian  7868532 Nov 10 18:20 lab_show_v.glb
    -rw------- 1 severian severian  6919124 Nov 10 18:20 lab_sizes.glb
    -rw------- 1 severian severian  1592796 Nov 10 18:20 light.glb
    -rw------- 1 severian severian  1419452 Nov 10 18:20 light_lancer.glb
    -rw------- 1 severian severian  1477908 Nov 10 18:20 light_line.glb
    -rw------- 1 severian severian  1435856 Nov 10 18:20 pattern_m.glb
    -rw------- 1 severian severian  1671740 Nov 10 18:20 raider_boss.glb
    -rw------- 1 severian severian  1880608 Nov 10 18:20 raider_brawler.glb
    -rw------- 1 severian severian  1634808 Nov 10 18:20 raider_grunt.glb
    -rw------- 1 severian severian    45456 Nov 10 18:20 rifle.glb
    -rw------- 1 severian severian   106456 Nov 10 18:20 salvage_pod.glb
    -rw------- 1 severian severian  1303976 Nov 10 18:20 ship.glb
    -rw------- 1 severian severian   738340 Nov 10 18:20 station.glb
    -rw------- 1 severian severian  1325664 Nov 10 18:20 striker_a.glb
    -rw------- 1 severian severian  1210224 Nov 10 18:20 striker_b.glb
    -rw------- 1 severian severian  1008336 Nov 10 18:20 striker.glb
    -rw------- 1 severian severian   462204 Nov 10 18:20 wreck_field.glb
    
    tools:
    total 72
    drwx------ 4 severian severian 4096 Nov 10 18:20 .
    drwx------ 8 severian severian 4096 Nov 10 18:24 ..
    -rw------- 1 severian severian 2144 Nov 10 18:20 artifact.mjs
    drwx------ 2 severian severian 4096 [redacted: server name]
    -rwx------ 1 severian severian 1530 Nov 10 18:20 [redacted: server name]
    -rw------- 1 severian severian 4047 Nov 10 18:20 clip.mjs
    drwx------ 2 severian severian 4096 Nov 10 18:20 fixtures
    -rwx------ 1 severian severian  329 Nov 10 18:20 log.sh
    -rw------- 1 severian severian 4530 Nov 10 18:20 outlines-lib.mjs
    -rw------- 1 severian severian 1806 Nov 10 18:20 outlines-lib.test.mjs
    -rw------- 1 severian severian 1747 Nov 10 18:20 outlines.mjs
    -rw------- 1 severian severian 2870 Nov 10 18:20 shoot.mjs
    -rwx------ 1 severian severian  487 Nov 10 18:20 show.sh
    -rw------- 1 severian severian 4512 Nov 10 18:20 squeeze.mjs
    -rwx------ 1 severian severian 1113 Nov 10 18:20 thruster-sheets.sh
    -rw------- 1 severian severian  511 Nov 10 18:20 turntable.py
    {
      "name": "sortie",
      "private": true,
      "version": "0.1.0",
      "type": "module",
      "scripts": {
        "dev": "vite --host",
        "build": "tsc --noEmit && vite build",
        "typecheck": "tsc --noEmit",
        "test": "vitest run",
        "kit": "blender -b --factory-startup -P kit/build.py --",
        "shoot": "node tools/shoot.mjs",
        "outlines": "node tools/outlines.mjs",
        "clip": "node tools/clip.mjs",
        "artifact": "VITE_MODEL_EXT=glb.json vite build && node tools/artifact.mjs"
      },
      "dependencies": {
        "@fontsource/chakra-petch": "^5.3.0",
        "@fontsource/share-tech-mono": "^5.3.0",
        "lil-gui": "^0.21.0",
        "three": "^0.186.1"
      },
      "devDependencies": {
        "@gltf-transform/core": "4.5.1",
        "@gltf-transform/extensions": "4.5.1",
        "@gltf-transform/functions": "4.5.1",
        "@types/three": "^0.186.0",
        "meshoptimizer": "1.3.0",
        "playwright": "^1.64.1",
        "typescript": "^7.0.2",
        "vite": "^8.3.5",
        "vitest": "^5.0.5"
      }
    }
    # Housekeeping
    
    State of the repo on 2026-11-08, for the one-mech restart. A snapshot, not a rule. Nothing was deleted.
    How to work is in [handbook.md](handbook.md).
    
    ## Docs
    
    | File | Status | Notes |
    |---|---|---|
    | [handbook.md](handbook.md) | Current | Start here |
    | [lore.md](lore.md) | Current | Agreed with the owner, names and "Open" still open |
    | [manufacturers.md](manufacturers.md) | Current | Roster agreed, stat leanings guessed |
    | [wiki.html](wiki.html) | Behind | Last changed 10-25. Lacks the atelier's house lines from 10-28. Published page, republish after syncing |
    | [thrusters.md](thrusters.md) | Current | The owner is happy with the result |
    | [sizes.md](sizes.md) | Current | Describes the shipped classes. 6 m and 24 m never confirmed by the owner |
    | [light-frames.md](light-frames.md) | Reference | Knightmare measurements, used by the light class |
    | [heads.md](heads.md) | Reference | The section on what the owner settled is earned, the principles are mine |
    | [factions.md](factions.md) | Reference | Applied to the shipped automatons, raiders and aliens |
    | [critique-factions.md](critique-factions.md) | Stale | Critique of a 10-25 round, kept as history |
    | [proposals/contracts.md](proposals/contracts.md) | Stale | Proposal, partly built since. The code and README are the truth |
    | [study-phantom-brigade.md](study-phantom-brigade.md) | Reference | Study notes. Its takeaways are proposals and the parts system is still open |
    | [visual-language.md](visual-language.md) | Parked | Mostly guessed rules, doesn't bind the restart |
    | [study-proportions.md](study-proportions.md) | Parked | Measurements usable, the targets are guessed |
    | [study-atelier.md](study-atelier.md) | Parked | Same: findings useful, rules guessed |
    
    ## Tools
    
    | File | Status | Notes |
    |---|---|---|
    | `tools/outlines.mjs`, `outlines-lib.mjs` | New | Outline sheets. `tools/fixtures/outlines-test.json` is a test, not a design |
    | `tools/clip.mjs`, `src/view/clip.ts`, `clip-plan.ts` | New | Review clips of any rigged model |
    | `kit/block.py`, `kit/blocks/` | New | Block models. `dummy.py` is a test fixture, not a design |
    | `tools/show.sh`, `tools/log.sh` | New | Open a file for the owner, timestamp a step |
    | `tools/shoot.mjs` | Current | Stills, needs a dev server on 5199 |
    | [redacted: server name] |
    | `tools/thruster-sheets.sh` | Current | Thruster bench sheets, needs a dev server |
    | `tools/artifact.mjs`, `tools/squeeze.mjs` | Unchecked | The playable page build. Last used in October, not run today |
    | `tools/turntable.py` | Looks dead | Nothing calls it. Kept |
    | `src/view/sheet.ts` (`?sheet=`) | Looks dead | Line art design sheets, last touched in the first days. Not run today. Kept |
    
    Reel scripts used for the thruster videos lived in a session scratchpad and are gone. `tools/clip.mjs` replaces them.
    
    ## Models
    
    - **In the game:** `striker`, `striker_a`, `striker_b`, `light*`, `heavy*`, `auto_*`, `alien_*`, `raider_*`, props, ship, station.
    - **Parked, not in the game:** `pattern_m` and everything from `kit/frame_std.py`, `kit/makers/`, `kit/lab/atelier_*`, `board_*`, `knightkit.py`.
    - **Review history:** 32 `lab_*.glb` files, none loaded by the game. The kit modules behind the head, chest
      and foot labs also feed `striker_a` and `striker_b` through `kit/lab/assembly.py`, so they aren't dead.
    - **Scratch:** `public/assets/block_*.glb`, gitignored.
    
    ## Where big files sit
    
    | Where | Size | In git | Notes |
    |---|---|---|---|
    | `public/assets/` | 170 MB | Yes | 141 MB of it is `lab_*.glb`, review only. Rebuildable, so could leave git one day, the owner's call |
    | `.git/` | 76 MB | | Old model versions |
    | `review/out/` | 532 MB | No | Local reference and render history. **Holds third-party art, never publish.** Biggest: `pb` 141 MB, `refs` 104 MB |
    | `.claude/worktrees/` | 1.7 GB | No | Four finished agent worktrees, three locked |
    | `[redacted: private path]` | 196 MB | No | Finished worker's worktree |
    | `Downloads\[redacted: private path]\` | about 440 MB for sortie | No | `pattern-r*`, `atelier-r*`, `thrusters`, `proportions`, `pb-study`. `sheet_refs*` holds third-party art |
    | [redacted: server name] | Not measured | No | A source tree per checkout, plus render runs |
    
    ## Branches
    
    All local branches are merged into main, and so are the remote ones. Safe to remove when wanted, nothing
    done: `atelier-board`, `harken-fixes-2`, `pattern-proportions`, the four `worktree-agent-*`, and on origin
    `pattern-proportions`, `thruster-plumes`, `worktree-agent-af68eccd1ec3c364c`. Remove the worktrees first, the
    locked ones need `git worktree unlock`.
    
    ## Open led todos, suggestions only
    
    | Todo | Suggestion | Why |
    |---|---|---|
    | #1005 owner picks: standard parts r13 to 15, sizes, naming, carry limits, `.q` fallback | **Split it** | Standard part picks are dead, those parts belong to the old striker work. Sizes, naming and carry limits still matter, but after the restart. `.q` is a separate technical check |
    | #981 pilot in a 00 style suit, from the lowmarch pipeline | Keep, someday | Unrelated to the restart. A code-built pilot (`kit/figure.py`) stands in, and clips use it for scale |
    | #982 ship and hangar look pass, flat explosions | Keep, someday | Unrelated to the restart. Not re-checked today |
    | #1369 project trackers | Not this session's | Belongs to personal/trackers |
    
    Worth adding, the owner's or lead's call: one todo for the one-mech restart, tied to this session.
    [redacted: listing of a private folder]
    10
     18:33:16 up 1 day,  6:41,  2 users,  load average: 2.54, 6.73, 7.72
                   total        used        free      shared  buff/cache   available
    Mem:              49          11           1           0          35          36
  • Bashls -la [redacted: private path]/fable52-sortie/ [redacted: private path]/fable52-lowmarch/ | head -30; cat tools/outlines-lib.mjs tools/outlines.mjs tools/clip.mjs kit/block.py kit/blocks/dummy.py tools/show.sh tools/log.sh; ls src/view tools/fixtures; cat .gitignore

    command

    ls -la [redacted: private path]/fable52-sortie/ [redacted: private path]/fable52-lowmarch/ | head -30; cat tools/outlines-lib.mjs tools/outlines.mjs tools/clip.mjs kit/block.py kit/blocks/dummy.py tools/show.sh tools/log.sh; ls src/view tools/fixtures; cat .gitignore

    result, 364 lines

    [redacted: private path]/fable52-lowmarch/:
    total 8
    drwx------  2 severian severian 4096 Nov 10 18:20 .
    drwx------ 29 severian severian 4096 Nov 10 18:20 ..
    
    [redacted: private path]/fable52-sortie/:
    total 8
    drwx------  2 severian severian 4096 Nov 10 18:20 .
    drwx------ 29 severian severian 4096 Nov 10 18:20 ..
    // Outline sheets: rough black shapes at one scale, for reacting to in seconds (docs/handbook.md).
    // A spec is plain data, in metres, x across, z up, ground at z = 0, centre line at x = 0:
    //   { "title": "round 1", "outlines": [ { "note": "optional", "parts": [
    //       { "pts": [[x, z], ...], "mirror": true },     a polygon, and its mirror across x = 0
    //       { "circle": [x, z, r], "mirror": true } ],    a circle
    //     "side": [ ... same parts ... ] } ] }            optional side view, drawn beside the front
    const PILOT_M = 1.75;
    
    function bounds(parts) {
      let x = 0, z = 0;
      for (const p of parts ?? []) {
        if (p.circle) {
          x = Math.max(x, Math.abs(p.circle[0]) + p.circle[2]);
          z = Math.max(z, p.circle[1] + p.circle[2]);
        } else for (const [px, pz] of p.pts) {
          x = Math.max(x, Math.abs(px));
          z = Math.max(z, pz);
        }
      }
      return { halfWidth: x, height: z };
    }
    
    function shape(p, tx, ty, s, flip) {
      const sign = flip ? -1 : 1;
      if (p.circle) {
        const [x, z, r] = p.circle;
        return `<circle cx="${(tx + sign * x * s).toFixed(1)}" cy="${(ty - z * s).toFixed(1)}" r="${(r * s).toFixed(1)}"/>`;
      }
      const pts = p.pts.map(([x, z]) => `${(tx + sign * x * s).toFixed(1)},${(ty - z * s).toFixed(1)}`).join(' ');
      return `<polygon points="${pts}"/>`;
    }
    
    function shapes(parts, tx, ty, s) {
      const out = [];
      for (const p of parts ?? []) {
        out.push(shape(p, tx, ty, s, false));
        if (p.mirror) out.push(shape(p, tx, ty, s, true));
      }
      return out.join('');
    }
    
    /** A person for scale: plain enough not to read as part of any design. */
    function person(x, ground, s) {
      const h = PILOT_M * s, w = Math.max(h * 0.28, 2);
      return `<g fill="#b03a2e"><rect x="${(x - w / 2).toFixed(1)}" y="${(ground - h * 0.82).toFixed(1)}" width="${w.toFixed(1)}" height="${(h * 0.82).toFixed(1)}"/>` +
        `<circle cx="${x.toFixed(1)}" cy="${(ground - h * 0.9).toFixed(1)}" r="${(h * 0.1).toFixed(1)}"/></g>`;
    }
    
    /** The sheet as an SVG string, with its pixel size. Every outline is drawn at the same scale. */
    export function outlineSheet(spec, { cols = 6, tileHeight = 460 } = {}) {
      const list = spec.outlines ?? [];
      if (!list.length) throw new Error('outlines: the spec has no outlines');
      let tall = 0, front = 0, side = 0;
      for (const o of list) {
        const f = bounds(o.parts), b = bounds(o.side);
        tall = Math.max(tall, f.height, b.height);
        front = Math.max(front, f.halfWidth);
        side = Math.max(side, b.halfWidth);
      }
      if (tall <= 0 || front <= 0) throw new Error('outlines: nothing has any size');
      const margin = { top: 34, bottom: 18, gap: 16 };
      const s = (tileHeight - margin.top - margin.bottom) / tall;
      const frontW = front * 2 * s, sideW = side * 2 * s;
      const tileW = Math.ceil(frontW + (side ? sideW + margin.gap : 0) + margin.gap * 2 + 14);
      const rows = Math.ceil(list.length / cols);
      const head = spec.title ? 34 : 0;
      const W = Math.min(cols, list.length) * tileW, H = rows * tileHeight + head;
      const tiles = list.map((o, i) => {
        const x0 = (i % cols) * tileW, y0 = Math.floor(i / cols) * tileHeight + head;
        const ground = y0 + tileHeight - margin.bottom;
        const fx = x0 + margin.gap + frontW / 2;
        const sx = fx + frontW / 2 + margin.gap + sideW / 2;
        const px = x0 + tileW - 9;
        return `<rect x="${x0 + .5}" y="${y0 + .5}" width="${tileW - 1}" height="${tileHeight - 1}" fill="none" stroke="#d6d6d2"/>` +
          `<line x1="${x0 + 6}" x2="${x0 + tileW - 6}" y1="${ground}" y2="${ground}" stroke="#a9a9a4"/>` +
          `<text x="${x0 + 8}" y="${y0 + 22}" class="n">${i + 1}</text>` +
          (o.note ? `<text x="${x0 + 38}" y="${y0 + 22}" class="t">${escapeXml(o.note)}</text>` : '') +
          `<g fill="#111" stroke="#111" stroke-width=".8">${shapes(o.parts, fx, ground, s)}${o.side ? shapes(o.side, sx, ground, s) : ''}</g>` +
          person(px, ground, s);
      }).join('');
      const title = spec.title ? `<text x="8" y="23" class="h">${escapeXml(spec.title)}</text>` : '';
      const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}">` +
        `<style>text{font-family:system-ui,sans-serif;fill:#333}.n{font-size:18px;font-weight:700}.t{font-size:12px}.h{font-size:16px;font-weight:600}</style>` +
        `<rect width="${W}" height="${H}" fill="#f4f4f1"/>${title}${tiles}</svg>`;
      return { svg, width: W, height: H, count: list.length, scale: s };
    }
    
    function escapeXml(t) {
      return String(t).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' })[c]);
    }
    // Render an outline sheet to SVG and PNG (spec format in tools/outlines-lib.mjs).
    //   node tools/outlines.mjs <spec.json|spec.mjs> [--cols 6] [--tile 460] [--out file.png]
    // A .mjs spec exports the spec as default, so variations can be generated in code. Headless only.
    import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
    import { dirname, resolve } from 'node:path';
    import { pathToFileURL } from 'node:url';
    import { chromium } from 'playwright';
    import { outlineSheet } from './outlines-lib.mjs';
    
    const args = process.argv.slice(2);
    const flag = (name, fallback) => {
      const i = args.indexOf(`--${name}`);
      return i >= 0 ? args[i + 1] : fallback;
    };
    const file = args[0];
    if (!file || file.startsWith('--')) {
      console.error('usage: node tools/outlines.mjs <spec.json|spec.mjs> [--cols 6] [--tile 460] [--out file.png]');
      process.exit(2);
    }
    const started = Date.now();
    const path = resolve(file);
    const spec = path.endsWith('.mjs') ? (await import(`${pathToFileURL(path)}?t=${Date.now()}`)).default : JSON.parse(readFileSync(path, 'utf8'));
    const { svg, width, height, count } = outlineSheet(spec, { cols: Number(flag('cols', 6)), tileHeight: Number(flag('tile', 460)) });
    const out = resolve(flag('out', path.replace(/\.(json|mjs)$/, '.png')));
    mkdirSync(dirname(out), { recursive: true });
    writeFileSync(out.replace(/\.png$/, '.svg'), svg);
    const browser = await chromium.launch();
    try {
      const page = await browser.newPage({ viewport: { width, height } });
      await page.setContent(`<!doctype html><body style="margin:0">${svg}</body>`);
      await page.screenshot({ path: out });
    } finally {
      await browser.close();
    }
    console.log(`outlines: ${out} (${count} outlines, ${width}x${height}, ${Date.now() - started} ms)`);
    // A review clip of one model: chase camera, orbit, turntable, range of motion, next to a pilot.
    //   node tools/clip.mjs <model> [--quick] [--shots chase,turn] [--fps 24] [--size 854x480] [--palette merc] [--look kit] [--out file.mp4]
    // --quick is for the loop: chase and turntable only, 12 fps, 640x360.
    // Starts its own dev server on a free port and always stops it. Frames are rendered one at a time, so
    // the clip is smooth however slow the machine (src/view/clip.ts). Writes the mp4 and, because a reader
    // that can't watch video still has to judge it, a contact sheet of frames beside it. Headless only.
    import { spawn, spawnSync } from 'node:child_process';
    import { mkdirSync } from 'node:fs';
    import { dirname, resolve } from 'node:path';
    import { chromium } from 'playwright';
    import { createServer } from 'vite';
    
    const args = process.argv.slice(2);
    const flag = (name, fallback) => {
      const i = args.indexOf(`--${name}`);
      return i >= 0 ? args[i + 1] : fallback;
    };
    const name = args[0];
    if (!name || name.startsWith('--')) {
      console.error('usage: node tools/clip.mjs <model> [--quick] [--shots chase,orbit,turn,bend,scale] [--fps 24] [--size 854x480] [--palette merc] [--look kit] [--out file.mp4]');
      process.exit(2);
    }
    const quick = args.includes('--quick');
    const [w, h] = flag('size', quick ? '640x360' : '854x480').split('x').map(Number);
    const fps = Number(flag('fps', quick ? 12 : 24));
    const out = resolve(flag('out', `review/out/one-mech/clips/${name}.mp4`));
    const params = new URLSearchParams({ view: 'clip', model: name, w, h, fps, palette: flag('palette', 'merc') });
    for (const k of ['shots', 'look']) if (flag(k)) params.set(k, flag(k));
    if (quick && !flag('shots')) params.set('shots', 'chase,turn');
    mkdirSync(dirname(out), { recursive: true });
    
    const started = Date.now();
    const server = await createServer({ server: { host: '127.0.0.1', port: 5230, strictPort: false }, logLevel: 'error' });
    await server.listen();
    const browser = await chromium.launch({ args: ['--use-angle=swiftshader', '--enable-unsafe-swiftshader', '--ignore-gpu-blocklist'] });
    let failed = false;
    try {
      const page = await browser.newPage({ viewport: { width: w, height: h } });
      page.setDefaultTimeout(300000);
      page.on('pageerror', (e) => { failed = true; console.error('[pageerror]', e.message); });
      page.on('console', (m) => { if (m.type() === 'error') console.error('[console]', m.text().slice(0, 300)); });
      await page.goto(`${server.resolvedUrls.local[0]}?${params}`);
      await page.waitForFunction(() => window.__ready === true);
      const frames = await page.evaluate(() => window.__clip.frames);
      const loaded = Date.now();
      const ffmpeg = spawn('ffmpeg', ['-loglevel', 'error', '-y', '-f', 'image2pipe', '-c:v', 'mjpeg', '-framerate', String(fps), '-i', '-',
        '-c:v', 'libx264', '-crf', '20', '-pix_fmt', 'yuv420p', '-movflags', '+faststart', out], { stdio: ['pipe', 'inherit', 'inherit'] });
      const ended = new Promise((ok) => ffmpeg.on('close', ok));
      for (let i = 0; i < frames; i++) {
        const url = await page.evaluate((n) => window.__clip.render(n), i);
        const jpeg = Buffer.from(url.slice(url.indexOf(',') + 1), 'base64');
        if (!ffmpeg.stdin.write(jpeg)) await new Promise((ok) => ffmpeg.stdin.once('drain', ok));
      }
      ffmpeg.stdin.end();
      const code = await ended;
      if (code !== 0) throw new Error(`ffmpeg exited ${code}`);
      const every = Math.max(1, Math.floor(frames / 12));
      const sheet = out.replace(/\.mp4$/, '.sheet.jpg');
      spawnSync('ffmpeg', ['-loglevel', 'error', '-y', '-i', out, '-vf', `select=not(mod(n\\,${every})),scale=480:-1,tile=4x3`, '-frames:v', '1', '-q:v', '4', sheet], { stdio: 'inherit' });
      const secs = (Date.now() - started) / 1000;
      console.log(`clip: ${out}`);
      console.log(`clip: ${sheet}`);
      console.log(`clip: ${frames} frames, ${(frames / fps).toFixed(1)} s of video, ${secs.toFixed(0)} s to make (${((Date.now() - loaded) / frames).toFixed(0)} ms a frame)`);
    } finally {
      await browser.close();
      await server.close();
    }
    process.exit(failed ? 1 : 0);
    """Block models: plain boxes on the 22 joint rig, for judging mass and motion before any plate exists.
    
    A block model is one file, kit/blocks/<name>.py, with a build() that takes this module's Blocks class.
    It builds in seconds, into a gitignored public/assets/block_<name>.glb:
    
        npm run kit -- block_dummy
        npm run clip -- block_dummy
    
    Geometry is authored in world rest pose coordinates in metres, models facing -Y, Z up, left is +X, as
    in the rest of the kit. Roles are the usual ones (main, accent, frame, joint). Nothing here is a design
    rule: no maker, frame or grade carries over unless a block file asks for it.
    """
    import importlib
    
    import bpy
    from mathutils import Vector
    
    from lib import loft, merge, mirror_x, octo, solid
    from mech import joints as striker_joints, nozzle_pair, pair
    
    SIDED = {"shoulder", "upperarm", "forearm", "hand", "grip", "thigh", "shin", "foot", "binder"}
    BEVEL = .03
    
    
    class Blocks:
        """The rig plus block primitives. `joints` overrides rest positions: {"thigh": (1.1, 0, 9.5)} moves
        both thighs (give the left, +X, the right mirrors), {"pelvis": (0, 0, 9.8)} moves one node. Other
        joints stay where the striker has them, in world coordinates, so moving one moves nothing else."""
    
        def __init__(self, joints=None, height=17.6):
            J = striker_joints()
            self.nodes = {o.name: o for o in J.values()}
            self.n = 0
            J["frame"]["frame"] = "block"
            J["frame"]["height"] = height
            place = {name: o.matrix_world.translation.copy() for name, o in self.nodes.items()}
            for key, at in (joints or {}).items():
                if key in SIDED:
                    place[f"{key}.L"] = Vector(at)
                    place[f"{key}.R"] = Vector((-at[0], at[1], at[2]))
                elif key in place:
                    place[key] = Vector(at)
                else:
                    raise KeyError(f"block: no joint {key}")
            for name, o in self.nodes.items():  # striker_joints() makes parents first
                if o.parent is not None:
                    o.location = o.parent.matrix_world.inverted() @ place[name]
                bpy.context.view_layer.update()
    
        def at(self, name):
            return self.nodes[name].matrix_world.translation.copy()
    
        def _put(self, joint, bm, role, mirror):
            self.n += 1
            name = f"block{self.n}_{joint}"
            if joint in SIDED:
                pair(name, bm, role, self.nodes[f"{joint}.L"], self.nodes[f"{joint}.R"], bevel=BEVEL, panels=False)
            elif mirror:
                solid(name, merge(bm, mirror_x(bm)), role, self.nodes[joint], bevel=BEVEL, panels=False)
            else:
                solid(name, bm, role, self.nodes[joint], bevel=BEVEL, panels=False)
    
        def box(self, joint, x, y, z, role="main", mirror=False):
            """A box from x, y, z ranges (lo, hi). A sided joint (thigh, shin, ...) takes the left's numbers
            and mirrors to the right. `mirror` does the same for a box on a centre joint."""
            r = [(x[0], y[0]), (x[1], y[0]), (x[1], y[1]), (x[0], y[1])]
            self._put(joint, loft([(z[0], r), (z[1], r)]), role, mirror)
    
        def taper(self, joint, rings, role="main", mirror=False, chamfer=.15):
            """A lofted block through rings (z, width, depth, x, y), bottom to top."""
            self._put(joint, loft([(z, octo(w, d, chamfer, x=x, y=y)) for z, w, d, x, y in rings]), role, mirror)
    
        def bone(self, joint, a, b, w, d, role="main", chamfer=.1):
            """A block from joint a to joint b, both named for the left side: bone("thigh", "thigh.L", "shin.L", 1, 1)."""
            pa, pb = self.at(a), self.at(b)
            lo, hi = (pa, pb) if pa.z < pb.z else (pb, pa)
            self.taper(joint, [(lo.z, w, d, lo.x, lo.y), (hi.z, w, d, hi.x, hi.y)], role, chamfer=chamfer)
    
        def nozzles(self, joint, at, direction, r=.45, length=.9, kind="main"):
            """A nozzle pair that fires plumes in the game. `kind`: main, binder or calf."""
            if joint in SIDED:
                jl, jr = self.nodes[f"{joint}.L"], self.nodes[f"{joint}.R"]
            else:
                jl = jr = self.nodes[joint]
            nozzle_pair(kind, at, direction, r, length, jl, jr, housing=False)
    
        def mannequin(self):
            """A neutral box on every bone, sized from the joints alone. For testing tools, not a design."""
            for joint, a, b, w, d in (("thigh", "thigh.L", "shin.L", 1.0, 1.0), ("shin", "shin.L", "foot.L", 1.0, 1.0),
                                      ("upperarm", "upperarm.L", "forearm.L", .7, .7), ("forearm", "forearm.L", "hand.L", .7, .7)):
                self.bone(joint, a, b, w, d)
            foot = self.at("foot.L")
            self.box("foot", (foot.x - .5, foot.x + .5), (foot.y - 1.2, foot.y + .6), (0, foot.z))
            hand = self.at("hand.L")
            self.box("hand", (hand.x - .3, hand.x + .3), (hand.y - .3, hand.y + .3), (hand.z - .8, hand.z))
            pelvis, torso, neck, head = self.at("pelvis"), self.at("torso"), self.at("neck"), self.at("head")
            self.box("pelvis", (-1.3, 1.3), (-.8, .8), (pelvis.z - .8, pelvis.z + .4))
            self.box("waist", (-.8, .8), (-.6, .6), (pelvis.z + .4, torso.z))
            shoulder = self.at("shoulder.L")
            self.box("torso", (-shoulder.x, shoulder.x), (-1, 1), (torso.z, neck.z))
            self.box("shoulder", (shoulder.x, shoulder.x + .9), (-.6, .6), (shoulder.z - .6, shoulder.z + .4))
            self.box("neck", (-.3, .3), (-.3, .3), (neck.z, head.z))
            self.box("head", (-.5, .5), (-.6, .6), (head.z, head.z + 1.1))
            pack = self.at("backpack")
            self.box("backpack", (-.9, .9), (pack.y - .5, pack.y + .5), (pack.z - 1, pack.z + 1))
    
    
    def build_block(name):
        """block_<name> from kit/blocks/<name>.py."""
        module = importlib.import_module(f"blocks.{name.removeprefix('block_')}")
        importlib.reload(module)
        module.build(Blocks)
    """Test fixture for the block tools: an automatic box on every bone, sized from the default joints.
    Not a design. Delete nothing here, copy it to start a real block file."""
    
    
    def build(Blocks):
        b = Blocks()
        b.mannequin()
        pack = b.at("backpack")
        b.nozzles("backpack", (.5, pack.y + .4, pack.z - .9), (0, .45, -.9))
    #!/usr/bin/env bash
    # Put a sheet or clip in front of the owner: copy it to their Downloads and open it, and note the time.
    #   tools/show.sh <file> [more files]     NO_OPEN=1 copies without opening
    set -euo pipefail
    here=$(cd "$(dirname "$0")" && pwd)
    dest=${SHOW_DEST:-[redacted: Windows home]/Downloads/[redacted: private path]/one-mech}
    mkdir -p "$dest"
    for f in "$@"; do
      cp "$f" "$dest/"
      [ "${NO_OPEN:-}" = 1 ] || cw view "$dest/$(basename "$f")"
      "$here/log.sh" "shown: $(basename "$f")"
    done
    #!/usr/bin/env bash
    # One timestamped line in the session log, so we can see how long each step takes.
    #   tools/log.sh "owner: feet too small"
    set -euo pipefail
    root=$(cd "$(dirname "$0")/.." && pwd)
    log="$root/review/out/one-mech/log.txt"
    mkdir -p "$(dirname "$log")"
    printf '%s  %s\n' "$(date +%H:%M:%S)" "$*" | tee -a "$log"
    src/view:
    cameras.ts
    clip-plan.test.ts
    clip-plan.ts
    clip.ts
    sheet.ts
    thrusters.ts
    viewer.ts
    
    tools/fixtures:
    outlines-test.json
    node_modules/
    dist/
    review/out/
    *.blend1
    __pycache__/
    # block models are scratch until one is worth keeping
    public/assets/block_*.glb
    
    # worktrees of finished agents, see docs/housekeeping.md
    .claude/worktrees/
  • Bashcat src/view/clip-plan.ts src/view/clip.ts && sed -n 1,60p src/view/viewer.ts && cat kit/build.py | head -120

    command

    cat src/view/clip-plan.ts src/view/clip.ts && sed -n 1,60p src/view/viewer.ts && cat kit/build.py | head -120

    result, 376 lines

    import type { Pose } from '../render/mech';
    import type { BenchState } from './thrusters';
    
    /**
     * The timeline of a review clip (src/view/clip.ts), as a pure function of frame number, so a clip is the
     * same every run whatever the machine's speed. Shots frame the model and nothing here is a design choice:
     * the chase shot sits where the game's camera sits, the rest show it from all round, bending and to scale.
     */
    export const SHOTS = { chase: 3.5, orbit: 3, turn: 4, bend: 3, scale: 2.5 } as const;
    export type ShotName = keyof typeof SHOTS;
    export const SHOT_NAMES = Object.keys(SHOTS) as ShotName[];
    
    /** Thruster states through a shot: [start second, state]. */
    const SCHEDULE: Partial<Record<ShotName, [number, BenchState][]>> = {
      chase: [[0, 'cruise'], [1, 'boost'], [2.4, 'quick'], [3, 'cruise']],
      orbit: [[0, 'boost'], [1.4, 'brake'], [2.2, 'idle']],
    };
    
    export interface ClipFrame {
      shot: ShotName;
      /** Seconds into the shot, and the same as a 0..1 fraction. */
      t: number;
      u: number;
      state: BenchState;
      /** Seconds since this thruster state began. */
      stateT: number;
      /** First frame of a shot: everything snaps. */
      cut: boolean;
    }
    
    export function clipFrames(shots: readonly ShotName[], fps: number): ClipFrame[] {
      const out: ClipFrame[] = [];
      for (const shot of shots) {
        const n = Math.max(1, Math.round(SHOTS[shot] * fps));
        const plan = SCHEDULE[shot] ?? [[0, 'idle'] as [number, BenchState]];
        for (let i = 0; i < n; i++) {
          const t = i / fps;
          let at = plan[0];
          for (const p of plan) if (p[0] <= t + 1e-9) at = p;
          out.push({ shot, t, u: n > 1 ? i / (n - 1) : 0, state: at[1], stateT: t - at[0], cut: i === 0 });
        }
      }
      return out;
    }
    
    /** Where things are in a shot. Lengths are in frame heights, angles in degrees. Yaw 0 looks at the
     *  frame's front, 180 at its back. `chase` means the game's chase camera, turned by mechYaw. */
    export interface ShotView {
      chase: boolean;
      mechYaw: number;
      camYaw: number;
      pitch: number;
      dist: number;
      /** Look point height as a fraction of the frame's height. */
      lookAt: number;
      pose: 'flight' | 'stand';
      /** How far toward BEND_POSE, 0..1. */
      bend: number;
      /** The pilot and the deck are in shot. */
      ground: boolean;
    }
    
    const ease = (x: number) => x * x * (3 - 2 * x);
    
    export function shotView(f: ClipFrame): ShotView {
      const base = { chase: false, mechYaw: 0, camYaw: 0, pitch: 8, dist: 2.4, lookAt: 0.5, pose: 'stand', bend: 0, ground: false } as ShotView;
      switch (f.shot) {
        case 'chase': {
          // a gentle turn and back: the camera trails the frame, so the stars pan and the frame leans in shot
          const turn = Math.sin(f.u * Math.PI * 2) * 22;
          return { ...base, chase: true, mechYaw: turn, camYaw: turn * 0.75, pose: 'flight' };
        }
        case 'orbit':
          return { ...base, camYaw: 165 - 75 * ease(f.u), pitch: 12, dist: 2.2, pose: 'flight' };
        case 'turn':
          return { ...base, camYaw: 180 + 360 * f.u };
        case 'bend':
          return { ...base, camYaw: 35, pitch: 6, bend: Math.sin(f.u * Math.PI) ** 2 };
        case 'scale':
          // from the deck beside the pilot, looking up at the frame, pushing in slowly
          return { ...base, camYaw: 28, pitch: -6 + 2 * f.u, dist: 2.25 - 0.15 * ease(f.u), lookAt: 0.42, ground: true };
      }
    }
    
    /** A deliberately large range of motion, to find plates that collide or joints that show. Glances at
     *  every limb: one arm up and forward, the other out, one knee high, a twist. */
    export const BEND_POSE: Pose = {
      torso: [12, 18, 0], head: [-8, -24, 0],
      'upperarm.L': [-115, 0, 22], 'forearm.L': [-80, 0, 0],
      'upperarm.R': [-20, 0, -72], 'forearm.R': [-100, 0, 0],
      'thigh.L': [-85, 0, 10], 'shin.L': [100, 0, 0], 'foot.L': [-22, 0, 0],
      'thigh.R': [-8, 0, -14], 'shin.R': [22, 0, 0], 'foot.R': [8, 0, 0],
      'binder.L': [-20, 0, 0], 'binder.R': [20, 0, 0],
    };
    
    /** A blend of two poses, joint by joint. */
    export function mixPose(a: Pose, b: Pose, w: number): Pose {
      const out: Pose = {};
      for (const j of new Set([...Object.keys(a), ...Object.keys(b)]) as Set<keyof Pose>) {
        const p = a[j] ?? [0, 0, 0], q = b[j] ?? [0, 0, 0];
        out[j] = [p[0] + (q[0] - p[0]) * w, p[1] + (q[1] - p[1]) * w, p[2] + (q[2] - p[2]) * w];
      }
      return out;
    }
    import * as THREE from 'three';
    import { model, type ModelName } from '../render/assets';
    import { STRIKER_DECALS, applyDecals } from '../render/decals';
    import { treatEyes } from '../render/eyes';
    import type { ThrustReading } from '../render/exhaust';
    import { setLook, look } from '../render/look';
    import { MechRig, POSES } from '../render/mech';
    import type { PaletteName } from '../render/palette';
    import { Pipeline } from '../render/pipeline';
    import { addSpaceLight, createBackdrop, followSun, spaceEnvironment } from '../render/space';
    import { BEND_POSE, SHOT_NAMES, clipFrames, mixPose, shotView, type ShotName } from './clip-plan';
    import { CameraRig } from './cameras';
    import { benchInput } from './thrusters';
    
    /**
     * A review clip of one model, rendered frame by frame so it comes out the same on any machine. Driven by
     * tools/clip.mjs, which calls window.__clip.render(i) and pipes the frames into ffmpeg.
     *   /?view=clip&model=block_dummy&shots=chase,turn&fps=24&palette=merc&look=kit
     * Any model with the 22 joint rig. Lab lineups hold many frames under slots, so they don't rig.
     */
    export async function startClip(canvas: HTMLCanvasElement, q: URLSearchParams) {
      setLook(q.get('look'));
      await document.fonts.ready;
      const w = Number(q.get('w') ?? 854), h = Number(q.get('h') ?? 480), fps = Number(q.get('fps') ?? 24);
      const shots = (q.get('shots')?.split(',') ?? SHOT_NAMES) as ShotName[];
      const frames = clipFrames(shots, fps);
    
      const scene = new THREE.Scene();
      const camera = new THREE.PerspectiveCamera(35, w / h, 0.3, 2e5);
      const backdrop = createBackdrop();
      const pipe = new Pipeline(canvas, scene, camera, backdrop);
      pipe.resize(w, h);
      const sun = addSpaceLight(scene);
      scene.environment = spaceEnvironment(pipe.renderer, backdrop);
      scene.environmentIntensity = 0.8 * look().fill;
    
      const name = (q.get('model') ?? 'striker') as ModelName;
      const palette = (q.get('palette') ?? 'merc') as PaletteName;
      const root = await model(name, palette);
      if (name === 'striker') applyDecals(root, STRIKER_DECALS);
      treatEyes(root, 'spill');
      scene.add(root);
      const rig = new MechRig(root);
      root.updateMatrixWorld(true);
      rig.apply(POSES.stand);
      root.updateMatrixWorld(true);
      const box = new THREE.Box3().setFromObject(root);
      const height = box.getSize(new THREE.Vector3()).y;
      const footY = box.min.y;
      const size = height / 17.6;
    
      const light = new THREE.PointLight('#ffffff', 0, 0, 2);
      scene.add(light);
    
      // the pilot and deck for the scale shot: a person is the one thing everyone knows the size of
      const ground = new THREE.Group();
      const deck = new THREE.Mesh(new THREE.CircleGeometry(height * 2, 48), new THREE.MeshStandardMaterial({ color: '#2a2f36', roughness: 0.85, metalness: 0.2 }));
      deck.rotation.x = -Math.PI / 2;
      deck.position.y = footY;
      ground.add(deck);
      const pilot = await model('lab_pilot' as ModelName, palette);
      pilot.traverse((o) => { if (/^slot\d+$/.test(o.name) && o.name !== 'slot0') o.visible = false; });
      // lab slot 0 stands at x = -.55: bring the pilot beside the frame's foot, facing the camera
      pilot.position.set(0.55 + height * 0.3, footY, height * 0.16);
      pilot.rotation.y = 0.4;
      ground.add(pilot);
      scene.add(ground);
    
      // the game's chase camera, read for its numbers: this view moves its own camera
      const chase = new CameraRig();
      const reading: ThrustReading = { x: 0, y: 0, z: 0, boosting: false };
      const centre = new THREE.Vector3();
      const offset = new THREE.Vector3();
      const look_ = new THREE.Vector3();
      const up = new THREE.Vector3(0, 1, 0);
      const yawQ = new THREE.Quaternion();
      const DT = 1 / 120;
      let clock = 0;
    
      const feed = (state: Parameters<typeof benchInput>[0], t: number, dt: number) => {
        const f = benchInput(state, t);
        reading.x = f.thrust.x;
        reading.y = f.thrust.y;
        reading.z = f.thrust.z;
        reading.boosting = f.boosting;
        reading.assault = f.assault;
        reading.quick = f.quick;
        rig.thrust(reading, clock, dt);
        rig.lightExhaust(light);
      };
    
      const render = (i: number) => {
        const f = frames[i];
        const v = shotView(f);
        // thrusters step at 120 Hz whatever the clip's frame rate, as a game would
        const dt = f.cut ? 0 : 1 / fps;
        if (f.cut) for (let k = 0; k < 120; k++) { clock += DT; feed('idle', k * DT, DT); }
        for (let s = 0; s < dt - 1e-9; s += DT) {
          clock += DT;
          feed(f.state, Math.max(0, f.stateT - dt + s), DT);
        }
        if (dt === 0) feed(f.state, f.stateT, 0);
    
        root.rotation.y = THREE.MathUtils.degToRad(v.mechYaw);
        rig.apply(v.bend > 0 ? mixPose(POSES.stand, BEND_POSE, v.bend) : POSES[v.pose]);
        root.updateMatrixWorld(true);
        ground.visible = v.ground;
        centre.set(0, footY + height * v.lookAt, 0);
        const fov = v.chase ? chase.camera.fov : 35;
        if (camera.fov !== fov) {
          camera.fov = fov;
          camera.updateProjectionMatrix();
        }
        if (v.chase) {
          // where the game's chase camera sits (src/view/cameras.ts), over the shoulder, scaled to the frame
          yawQ.setFromAxisAngle(up, THREE.MathUtils.degToRad(v.camYaw));
          offset.set(chase.shoulder * size, chase.chaseOffset.y * size, chase.chaseOffset.z * size).applyQuaternion(yawQ);
          camera.position.copy(centre).add(offset);
          look_.set(chase.shoulder * size, (chase.chaseOffset.y - chase.lookDrop) * size, 400).applyQuaternion(yawQ).add(centre);
          camera.up.copy(up);
          camera.lookAt(look_);
        } else {
          const yaw = THREE.MathUtils.degToRad(v.camYaw), pitch = THREE.MathUtils.degToRad(v.pitch);
          camera.position.set(Math.sin(yaw) * Math.cos(pitch), Math.sin(pitch), Math.cos(yaw) * Math.cos(pitch)).multiplyScalar(v.dist * height).add(centre);
          if (v.ground) camera.position.y = Math.max(camera.position.y, footY + 1.6); // eye height, above the deck
          camera.up.copy(up);
          camera.lookAt(centre);
        }
        camera.updateMatrixWorld(true);
        followSun(sun, centre);
        pipe.render();
        // read straight after the draw, in the same task, while the buffer still holds it
        return canvas.toDataURL('image/jpeg', 0.93);
      };
    
      const win = window as unknown as { __clip: unknown; __ready: boolean };
      win.__clip = { frames: frames.length, fps, render };
      win.__ready = true;
    }
    import * as THREE from 'three';
    import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
    import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
    import { model, type ModelName } from '../render/assets';
    import { MechRig, POSES, type PoseName } from '../render/mech';
    import type { PaletteName } from '../render/palette';
    import { Pipeline } from '../render/pipeline';
    import { addSpaceLight, createBackdrop, followSun, spaceEnvironment } from '../render/space';
    import { STRIKER_DECALS, applyDecals, type DecalSpec } from '../render/decals';
    import { PALETTES } from '../render/palette';
    import { look, setLook } from '../render/look';
    import { treatEyes, type EyeMode } from '../render/eyes';
    import { fitShip } from '../render/ship';
    import type { FrameClassId } from '../sim/frames';
    
    /**
     * Model viewer for review shots, in the game's own renderer:
     *   /?view=striker&yaw=35&pitch=8&dist=34&pose=flight&weapon=rifle&palette=automaton
     *   /?view=lineup  (the frame in each palette, side by side)
     *   /?view=ship&bays=light,heavy&frame=light  (bay fits and shuttle clamps)
     *   /?view=light&pose=launch&weapon=rifle  (light and heavy frames and their variants pose like the striker)
     */
    const FRAMES: string[] = ['striker_a', 'striker_b', 'light', 'light_line', 'light_lancer', 'heavy', 'heavy_B', 'heavy_C'];
    
    /** An emblem at every bearing anchor of a model: the anchor's position, its direction into the plate, its size. */
    function bearingDecals(root: THREE.Object3D, color: string): DecalSpec[] {
      root.updateMatrixWorld(true);
      const out: DecalSpec[] = [];
      root.traverse((o) => {
        if (!o.name.startsWith('bearing') || !o.visible) return;
        const at = root.worldToLocal(o.getWorldPosition(new THREE.Vector3()));
        const dir = o.userData.dir as [number, number, number] | undefined;
        const size = Number(o.userData.size ?? 0.5);
        if (dir) out.push({ kind: 'emblem', at: [at.x, at.y, at.z], dir, size: [size, size], color });
      });
      return out;
    }
    
    export async function startViewer(canvas: HTMLCanvasElement, q: URLSearchParams) {
      setLook(q.get('look'));
      await document.fonts.ready;
      const scene = new THREE.Scene();
      const camera = new THREE.PerspectiveCamera(Number(q.get('fov') ?? 35), 1, 0.5, 2e5);
      // ?bg=studio: a plain grey ground, an even room light and little bloom, for judging shape
      const studio = q.get('bg') === 'studio';
      const backdrop = createBackdrop();
      const pipe = new Pipeline(canvas, scene, camera, studio ? null : backdrop);
      const sun = addSpaceLight(scene);
      if (studio) {
        scene.background = new THREE.Color('#3a3e45');
        const pmrem = new THREE.PMREMGenerator(pipe.renderer);
        scene.environment = pmrem.fromScene(new RoomEnvironment(), 0.04).texture;
        pipe.bloom.strength = Number(q.get('bloom') ?? 0.12);
      } else scene.environment = spaceEnvironment(pipe.renderer, backdrop);
      scene.environmentIntensity = Number(q.get('env') ?? (studio ? 0.6 : 0.8) * look().fill);
      const name = q.get('view') as ModelName | 'lineup';
      const target = new THREE.Vector3();
      const pose = (q.get('pose') ?? 'stand') as PoseName;
      const weapon = q.get('weapon') as ModelName | null;
    
    """Build every model into public/assets/*.glb.
    
        npm run kit                 # everything
        npm run kit -- striker ship # just these
        npm run kit -- block_dummy  # a block model, kit/blocks/dummy.py
    """
    import os
    import sys
    import time
    
    sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
    
    import lib  # noqa: E402
    from block import build_block  # noqa: E402
    from cockpit import build_cockpit  # noqa: E402
    from cockpit_light import build_cockpit_light  # noqa: E402
    from mech import build_striker  # noqa: E402
    from heavy import build_heavy, build_heavy_lab  # noqa: E402
    from props import build_cannon, build_drone, build_rifle  # noqa: E402
    from ship import build_ship  # noqa: E402
    from station import build_station  # noqa: E402
    from salvage import build_salvage_pod, build_wreck_field  # noqa: E402
    from escape_pod import build_escape_pod  # noqa: E402
    from light import build_light, build_light_lab  # noqa: E402
    from automaton import build_automaton, build_automaton_lab  # noqa: E402
    from alien import build_alien, build_alien_lab  # noqa: E402
    sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "lab"))
    from heads import build_head_lab, build_head_lab2  # noqa: E402
    from headkit import build_head_lab3, build_head_lab4, build_head_lab5, build_head_lab6, build_head_lab7, build_head_lab8  # noqa: E402
    from sizes import build_sizes  # noqa: E402
    from pilotlab import build_pilot_lab  # noqa: E402
    from assembly import build_assembly_lab, build_back_lab, build_chest_frames, build_show, game_frame  # noqa: E402
    from raider import build_raider, build_raider_lab  # noqa: E402
    from pattern_lab import build_pattern_lab, build_pattern_m  # noqa: E402
    from atelier_lab import build_atelier_lab  # noqa: E402
    from atelier_board import build_atelier_line  # noqa: E402
    from bodykit import build_chest_lab, build_chest_lab2, build_foot_lab, build_foot_lab2, build_chest_lab3, build_foot_lab3  # noqa: E402
    
    OUT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "public", "assets")
    ASSETS = {"striker": build_striker, "striker_a": lambda: game_frame(0), "striker_b": lambda: game_frame(1), "rifle": build_rifle, "cannon": build_cannon, "drone": build_drone,
              "cockpit": build_cockpit, "cockpit_light": build_cockpit_light, "ship": build_ship, "station": build_station,
              "wreck_field": build_wreck_field, "salvage_pod": build_salvage_pod, "escape_pod": build_escape_pod,
              "light": lambda: build_light("knight"), "light_line": lambda: build_light("line"), "light_lancer": lambda: build_light("lancer"),
              "heavy": lambda: build_heavy("A"), "heavy_B": lambda: build_heavy("B"), "heavy_C": lambda: build_heavy("C"),
              "lab_heads": build_head_lab, "lab_heads2": build_head_lab2, "lab_heads3": build_head_lab3, "lab_heads4": build_head_lab4, "lab_heads5": build_head_lab5, "lab_heads6": build_head_lab6, "lab_heads7": build_head_lab7, "lab_heads8": build_head_lab8, "lab_chests": build_chest_lab, "lab_feet": build_foot_lab, "lab_chests2": build_chest_lab2, "lab_feet2": build_foot_lab2, "lab_chests3": build_chest_lab3, "lab_feet3": build_foot_lab3, "lab_frames": build_assembly_lab, "lab_backs": build_back_lab, "lab_chests4": build_chest_frames,
              "lab_show": build_show, "lab_show_v": lambda: build_show(formation=True),
              "lab_heavy": build_heavy_lab, "lab_light": build_light_lab, "lab_sizes": build_sizes, "lab_pilot": build_pilot_lab,
              "auto_tally": lambda: build_automaton("tally"), "auto_tick": lambda: build_automaton("tick"),
              "auto_ledger": lambda: build_automaton("ledger"),
              "alien_acicular": lambda: build_alien("acicular"), "alien_druse": lambda: build_alien("druse"),
              "alien_druse_mimic": lambda: build_alien("druse_mimic"), "alien_geode": lambda: build_alien("geode"),
              "raider_grunt": lambda: build_raider("grunt"), "raider_brawler": lambda: build_raider("brawler"),
              "raider_boss": lambda: build_raider("boss"),
              "pattern_m": build_pattern_m, "lab_pattern": build_pattern_lab, "lab_atelier": build_atelier_lab, "lab_atelier_a": lambda: build_atelier_line("a"), "lab_atelier_b": lambda: build_atelier_line("b"),
              "lab_atelier_c": lambda: build_atelier_line("c"), "lab_atelier_d": lambda: build_atelier_line("d"),
              "lab_auto": build_automaton_lab, "lab_alien": build_alien_lab, "lab_raider": build_raider_lab}
    
    
    def main(names):
        os.makedirs(OUT, exist_ok=True)
        for name in names or [n for n in ASSETS if not n.startswith("lab")]:
            t = time.time()
            lib.reset()
            if name.startswith("block_"):  # scratch models, kit/blocks/<name>.py
                build_block(name)
            else:
                ASSETS[name]()
            path = os.path.normpath(os.path.join(OUT, f"{name}.glb"))
            lib.export(path)
            print(f"kit: {name} -> {path} ({os.path.getsize(path) // 1024} KB, {time.time() - t:.1f}s)")
    
    
    main(sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])

agent

+1:15

Read the brief, handbook, reflection and history. Now trying the first-session tools (block build and quick clip) to see what they produce before choosing the visual.

  • Bashls -la node_modules | head -3; time npm run -s kit -- block_dummy 2>&1 | tail -3; time npm run -s clip -- block_dummy --quick 2>&1 | tail -5; ls -la review/out/one-mech/clips/

    command

    ls -la node_modules | head -3; time npm run -s kit -- block_dummy 2>&1 | tail -3; time npm run -s clip -- block_dummy --quick 2>&1 | tail -5; ls -la review/out/one-mech/clips/

    result, 20 lines

    lrwxrwxrwx 1 severian severian 43 Nov 10 18:22 node_modules -> [redacted: private path]
    Blender 5.2.3 LTS (hash e13b728c6880 built 2026-10-22 01:35:05)
    
    Blender quit
    
    real	0m3.281s
    user	0m1.666s
    sys	0m0.965s
    clip: ~/Projects/sortie-wt/fable52/review/out/one-mech/clips/block_dummy.mp4
    clip: ~/Projects/sortie-wt/fable52/review/out/one-mech/clips/block_dummy.sheet.jpg
    clip: 90 frames, 7.5 s of video, 57 s to make (565 ms a frame)
    
    real	0m57.901s
    user	0m7.459s
    sys	0m3.008s
    total 2816
    drwx------ 2 severian severian    4096 Nov 10 18:35 .
    drwx------ 3 severian severian    4096 Nov 10 18:34 ..
    -rw------- 1 severian severian 2691314 Nov 10 18:35 block_dummy.mp4
    -rw------- 1 severian severian  176134 Nov 10 18:35 block_dummy.sheet.jpg
  • Read~/Projects/sortie-wt/fable52/review/out/one-mech/clips/block_dummy.sheet.jpgno result

    input

    {
      "file_path": "~/Projects/sortie-wt/fable52/review/out/one-mech/clips/block_dummy.sheet.jpg"
    }