A mech game prototype, pushed by Gemini 4 Argon
agent
+2:45reasoning
The models are confirmed to be in the expected directory. A performance test of the processing tools is the next logical step. Initial testing will use a specific asset with a quick run to assess overall speed.
run_command{"CommandLine":"time npm run -s outlines && ls -lh out/outlines/","WaitMsBeforeAsync":10000,"toolSummary":"Test outlines tool speed and output"}error
input
{ "CommandLine": "time npm run -s outlines && ls -lh out/outlines/", "WaitMsBeforeAsync": 10000, "toolSummary": "Test outlines tool speed and output" }result, error, 8 lines
Command exited with code 2. Command output: usage: node tools/outlines.mjs <spec.json|spec.mjs> [--cols 6] [--tile 460] [--out file.png] real 0m2.087s user 0m0.975s sys 0m0.239s
run_command{"CommandLine":"ls -la tools/ kit/ kit/blocks/ kit/lab/ kit/makers/","WaitMsBeforeAsync":5000,"toolSummary":"List tools and kit directories"}
input
{ "CommandLine": "ls -la tools/ kit/ kit/blocks/ kit/lab/ kit/makers/", "WaitMsBeforeAsync": 5000, "toolSummary": "List tools and kit directories" }result, 84 lines
Command exited with code 0. Command output: kit/: total 496 drwx------ 5 runner runner 4096 Nov 15 01:36 . drwx------ 9 runner runner 4096 Nov 15 01:36 .. -rw------- 1 runner runner 25748 Nov 15 01:36 alien.py -rw------- 1 runner runner 55524 Nov 15 01:36 automaton.py -rw------- 1 runner runner 5766 Nov 15 01:36 block.py drwx------ 2 runner runner 4096 Nov 15 01:36 blocks -rw------- 1 runner runner 5010 Nov 15 01:36 build.py -rw------- 1 runner runner 12174 Nov 15 01:36 cockpit.py -rw------- 1 runner runner 12692 Nov 15 01:36 cockpit_light.py -rw------- 1 runner runner 3593 Nov 15 01:36 escape_pod.py -rw------- 1 runner runner 20148 Nov 15 01:36 figure.py -rw------- 1 runner runner 23442 Nov 15 01:36 frame_std.py -rw------- 1 runner runner 72617 Nov 15 01:36 heavy.py drwx------ 2 runner runner 4096 Nov 15 01:36 lab -rw------- 1 runner runner 16726 Nov 15 01:36 lib.py -rw------- 1 runner runner 62232 Nov 15 01:36 light.py drwx------ 2 runner runner 4096 Nov 15 01:36 makers -rw------- 1 runner runner 30154 Nov 15 01:36 mech.py -rw------- 1 runner runner 4016 Nov 15 01:36 props.py -rw------- 1 runner runner 53247 Nov 15 01:36 raider.py -rw------- 1 runner runner 17542 Nov 15 01:36 salvage.py -rw------- 1 runner runner 22634 Nov 15 01:36 ship.py -rw------- 1 runner runner 9722 Nov 15 01:36 station.py kit/blocks/: total 12 drwx------ 2 runner runner 4096 Nov 15 01:36 . drwx------ 5 runner runner 4096 Nov 15 01:36 .. -rw------- 1 runner runner 0 Nov 15 01:36 __init__.py -rw------- 1 runner runner 331 Nov 15 01:36 dummy.py kit/lab/: total 280 drwx------ 2 runner runner 4096 Nov 15 01:36 . drwx------ 5 runner runner 4096 Nov 15 01:36 .. -rw------- 1 runner runner 9158 Nov 15 01:36 assembly.py -rw------- 1 runner runner 2206 Nov 15 01:36 atelier_board.py -rw------- 1 runner runner 1812 Nov 15 01:36 atelier_lab.py -rw------- 1 runner runner 22504 Nov 15 01:36 backkit.py -rw------- 1 runner runner 21490 Nov 15 01:36 board_heraldic.py -rw------- 1 runner runner 17731 Nov 15 01:36 board_plate.py -rw------- 1 runner runner 15740 Nov 15 01:36 board_sleek.py -rw------- 1 runner runner 20119 Nov 15 01:36 board_tourney.py -rw------- 1 runner runner 39323 Nov 15 01:36 bodykit.py -rw------- 1 runner runner 10357 Nov 15 01:36 chestkit.py -rw------- 1 runner runner 37640 Nov 15 01:36 headkit.py -rw------- 1 runner runner 16334 Nov 15 01:36 heads.py -rw------- 1 runner runner 26120 Nov 15 01:36 knightkit.py -rw------- 1 runner runner 2407 Nov 15 01:36 pattern_lab.py -rw------- 1 runner runner 1944 Nov 15 01:36 pilotlab.py -rw------- 1 runner runner 1662 Nov 15 01:36 sizes.py kit/makers/: total 92 drwx------ 2 runner runner 4096 Nov 15 01:36 . drwx------ 5 runner runner 4096 Nov 15 01:36 .. -rw------- 1 runner runner 0 Nov 15 01:36 __init__.py -rw------- 1 runner runner 35108 Nov 15 01:36 atelier.py -rw------- 1 runner runner 36676 Nov 15 01:36 pattern.py -rw------- 1 runner runner 12117 Nov 15 01:36 shell.py tools/: total 72 drwx------ 4 runner runner 4096 Nov 15 01:36 . drwx------ 9 runner runner 4096 Nov 15 01:36 .. -rw------- 1 runner runner 2144 Nov 15 01:36 artifact.mjs drwx------ 2 runner runner 4096 Nov 15 01:36 c1 -rwx------ 1 runner runner 1530 Nov 15 01:36 c1-render.sh -rw------- 1 runner runner 4047 Nov 15 01:36 clip.mjs drwx------ 2 runner runner 4096 Nov 15 01:36 fixtures -rwx------ 1 runner runner 329 Nov 15 01:36 log.sh -rw------- 1 runner runner 4530 Nov 15 01:36 outlines-lib.mjs -rw------- 1 runner runner 1806 Nov 15 01:36 outlines-lib.test.mjs -rw------- 1 runner runner 1747 Nov 15 01:36 outlines.mjs -rw------- 1 runner runner 2870 Nov 15 01:36 shoot.mjs -rwx------ 1 runner runner 487 Nov 15 01:36 show.sh -rw------- 1 runner runner 4512 Nov 15 01:36 squeeze.mjs -rwx------ 1 runner runner 1113 Nov 15 01:36 thruster-sheets.sh -rw------- 1 runner runner 511 Nov 15 01:36 turntable.py
read_file{"Path":"~/work/sortie/tools/thruster-sheets.sh"}
input
{ "Path": "~/work/sortie/tools/thruster-sheets.sh" }result, 18 lines
Showing lines 1-17 of 17 1: #!/usr/bin/env bash 2: # Thruster bench sheets, rendered headless, one page load per sheet (the bench's cells mode): the 3: # states, a quick boost strip, an assault ignition strip and close ups. Needs the dev server 4: # (SORTIE_URL, default :5199). 5: # tools/thruster-sheets.sh <out dir> [tag] [extra query, e.g. &frame=heavy_C] 6: set -euo pipefail 7: out=$1; tag=${2:-now}; extra=${3:-} 8: cw=${CW:-480}; ch=${CH:-300} 9: mkdir -p "$out" 10: sheet() { # name, rows, cells 11: W=$((4 * cw)) H=$(($2 * ch)) node "$(dirname "$0")/shoot.mjs" "$out" \ 12: "$tag-$1=/?view=thrusters&cols=4&cw=$cw&ch=$ch&cells=$3$extra" 13: } 14: sheet states 2 idle:0.5,cruise:0.5,boost:0.5,quick:0.06,assault:0.5,brake:0.5,strafe:0.5,boost:0.5:main 15: sheet quick-strip 2 quick:0,quick:0.02,quick:0.05,quick:0.09,quick:0.14,quick:0.2,quick:0.3,quick:0.45 16: sheet assault-strip 2 assault:0,assault:0.04,assault:0.1,assault:0.2,assault:0.35,assault:0.6,assault:1,assault:2 17: sheet close 3 idle:0.5:main,boost:0.5:main,quick:0.05:main,assault:0.5:main,boost:0.5:main:178:4,assault:0.5:main:178:4,boost:0.5::90:0,assault:0.5::90:0,boost:0.5,boost:0.517,boost:0.533,boost:0.55read_file{"Path":"~/work/sortie/tools/show.sh"}
input
{ "Path": "~/work/sortie/tools/show.sh" }result, 13 lines
Showing lines 1-12 of 12 1: #!/usr/bin/env bash 2: # Put a sheet or clip in front of the owner: copy it to their Downloads and open it, and note the time. 3: # tools/show.sh <file> [more files] NO_OPEN=1 copies without opening 4: set -euo pipefail 5: here=$(cd "$(dirname "$0")" && pwd) 6: dest=${SHOW_DEST:-[redacted: Windows home]/Downloads/citadel-shots/one-mech} 7: mkdir -p "$dest" 8: for f in "$@"; do 9: cp "$f" "$dest/" 10: [ "${NO_OPEN:-}" = 1 ] || cw view "$dest/$(basename "$f")" 11: "$here/log.sh" "shown: $(basename "$f")" 12: doneread_file{"Path":"~/work/sortie/tools/outlines.mjs"}
input
{ "Path": "~/work/sortie/tools/outlines.mjs" }result, 36 lines
Showing lines 1-35 of 35 1: // Render an outline sheet to SVG and PNG (spec format in tools/outlines-lib.mjs). 2: // node tools/outlines.mjs <spec.json|spec.mjs> [--cols 6] [--tile 460] [--out file.png] 3: // A .mjs spec exports the spec as default, so variations can be generated in code. Headless only. 4: import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'; 5: import { dirname, resolve } from 'node:path'; 6: import { pathToFileURL } from 'node:url'; 7: import { chromium } from 'playwright'; 8: import { outlineSheet } from './outlines-lib.mjs'; 9: 10: const args = process.argv.slice(2); 11: const flag = (name, fallback) => { 12: const i = args.indexOf(`--${name}`); 13: return i >= 0 ? args[i + 1] : fallback; 14: }; 15: const file = args[0]; 16: if (!file || file.startsWith('--')) { 17: console.error('usage: node tools/outlines.mjs <spec.json|spec.mjs> [--cols 6] [--tile 460] [--out file.png]'); 18: process.exit(2); 19: } 20: const started = Date.now(); 21: const path = resolve(file); 22: const spec = path.endsWith('.mjs') ? (await import(`${pathToFileURL(path)}?t=${Date.now()}`)).default : JSON.parse(readFileSync(path, 'utf8')); 23: const { svg, width, height, count } = outlineSheet(spec, { cols: Number(flag('cols', 6)), tileHeight: Number(flag('tile', 460)) }); 24: const out = resolve(flag('out', path.replace(/\.(json|mjs)$/, '.png'))); 25: mkdirSync(dirname(out), { recursive: true }); 26: writeFileSync(out.replace(/\.png$/, '.svg'), svg); 27: const browser = await chromium.launch(); 28: try { 29: const page = await browser.newPage({ viewport: { width, height } }); 30: await page.setContent(`<!doctype html><body style="margin:0">${svg}</body>`); 31: await page.screenshot({ path: out }); 32: } finally { 33: await browser.close(); 34: } 35: console.log(`outlines: ${out} (${count} outlines, ${width}x${height}, ${Date.now() - started} ms)`);run_command{"CommandLine":"ls -la src/view/ src/render/","WaitMsBeforeAsync":5000,"toolSummary":"List src/view and src/render directories"}
input
{ "CommandLine": "ls -la src/view/ src/render/", "WaitMsBeforeAsync": 5000, "toolSummary": "List src/view and src/render directories" }result, 42 lines
Command exited with code 0. Command output: src/render/: total 232 drwx------ 2 runner runner 4096 Nov 15 01:36 . drwx------ 8 runner runner 4096 Nov 15 01:36 .. -rw------- 1 runner runner 18089 Nov 15 01:36 aliens.ts -rw------- 1 runner runner 9191 Nov 15 01:36 assets.ts -rw------- 1 runner runner 5077 Nov 15 01:36 debris.ts -rw------- 1 runner runner 6077 Nov 15 01:36 decals.ts -rw------- 1 runner runner 10233 Nov 15 01:36 effects.ts -rw------- 1 runner runner 8371 Nov 15 01:36 eject.ts -rw------- 1 runner runner 9771 Nov 15 01:36 enemies.ts -rw------- 1 runner runner 7806 Nov 15 01:36 exhaust.test.ts -rw------- 1 runner runner 7330 Nov 15 01:36 exhaust.ts -rw------- 1 runner runner 6515 Nov 15 01:36 eyes.ts -rw------- 1 runner runner 11208 Nov 15 01:36 look.ts -rw------- 1 runner runner 6851 Nov 15 01:36 materials.ts -rw------- 1 runner runner 9039 Nov 15 01:36 mech.ts -rw------- 1 runner runner 7972 Nov 15 01:36 palette.ts -rw------- 1 runner runner 1050 Nov 15 01:36 pipeline.test.ts -rw------- 1 runner runner 10229 Nov 15 01:36 pipeline.ts -rw------- 1 runner runner 8550 Nov 15 01:36 plume.ts -rw------- 1 runner runner 3073 Nov 15 01:36 salvage.ts -rw------- 1 runner runner 5056 Nov 15 01:36 ship.ts -rw------- 1 runner runner 8845 Nov 15 01:36 space.ts -rw------- 1 runner runner 2120 Nov 15 01:36 squeeze.test.ts -rw------- 1 runner runner 4248 Nov 15 01:36 station.ts -rw------- 1 runner runner 8272 Nov 15 01:36 wrecks.ts src/view/: total 60 drwx------ 2 runner runner 4096 Nov 15 01:36 . drwx------ 8 runner runner 4096 Nov 15 01:36 .. -rw------- 1 runner runner 4459 Nov 15 01:36 cameras.ts -rw------- 1 runner runner 2810 Nov 15 01:36 clip-plan.test.ts -rw------- 1 runner runner 4271 Nov 15 01:36 clip-plan.ts -rw------- 1 runner runner 6266 Nov 15 01:36 clip.ts -rw------- 1 runner runner 5435 Nov 15 01:36 sheet.ts -rw------- 1 runner runner 7968 Nov 15 01:36 thrusters.ts -rw------- 1 runner runner 6991 Nov 15 01:36 viewer.ts
read_file{"Path":"~/work/sortie/src/view/thrusters.ts"}
input
{ "Path": "~/work/sortie/src/view/thrusters.ts" }result, 167 lines
Showing lines 1-166 of 166 1: import * as THREE from 'three'; 2: import { model, type ModelName } from '../render/assets'; 3: import { MechRig, POSES } from '../render/mech'; 4: import type { PaletteName } from '../render/palette'; 5: import { Pipeline } from '../render/pipeline'; 6: import { addSpaceLight, createBackdrop, followSun, spaceEnvironment } from '../render/space'; 7: import { STRIKER_DECALS, applyDecals } from '../render/decals'; 8: import { treatEyes } from '../render/eyes'; 9: import type { ThrustReading } from '../render/exhaust'; 10: 11: /** 12: * Thruster bench: one frame in a fixed thruster state at a fixed time, for judging plumes as stills. 13: * /?view=thrusters&state=quick&t=0.06 a quick boost 60 ms after onset 14: * /?view=thrusters&state=boost&close=main close on one main nozzle 15: * /?view=thrusters&state=cycle&play=1 every state in turn, live 16: * /?view=thrusters&cells=quick:0,quick:0.05,boost:0.5:main&cols=4&cw=480&ch=300 a sheet of stills 17: * &frame=heavy_C &palette=raider &yaw=150 &pitch=12 &dist=40 &light=0 &tier=low 18: * States: idle, cruise, boost, quick, assault, brake, strafe. `t` is seconds since the state began. 19: */ 20: export const BENCH_STATES = ['idle', 'cruise', 'boost', 'quick', 'assault', 'brake', 'strafe'] as const; 21: export type BenchState = (typeof BENCH_STATES)[number]; 22: 23: /** A scripted flight reading for a bench state `t` seconds in: local thrust (left, up, forward as a 24: * fraction of boosted forward thrust) and the boost flags, as the sim would report them. */ 25: export function benchInput(state: BenchState, t: number) { 26: const thrust = new THREE.Vector3(); 27: let boosting = false, assault = false, quick = Infinity; 28: if (state === 'cruise') thrust.set(0, 0, 0.35); 29: else if (state === 'boost') (thrust.set(0, 0, 1), (boosting = true)); 30: else if (state === 'quick') (thrust.set(0, 0, 0.05), (quick = t)); 31: else if (state === 'assault') (thrust.set(0, 0, 1), (boosting = true), (assault = true)); 32: else if (state === 'brake') thrust.set(0, 0.15, -0.6); 33: else if (state === 'strafe') thrust.set(0.55, 0, 0.1); 34: return { thrust, boosting, assault, quick }; 35: } 36: 37: export async function startThrusterBench(canvas: HTMLCanvasElement, q: URLSearchParams) { 38: await document.fonts.ready; 39: const scene = new THREE.Scene(); 40: const camera = new THREE.PerspectiveCamera(Number(q.get('fov') ?? 35), 1, 0.3, 2e5); 41: const backdrop = createBackdrop(); 42: const pipe = new Pipeline(canvas, scene, camera, backdrop); 43: // ?tier=low: the software and weak GPU tier, no bloom 44: const tier = q.get('tier'); 45: if (tier === 'low' || tier === 'medium') pipe.setQuality({ tier }); 46: const sun = addSpaceLight(scene); 47: scene.environment = spaceEnvironment(pipe.renderer, backdrop); 48: scene.environmentIntensity = Number(q.get('env') ?? 0.8); 49: 50: const name = (q.get('frame') ?? 'striker') as ModelName; 51: const root = await model(name, (q.get('palette') ?? 'merc') as PaletteName); 52: if (name === 'striker') applyDecals(root, STRIKER_DECALS); 53: treatEyes(root, 'spill'); 54: scene.add(root); 55: const rig = new MechRig(root); 56: rig.apply(POSES.flight); 57: root.updateMatrixWorld(true); 58: 59: const box = new THREE.Box3().setFromObject(root); 60: const height = box.getSize(new THREE.Vector3()).y; 61: const target = new THREE.Vector3(); 62: /** Aim the camera at the frame, or close on its first nozzle of a kind. */ 63: const aim = (close: string | null, yawAt?: string, pitchAt?: string) => { 64: box.getCenter(target); 65: const nozzle = close ? rig.nozzles.find((n) => n.kind === close) : undefined; 66: if (nozzle) nozzle.node.getWorldPosition(target); 67: const dist = Number(q.get('dist') ?? (nozzle ? height * 0.6 : height * 2.6)); 68: const yaw = THREE.MathUtils.degToRad(Number(yawAt || q.get('yaw') || (nozzle ? 125 : 132))); 69: const pitch = THREE.MathUtils.degToRad(Number(pitchAt || q.get('pitch') || 10)); 70: if (q.has('ty')) target.y += Number(q.get('ty')); 71: if (q.has('tz')) target.z += Number(q.get('tz')); 72: camera.position.set(Math.sin(yaw) * Math.cos(pitch), Math.sin(pitch), Math.cos(yaw) * Math.cos(pitch)).multiplyScalar(dist).add(target); 73: camera.lookAt(target); 74: followSun(sun, target); 75: }; 76: 77: const light = new THREE.PointLight('#ffffff', 0, 0, 2); 78: scene.add(light); 79: const lit = q.get('light') !== '0'; 80: const reading: ThrustReading = { x: 0, y: 0, z: 0, boosting: false }; 81: const DT = 1 / 120; 82: const feed = (state: BenchState, t: number, dt: number) => { 83: const f = benchInput(state, t); 84: reading.x = f.thrust.x; 85: reading.y = f.thrust.y; 86: reading.z = f.thrust.z; 87: reading.boosting = f.boosting; 88: reading.assault = f.assault; 89: reading.quick = f.quick; 90: rig.thrust(reading, t, dt); 91: if (lit) rig.lightExhaust(light); 92: }; 93: /** A still: a second of idle, then the state from its start to `t` in 120 Hz steps, as a game would. */ 94: const still = (state: BenchState, t: number) => { 95: for (let i = 0; i < 120; i++) feed('idle', 1 + i * DT, DT); 96: for (let s = 0; s < t - 1e-9; s += DT) feed(state, s, Math.min(DT, t - s)); 97: feed(state, t, 0); 98: }; 99: const ready = () => ((window as unknown as { __ready: boolean }).__ready = true); 100: const tag = (state: string, t: number, close: string | null) => `${state.toUpperCase()} t=${t.toFixed(2)}s${close ? ' close' : ''}`; 101: 102: // ?cells=quick:0,quick:0.05,boost:0.5:main,boost:0.5:main:178:4&cols=4&cw=480&ch=300 renders every 103: // cell (state:t[:close kind[:yaw[:pitch]]]) in one page 104: // and shows them as one sheet: one model load and one shader compile for the lot 105: const cells = q.get('cells'); 106: if (cells) { 107: const list = cells.split(',').map((c) => c.split(':')); 108: const cols = Number(q.get('cols') ?? 4), cw = Number(q.get('cw') ?? 480), ch = Number(q.get('ch') ?? 300); 109: const sheet = document.createElement('canvas'); 110: sheet.width = cols * cw; 111: sheet.height = Math.ceil(list.length / cols) * ch; 112: const ctx = sheet.getContext('2d')!; 113: ctx.fillStyle = '#111'; 114: ctx.fillRect(0, 0, sheet.width, sheet.height); 115: pipe.resize(cw, ch); 116: list.forEach(([state, t, close, yaw, pitch], i) => { 117: aim(close || null, yaw, pitch); 118: still(state as BenchState, Number(t)); 119: pipe.render(); 120: const x = (i % cols) * cw, y = Math.floor(i / cols) * ch; 121: ctx.drawImage(canvas, x, y, cw, ch); 122: ctx.strokeStyle = '#111'; 123: ctx.strokeRect(x + 0.5, y + 0.5, cw - 1, ch - 1); 124: ctx.font = '600 13px "Chakra Petch", sans-serif'; 125: ctx.fillStyle = '#cfe3ff'; 126: ctx.fillText(tag(state, Number(t), close || null) + (yaw ? ` yaw ${yaw}` : ''), x + 10, y + 18); 127: }); 128: canvas.style.display = 'none'; 129: sheet.style.cssText = 'position:fixed;left:0;top:0'; 130: document.body.appendChild(sheet); 131: ready(); 132: return; 133: } 134: 135: const label = document.createElement('div'); 136: label.style.cssText = 'position:fixed;left:14px;top:10px;font:600 15px "Chakra Petch",sans-serif;color:#cfe3ff;letter-spacing:.06em;text-shadow:0 1px 2px #000'; 137: if (!q.has('nolabel')) document.body.appendChild(label); 138: const fixed = (q.get('state') ?? 'boost') as BenchState | 'cycle'; 139: const t0 = Number(q.get('t') ?? 0.5); 140: const close = q.get('close'); 141: aim(close); 142: const play = q.has('play'); 143: const start = performance.now(); 144: /** cycle: each state for `hold` seconds in turn */ 145: const hold = 2.5; 146: let shown = ''; 147: let last = 0; 148: const drive = (time: number, first = false) => { 149: const state = fixed === 'cycle' ? BENCH_STATES[Math.floor(time / hold) % BENCH_STATES.length] : fixed; 150: const t = fixed === 'cycle' ? time % hold : time; 151: if (first) still(state, t); 152: else feed(state, t, Math.min(0.1, time - last)); 153: last = time; 154: const text = tag(state, t, close); 155: if (text !== shown) label.textContent = shown = text; 156: }; 157: drive(t0, true); 158: window.addEventListener('resize', () => pipe.resize()); 159: const loop = () => { 160: if (play) drive(t0 + (performance.now() - start) / 1000); 161: pipe.render(); 162: requestAnimationFrame(loop); 163: }; 164: loop(); 165: ready(); 166: }read_file{"Path":"~/work/sortie/src/view/sheet.ts"}
input
{ "Path": "~/work/sortie/src/view/sheet.ts" }result, 112 lines
Showing lines 1-111 of 111 1: import * as THREE from 'three'; 2: import { model, type ModelName } from '../render/assets'; 3: import { MechRig, POSES, type PoseName } from '../render/mech'; 4: 5: /** 6: * Orthographic line-art sheets in the style of mecha design sheets: front, side and back views of a 7: * model, white fill with ink lines at silhouettes, creases and part boundaries. For judging shape 8: * against reference line art, so it skips lighting and materials entirely. 9: * /?sheet=striker&pose=stand&views=front,side,back 10: */ 11: 12: const LINE = /* glsl */ ` 13: uniform sampler2D tNormal, tId; uniform vec2 px; uniform float near, far; 14: varying vec2 vUv; 15: void main() { 16: vec4 n0 = texture2D(tNormal, vUv), i0 = texture2D(tId, vUv); 17: float e = 0.0; 18: for (int k = 0; k < 8; k++) { 19: vec2 o = vec2(k == 0 ? 1.0 : k == 1 ? -1.0 : k == 4 ? 1.0 : k == 5 ? -1.0 : k == 6 ? 1.0 : k == 7 ? -1.0 : 0.0, 20: k == 2 ? 1.0 : k == 3 ? -1.0 : k == 4 ? 1.0 : k == 5 ? -1.0 : k == 6 ? -1.0 : k == 7 ? 1.0 : 0.0) * px; 21: vec4 n1 = texture2D(tNormal, vUv + o), i1 = texture2D(tId, vUv + o); 22: float cover = abs(n0.a - n1.a); 23: float part = step(0.002, distance(i0.rgb, i1.rgb)) * max(n0.a, n1.a); 24: float crease = smoothstep(0.25, 0.45, 1.0 - dot(n0.xyz * 2.0 - 1.0, n1.xyz * 2.0 - 1.0)) * n0.a * n1.a; 25: e = max(e, max(cover, max(part, crease * 0.8))); 26: } 27: float shade = n0.a > 0.5 ? mix(0.86, 1.0, clamp((n0.z * 2.0 - 1.0), 0.0, 1.0)) : 1.0; 28: gl_FragColor = vec4(vec3(shade * (1.0 - e)), 1.0); 29: }`; 30: 31: export async function startSheet(canvas: HTMLCanvasElement, q: URLSearchParams) { 32: const name = (q.get('sheet') ?? 'striker') as ModelName; 33: const views = (q.get('views') ?? 'front,side,back').split(','); 34: const W = window.innerWidth, H = window.innerHeight; 35: const renderer = new THREE.WebGLRenderer({ canvas, antialias: false, preserveDrawingBuffer: true }); 36: renderer.setPixelRatio(1); 37: renderer.setSize(W, H, false); 38: renderer.setClearColor(0xffffff, 1); 39: 40: const scene = new THREE.Scene(); 41: const root = await model(name); 42: scene.add(root); 43: if (name === 'striker') new MechRig(root).apply(POSES[(q.get('pose') ?? 'stand') as PoseName] ?? POSES.stand); 44: root.updateMatrixWorld(true); 45: const box = new THREE.Box3().setFromObject(root); 46: const size = box.getSize(new THREE.Vector3()), centre = box.getCenter(new THREE.Vector3()); 47: 48: // every mesh gets a unique flat colour for the part-boundary pass 49: const ids = new Map<THREE.Mesh, THREE.MeshBasicMaterial>(); 50: let n = 0; 51: root.traverse((o) => { 52: const m = o as THREE.Mesh; 53: if (!m.isMesh) return; 54: n++; 55: ids.set(m, new THREE.MeshBasicMaterial({ color: new THREE.Color().setHSL((n * 0.6180339) % 1, 0.7, 0.3 + (n % 5) * 0.1) })); 56: }); 57: const normalMat = new THREE.MeshNormalMaterial({ side: THREE.DoubleSide }); 58: const targets = { normal: new THREE.WebGLRenderTarget(W, H), id: new THREE.WebGLRenderTarget(W, H) }; 59: const quad = new THREE.Mesh(new THREE.PlaneGeometry(2, 2), new THREE.ShaderMaterial({ 60: uniforms: { tNormal: { value: targets.normal.texture }, tId: { value: targets.id.texture }, px: { value: new THREE.Vector2(1.3 / W, 1.3 / H) }, 61: near: { value: 0 }, far: { value: 0 } }, 62: vertexShader: 'varying vec2 vUv; void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); }', 63: fragmentShader: LINE, 64: })); 65: const post = new THREE.Scene(); 66: post.add(quad); 67: const postCam = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1); 68: 69: // views side by side, same scale, feet on a common ground line 70: const span = Math.max(size.y, size.x * 1.15, size.z * 1.15) * 1.12; 71: const vw = W / views.length; 72: const cam = new THREE.OrthographicCamera(-1, 1, 1, -1, 0.1, 1000); 73: const dirs: Record<string, THREE.Vector3> = { 74: front: new THREE.Vector3(0, 0, 1), back: new THREE.Vector3(0, 0, -1), side: new THREE.Vector3(1, 0, 0), top: new THREE.Vector3(0, 1, 0.0001), 75: // three-quarter views: front from the frame's left, back from its right, both slightly from above 76: front34: new THREE.Vector3(1, 0.25, 1).normalize(), back34: new THREE.Vector3(-1, 0.25, -1).normalize(), 77: low34: new THREE.Vector3(-1, -0.35, 1).normalize(), 78: }; 79: renderer.autoClear = false; 80: renderer.setRenderTarget(null); 81: renderer.clear(); 82: views.forEach((v, i) => { 83: const aspect = vw / H; 84: cam.left = (-span * aspect) / 2; 85: cam.right = (span * aspect) / 2; 86: cam.top = span / 2; 87: cam.bottom = -span / 2; 88: cam.position.copy(centre).addScaledVector(dirs[v] ?? dirs.front, 200); 89: cam.up.set(0, v === 'top' ? 0 : 1, v === 'top' ? -1 : 0); 90: cam.lookAt(centre); 91: cam.updateProjectionMatrix(); 92: for (const [mat, target] of [[normalMat, targets.normal], [null, targets.id]] as const) { 93: renderer.setRenderTarget(target); 94: renderer.setViewport(i * vw, 0, vw, H); 95: renderer.setScissor(i * vw, 0, vw, H); 96: renderer.setScissorTest(true); 97: renderer.setClearColor(0x000000, 0); 98: renderer.clear(); 99: if (mat) scene.overrideMaterial = mat; 100: else for (const [m, idm] of ids) { m.userData.mat = m.material; m.material = idm; } 101: renderer.render(scene, cam); 102: scene.overrideMaterial = null; 103: if (!mat) for (const m of ids.keys()) m.material = m.userData.mat; 104: } 105: }); 106: renderer.setScissorTest(false); 107: renderer.setViewport(0, 0, W, H); 108: renderer.setRenderTarget(null); 109: renderer.render(post, postCam); 110: (window as unknown as { __ready: boolean }).__ready = true; 111: }read_file{"Path":"~/work/sortie/src/view/cameras.ts"}
input
{ "Path": "~/work/sortie/src/view/cameras.ts" }result, 103 lines
Showing lines 1-102 of 102 1: import * as THREE from 'three'; 2: 3: export type ViewMode = 'cockpit' | 'chase'; 4: 5: const FLIP = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI); 6: const _p = new THREE.Vector3(); 7: const _look = new THREE.Matrix4(); 8: const _up = new THREE.Vector3(); 9: 10: /** 11: * Cockpit: the camera sits at the frame's cockpit node, looking along the frame's nose. 12: * Chase (F5): over the frame's right shoulder, so the frame sits left of centre and the crosshair 13: * (screen centre) has clear space. Position follows rigidly; only the orientation is smoothed, so the 14: * frame never drifts toward or away from the camera when it speeds up or slows down. 15: */ 16: export class CameraRig { 17: mode: ViewMode = 'chase'; 18: readonly camera: THREE.PerspectiveCamera; 19: /** Chase offset in the frame's axes (+X is the frame's left, +Z forward). X is set from `shoulder`. */ 20: chaseOffset = new THREE.Vector3(0, 4.5, -30); 21: /** How far over the right shoulder the chase camera sits in flight (negative X is the frame's right). */ 22: shoulder = -8.5; 23: /** How far below the camera the look point sits, so the frame rides low in the view. */ 24: lookDrop = 1.5; 25: /** Scales the chase distance and height. On the catapult a heavy's camera pulls in to the 26: * striker's distance, so it stays near the tube mouth instead of deep in the hangar. */ 27: reach = 1; 28: /** 0 centred behind the frame (on the catapult), 1 fully over the shoulder. Eases toward `shoulderWanted`. */ 29: private shoulderBlend = 0; 30: shoulderWanted = 0; 31: private smoothed = new THREE.Quaternion(); 32: private shake = 0; 33: private time = 0; 34: 35: constructor(fov = 68) { 36: this.camera = new THREE.PerspectiveCamera(fov, 1, 0.5, 60000); 37: } 38: 39: toggle() { 40: this.mode = this.mode === 'cockpit' ? 'chase' : 'cockpit'; 41: } 42: 43: /** Jolt the view (catapult, hits). Decays on its own. */ 44: kick(amount: number) { 45: this.shake = Math.max(this.shake, amount); 46: } 47: 48: update(mech: { pos: THREE.Vector3; rot: THREE.Quaternion }, cockpit: THREE.Object3D, dt: number, snap = false) { 49: this.time += dt; 50: const cam = this.camera; 51: if (snap) this.smoothed.copy(mech.rot); 52: else this.smoothed.slerp(mech.rot, 1 - Math.exp(-10 * dt)); 53: this.shoulderBlend = snap ? this.shoulderWanted : this.shoulderBlend + (this.shoulderWanted - this.shoulderBlend) * (1 - Math.exp(-1.8 * dt)); 54: this.chaseOffset.x = this.shoulder * THREE.MathUtils.smoothstep(this.shoulderBlend, 0, 1); 55: if (this.mode === 'cockpit') { 56: cockpit.getWorldPosition(cam.position); 57: cam.quaternion.copy(mech.rot).multiply(FLIP); 58: } else { 59: const q = this.smoothed; 60: const o = this.chaseOffset, r = this.reach; 61: cam.position.set(o.x, o.y * r, o.z * r).applyQuaternion(q).add(mech.pos); 62: // look straight ahead from the shoulder, parallel to the frame's nose 63: _p.set(o.x, (o.y - this.lookDrop) * r, 400).applyQuaternion(q).add(mech.pos); 64: _up.set(0, 1, 0).applyQuaternion(q); 65: _look.lookAt(cam.position, _p, _up); 66: cam.quaternion.setFromRotationMatrix(_look); 67: } 68: this.applyShake(dt); 69: } 70: 71: /** 72: * The wreck seen from outside: a slow orbit round the drifting frame that pulls back as it goes, 73: * starting from the chase spot behind the heading it had when it was hit. `t` is seconds since 74: * the wreck and `size` the frame's scale, so the shot is a pure function of time. 75: */ 76: wreck(target: THREE.Vector3, heading: THREE.Quaternion, t: number, size: number, dt: number) { 77: this.time += dt; 78: const cam = this.camera; 79: const ease = 1 - Math.exp(-t * 0.8); 80: const dist = (32 + 95 * ease) * size; 81: const yaw = 0.35 * t + 0.25 * ease; 82: const rise = 0.18 + 0.32 * ease; 83: _p.set(Math.sin(yaw) * Math.cos(rise), Math.sin(rise), -Math.cos(yaw) * Math.cos(rise)).multiplyScalar(dist); 84: cam.position.copy(_p.applyQuaternion(heading)).add(target); 85: _up.set(0, 1, 0).applyQuaternion(heading); 86: _look.lookAt(cam.position, target, _up); 87: cam.quaternion.setFromRotationMatrix(_look); 88: this.smoothed.copy(heading); 89: this.applyShake(dt); 90: } 91: 92: private applyShake(dt: number) { 93: const cam = this.camera; 94: if (this.shake > 0.001) { 95: const s = this.shake; 96: cam.position.x += (Math.sin(this.time * 71) + Math.sin(this.time * 113)) * 0.05 * s; 97: cam.position.y += (Math.sin(this.time * 89) + Math.sin(this.time * 131)) * 0.05 * s; 98: cam.rotateZ(Math.sin(this.time * 47) * 0.004 * s); 99: this.shake *= Math.exp(-4 * dt); 100: } 101: } 102: }read_file{"Path":"~/work/sortie/src/render/materials.ts"}
input
{ "Path": "~/work/sortie/src/render/materials.ts" }result, 131 lines
Showing lines 1-130 of 130 1: import * as THREE from 'three'; 2: import type { Palette, Role } from './palette'; 3: import { addPaintVariation, look } from './look'; 4: 5: /** Painted armour roles: their finish follows the look (matte field paint or gloss kit paint). */ 6: const PAINT = new Set<Role>(['main', 'accent', 'trim', 'hull', 'suit', 'donor_a', 'donor_b', 'donor_c', 'primer', 'handpaint', 7: 'warpaint']); 8: /** Unpainted roles: no wear, grime or ink lines from the detail pass (alien crystal). */ 9: export const BARE = new Set<Role>(['crystal', 'crystal_lit']); 10: 11: // Physically based materials by role: painted armour, bare and dark metal, glass, and unlit glows 12: // that feed the bloom. 13: 14: /** Diagonal hazard stripes from world position, so no UVs are needed. */ 15: function addStripes(m: THREE.MeshStandardMaterial) { 16: m.onBeforeCompile = (shader) => { 17: shader.vertexShader = shader.vertexShader 18: .replace('#include <common>', '#include <common>\nvarying vec3 vStripePos;') 19: .replace('#include <worldpos_vertex>', '#include <worldpos_vertex>\nvStripePos = (modelMatrix * vec4(transformed, 1.0)).xyz;'); 20: shader.fragmentShader = shader.fragmentShader 21: .replace('#include <common>', '#include <common>\nvarying vec3 vStripePos;') 22: .replace( 23: '#include <color_fragment>', 24: `#include <color_fragment> 25: float stripe = step(0.5, fract((vStripePos.x + vStripePos.y + vStripePos.z) * 0.6)); 26: diffuseColor.rgb = mix(vec3(0.03, 0.03, 0.035), diffuseColor.rgb, stripe);`, 27: ); 28: }; 29: m.customProgramCacheKey = () => 'stripes'; 30: } 31: 32: const cache = new Map<string, THREE.Material>(); 33: 34: let bands: THREE.DataTexture | null = null; 35: /** Three lighting bands for the sketch look: shade, half-tone, lit. */ 36: function toonBands() { 37: if (bands) return bands; 38: const d = new Uint8Array([60, 60, 60, 140, 255, 255]); 39: bands = new THREE.DataTexture(d, d.length, 1, THREE.RedFormat); 40: bands.minFilter = bands.magFilter = THREE.NearestFilter; 41: bands.needsUpdate = true; 42: return bands; 43: } 44: 45: export function material(palette: Palette, role: Role, key: string): THREE.Material { 46: const l = look(); 47: const id = `${key}:${role}:${l.name}`; 48: const hit = cache.get(id); 49: if (hit) return hit; 50: const p = palette[role] ?? { color: '#ff00ff' }; 51: let m: THREE.Material; 52: if (p.glow) { 53: m = new THREE.MeshBasicMaterial({ color: new THREE.Color(p.color).multiplyScalar(p.glow) }); 54: } else { 55: // A floor on roughness: a near-mirror catching the sun makes a highlight brighter than the 56: // half-float buffers can hold, and the bloom smears that across the whole screen. 57: const painted = PAINT.has(role); 58: // a lacquered livery keeps its own finish under a matte look: its roughness at most, and a clear coat 59: const lacquer = painted ? p.lacquer ?? 0 : 0; 60: const paintRough = lacquer ? Math.min(l.paintRough, p.rough ?? l.paintRough) : l.paintRough; 61: const roughness = Math.max(0.2, painted ? paintRough : p.rough ?? 0.5); 62: const coat = painted ? Math.max(l.gloss ? 0.6 : 0, lacquer) : p.coat ?? 0; 63: const color = new THREE.Color(p.color); 64: if (painted && l.desaturate > 0) { 65: // weathered paint: pulled toward grey and warmed slightly, less so under lacquer 66: const grey = color.r * 0.3 + color.g * 0.59 + color.b * 0.11; 67: color.lerp(new THREE.Color(grey, grey, grey), l.desaturate * (1 - lacquer * 0.6)).multiply(new THREE.Color(1.0, 0.98, 0.94)); 68: } 69: if (l.toon) { 70: const t = new THREE.MeshToonMaterial({ color, gradientMap: toonBands() }); 71: t.name = role; 72: if (role === 'hazard') addStripes(t as unknown as THREE.MeshStandardMaterial); 73: cache.set(id, t); 74: return t; 75: } 76: const s = coat >= 0.5 77: ? new THREE.MeshPhysicalMaterial({ color, roughness, metalness: p.metal ?? 0, clearcoat: coat, clearcoatRoughness: 0.25 }) 78: : new THREE.MeshStandardMaterial({ color, roughness, metalness: p.metal ?? 0 }); 79: if (p.emit) s.emissive.copy(color).multiplyScalar(p.emit); 80: if (role === 'hazard') addStripes(s); 81: else if (painted || role === 'frame' || role === 'joint' || role === 'rust') addPaintVariation(s, l.grime * (painted ? 1 : 0.6)); 82: if (p.rust) addRust(s, p.rust); 83: m = s; 84: } 85: m.name = role; 86: cache.set(id, m); 87: return m; 88: } 89: 90: /** Rust from world position, so no UVs are needed: blotches that grow with `amount`, streaks running down 91: * from them, rougher and duller where the paint has gone. */ 92: function addRust(m: THREE.MeshStandardMaterial, amount: number) { 93: const prev = m.onBeforeCompile; 94: m.onBeforeCompile = (shader, r) => { 95: prev?.call(m, shader, r); 96: shader.vertexShader = shader.vertexShader 97: .replace('#include <common>', '#include <common>\nvarying vec3 vRustPos;') 98: .replace('#include <worldpos_vertex>', '#include <worldpos_vertex>\nvRustPos = (modelMatrix * vec4(transformed, 1.0)).xyz;'); 99: shader.fragmentShader = shader.fragmentShader 100: .replace('#include <common>', `#include <common> 101: varying vec3 vRustPos; 102: float rn(vec3 p) { vec3 i = floor(p), f = fract(p); f = f * f * (3.0 - 2.0 * f); 103: vec3 k = vec3(12.9, 78.2, 37.7); 104: return mix(mix(mix(fract(sin(dot(i, k)) * 43758.5), fract(sin(dot(i + vec3(1,0,0), k)) * 43758.5), f.x), 105: mix(fract(sin(dot(i + vec3(0,1,0), k)) * 43758.5), fract(sin(dot(i + vec3(1,1,0), k)) * 43758.5), f.x), f.y), 106: mix(mix(fract(sin(dot(i + vec3(0,0,1), k)) * 43758.5), fract(sin(dot(i + vec3(1,0,1), k)) * 43758.5), f.x), 107: mix(fract(sin(dot(i + vec3(0,1,1), k)) * 43758.5), fract(sin(dot(i + vec3(1,1,1), k)) * 43758.5), f.x), f.y), f.z); } 108: float rustMask(vec3 p) { 109: // patches where paint has gone, fine-grained, and thin streaks running down from them 110: float blot = rn(p * 1.3) * 0.6 + rn(p * 4.7) * 0.4; 111: float t = 1.0 - ${(0.7 * amount).toFixed(3)}; 112: float streak = smoothstep(0.6, 0.82, rn(vec3(p.x * 9.0, p.y * 0.22, p.z * 9.0))) * smoothstep(t - 0.2, t, rn(p * 0.9)); 113: return clamp(smoothstep(t, t + 0.06, blot) + streak * 0.6, 0.0, 1.0); 114: }`) 115: .replace('#include <color_fragment>', `#include <color_fragment> 116: float rm = rustMask(vRustPos); 117: vec3 rc = mix(vec3(0.15, 0.065, 0.03), vec3(0.34, 0.14, 0.055), rn(vRustPos * 6.0)); 118: diffuseColor.rgb = mix(diffuseColor.rgb, rc, rm);`) 119: .replace('#include <roughnessmap_fragment>', `#include <roughnessmap_fragment> 120: roughnessFactor = mix(roughnessFactor, 0.92, rm);`) 121: .replace('#include <metalnessmap_fragment>', `#include <metalnessmap_fragment> 122: metalnessFactor = mix(metalnessFactor, 0.15, rm);`); 123: }; 124: const key = m.customProgramCacheKey?.bind(m); 125: m.customProgramCacheKey = () => `${key ? key() : ''}rust${amount}`; 126: } 127: 128: export function isRole(name: string): name is Role { 129: return /^[a-z_]+$/.test(name); 130: }
agent
+3:25reasoning
Initial testing involves measuring the execution time of a command that creates a short video clip, using different input targets. Attempting to run this command with various input parameters to assess performance. The focus is to determine the fastest configuration for creating these clips.
run_command{"CommandLine":"time node tools/clip.mjs striker --quick --shots chase --seconds 1 --fps 12 --out /tmp/test.mp4","WaitMsBeforeAsync":10000,"toolSummary":"Benchmark clip tool speed"}
input
{ "CommandLine": "time node tools/clip.mjs striker --quick --shots chase --seconds 1 --fps 12 --out /tmp/test.mp4", "WaitMsBeforeAsync": 10000, "toolSummary": "Benchmark clip tool speed" }result, 6 lines
Tool is running as a background task with task id: abb0eba5-92ad-4ab4-8738-458f4e606a27/task-79 Task Description: time node tools/clip.mjs striker --quick --shots chase --seconds 1 --fps 12 --out /tmp/test.mp4 Task logs are available at: file://~/.gemini/antigravity-cli/brain/abb0eba5-92ad-4ab4-8738-458f4e606a27/.system_generated/tasks/task-79.log YOU MUST TAKE ONE OF THE FOLLOWING TWO ACTIONS: A) either proceed to other relevant work (if any) or, B) simply update the user with a short message (that you have launched the command and will wait for it to finish) and end the turn. DO NOTHING ELSE. When updating the user, always respond in the language of the user (defaulting to English). Never mix two or more languages in the same response.
read_file{"Path":"~/work/sortie/kit/lab/board_sleek.py"}
input
{ "Path": "~/work/sortie/kit/lab/board_sleek.py" }result, 317 lines
Showing lines 1-316 of 316 1: """Estoc (line B), sleek knight: few strong shapes in smooth compound curves, every one ending in a sharp 2: tapered point (docs/study-atelier.md). Knightmare elegance on the atelier's stance. 3: 4: Leaf pauldrons swept back to a rising point, a keeled breastplate whose hem runs to a V, a corseted 5: waist, long blade tassets pointed at the hem, spiked couters, knee guards rising to a point, greaves 6: that sweep to a point over the instep, twin blades swept back from the helm. Thin gold piping on the 7: hems only. Long smooth faces carry long highlights: this direction leans hardest on the sheen. 8: 9: Grades by plate count (plates(J, P, g)): the light a smaller leaf, a bellows waist, short blade tassets, 10: an arming sleeve, one pair of short blades on the helm, the core block. The medium the board's line 11: knight. The heavy a second leaf under the first and a blade under that, a V plate over the lower breast, 12: flank blades, tassets in two layers, blade add-ons over the vambraces, cuisses and greaves, knee blades, 13: two pairs of helm blades. 14: """ 15: import math 16: 17: from knightkit import Sheet, addon, band, by, curve, horn, joint_covers, lames, lin, put, put2, rim, smooth, tent 18: from lib import copy 19: from makers import atelier 20: from makers.atelier import bearing_at, lr 21: from makers.shell import subtract 22: 23: FRONT = lin(-172, -8, 32) 24: breast_r = curve([1.0, 1.34, 1.52, 1.52, 1.42, 1.26, 1.1]) 25: 26: 27: def keel(u, z, grow=0.0, z0=12.1, z1=15.05): 28: r = breast_r(min(max((z - z0) / (z1 - z0), 0), 1)) + grow 29: a = math.radians(u) 30: return (r * 1.08 * math.cos(a), -.15 + r * math.sin(a), z) 31: 32: 33: def chest(P, J, g): 34: T, C = J["torso"], J["cockpit"] 35: H = T if g == "light" else C # the light's cockpit is the core block: its breast does not open 36: bot = lambda u: 12.1 + .7 * (1 - tent(u, -90, 70)) # the hem runs down to a V 37: top = lambda u: 15.05 - .28 * tent(u, -90, 40) - .55 * smooth(abs(u + 90), 56, 80) 38: ridge = lambda u, v: .2 * tent(u, -90, 34) * (1 - smooth(v, .85, 1)) # a keel, crisp on its crest 39: hi = lambda u: 12.9 + 1.2 * (1 - tent(u, -90, 100)) ** 1.6 # the ivory field above a second V, clear of the socket 40: s = Sheet(lambda u, v: keel(u, bot(u) + (top(u) - bot(u)) * v), FRONT, lin(0, 1, 16), .15, disp=ridge, inside=(0, 0, 13.6)) 41: bm = s.bm() 42: up = subtract(copy(bm), _below(hi)) 43: lo = subtract(bm, _above(hi)) 44: # the ivory field above the V is the hatch: it leaves with the pod, so no box is cut in the breast 45: P.solid("hatch", up, "accent", H, bevel=.012) 46: P.solid("breast_lo", lo, "main", T, bevel=.012) 47: rim(P, "breast_pipe", s.edge("v0", out=.01), .045, T) 48: bearing_at("chest", (1.0, -1.55, 14.3), (0, -1, 0), T, .8) 49: back = band((0, .15), 12.3, lambda u: 15.0 - .4 * smooth(u, 55, 80), [1.0, 1.42, 1.56, 1.5, 1.3], lin(14, 82, 10), nv=10, kx=1.04, ky=.92, t=.14) 50: put(P, "backplate", back, "main", T, T) 51: gg = band((0, .05), 14.8, 15.36, [1.14, 1.04, .92], lin(-168, -12, 24), nv=5, kx=1.05, t=.12) 52: put(P, "gorget", gg, "main", T) 53: if g == "light": 54: return 55: g2 = band((0, .05), 15.2, 15.62, [1.0, .94, .86], lin(-164, -16, 22), nv=4, kx=1.05, t=.1) 56: put(P, "gorget2", g2, "main", T) 57: rim(P, "gorget2_pipe", g2.edge("v1", out=.01), .04, T) 58: if g != "heavy": 59: return 60: # the castellan: a V plate over the lower breast, blades down the flanks 61: vb = lambda u: 12.0 + .7 * (1 - tent(u, -90, 70)) 62: vt = lambda u: 12.75 + .5 * (1 - tent(u, -90, 70)) 63: v = Sheet(lambda u, v: keel(u, vb(u) + (vt(u) - vb(u)) * v, .17), lin(-158, -22, 28), lin(0, 1, 5), .14, 64: disp=lambda u, v: .2 * tent(u, -90, 34), inside=(0, 0, 13.0)) 65: put(P, "breast_v", v, "main", T) 66: rim(P, "breast_v_pipe", v.edge("v1", out=.01), .045, T) 67: P.solid("flank_blade", horn([(1.5, -.3, 14.3), (1.62, -.2, 13.6), (1.6, -.1, 12.9), (1.42, 0, 12.2)], .26, n=10, power=1.0, squash=.3, 68: up=(1, 0, 0)), "main", T, T, bevel=0) 69: 70: 71: def _below(h): 72: """A solid under the curve z = h(u) on the chest front (u in plan degrees).""" 73: return _split(h, -1) 74: 75: 76: def _above(h): 77: return _split(h, 1) 78: 79: 80: def _split(h, side): 81: import bmesh 82: bm = bmesh.new() 83: us = lin(-178, -2, 120) 84: far = 30 if side > 0 else -30 85: rings = [] 86: for z in (None, far): 87: ring = [] 88: for u in us: 89: a = math.radians(u) 90: zz = h(u) if z is None else h(u) + far 91: ring += [bm.verts.new((.2 * math.cos(a), -.15 + .2 * math.sin(a), zz)), bm.verts.new((4 * math.cos(a), -.15 + 4 * math.sin(a), zz))] 92: rings.append(ring) 93: n = len(us) 94: A, B = rings 95: for i in range(n - 1): 96: a0, a1, b0, b1 = A[2 * i], A[2 * i + 1], A[2 * i + 2], A[2 * i + 3] 97: c0, c1, d0, d1 = B[2 * i], B[2 * i + 1], B[2 * i + 2], B[2 * i + 3] 98: bm.faces.new((a0, b0, b1, a1)) 99: bm.faces.new((c0, c1, d1, d0)) 100: bm.faces.new((a1, b1, d1, c1)) 101: bm.faces.new((a0, c0, d0, b0)) 102: bm.faces.new((A[0], A[1], B[1], B[0])) 103: bm.faces.new((A[-2], B[-2], B[-1], A[-1])) 104: bmesh.ops.recalc_face_normals(bm, faces=bm.faces) 105: return bm 106: 107: 108: def waist(P, J, g): 109: W = J["waist"] 110: if g == "light": 111: return # a bellows waist (joint_covers) 112: s = band((0, -.1), 11.3, 12.3, [.94, .8, .86, .96], lin(-170, -10, 26), nv=8, kx=1.08, t=.16, 113: disp=lambda u, v: .08 * tent(u, -90, 30)) 114: put(P, "corset", s, "main", W) 115: 116: 117: def pelvis(P, J, g): 118: Pv = J["pelvis"] 119: heavy = g == "heavy" 120: f = band((0, 0), 10.55, 11.25, [1.42, 1.36, 1.2], lin(-172, -8, 30), nv=5, kx=1.06, ky=.84, t=.16, disp=lambda u, v: .1 * tent(u, -90, 30)) 121: put(P, "fauld", f, "main", Pv) 122: P.solid("crotch", atelier.sheet([(-.5, 10.6), (.5, 10.6), (.36, 10.0), (0, 9.5), (-.36, 10.0)], 123: [(-1.04, 10.6), (-.38, 10.6), (-.38, 9.5), (-.9, 9.5)], None), "main", Pv) 124: # a long blade tasset over each thigh, pointed at the hem 125: hem = by(g, lambda u: 9.2 + .7 * (1 - tent(u, -100, 62)), lambda u: 8.35 + .95 * (1 - tent(u, -100, 62)), 126: lambda u: 8.0 + 1.0 * (1 - tent(u, -100, 62))) 127: t = band((1.1, -.12), hem, 10.72, lambda u, v: 1.18 - .22 * v + .06 * math.sin(math.pi * v), lin(-164, -36, 24), nv=10, t=.14, 128: disp=lambda u, v: .07 * tent(u, -100, 22)) 129: put(P, "tasset", t, "main", Pv, Pv) 130: rim(P, "tasset_pipe", t.edge("v0", out=.01), .04, Pv, Pv) 131: if g != "light": 132: # a shorter blade over the long one: the tasset in two layers 133: oh = lambda u: 9.0 + .8 * (1 - tent(u, -100, 56)) 134: t2 = band((1.1, -.12), oh, 10.76, lambda u, v: 1.3 - .22 * v + .06 * math.sin(math.pi * v), lin(-156, -44, 20), nv=8, t=.13, 135: disp=lambda u, v: .07 * tent(u, -100, 22)) 136: put(P, "tasset_over", t2, "main", Pv, Pv) 137: rim(P, "tasset_over_pipe", t2.edge("v0", out=.01), .045, Pv, Pv) 138: if heavy: 139: lames(P, "tasset_side_lame", (1.3, 0), 9.4, 2, .4, .32, 1.12, -.03, lin(-46, 46, 12), Pv, Pv, "main", "main") 140: if g == "light": 141: c = band((0, 0), 10.0, 10.95, [1.36, 1.28, 1.22], lin(10, 88, 12), nv=4, ky=.92, t=.12) 142: put(P, "culet", c, "main", Pv, Pv) 143: return 144: side = band((1.3, 0), lambda u: 9.25 + .5 * (1 - tent(u, 0, 50)), 10.55, [1.12, .86], lin(-50, 50, 12), nv=6, t=.12) 145: put(P, "tasset_side", side, "main", Pv, Pv) 146: c = band((0, 0), lambda u: 9.6 + .5 * smooth(u, 20, 80), 10.95, [1.42, 1.3, 1.22], lin(10, 88, 12), nv=6, ky=.92, t=.14) 147: put(P, "culet", c, "main", Pv, Pv) 148: 149: 150: def shoulder(P, J, g): 151: """A leaf: one shell over the shoulder, blunt in front, drawn back and up into a point. The castellan 152: layers a second leaf under it and a blade under that.""" 153: S = lr(J, "shoulder") 154: # light one small leaf, medium a leaf over a second, heavy one great leaf over a long swept mantle: the 155: # extra mass goes into one gesture, the surfaces stay smooth 156: leaves = by(g, [(.82, 0.0, 2.0, 1.75)], [(1.0, 0.0, 2.0, 1.75), (.9, -.55, 1.4, 1.75)], [(1.12, 0.0, 2.2, 1.75), (1.0, -.5, 1.0, 2.9)]) 157: for i, (k, dz, rise, length) in enumerate(leaves): 158: leaf(P, S, f"pauldron{i}" if i else "pauldron", k, dz, rise, ridge=i == 0, pipe="trim" if i == 0 else "main", length=length) 159: for side, j, sx in (("L", S[0], 1), ("R", S[1], -1)): 160: bearing_at(f"shoulder.{side}", (3.8 * sx, .1, 14.2), (sx, 0, 0), j, .5) 161: 162: 163: def leaf(P, S, name, k, dz, rise, ridge=True, pipe="trim", length=1.75): 164: 165: def width(s): 166: return (1 - abs(s) ** 4) ** .35 if s < 0 else (1 - s ** 1.4) ** .8 # a broad root in front, one point behind 167: 168: def f(s, p): 169: back = max(s, 0.0) 170: w = width(s) 171: y = s * (1.2 if s < 0 else length) * k 172: xc, zc = 2.5 + .7 * k * back ** 2, 14.4 + dz + rise * k * back ** 2 # the point sweeps up and out behind the shoulder, seen from the front 173: a = math.radians(p) 174: c, n = math.cos(a), math.sin(a) 175: return (xc + 1.36 * k * w * math.copysign(abs(c) ** .75, c), .06 + y, zc + .86 * k * w * math.copysign(abs(n) ** .85, n)) 176: # a ridge along the crown from the root into the point 177: sh = Sheet(f, lin(-1.0, .985, 40), lin(116, -96, 28) if ridge else lin(70, -96, 22), .15, 178: disp=(lambda s, p: .16 * width(s) * tent(p, 52, 26)) if ridge else None, inside=(2.5, 0, 14.3 + dz)) 179: put(P, name, sh, "main", *S) 180: if pipe: 181: rim(P, f"{name}_pipe", sh.edge("v1", out=.01), .045, *S, role=pipe) 182: 183: 184: def upperarm(P, J, g): 185: UA = lr(J, "upperarm") 186: if g == "light": 187: return # an arming sleeve (joint_covers) 188: s = band((2.45, 0), 12.4, 13.6, [.56, .54, .5], lin(-150, 150, 26), nv=5, t=.16) 189: put(P, "sleeve", s, "main", *UA) 190: if g == "heavy": 191: lames(P, "sleeve_lame", (2.45, 0), 13.7, 1, .4, .3, .62, 0, lin(-150, 150, 26), *UA, "main", "trim") 192: 193: 194: def forearm(P, J, g): 195: FA = lr(J, "forearm") 196: k = by(g, .7, 1.0, 1.2) 197: s = band((2.5, 0), 9.86, 11.6, [.6, .54, .48, .47], lin(-165, 165, 40), nv=8, kx=.92, t=.16, 198: disp=lambda u, v: .07 * tent(u, -90, 26)) 199: put(P, "vambrace", s, "main", *FA) 200: rim(P, "vambrace_pipe", s.edge("v0", out=.01), .04, *FA) 201: # the couter: a swept spike off the back of the elbow 202: P.solid("couter", horn([(2.5, .2, 12.0), (2.56, .2 + .5 * k, 12.05), (2.62, .2 + 1.0 * k, 12.05 + .25 * k), (2.66, .2 + 1.35 * k, 12.05 + .7 * k)], 203: .42, n=12, power=1.2, squash=.7), "main", *FA, bevel=0) 204: if g != "light": 205: cuff = band((2.5, 0), 9.5, 9.92, [.62, .58], lin(-165, 165, 30), nv=2, kx=.92, t=.1) 206: put(P, "vambrace_cuff", cuff, "main", *FA) 207: if g == "heavy": 208: addon(P, "vambrace_blade", (2.5, 0), lambda v: .66 - .08 * v, lin(-140, -40, 12), 9.95, 11.4, .55, *FA, "main", kx=.92, studs=0, rim_role="main") 209: P.solid("couter_cup", Sheet(_cup((2.5, .1, 11.95)), lin(0, 360, 20), lin(0, 80, 6), .1, wrap=True, inside=(2.5, 0, 11.95)).bm(), "main", *FA, bevel=0) 210: 211: 212: def _cup(c): 213: from knightkit import cap 214: return cap(c, (0, 1, 0), (.55, .55, .4)) 215: 216: 217: def thigh(P, J, g): 218: TH = lr(J, "thigh") 219: s = band((1.16, -.05), 6.75, 9.7, [.74, .8, .86, .86], lin(-162, -18, 24), nv=10, t=.2, disp=lambda u, v: .1 * tent(u, -90, 30)) 220: put(P, "cuisse", s, "main", *TH) 221: if g == "light": 222: return 223: b = band((1.16, -.05), 7.0, 9.5, [.72, .8, .84], lin(28, 152, 16), nv=6, t=.18) 224: put(P, "cuisse_back", b, "main", *TH) 225: if g == "heavy": 226: addon(P, "cuisse_blade", (1.16, -.05), lambda v: .98 + .04 * v, lin(-136, -44, 14), 7.4, 9.5, .8, *TH, "main", studs=0, rim_role="main") 227: 228: 229: GC = (1.2, .02) 230: 231: 232: def shin(P, J, g): 233: SH = lr(J, "shin") 234: heavy = g == "heavy" 235: # the knee guard: a shell over the knee rising to a point above it 236: top = lambda u: 6.55 + 1.0 * tent(u, -90, 46) ** 1.6 237: k = band((1.2, -.12), 5.45, top, lambda u, v: .74 + .08 * math.sin(math.pi * v) - .14 * v * v, lin(-160, -20, 26), nv=10, ky=1.1, t=.16, 238: disp=lambda u, v: .1 * tent(u, -90, 30)) 239: put(P, "knee", k, "main", *SH) 240: rim(P, "knee_pipe", k.edge("v0", out=.01), .04, *SH) 241: # the greave: one smooth sheet, its hem swept down to a point over the instep 242: hem = lambda u: 1.7 - .55 * tent(u, -90, 50) ** 1.5 243: g_ = band(GC, hem, 5.45, [1.08, .86, .68, .64, .66, .6, .55], lin(-176, -4, 34), nv=14, ky=1.14, t=.16, 244: disp=lambda u, v: .09 * tent(u, -90, 30) * (1 - smooth(v, .9, 1))) 245: put(P, "greave", g_, "main", *SH) 246: if heavy: 247: addon(P, "greave_blade", GC, lambda v: [1.14, .96, .8, .74, .74][min(int(v * 4.999), 4)] + .02, lin(-124, -56, 12), 2.2, 5.1, 1.2, *SH, 248: "main", ky=1.14, studs=0, rim_role="main") 249: if g != "light": 250: for nm, sx in (("o", 1), ("i", -1))[:by(g, 0, 1, 2)]: 251: x = 1.2 + sx * .72 252: P.solid(f"knee_blade_{nm}", horn([(x, -.1, 6.0), (x + sx * .12, .2, 6.3), (x + sx * .2, .6, 6.8)], .3, n=10, power=1.0, squash=.3, 253: up=(1, 0, 0)), "main", *SH, bevel=0) 254: if g == "light": 255: rim(P, "greave_pipe", g_.edge("v0", out=.01), .045, *SH) 256: calf = band(GC, 2.0, 5.2, [.9, .76, .66, .7, .72, .6], lin(40, 140, 14), nv=10, ky=1.12, t=.1) 257: put(P, "calf", calf, "main", *SH) 258: return 259: panel = band(GC, lambda u: hem(u) + .25, 5.2, [1.12, .9, .72, .68, .7, .64, .58], lin(-108, -72, 8), nv=14, ky=1.14, t=.08, 260: disp=lambda u, v: .09 * tent(u, -90, 30) * (1 - smooth(v, .9, 1))) 261: put(P, "greave_panel", panel, "accent", *SH) 262: rim(P, "greave_pipe", g_.edge("v0", out=.01), .045, *SH) 263: calf = band(GC, 1.92, 5.3, [1.0, .84, .7, .76, .82, .66], lin(10, 170, 22), nv=12, ky=1.12, t=.14) 264: put(P, "calf", calf, "main", *SH) 265: for side, j, sx in (("L", SH[0], 1), ("R", SH[1], -1)): 266: bearing_at(f"shin.{side}", (1.2 * sx, GC[1] - .85, 4.0), (0, -1, 0), j, .4) 267: 268: 269: def helm_blades(g): 270: def make(P, J): 271: """Twin blades swept back from the temples: short on the light, a second lower pair on the heavy.""" 272: from knightkit import head_layers 273: H = J["head"] 274: pairs = by(g, [(.6, 0)], [(1.0, 0)], [(1.0, 0), (.7, -.32)]) 275: for i, (k, dz) in enumerate(pairs): 276: for s, sx in (("L", 1), ("R", -1)): 277: b = horn([(.5 * sx, -.2, 16.5 + dz), (.62 * sx, -.2 + .4 * k, 16.5 + dz + .25 * k), (.74 * sx, -.2 + .9 * k, 16.5 + dz + .6 * k), 278: (.8 * sx, -.2 + 1.4 * k, 16.5 + dz + 1.1 * k)], .2, n=10, power=1.1, squash=.25, up=(1, 0, 0)) 279: P.solid(f"helm_blade{i}.{s}", b, "trim", H, bevel=0) 280: head_layers(P, J, g) 281: return make 282: 283: 284: def back(P, J, g): 285: """A smooth plate over the pack drawn up to a point between the binders, broader on the castellan.""" 286: from knightkit import back_layers 287: if g == "light": 288: return 289: B = J["backpack"] 290: k = by(g, 0, 0.0, .45) 291: back_layers(P, J, g, "main") 292: s = band((0, 1.5), 12.7 - k * .3, lambda u: 14.4 + 1.0 * tent(u, 90, 34) ** 1.4, [1.2 + k, 1.26 + k, 1.22 + k, 1.1 + k], lin(54, 126, 24), nv=10, 293: kx=.86, t=.12, 294: disp=lambda u, v: .08 * tent(u, 90, 22)) 295: put(P, "pack_plate", s, "accent", B) 296: rim(P, "pack_plate_pipe", s.edge("v0", out=.01), .04, B) 297: 298: 299: def plates(J, P, g="medium"): 300: from knightkit import helm, sabaton, shoulder_root 301: helm(P, J, g, helm_blades(g)) 302: chest(P, J, g) 303: waist(P, J, g) 304: pelvis(P, J, g) 305: shoulder(P, J, g) 306: shoulder_root(P, J) 307: upperarm(P, J, g) 308: forearm(P, J, g) 309: thigh(P, J, g) 310: shin(P, J, g) 311: sab = by(g, ((.55, -3.4),), ((.55, -3.6),), ((.55, -1.4), (-1.2, -3.7))) 312: sabaton(P, J, lames=sab, point=1.0, keel=.08, rims="all") 313: atelier.backpack(P, J, g) 314: back(P, J, g) 315: atelier.binder(P, J, g) 316: joint_covers(P, J, g, style="bellows", fauld="bellows")