A mech game prototype, pushed by GPT-6.2-Astra
agent (cont.)
+23:06exec_commandcat kit/block.py kit/blocks/dummy.py && cat src/view/clip.ts (+3 more)
command
cat kit/block.py kit/blocks/dummy.py && cat src/view/clip.ts cat tools/clip.mjs && cat src/view/thrusters.ts | head -230 cat src/render/plume.ts | head -205 && cat src/render/exhaust.ts | head -155 && cat tools/squeeze.mjs | head -75 && cat src/render/assets.ts | head -110 ls -l ~/out && git status -sb && cat src/view/clip-plan.ts && cat src/render/mech.ts | head -56 && cat kit/mech.py | head -121
result, 826 lines
Script completed Wall time 0.1 seconds Output: Warning: truncated output (original token count: 12198) Total output lines: 999 """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)) 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; } // 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); import * as THREE from 'three'; import { model, type ModelName } from '../render/assets'; 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 { STRIKER_DECALS, applyDecals } from '../render/decals'; import { treatEyes } from '../render/eyes'; import type { ThrustReading } from '../render/exhaust'; /** * Thruster bench: one frame in a fixed thruster state at a fixed time, for judging plumes as stills. * /?view=thrusters&state=quick&t=0.06 a quick boost 60 ms after onset * /?view=thrusters&state=boost&close=main close on one main nozzle * /?view=thrusters&state=cycle&play=1 every state in turn, live * /?view=thrusters&cells=quick:0,quick:0.05,boost:0.5:main&cols=4&cw=480&ch=300 a sheet of stills * &frame=heavy_C &palette=raider &yaw=150 &pitch=12 &dist=40 &light=0 &tier=low * States: idle, cruise, boost, quick, assault, brake, strafe. `t` is seconds since the state began. */ export const BENCH_STATES = ['idle', 'cruise', 'boost', 'quick', 'assault', 'brake', 'strafe'] as const; export type BenchState = (typeof BENCH_STATES)[number]; /** A scripted flight reading for a bench state `t` seconds in: local thrust (left, up, forward as a * fraction of boosted forward thrust) and the boost flags, as the sim would report them. */ export function benchInput(state: BenchState, t: number) { const thrust = new THREE.Vector3(); let boosting = false, assault = false, quick = Infinity; if (state === 'cruise') thrust.set(0, 0, 0.35); else if (state === 'boost') (thrust.set(0, 0, 1), (boosting = true)); else if (state === 'quick') (thrust.set(0, 0, 0.05), (quick = t)); else if (state === 'assault') (thrust.set(0, 0, 1), (boosting = true), (assault = true)); else if (state === 'brake') thrust.set(0, 0.15, -0.6); else if (state === 'strafe') thrust.set(0.55, 0, 0.1); return { thrust, boosting, assault, quick }; } export async function startThrusterBench(canvas: HTMLCanvasElement, q: URLSearchParams) { await document.fonts.ready; const scene = new THREE.Scene(); const camera = new THREE.PerspectiveCamera(Number(q.get('fov') ?? 35), 1, 0.3, 2e5); const backdrop = createBackdrop(); const pipe = new Pipeline(canvas, scene, camera, backdrop); // ?tier=low: the software and weak GPU tier, no bloom const tier = q.get('tier'); if (tier === 'low' || tier === 'medium') pipe.setQuality({ tier }); const sun = addSpaceLight(scene); scene.environment = spaceEnvironment(pipe.renderer, backdrop); scene.environmentIntensity = Number(q.get('env') ?? 0.8); const name = (q.get('frame') ?? 'striker') as ModelName; const root = await model(name, (q.get('palette') ?? 'merc') as PaletteName); if (name === 'striker') applyDecals(root, STRIKER_DECALS); treatEyes(root, 'spill'); scene.add(root); const rig = new MechRig(root); rig.apply(POSES.flight); root.updateMatrixWorld(true); const box = new THREE.Box3().setFromObject(root); const height = box.getSize(new THREE.Vector3()).y; const target = new THREE.Vector3(); /** Aim the camera at the frame, or close on its first nozzle of a kind. */ const aim = (close: string | null, yawAt?: string, pitchAt?: string) => { box.getCenter(target); const nozzle = close ? rig.nozzles.find((n) => n.kind === close) : undefined;426 more lines not shown.
exec_commanddate -u; cat kit/lib.py | sed -n '62,165p;246,267p'; cat src/render/palette.ts | tail -60; cat src/render/look.ts | head -100; cat vite.config.ts; ls review; which ffmpeg; ls -la ~/context
command
date -u; cat kit/lib.py | sed -n '62,165p;246,267p'; cat src/render/palette.ts | tail -60; cat src/render/look.ts | head -100; cat vite.config.ts; ls review; which ffmpeg; ls -la ~/context
result, 189 lines
Script completed Wall time 0.1 seconds Output: Warning: truncated output (original token count: 3134) Total output lines: 304 Tue Nov 17 23:07:37 UTC 2026 o = link(bpy.data.objects.new(name, None)) o.empty_display_size = 0.4 o.location = Vector(at) if parent is None else parent.matrix_world.inverted() @ Vector(at) if parent is not None: o.parent = parent for k, v in extras.items(): o[k] = v bpy.context.view_layer.update() return o def attach(o, parent): """Parent without moving: geometry is authored in world (rest pose) coordinates.""" bpy.context.view_layer.update() mw = o.matrix_world.copy() o.parent = parent o.matrix_parent_inverse = parent.matrix_world.inverted() o.matrix_world = mw return o # ---- 2D outlines ------------------------------------------------------------------------------------------ def octo(w, d, c=0.2, cf=None, cb=None, x=0.0, y=0.0): """A chamfered rectangle, w along X and d along Y, CCW seen from above. The front (-Y) and back chamfers can differ: cf, cb. Returns 8 points.""" cf = c if cf is None else cf cb = c if cb is None else cb hw, hd = w / 2, d / 2 cf, cb = min(cf, hw * 0.95, hd * 0.95), min(cb, hw * 0.95, hd * 0.95) return [(x - hw + cf, y - hd), (x + hw - cf, y - hd), (x + hw, y - hd + cf), (x + hw, y + hd - cb), (x + hw - cb, y + hd), (x - hw + cb, y + hd), (x - hw, y + hd - cb), (x - hw, y - hd + cf)] def circle(r, n=12, x=0.0, y=0.0, phase=0.5): return [(x + r * math.cos(2 * math.pi * (i + phase) / n), y + r * math.sin(2 * math.pi * (i + phase) / n)) for i in range(n)] def ccw(poly): a = sum(poly[i][0] * poly[(i + 1) % len(poly)][1] - poly[(i + 1) % len(poly)][0] * poly[i][1] for i in range(len(poly))) return poly if a > 0 else list(reversed(poly)) # ---- solids (bmesh) --------------------------------------------------------------------------------------- def loft(rings, axis="z", caps=True): """rings: [(height, [(u, v), ...]), ...], all with the same point count. With axis "z" the outline is (x, y) at height z; "y" means (x, z) outlines along y; "x" means (y, z) outlines along x.""" bm = bmesh.new() loops = [] for h, pts in rings: loop = [] for u, v in pts: p = {"z": (u, v, h), "y": (u, h, v), "x": (h, u, v)}[axis] loop.append(bm.verts.new(p)) loops.append(loop) n = len(loops[0]) for a, b in zip(loops, loops[1:]): for i in range(n): j = (i + 1) % n bm.faces.new((a[i], a[j], b[j], b[i])) if caps: bm.faces.new(list(reversed(loops[0]))) bm.faces.new(loops[-1]) _outward(bm) return bm def prism(poly, lo, hi, plane="xz"): """A 2D outline pushed through [lo, hi]. plane "xz": outline in (x, z), depth along y. "yz": (y, z) along x. "xy": (x, y) along z.""" poly = ccw(poly) axis = {"xz": "y", "yz": "x", "xy": "z"}[plane] return loft([(lo, poly), (hi, poly)], axis=axis) def _outward(bm): bmesh.ops.recalc_face_normals(bm, faces=bm.faces) def merge(*bms): out = bmesh.new() for b in bms: me = bpy.data.meshes.new("_tmp") b.to_mesh(me) out.from_mesh(me) bpy.data.meshes.remove(me) b.free() return out def transform(bm, m): bmesh.ops.transform(bm, matrix=m, verts=bm.verts) return bm def mirror_x(bm): """A mirrored copy (left from right) with the winding fixed.""" me = bpy.data.meshes.new("_m") bm.to_mesh(me) out = bmesh.new() out.from_mesh(me) bpy.data.meshes.remove(me) bmesh.ops.scale(out, vec=(-1, 1, 1), verts=out.verts) mod.solver =…1330 tokens truncated…, sketch: { name: 'sketch', ridge: 0.1, valley: 0.25, ink: 1, grime: 0, grain: 0.02, vignette: 0.2, paintRough: 0.55, gloss: false, chipped: false, desaturate: 0.12, fill: 0.85, toon: true, hatch: 1, paper: 1 }, }; let current: Look = LOOKS.field; export const look = () => current; export function setLook(name: string | null) { current = LOOKS[(name as Look['name']) ?? 'field'] ?? LOOKS.field; return current; } /** Screen-space surface detail from the normal/depth pre-pass: [redacted: secret] wear, grime, ink. */ export const DetailShader = { uniforms: { tDiffuse: { value: null }, tNormal: { value: null }, tDepth: { value: null }, px: { value: new THREE.Vector2(1, 1) }, near: { value: 0.5 }, far: { value: 60000 }, ridgeK: { value: 0.5 }, valleyK: { value: 0.5 }, inkK: { value: 0.2 }, chipped: { value: 0 }, hatch: { value: 0 }, projInv: { value: new THREE.Matrix4() }, viewInv: { value: new THREE.Matrix4() }, }, vertexShader: 'varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }', fragmentShader: /* glsl */ ` #include <packing> uniform sampler2D tDiffuse, tNormal, tDepth; uniform vec2 px; uniform float near, far, ridgeK, valleyK, inkK, chipped, hatch; uniform mat4 projInv, viewInv; varying vec2 vUv; float hash3(vec3 p) { return fract(sin(dot(p, vec3(7.1, 157.3, 113.7))) * 43758.5); } float vnoise(vec3 p) { vec3 i = floor(p), f = fract(p); f = f * f * (3.0 - 2.0 * f); return mix(mix(mix(hash3(i), hash3(i + vec3(1,0,0)), f.x), mix(hash3(i + vec3(0,1,0)), hash3(i + vec3(1,1,0)), f.x), f.y), mix(mix(hash3(i + vec3(0,0,1)), hash3(i + vec3(1,0,1)), f.x), mix(hash3(i + vec3(0,1,1)), hash3(i + vec3(1,1,1)), f.x), f.y), f.z); } vec3 worldAt(vec2 uv) { float d = texture2D(tDepth, uv).x; vec4 v = projInv * vec4(uv * 2.0 - 1.0, d * 2.0 - 1.0, 1.0); return (viewInv * vec4(v.xyz / v.w, 1.0)).xyz; } vec4 N(vec2 uv) { vec4 n = texture2D(tNormal, uv); return vec4(n.xyz * 2.0 - 1.0, n.a); } float Z(vec2 uv) { return -perspectiveDepthToViewZ(texture2D(tDepth, uv).x, near, far); } void main() { vec4 c = texture2D(tDiffuse, vUv); vec4 n0 = N(vUv); if (n0.a < 0.5) { gl_FragColor = c; return; } vec4 l = N(vUv - vec2(px.x, 0.0)), r = N(vUv + vec2(px.x, 0.0)), d = N(vUv - vec2(0.0, px.y)), u = N(vUv + vec2(0.0, px.y)); float z0 = Z(vUv); // convex where neighbouring normals spread apart, concave where they close in float curv = ((r.x - l.x) * r.a * l.a + (u.y - d.y) * u.a * d.a) * 0.5; float ridge = smoothstep(0.08, 0.45, curv); float valley = smoothstep(0.08, 0.45, -curv); // ink at creases and wherever depth steps (seams, overlaps, silhouettes) float turn = max(max(1.0 - dot(n0.xyz, l.xyz), 1.0 - dot(n0.xyz, r.xyz)), max(1.0 - dot(n0.xyz, u.xyz), 1.0 - dot(n0.xyz, d.xyz))); import { defineConfig } from 'vite'; export default defineConfig({ // relative paths so the build runs from any folder (an artifact page, a static host) base: './', server: { port: 5199 }, test: { environment: 'node', include: ['src/**/*.test.ts', 'tools/**/*.test.mjs'] }, } as never); out rear-cockpit /usr/bin/ffmpeg total 32 drwx------ 3 runner runner 4096 Nov 17 22:43 . drwx------ 8 runner runner 4096 Nov 17 22:47 .. -rw------- 1 runner runner 3877 Nov 17 22:43 brief-sortie-full.md -rw------- 1 runner runner 14308 Nov 17 22:43 project_sortie_mech_game.md drwx------ 2 runner runner 4096 Nov 17 22:43 reflectexec_commandmkdir -p review/out/form-zero review/form-zero
command
mkdir -p review/out/form-zero review/form-zero date -u -d '2026-11-17 23:07:00' +'%s brief and source review' > review/out/form-zero/stages date -u +'%s armour and cockpit design' >> review/out/form-zero/stages rg -n 'export function mergeParts|function mergeParts' src/render/assets.ts -A66 rg -A37 'const base:|merc:|admin:|houses:' src/render/palette.ts | tail -56 rg -n '^def (cylinder|piston|nozzle|subd|boolean|halves)' kit/lib.py && cat src/render/space.ts | head -92 && rg 'publicDir|cacheDir' node_modules/vite/package.json | head
result, 4 lines
Script completed Wall time 0.1 seconds Output: {"chunk_id":"3006ff","wall_time_seconds":0.00000336,"exit_code":0,"original_token_count":2569,"output":"Warning: truncated output (original token count: 2569)\nTotal output lines: 221\n\n122:function mergeParts(root: THREE.Object3D): THREE.Object3D {\n123- const groups = new Map<THREE.Object3D, Map<THREE.Material, THREE.Mesh[]>>();\n124- root.traverse((o) => {\n125- const m = o as THREE.Mesh;\n126- if (!m.isMesh || m.children.length || !m.parent || Array.isArray(m.material)) return;\n127- let byMat = groups.get(m.parent);\n128- if (!byMat) groups.set(m.parent, (byMat = new Map()));\n129- const list = byMat.get(m.material) ?? [];\n130- list.push(m);\n131- byMat.set(m.material, list);\n132- });\n133- for (const [parent, byMat] of groups) {\n134- for (const [mat, meshes] of byMat) {\n135- if (meshes.length < 2) continue;\n136- const geoms = meshes.map((m) => {\n137- m.updateMatrix();\n138- const g = m.geometry.clone();\n139- for (const k of Object.keys(g.attributes)) if (k !== 'position' && k !== 'normal') g.deleteAttribute(k);\n140- return g.applyMatrix4(m.matrix);\n141- });\n142- const merged = mergeGeometries(geoms, false);\n143- if (!merged) continue;\n144- const mesh = new THREE.Mesh(merged, mat);\n145- mesh.name = `${parent.name}:${mat.name}`;\n146- mesh.userData = { ...meshes[0].userData };\n147- for (const m of meshes) m.removeFromParent();\n148- parent.add(mesh);\n149- }\n150- }\n151- return root;\n152-}\n153-\n154-/** tools/squeeze.mjs puts each mesh on a child node of this name, holding its dequantizing transform. */\n155-const QUANT_NODE = 'q__';\n156-\n157-/** A float copy of a (possibly quantized) vec3 attribute, as unit vectors if `unit`. */\n158-function toFloat(a: THREE.BufferAttribute | THREE.InterleavedBufferAttribute, unit = false) {\n159- const out = new THREE.Float32BufferAttribute(a.count * 3, 3);\n160- for (let i = 0; i < a.count; i++) {\n161- _v.fromBufferAttribute(a, i);\n162- if (unit) _v.normalize();\n163- out.setXYZ(i, _v.x, _v.y, _v.z);\n164- }\n165- return out;\n166-}\n167-const _v = new THREE.Vector3();\n168-\n169-/**\n170- * Fold squeezed meshes back into the nodes the kit built: bake each quantized mesh's transform into\n171- * float vertices and put the mesh where its node was, with the node's name, transform, extras and\n172- * children. A plain GLB passes through untouched.\n173- */\n174-function unquantize(root: THREE.Object3D): THREE.Object3D {\n175- const found: THREE.Object3D[] = [];\n176- root.traverse((o) => {\n177- if (o.name.startsWith(QUANT_NODE)) found.push(o);\n178- });\n179- // a mesh used by several nodes shares its geometry: each gets its own before any is baked\n180- const seen = new Set<THREE.BufferGeometry>();\n181- for (const q of found) {\n182- q.traverse((o) => {\n183- const m = o as THREE.Mesh;\n184- if (!m.isMesh) return;\n185- …1203 tokens truncated…* 3);\n const c = tint[Math.floor(rnd() * tint.length)].clone().multiplyScalar(0.25 + Math.pow(rnd(), 3) * 1.6);\n col.set([c.r, c.g, c.b], i * 3);\n }\n const g = new THREE.BufferGeometry();\n g.setAttribute('position', new THREE.BufferAttribute(pos, 3));\n g.setAttribute('color', new THREE.BufferAttribute(col, 3));\n return new THREE.Points(g, new THREE.PointsMaterial({ size: 1.6, sizeAttenuation: false, vertexColors: true, depthWrite: false }));\n}\n\nfunction nebula(sunDir: THREE.Vector3): THREE.Mesh {\n const m = new THREE.ShaderMaterial({\n side: THREE.BackSide,\n depthWrite: false,\n uniforms: { sunDir: { value: sunDir } },\n vertexShader: logv(/* glsl */ `\n varying vec3 vDir;\n void main() { vDir = normalize(position); gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }`),\n fragmentShader: logf(/* glsl */ `\n ${NOISE}\n uniform vec3 sunDir;\n varying vec3 vDir;\n void main() {\n vec3 d = normalize(vDir);\n float n = fbm(d * 2.2 + vec3(3.1, 0.0, 1.7));\n float m = fbm(d * 4.5 + n * 1.5);\n float band = exp(-pow(dot(d, normalize(vec3(0.3, 0.85, -0.4))) * 2.6, 2.0));\n vec3 deep = vec3(0.012, 0.016, 0.035);\n vec3 c1 = vec3(0.10, 0.05, 0.20) * smoothstep(0.45, 0.8, n) * band;\n vec3 c2 = vec3(0.02, 0.13, 0.17) * smoothstep(0.5, 0.85, m) * band;\n float sun = max(dot(d, sunDir), 0.0);\n vec3 glare = vec3(1.0, 0.85, 0.65) * (pow(sun, 900.0) * 6.0 + pow(sun, 60.0) * 0.25 + pow(sun, 8.0) * 0.04);\n gl_FragColor = vec4(deep + c1 + c2 + glare, 1.0);\n }`),\n });\n return new THREE.Mesh(new THREE.SphereGeometry(9.5e5, 48, 24), m);\n}\n\nfunction planet(sunDir: THREE.Vector3): THREE.Group {\n const g = new THREE.Group();\n const R = 1.4e5;\n const body = new THREE.Mesh(\n new THREE.SphereGeometry(R, 96, 64),\n new THREE.ShaderMaterial({\n uniforms: { sunDir: { value: sunDir } },\n vertexShader: logv(/* glsl */ `\n varying vec3 vN; varying vec3 vObj; varying vec3 vView;\n void main() {\n vObj = normalize(position);\n vN = normalize(mat3(modelMatrix) * normal);\n vec4 wp = modelMatrix * vec4(position, 1.0);\n vView = normalize(cameraPosition - wp.xyz);\n gl_Position = projectionMatrix * viewMatrix * wp;\n }`),\n fragmentShader: logf(/* glsl */ `\n ${NOISE}\n uniform vec3 sunDir;\n varying vec3 vN; varying vec3 vObj; varying vec3 vView;\n void main() {\n float land = smoothstep(0.52, 0.56, fbm(vObj * 3.0 + vec3(1.3, 4.2, 0.7)));\n float cloud = smoothstep(0.5, 0.72, fbm(vObj * 5.0 + vec3(fbm(vObj * 2.0) * 2.0)));\n vec3 ocean = vec3(0.07, 0.22, 0.42);\n"}