Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.
JavaScript 3d3d-assets3d-modelingagent-skillsagent-toolsai-agentsasset-pipelinecligame-assetsglbgltfmcpmcp-servermodel-context-protocolprocedural-generationprocedural-modelingtext-to-3dthreejstypescript
feat(examples): a fifty-program library, and the dispatcher that produced it
Matt Kissinger16a61d1d9f4a
diff --git a/examples/air-defense-radar.kiln.js b/examples/air-defense-radar.kiln.jsnew file mode 100644index 00000000..62ebf7aa--- /dev/null+++ b/examples/air-defense-radar.kiln.js@@ -0,0 +1,624 @@+// Authored by: opus, via claude.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.+//+// Refined later, in this repository, with `kiln_edit`: four fittings brought+// back onto the parts they bolt to, and the two bare-metal materials taken off+// a light base at metalness 0.9, which had been returning the studio dome at+// full brightness in the shape of a hub cap.+// The attribution above is for the authoring run, which had none of this in+// scope. Both passes went through the same tools; only the second one could+// see the gallery it was going into.++const meta = { name: 'AirDefenseRadar', category: 'prop', role: 'vehicle' };++// Truck-mounted air-defense phased-array radar, deployed on level ground.+// Frame: +X forward (cab), +Y up, +Z asset right. Ground plane at Y = 0.+//+// Layout along X:+// +5.75 .. +3.10 flat cab-over cab, bumper, whips+// +3.00 .. -2.85 load deck: generator box, cable trunk, lift rams, spare wheel+// -0.40 array hinge line; the 4.5 x 5.5 m panel leans back at 60 deg+// and passes clear over the shelter roof+// -2.60 .. -5.40 rear equipment shelter (door on the -X face)+// Axles at x = +4.05, +2.65, -2.75, -4.15 (8 wheels). Outrigger feet at Y = 0.++const TAU = Math.PI * 2;++// ---------------------------------------------------------------- helpers++// createPart auto-parents; position/rotation are set on the returned object so+// no assumption is made about the option-bag key names.+function part(name, geo, material, parent, pos, rot) {+ const p = createPart(name, geo, material, { parent: parent });+ if (pos && p && p.position) p.position.set(pos[0], pos[1], pos[2]);+ if (rot && p && p.rotation) p.rotation.set(rot[0], rot[1], rot[2]);+ return p;+}++function pivot(name, pos, parent) {+ const g = createPivot(name, [pos[0], pos[1], pos[2]], parent);+ if (g && g.position) g.position.set(pos[0], pos[1], pos[2]);+ return g;+}++// Verify a geometry actually came out the size we asked for; fall back to a box+// of the intended dimensions if it did not.+function checkGeo(geo, w, h, d, fallback) {+ try {+ if (!geo) return fallback();+ if (geo.computeBoundingBox) geo.computeBoundingBox();+ const b = geo.boundingBox;+ if (!b) return geo;+ const got = [b.max.x - b.min.x, b.max.y - b.min.y, b.max.z - b.min.z];+ const want = [w, h, d];+ for (let i = 0; i < 3; i++) {+ const tol = Math.max(0.06, want[i] * 0.3);+ if (Math.abs(got[i] - want[i]) > tol) return fallback();+ }+ return geo;+ } catch (e) {+ return fallback();+ }+}++function cylY(r, h, seg) {+ const s = seg || 16;+ try { return checkGeo(cylinderYGeo(r, h, s), r * 2, h, r * 2, function () { return boxGeo(r * 2, h, r * 2); }); }+ catch (e) { return boxGeo(r * 2, h, r * 2); }+}++function cylX(r, len, seg) {+ const s = seg || 16;+ try { return checkGeo(cylinderXGeo(r, len, s), len, r * 2, r * 2, function () { return boxGeo(len, r * 2, r * 2); }); }+ catch (e) { return boxGeo(len, r * 2, r * 2); }+}++function cylZ(r, len, seg) {+ const s = seg || 16;+ try { return checkGeo(cylinderZGeo(r, len, s), r * 2, r * 2, len, function () { return boxGeo(r * 2, r * 2, len); }); }+ catch (e) { return boxGeo(r * 2, r * 2, len); }+}++// Chamfered box for manufactured masses. Awaits WASM, hence async build().+async function rbox(w, h, d, r) {+ try {+ const g = await roundedBoxGeo(w, h, d, r === undefined ? 0.04 : r, 2);+ return checkGeo(g, w, h, d, function () { return boxGeo(w, h, d); });+ } catch (e) {+ return boxGeo(w, h, d);+ }+}++function mkMat(color, rough, metal) {+ let m;+ try {+ m = gameMaterial({ color: color, roughness: rough, metalness: metal });+ } catch (e) {+ try { m = gameMaterial(color); } catch (e2) { m = null; }+ }+ if (m) {+ if (m.color && m.color.setHex) m.color.setHex(color);+ if (rough !== undefined && 'roughness' in m) m.roughness = rough;+ if (metal !== undefined && 'metalness' in m) m.metalness = metal;+ }+ return m;+}++function mkGlass(color) {+ try {+ const g = glassMaterial({ color: color, roughness: 0.1 });+ if (g) {+ if (g.color && g.color.setHex) g.color.setHex(color);+ return g;+ }+ } catch (e) { /* fall through */ }+ return mkMat(color, 0.12, 0.35);+}++// ---------------------------------------------------------------- materials++const MAT = {};++// ---------------------------------------------------------------- sub-builders++// One road wheel. Axle runs along Z; `side` is +1 for the right-hand side so the+// lug nuts and hub cap sit on the outboard face.+function buildWheel(name, parent, x, y, z, side) {+ const R = 0.66;+ const W = 0.44;+ const g = pivot(name, [x, y, z], parent);++ part(name + '_Tire', cylZ(R, W, 20), MAT.rubber, g);+ part(name + '_Sidewall', cylZ(R - 0.10, W + 0.03, 16), MAT.rubberDark, g);+ part(name + '_Rim', cylZ(0.40, W + 0.05, 16), MAT.dark, g);+ part(name + '_HubCap', cylZ(0.17, W + 0.20, 12), MAT.steel, g);++ // tread blocks+ for (let i = 0; i < 14; i++) {+ const a = (i / 14) * TAU;+ part(name + '_Tread' + i, boxGeo(0.11, 0.17, W - 0.03), MAT.rubberDark, g,+ [Math.cos(a) * (R - 0.03), Math.sin(a) * (R - 0.03), 0], [0, 0, a]);+ }+ // lug nuts on the outboard face+ for (let i = 0; i < 6; i++) {+ const a = (i / 6) * TAU + 0.3;+ part(name + '_Lug' + i, cylZ(0.045, 0.09, 8), MAT.steel, g,+ [Math.cos(a) * 0.27, Math.sin(a) * 0.27, side * (W * 0.5 + 0.06)]);+ }+ return g;+}++// One hydraulic outrigger jack: swing beam, housing, extended ram, foot pad on Y=0.+function buildOutrigger(name, parent, x, z, side) {+ const g = pivot(name, [x, 1.05, z], parent);+ part(name + '_Beam', boxGeo(0.34, 0.24, 0.95), MAT.body, g, [0, 0.12, -side * 0.50]);+ part(name + '_BeamCap', boxGeo(0.40, 0.30, 0.16), MAT.dark, g, [0, 0.12, 0]);+ part(name + '_Gusset', boxGeo(0.30, 0.16, 0.60), MAT.body, g, [0, -0.02, -side * 0.42]);+ part(name + '_Housing', cylY(0.15, 0.62, 14), MAT.dark, g, [0, -0.18, 0]);+ part(name + '_HousingCap', cylY(0.17, 0.08, 14), MAT.steel, g, [0, 0.14, 0]);+ part(name + '_Ram', cylY(0.095, 0.62, 12), MAT.chrome, g, [0, -0.55, 0]);+ part(name + '_Swivel', cylY(0.13, 0.16, 12), MAT.dark, g, [0, -0.85, 0]);+ part(name + '_Foot', cylY(0.32, 0.13, 18), MAT.dark, g, [0, -0.94, 0]);+ part(name + '_FootRib', boxGeo(0.56, 0.06, 0.10), MAT.dark, g, [0, -0.90, 0]);+ part(name + '_FootPad', cylY(0.34, 0.05, 18), MAT.rubberDark, g, [0, -1.025, 0]);+ // feed hoses+ part(name + '_Hose', cylY(0.035, 0.55, 8), MAT.rubberDark, g, [0.16, -0.15, side * 0.06]);+ part(name + '_HoseElbow', cylX(0.035, 0.22, 8), MAT.rubberDark, g, [0.06, 0.10, side * 0.06]);+ return g;+}++// One panel lift ram, built along local +Y then swung into place about Z.+function buildRam(name, parent, ax, ay, z, bx, by) {+ const dx = bx - ax;+ const dy = by - ay;+ const len = Math.sqrt(dx * dx + dy * dy);+ const g = pivot(name, [ax, ay, z], parent);+ if (g && g.rotation) g.rotation.z = Math.atan2(-dx, dy);++ part(name + '_Clevis', boxGeo(0.20, 0.22, 0.26), MAT.dark, g, [0, 0.10, 0]);+ part(name + '_Pin', cylZ(0.07, 0.40, 10), MAT.steel, g, [0, 0.10, 0]);+ part(name + '_Barrel', cylY(0.115, len * 0.58, 16), MAT.body, g, [0, len * 0.32, 0]);+ part(name + '_BarrelRib', cylY(0.135, 0.09, 16), MAT.dark, g, [0, len * 0.14, 0]);+ part(name + '_Gland', cylY(0.135, 0.12, 16), MAT.steel, g, [0, len * 0.61, 0]);+ part(name + '_Rod', cylY(0.062, len * 0.42, 12), MAT.chrome, g, [0, len * 0.80, 0]);+ part(name + '_RodEye', cylZ(0.095, 0.24, 12), MAT.steel, g, [0, len - 0.02, 0]);+ part(name + '_RodPin', cylZ(0.05, 0.36, 10), MAT.chrome, g, [0, len - 0.02, 0]);+ part(name + '_FeedHose', cylY(0.032, len * 0.5, 8), MAT.rubberDark, g, [0.15, len * 0.30, 0]);+ part(name + '_FeedBlock', boxGeo(0.14, 0.16, 0.14), MAT.dark, g, [0.13, len * 0.10, 0]);+ return g;+}++// A louvred vent panel lying in the XY plane, facing +/-Z.+function buildVent(name, parent, x, y, z, w, h, slats, dir) {+ const d = dir === undefined ? 1 : dir;+ const g = pivot(name, [x, y, z], parent);+ part(name + '_Frame', boxGeo(w, h, 0.05), MAT.dark, g);+ part(name + '_Surround', boxGeo(w + 0.10, h + 0.10, 0.04), MAT.body, g, [0, 0, -d * 0.02]);+ const pitch = h / slats;+ for (let i = 0; i < slats; i++) {+ part(name + '_Slat' + i, boxGeo(w - 0.08, pitch * 0.55, 0.07), MAT.dark, g,+ [0, -h / 2 + pitch * (i + 0.5), d * 0.04], [d * 0.5, 0, 0]);+ }+ return g;+}++// ---------------------------------------------------------------- build++async function build() {+ const root = createRoot('AirDefenseRadar');++ MAT.body = mkMat(0x4c5344, 0.85, 0.10); // olive drab paint+ MAT.dark = mkMat(0x2f342c, 0.80, 0.20); // dark green / cast fittings+ // These two were 0xa4a9ae at metalness 0.90 and 0xc8ccd0 at 0.95, and every+ // fitting made of them -- hub caps, tow eyes, grab rails, the exhaust, the+ // ram rod -- came back as flat white silhouettes. A metal returns the+ // environment tinted by its base colour rather than a diffuse response, so a+ // light base at that metalness has nothing left to shade with: it is the+ // studio dome, at full brightness, in the shape of a part. Bringing both+ // nearer the panel elements (0x7a828b at 0.60, which reads correctly two+ // metres away in the same render) gives them back their cylinders.+ MAT.steel = mkMat(0x6a7076, 0.55, 0.55); // bare steel+ MAT.chrome = mkMat(0x7a8087, 0.35, 0.62); // hydraulic rod+ MAT.rubber = mkMat(0x1e1f22, 0.95, 0.05); // tyre+ MAT.rubberDark = mkMat(0x121315, 0.95, 0.05); // tread / hoses / flaps+ MAT.face = mkMat(0x2c3138, 0.55, 0.35); // array face plate+ MAT.elem = mkMat(0x7a828b, 0.40, 0.60); // radiating elements+ MAT.amber = mkMat(0xc4761a, 0.45, 0.30); // lamps+ MAT.glass = mkGlass(0x93aab8);++ // ============================================================ chassis+ const chassis = pivot('Chassis', [0, 0, 0], root);++ for (let s = -1; s <= 1; s += 2) {+ part('FrameRail' + (s < 0 ? 'L' : 'R'), boxGeo(11.0, 0.30, 0.20), MAT.dark, chassis,+ [-0.05, 1.03, s * 0.62]);+ part('FrameFlangeTop' + (s < 0 ? 'L' : 'R'), boxGeo(11.0, 0.06, 0.30), MAT.dark, chassis,+ [-0.05, 1.16, s * 0.62]);+ part('FrameFlangeBot' + (s < 0 ? 'L' : 'R'), boxGeo(11.0, 0.06, 0.30), MAT.dark, chassis,+ [-0.05, 0.90, s * 0.62]);+ }+ for (let i = 0; i < 9; i++) {+ const x = -5.0 + i * 1.25;+ part('CrossMember' + i, boxGeo(0.16, 0.24, 1.32), MAT.dark, chassis, [x, 1.02, 0]);+ }+ part('BellyPlate', boxGeo(6.6, 0.10, 1.34), MAT.dark, chassis, [-0.4, 0.86, 0]);+ part('Deck', await rbox(6.10, 0.12, 2.50, 0.04), MAT.body, chassis, [0.20, 1.24, 0]);+ part('DeckRibA', boxGeo(6.10, 0.06, 0.10), MAT.dark, chassis, [0.20, 1.31, 0.85]);+ part('DeckRibB', boxGeo(6.10, 0.06, 0.10), MAT.dark, chassis, [0.20, 1.31, -0.85]);+ part('DeckKerbL', boxGeo(6.10, 0.14, 0.09), MAT.dark, chassis, [0.20, 1.36, -1.24]);+ part('DeckKerbR', boxGeo(6.10, 0.14, 0.09), MAT.dark, chassis, [0.20, 1.36, 1.24]);++ // under-frame tankage+ part('FuelTank', cylX(0.34, 1.70, 18), MAT.steel, chassis, [0.10, 0.86, -1.02]);+ part('FuelTankStrapA', boxGeo(0.08, 0.76, 0.76), MAT.dark, chassis, [-0.40, 0.86, -1.02]);+ part('FuelTankStrapB', boxGeo(0.08, 0.76, 0.76), MAT.dark, chassis, [0.60, 0.86, -1.02]);+ part('FuelCap', cylZ(0.10, 0.12, 10), MAT.steel, chassis, [0.10, 0.98, -1.40]);+ part('AirTankA', cylX(0.20, 0.85, 14), MAT.steel, chassis, [1.30, 0.80, 1.02]);+ part('AirTankB', cylX(0.20, 0.85, 14), MAT.steel, chassis, [0.26, 0.80, 1.02]);+ part('BatteryBox', await rbox(0.70, 0.44, 0.52, 0.03), MAT.dark, chassis, [-0.70, 0.90, 1.05]);+ part('BatteryLid', boxGeo(0.74, 0.05, 0.56), MAT.body, chassis, [-0.70, 1.14, 1.05]);+ part('ToolBox', await rbox(0.90, 0.40, 0.48, 0.03), MAT.body, chassis, [-1.75, 0.92, -1.05]);+ part('ToolBoxLatch', boxGeo(0.06, 0.12, 0.10), MAT.steel, chassis, [-1.29, 0.92, -1.05]);++ // ============================================================ running gear+ const axleX = [4.05, 2.65, -2.75, -4.15];+ const running = pivot('RunningGear', [0, 0, 0], root);+ for (let i = 0; i < axleX.length; i++) {+ const x = axleX[i];+ part('Axle' + i, cylZ(0.10, 2.40, 14), MAT.dark, running, [x, 0.66, 0]);+ part('Diff' + i, cylZ(0.26, 0.46, 14), MAT.dark, running, [x, 0.66, 0.10]);+ for (let s = -1; s <= 1; s += 2) {+ buildWheel('Wheel' + i + (s < 0 ? 'L' : 'R'), running, x, 0.66, s * 1.30, s);+ part('Hub' + i + (s < 0 ? 'L' : 'R'), cylZ(0.22, 0.30, 12), MAT.dark, running, [x, 0.66, s * 1.05]);+ part('Spring' + i + (s < 0 ? 'L' : 'R'), boxGeo(1.10, 0.10, 0.16), MAT.dark, running, [x, 0.86, s * 0.78]);+ part('Damper' + i + (s < 0 ? 'L' : 'R'), cylY(0.07, 0.46, 10), MAT.steel, running,+ [x + 0.22, 0.88, s * 0.82], [0, 0, s * 0.18]);+ part('BrakeLine' + i + (s < 0 ? 'L' : 'R'), cylZ(0.03, 0.42, 6), MAT.rubberDark, running, [x - 0.12, 0.80, s * 0.85]);+ }+ }+ // drive shafts between the bogies+ part('DriveShaftF', cylX(0.07, 1.30, 10), MAT.steel, running, [3.35, 0.68, 0.10]);+ part('DriveShaftM', cylX(0.07, 2.20, 10), MAT.steel, running, [-0.05, 0.75, 0.10]);+ part('DriveShaftR', cylX(0.07, 1.30, 10), MAT.steel, running, [-3.45, 0.68, 0.10]);++ // mudguards: one flat guard per bogie per side, with turned-down lips+ const bogie = [[3.35, 2.90], [-3.45, 2.90]];+ for (let b = 0; b < bogie.length; b++) {+ for (let s = -1; s <= 1; s += 2) {+ const tag = 'Guard' + b + (s < 0 ? 'L' : 'R');+ const cx = bogie[b][0];+ const gl = bogie[b][1];+ part(tag + '_Top', boxGeo(gl, 0.07, 0.72), MAT.body, running, [cx, 1.52, s * 1.32]);+ part(tag + '_Skirt', boxGeo(gl, 0.26, 0.06), MAT.body, running, [cx, 1.40, s * 1.66]);+ part(tag + '_LipF', boxGeo(0.34, 0.06, 0.72), MAT.body, running,+ [cx + gl * 0.5 + 0.13, 1.45, s * 1.32], [0, 0, 0.45]);+ part(tag + '_LipR', boxGeo(0.34, 0.06, 0.72), MAT.body, running,+ [cx - gl * 0.5 - 0.13, 1.45, s * 1.32], [0, 0, -0.45]);+ part(tag + '_Brace', boxGeo(0.08, 0.30, 0.60), MAT.dark, running, [cx, 1.38, s * 1.02]);+ part(tag + '_Flap', boxGeo(0.04, 0.42, 0.66), MAT.rubberDark, running,+ [cx - gl * 0.5 - 0.26, 1.26, s * 1.32]);+ }+ }++ // spare wheel slung on the right of the deck+ buildWheel('SpareWheel', root, -1.30, 0.78, 1.55, 1);+ part('SpareCarrierArm', boxGeo(0.10, 0.90, 0.55), MAT.dark, root, [-1.30, 1.05, 1.25]);+ part('SpareCarrierPlate', boxGeo(0.80, 0.10, 0.30), MAT.dark, root, [-1.30, 1.44, 1.32]);+ part('SpareStrap', boxGeo(0.08, 1.32, 0.06), MAT.rubberDark, root, [-1.30, 0.78, 1.55]);++ // ============================================================ cab+ const cab = pivot('Cab', [4.28, 0, 0], root);+ part('CabShell', await rbox(2.35, 1.75, 2.44, 0.09), MAT.body, cab, [0, 2.14, 0]);+ part('CabRoof', await rbox(2.42, 0.10, 2.50, 0.05), MAT.body, cab, [0, 3.05, 0]);+ part('CabRoofRailL', boxGeo(2.30, 0.09, 0.08), MAT.dark, cab, [0, 3.14, -1.12]);+ part('CabRoofRailR', boxGeo(2.30, 0.09, 0.08), MAT.dark, cab, [0, 3.14, 1.12]);+ part('CabRoofHatch', await rbox(0.72, 0.09, 0.72, 0.03), MAT.dark, cab, [-0.20, 3.14, 0]);+ part('CabRoofHatchHandle', cylZ(0.03, 0.30, 8), MAT.steel, cab, [0.10, 3.20, 0]);+ part('CabFloorPan', boxGeo(2.35, 0.14, 2.40), MAT.dark, cab, [0, 1.28, 0]);+ part('CabWindshield', boxGeo(0.06, 0.72, 2.10), MAT.glass, cab, [1.19, 2.62, 0]);+ part('CabWindshieldPillar', boxGeo(0.10, 0.76, 0.10), MAT.body, cab, [1.19, 2.62, 0]);+ part('CabWindshieldSill', boxGeo(0.12, 0.10, 2.20), MAT.dark, cab, [1.18, 2.22, 0]);+ part('CabWindshieldHead', boxGeo(0.12, 0.10, 2.20), MAT.dark, cab, [1.18, 3.02, 0]);+ for (let s = -1; s <= 1; s += 2) {+ const t = s < 0 ? 'L' : 'R';+ part('CabDoor' + t, await rbox(1.30, 1.55, 0.06, 0.03), MAT.body, cab, [-0.15, 2.14, s * 1.24]);+ part('CabDoorWindow' + t, boxGeo(1.00, 0.58, 0.05), MAT.glass, cab, [-0.05, 2.60, s * 1.27]);+ part('CabDoorHandle' + t, boxGeo(0.22, 0.06, 0.07), MAT.steel, cab, [-0.68, 2.24, s * 1.29]);+ part('CabDoorHingeA' + t, boxGeo(0.08, 0.14, 0.10), MAT.dark, cab, [0.48, 2.62, s * 1.28]);+ part('CabDoorHingeB' + t, boxGeo(0.08, 0.14, 0.10), MAT.dark, cab, [0.48, 1.76, s * 1.28]);+ part('CabStepA' + t, boxGeo(0.60, 0.06, 0.34), MAT.dark, cab, [-0.30, 1.06, s * 1.30]);+ part('CabStepB' + t, boxGeo(0.60, 0.06, 0.34), MAT.dark, cab, [-0.30, 0.62, s * 1.30]);+ part('CabStepBracket' + t, boxGeo(0.08, 0.60, 0.30), MAT.dark, cab, [-0.02, 0.84, s * 1.30]);+ part('MirrorArm' + t, cylY(0.035, 0.80, 8), MAT.dark, cab, [1.02, 2.96, s * 1.34]);+ part('MirrorArmOut' + t, cylZ(0.035, 0.30, 8), MAT.dark, cab, [1.02, 3.34, s * 1.46]);+ part('Mirror' + t, boxGeo(0.07, 0.52, 0.20), MAT.dark, cab, [1.02, 3.02, s * 1.60]);+ part('MirrorGlass' + t, boxGeo(0.03, 0.44, 0.15), MAT.glass, cab, [0.98, 3.02, s * 1.60]);+ part('GrabRail' + t, cylY(0.035, 0.90, 8), MAT.steel, cab, [0.62, 2.10, s * 1.25]);+ part('Headlight' + t, cylX(0.15, 0.14, 14), MAT.glass, cab, [1.25, 1.62, s * 0.86]);+ part('HeadlightRim' + t, cylX(0.18, 0.10, 14), MAT.dark, cab, [1.22, 1.62, s * 0.86]);+ part('MarkerLamp' + t, boxGeo(0.08, 0.10, 0.16), MAT.amber, cab, [1.20, 3.02, s * 1.00]);+ part('ConvoyLamp' + t, cylX(0.07, 0.10, 10), MAT.amber, cab, [1.24, 1.30, s * 0.42]);+ }+ part('CabFrontPlate', await rbox(0.10, 0.60, 2.36, 0.03), MAT.body, cab, [1.20, 1.72, 0]);+ for (let i = 0; i < 6; i++) {+ part('CabGrille' + i, boxGeo(0.06, 0.07, 1.70), MAT.dark, cab, [1.26, 1.94 + i * 0.10, 0]);+ }+ part('Bumper', await rbox(0.34, 0.42, 2.62, 0.05), MAT.dark, cab, [1.42, 1.00, 0]);+ part('BumperStepL', boxGeo(0.30, 0.06, 0.50), MAT.steel, cab, [1.42, 1.22, -0.80]);+ part('BumperStepR', boxGeo(0.30, 0.06, 0.50), MAT.steel, cab, [1.42, 1.22, 0.80]);+ part('TowEyeL', boxGeo(0.30, 0.22, 0.09), MAT.steel, cab, [1.50, 0.90, -0.55]);+ part('TowEyeR', boxGeo(0.30, 0.22, 0.09), MAT.steel, cab, [1.50, 0.90, 0.55]);+ part('CabRearPanel', boxGeo(0.08, 1.75, 2.44), MAT.dark, cab, [-1.20, 2.14, 0]);+ part('ExhaustStack', cylY(0.09, 1.90, 12), MAT.steel, cab, [-1.10, 2.30, 1.32]);+ part('ExhaustCap', cylY(0.11, 0.12, 12), MAT.dark, cab, [-1.10, 3.30, 1.32]);+ part('ExhaustHeatShield', boxGeo(0.18, 0.80, 0.24), MAT.dark, cab, [-1.02, 2.10, 1.32]);+ part('AirIntake', cylY(0.13, 1.60, 12), MAT.dark, cab, [-1.10, 2.20, -1.32]);+ part('AirIntakeHead', await rbox(0.30, 0.30, 0.30, 0.04), MAT.dark, cab, [-1.10, 3.12, -1.32]);++ // antenna whips on the cab roof+ for (let s = -1; s <= 1; s += 2) {+ const t = s < 0 ? 'L' : 'R';+ const w = pivot('Whip' + t, [3.30, 3.12, s * 1.02], root);+ if (w && w.rotation) w.rotation.z = 0.11; // slight rearward lean+ part('WhipBase' + t, cylY(0.09, 0.16, 10), MAT.dark, w, [0, 0.06, 0]);+ part('WhipInsulator' + t, cylY(0.055, 0.22, 10), MAT.rubberDark, w, [0, 0.24, 0]);+ part('WhipSegA' + t, cylY(0.035, 1.00, 8), MAT.dark, w, [0, 0.86, 0]);+ part('WhipSegB' + t, cylY(0.024, 0.90, 8), MAT.dark, w, [0, 1.80, 0]);+ part('WhipSegC' + t, cylY(0.014, 0.80, 6), MAT.dark, w, [0, 2.62, 0]);+ part('WhipTip' + t, cylY(0.022, 0.08, 6), MAT.amber, w, [0, 3.04, 0]);+ part('WhipTieDown' + t, cylY(0.012, 0.70, 6), MAT.rubberDark, w, [0.18, 0.60, 0], [0, 0, 0.5]);+ }++ // ============================================================ generator box+ const gen = pivot('GeneratorBox', [1.85, 0, -0.60], root);+ part('GenShell', await rbox(1.90, 1.02, 1.20, 0.05), MAT.body, gen, [0, 1.82, 0]);+ part('GenBase', boxGeo(1.96, 0.10, 1.26), MAT.dark, gen, [0, 1.34, 0]);+ part('GenRoof', await rbox(1.98, 0.08, 1.28, 0.03), MAT.dark, gen, [0, 2.36, 0]);+ part('GenRoofRib', boxGeo(0.10, 0.07, 1.28), MAT.body, gen, [0, 2.42, 0]);+ part('GenLiftEyeA', cylZ(0.06, 0.06, 8), MAT.steel, gen, [0.70, 2.46, -0.40]);+ part('GenLiftEyeB', cylZ(0.06, 0.06, 8), MAT.steel, gen, [-0.70, 2.46, -0.40]);+ buildVent('GenVentIn', gen, 0.45, 1.82, -0.62, 0.70, 0.66, 6, -1);+ buildVent('GenVentOut', gen, -0.45, 1.82, -0.62, 0.70, 0.66, 6, -1);+ part('GenAccessDoor', await rbox(1.10, 0.80, 0.05, 0.02), MAT.dark, gen, [0.10, 1.80, 0.61]);+ part('GenDoorHandle', boxGeo(0.18, 0.05, 0.06), MAT.steel, gen, [-0.38, 1.80, 0.66]);+ part('GenDoorHingeA', boxGeo(0.07, 0.12, 0.06), MAT.steel, gen, [0.60, 2.10, 0.64]);+ part('GenDoorHingeB', boxGeo(0.07, 0.12, 0.06), MAT.steel, gen, [0.60, 1.50, 0.64]);+ part('GenPanel', boxGeo(0.44, 0.34, 0.05), MAT.dark, gen, [-0.62, 2.02, 0.62]);+ part('GenPanelFace', boxGeo(0.34, 0.24, 0.04), MAT.steel, gen, [-0.62, 2.02, 0.65]);+ part('GenPanelLamp', cylZ(0.035, 0.05, 8), MAT.amber, gen, [-0.72, 2.10, 0.67]);+ part('GenExhaust', cylY(0.10, 0.95, 12), MAT.steel, gen, [0.78, 2.84, -0.42]);+ part('GenExhaustElbow', cylX(0.10, 0.30, 12), MAT.steel, gen, [0.78, 3.28, -0.42], [0, 0, 0]);+ part('GenExhaustCap', cylY(0.13, 0.09, 12), MAT.dark, gen, [0.78, 3.32, -0.42]);+ part('GenFuelCap', cylY(0.09, 0.09, 10), MAT.steel, gen, [-0.80, 2.42, 0.30]);+ part('GenMountA', boxGeo(0.16, 0.14, 1.26), MAT.dark, gen, [0.78, 1.24, 0]);+ part('GenMountB', boxGeo(0.16, 0.14, 1.26), MAT.dark, gen, [-0.78, 1.24, 0]);++ // ============================================================ cable trunk+ const trunk = pivot('CableTrunk', [0, 0, 0], root);+ part('TrunkRun', cylX(0.11, 2.30, 12), MAT.rubberDark, trunk, [0.02, 1.42, -1.05]);+ part('TrunkRunB', cylX(0.07, 2.30, 10), MAT.rubberDark, trunk, [0.02, 1.42, -0.86]);+ part('TrunkRiser', cylY(0.11, 0.45, 12), MAT.rubberDark, trunk, [1.16, 1.62, -1.05]);+ part('TrunkElbow', cylZ(0.11, 0.24, 12), MAT.rubberDark, trunk, [1.16, 1.42, -1.05]);+ part('TrunkGland', cylY(0.14, 0.12, 12), MAT.steel, trunk, [1.16, 1.84, -1.05]);+ for (let i = 0; i < 5; i++) {+ part('TrunkClamp' + i, boxGeo(0.09, 0.34, 0.14), MAT.dark, trunk, [-0.95 + i * 0.52, 1.34, -1.05]);+ }+ part('TrunkJunction', await rbox(0.50, 0.46, 0.42, 0.03), MAT.dark, trunk, [-1.24, 1.58, -1.05]);+ part('TrunkJunctionLid', boxGeo(0.54, 0.05, 0.46), MAT.body, trunk, [-1.24, 1.83, -1.05]);+ // slack loop climbing to the panel hinge+ part('TrunkLoopA', cylY(0.09, 0.46, 10), MAT.rubberDark, trunk, [-1.30, 2.02, -1.05], [0, 0, -0.30]);+ part('TrunkLoopB', cylX(0.09, 0.52, 10), MAT.rubberDark, trunk, [-1.08, 2.26, -1.05], [0, 0, 0.45]);+ part('TrunkLoopC', cylY(0.09, 0.44, 10), MAT.rubberDark, trunk, [-0.86, 2.10, -1.05], [0, 0, 0.35]);+ part('TrunkPanelGland', cylY(0.13, 0.14, 12), MAT.steel, trunk, [-0.80, 1.92, -1.05]);++ // stowage on the deck under the raised panel+ part('DeckCrate', await rbox(1.10, 0.62, 1.00, 0.04), MAT.body, root, [-1.95, 1.62, 0.55]);+ part('DeckCrateLid', boxGeo(1.16, 0.06, 1.06), MAT.dark, root, [-1.95, 1.95, 0.55]);+ part('DeckCrateStrapA', boxGeo(0.07, 0.66, 1.06), MAT.dark, root, [-1.60, 1.62, 0.55]);+ part('DeckCrateStrapB', boxGeo(0.07, 0.66, 1.06), MAT.dark, root, [-2.30, 1.62, 0.55]);+ part('DeckWaveguide', cylX(0.10, 1.80, 12), MAT.steel, root, [-1.70, 1.42, -0.30]);+ part('DeckWaveguideClampA', boxGeo(0.08, 0.30, 0.13), MAT.dark, root, [-1.20, 1.34, -0.30]);+ part('DeckWaveguideClampB', boxGeo(0.08, 0.30, 0.13), MAT.dark, root, [-2.20, 1.34, -0.30]);++ // ============================================================ rear shelter+ const shel = pivot('EquipmentShelter', [-4.00, 0, 0], root);+ part('ShelterShell', await rbox(2.80, 1.72, 2.42, 0.06), MAT.body, shel, [0, 2.16, 0]);+ part('ShelterBase', boxGeo(2.86, 0.10, 2.48), MAT.dark, shel, [0, 1.32, 0]);+ part('ShelterSubframe', boxGeo(2.80, 0.16, 2.10), MAT.dark, shel, [0, 1.20, 0]);+ part('ShelterSubBearerL', boxGeo(2.80, 0.10, 0.26), MAT.dark, shel, [0, 1.12, -0.62]);+ part('ShelterSubBearerR', boxGeo(2.80, 0.10, 0.26), MAT.dark, shel, [0, 1.12, 0.62]);+ part('ShelterRoof', await rbox(2.88, 0.09, 2.50, 0.04), MAT.dark, shel, [0, 3.05, 0]);+ part('ShelterRoofRibA', boxGeo(0.09, 0.07, 2.50), MAT.body, shel, [0.80, 3.12, 0]);+ part('ShelterRoofRibB', boxGeo(0.09, 0.07, 2.50), MAT.body, shel, [0, 3.12, 0]);+ part('ShelterRoofRibC', boxGeo(0.09, 0.07, 2.50), MAT.body, shel, [-0.80, 3.12, 0]);+ part('ShelterCornerFL', boxGeo(0.10, 1.72, 0.10), MAT.dark, shel, [1.38, 2.16, -1.18]);+ part('ShelterCornerFR', boxGeo(0.10, 1.72, 0.10), MAT.dark, shel, [1.38, 2.16, 1.18]);+ part('ShelterCornerBL', boxGeo(0.10, 1.72, 0.10), MAT.dark, shel, [-1.38, 2.16, -1.18]);+ part('ShelterCornerBR', boxGeo(0.10, 1.72, 0.10), MAT.dark, shel, [-1.38, 2.16, 1.18]);+ // door on the -X face+ part('ShelterDoor', await rbox(0.07, 1.52, 0.86, 0.02), MAT.dark, shel, [-1.42, 2.14, 0.42]);+ part('ShelterDoorFrame', boxGeo(0.05, 1.66, 1.00), MAT.body, shel, [-1.38, 2.14, 0.42]);+ part('ShelterDoorWindow', boxGeo(0.05, 0.34, 0.40), MAT.glass, shel, [-1.46, 2.62, 0.42]);+ part('ShelterDoorHandle', cylZ(0.05, 0.26, 10), MAT.steel, shel, [-1.48, 2.10, 0.06]);+ part('ShelterDoorLever', boxGeo(0.06, 0.24, 0.06), MAT.steel, shel, [-1.50, 1.98, 0.06]);+ part('ShelterDoorHingeA', boxGeo(0.08, 0.16, 0.10), MAT.steel, shel, [-1.46, 2.72, 0.84]);+ part('ShelterDoorHingeB', boxGeo(0.08, 0.16, 0.10), MAT.steel, shel, [-1.46, 2.14, 0.84]);+ part('ShelterDoorHingeC', boxGeo(0.08, 0.16, 0.10), MAT.steel, shel, [-1.46, 1.56, 0.84]);+ part('ShelterDoorSill', boxGeo(0.24, 0.07, 0.94), MAT.dark, shel, [-1.44, 1.34, 0.42]);+ // access ladder below the door+ part('LadderStileL', boxGeo(0.07, 1.20, 0.07), MAT.dark, shel, [-1.48, 0.72, 0.06]);+ part('LadderStileR', boxGeo(0.07, 1.20, 0.07), MAT.dark, shel, [-1.48, 0.72, 0.78]);+ for (let i = 0; i < 3; i++) {+ part('LadderRung' + i, cylZ(0.035, 0.78, 8), MAT.steel, shel, [-1.48, 0.34 + i * 0.36, 0.42]);+ }+ // vents and fittings on the flanks+ buildVent('ShelterVentA', shel, 0.70, 2.30, 1.22, 0.80, 0.70, 7, 1);+ buildVent('ShelterVentB', shel, -0.30, 2.30, 1.22, 0.80, 0.70, 7, 1);+ buildVent('ShelterVentC', shel, 0.70, 2.30, -1.22, 0.80, 0.70, 7, -1);+ buildVent('ShelterVentD', shel, -0.30, 2.30, -1.22, 0.80, 0.70, 7, -1);+ part('ShelterAC', await rbox(0.80, 0.44, 0.66, 0.04), MAT.dark, shel, [0.60, 3.32, -0.60]);+ part('ShelterACGrille', boxGeo(0.06, 0.32, 0.54), MAT.steel, shel, [0.24, 3.32, -0.60]);+ part('ShelterCableDuct', await rbox(2.20, 0.16, 0.20, 0.03), MAT.dark, shel, [0, 3.20, 0.92]);+ part('ShelterAntennaMount', boxGeo(0.20, 0.20, 0.20), MAT.dark, shel, [-1.10, 3.20, -0.90]);+ part('ShelterAntenna', cylY(0.03, 0.90, 8), MAT.dark, shel, [-1.10, 3.72, -0.90]);+ part('ShelterHandrail', cylX(0.035, 2.40, 8), MAT.steel, shel, [0, 3.34, 1.14]);+ part('ShelterHandrailPostA', cylY(0.035, 0.30, 8), MAT.steel, shel, [1.10, 3.20, 1.14]);+ part('ShelterHandrailPostB', cylY(0.035, 0.30, 8), MAT.steel, shel, [-1.10, 3.20, 1.14]);+ part('ShelterStowRack', boxGeo(1.20, 0.09, 0.60), MAT.dark, shel, [-0.60, 3.16, -0.30]);+ part('ShelterTailLampL', boxGeo(0.09, 0.26, 0.20), MAT.amber, shel, [-1.44, 1.60, -0.92]);+ part('ShelterTailLampR', boxGeo(0.09, 0.26, 0.20), MAT.amber, shel, [-1.44, 1.60, 1.10]);+ part('ShelterRearTowEyeL', boxGeo(0.26, 0.20, 0.09), MAT.steel, shel, [-1.52, 1.02, -0.60]);+ part('ShelterRearTowEyeR', boxGeo(0.26, 0.20, 0.09), MAT.steel, shel, [-1.52, 1.02, 0.60]);++ // ============================================================ outriggers+ buildOutrigger('OutriggerFL', root, 1.55, -1.60, -1);+ buildOutrigger('OutriggerFR', root, 1.55, 1.60, 1);+ buildOutrigger('OutriggerRL', root, -4.95, -1.60, -1);+ buildOutrigger('OutriggerRR', root, -4.95, 1.60, 1);++ // ============================================================ array hinge+ const HX = -0.40;+ const HY = 1.60;+ const hinge = pivot('ArrayHinge', [HX, HY, 0], root);+ part('HingeBeam', boxGeo(0.34, 0.30, 3.10), MAT.dark, hinge, [0, -0.12, 0]);+ part('HingePin', cylZ(0.11, 3.40, 14), MAT.steel, hinge, [0, 0, 0]);+ for (let i = 0; i < 4; i++) {+ const z = [-1.42, -0.62, 0.62, 1.42][i];+ part('HingeLug' + i, boxGeo(0.40, 0.60, 0.20), MAT.dark, hinge, [0, -0.22, z]);+ }+ part('HingePedestalL', boxGeo(0.50, 0.46, 0.34), MAT.body, root, [HX, 1.22, -1.10]);+ part('HingePedestalR', boxGeo(0.50, 0.46, 0.34), MAT.body, root, [HX, 1.22, 1.10]);+ // ram base mounts on the deck, forward of the hinge+ for (let s = -1; s <= 1; s += 2) {+ part('RamMount' + (s < 0 ? 'L' : 'R'), boxGeo(0.42, 0.34, 0.30), MAT.dark, root, [0.55, 1.42, s * 1.20]);+ part('RamMountGusset' + (s < 0 ? 'L' : 'R'), boxGeo(0.28, 0.22, 0.10), MAT.body, root, [0.55, 1.26, s * 1.20]);+ }++ // ============================================================ array panel+ // Local frame: +X up the panel from the hinge, +Z across its width,+ // -Y is the radiating face. Swung 120 deg about Z -> 60 deg from horizontal,+ // leaning back over the shelter, face pointing forward and up.+ const panel = pivot('ArrayPanel', [HX, HY, 0], root);+ if (panel && panel.rotation) panel.rotation.z = TAU / 3;++ const PL = 5.45; // length up the panel+ const PW = 4.42; // width across+ const PCX = 0.10 + PL * 0.5;++ part('PanelBacking', await rbox(PL, 0.14, PW, 0.04), MAT.dark, panel, [PCX, 0.09, 0]);+ part('PanelFacePlate', boxGeo(PL - 0.20, 0.08, PW - 0.16), MAT.face, panel, [PCX, -0.04, 0]);++ // back structure: longerons, cross ribs, diagonal braces+ for (let i = 0; i < 4; i++) {+ const z = [-1.72, -0.58, 0.58, 1.72][i];+ part('PanelLongeron' + i, boxGeo(PL - 0.10, 0.26, 0.13), MAT.dark, panel, [PCX, 0.28, z]);+ }+ for (let i = 0; i < 8; i++) {+ const x = 0.35 + i * 0.72;+ part('PanelCrossRib' + i, boxGeo(0.12, 0.24, PW - 0.10), MAT.dark, panel, [x, 0.28, 0]);+ }+ for (let i = 0; i < 6; i++) {+ const x = 0.70 + i * 0.85;+ const sgn = i % 2 === 0 ? 1 : -1;+ part('PanelBraceA' + i, boxGeo(0.90, 0.10, 0.09), MAT.dark, panel, [x, 0.40, sgn * 1.15], [0, sgn * 0.62, 0]);+ part('PanelBraceB' + i, boxGeo(0.90, 0.10, 0.09), MAT.dark, panel, [x, 0.40, -sgn * 1.15], [0, -sgn * 0.62, 0]);+ }+ part('PanelSpineBeam', boxGeo(PL - 0.10, 0.20, 0.22), MAT.dark, panel, [PCX, 0.44, 0]);+ part('PanelHingeBoss', cylZ(0.20, 3.10, 14), MAT.steel, panel, [0.12, 0.06, 0]);+ for (let i = 0; i < 4; i++) {+ const z = [-1.42, -0.62, 0.62, 1.42][i];+ part('PanelHingeLug' + i, boxGeo(0.46, 0.46, 0.22), MAT.dark, panel, [0.16, 0.12, z]);+ }++ // coolant manifold and waveguide runs on the back+ part('PanelManifold', cylZ(0.14, PW - 0.30, 14), MAT.steel, panel, [0.60, 0.46, 0]);+ part('PanelManifoldB', cylZ(0.10, PW - 0.60, 12), MAT.steel, panel, [1.30, 0.48, 0]);+ for (let i = 0; i < 5; i++) {+ part('PanelCoolantRun' + i, boxGeo(PL - 1.4, 0.10, 0.10), MAT.steel, panel, [PCX + 0.30, 0.50, -1.60 + i * 0.80]);+ }+ part('PanelJunctionBox', await rbox(0.60, 0.36, 0.50, 0.03), MAT.body, panel, [0.85, 0.52, -1.90]);+ part('PanelFeedTrunk', cylY(0.11, 0.60, 12), MAT.rubberDark, panel, [0.55, 0.52, -1.90], [0, 0, 1.2]);++ // ram attach lugs+ for (let s = -1; s <= 1; s += 2) {+ part('PanelRamLug' + (s < 0 ? 'L' : 'R'), boxGeo(0.36, 0.44, 0.20), MAT.dark, panel, [1.80, 0.30, s * 1.20]);+ part('PanelRamPin' + (s < 0 ? 'L' : 'R'), cylZ(0.06, 0.32, 10), MAT.steel, panel, [1.80, 0.34, s * 1.20]);+ }++ // ---- lattice border standing proud of the face+ const BY = -0.16;+ part('BorderRailL', boxGeo(PL, 0.34, 0.16), MAT.body, panel, [PCX, BY, -PW * 0.5 + 0.08]);+ part('BorderRailR', boxGeo(PL, 0.34, 0.16), MAT.body, panel, [PCX, BY, PW * 0.5 - 0.08]);+ part('BorderRailBottom', boxGeo(0.16, 0.34, PW), MAT.body, panel, [0.18, BY, 0]);+ part('BorderRailTop', boxGeo(0.16, 0.34, PW), MAT.body, panel, [PL, BY, 0]);+ part('BorderCornerBL', boxGeo(0.26, 0.36, 0.26), MAT.dark, panel, [0.18, BY, -PW * 0.5 + 0.10]);+ part('BorderCornerBR', boxGeo(0.26, 0.36, 0.26), MAT.dark, panel, [0.18, BY, PW * 0.5 - 0.10]);+ part('BorderCornerTL', boxGeo(0.26, 0.36, 0.26), MAT.dark, panel, [PL, BY, -PW * 0.5 + 0.10]);+ part('BorderCornerTR', boxGeo(0.26, 0.36, 0.26), MAT.dark, panel, [PL, BY, PW * 0.5 - 0.10]);+ // diagonal lattice ties along the long sides+ for (let i = 0; i < 16; i++) {+ const x = 0.50 + i * 0.31;+ const sgn = i % 2 === 0 ? 1 : -1;+ for (let s = -1; s <= 1; s += 2) {+ part('LatticeTie' + i + (s < 0 ? 'L' : 'R'), boxGeo(0.34, 0.06, 0.26), MAT.dark, panel,+ [x, BY - 0.02, s * (PW * 0.5 - 0.17)], [0, sgn * s * 0.72, 0]);+ }+ }+ // ties across the ends+ for (let i = 0; i < 12; i++) {+ const z = -1.95 + i * 0.355;+ const sgn = i % 2 === 0 ? 1 : -1;+ part('LatticeTieBot' + i, boxGeo(0.26, 0.06, 0.34), MAT.dark, panel, [0.42, BY - 0.02, z], [0, sgn * 0.72, 0]);+ part('LatticeTieTop' + i, boxGeo(0.26, 0.06, 0.34), MAT.dark, panel, [PL - 0.24, BY - 0.02, z], [0, -sgn * 0.72, 0]);+ }++ // ---- dense grid of square radiating elements+ const COLS = 18;+ const ROWS = 20;+ const PZ = 0.205;+ const PXP = 0.215;+ const z0 = -((COLS - 1) * PZ) * 0.5;+ const x0 = 0.75;+ const face = pivot('RadiatingArray', [0, 0, 0], panel);+ for (let r = 0; r < ROWS; r++) {+ for (let c = 0; c < COLS; c++) {+ part('Element_r' + r + '_c' + c, boxGeo(0.15, 0.09, 0.15), MAT.elem, face,+ [x0 + r * PXP, -0.125, z0 + c * PZ]);+ }+ }+ // element sub-array separators, every 5 columns / 6 rows+ for (let c = 5; c < COLS; c += 5) {+ part('ArraySeamC' + c, boxGeo(ROWS * PXP + 0.10, 0.05, 0.04), MAT.dark, face,+ [x0 + (ROWS - 1) * PXP * 0.5, -0.10, z0 + (c - 0.5) * PZ]);+ }+ for (let r = 6; r < ROWS; r += 6) {+ part('ArraySeamR' + r, boxGeo(0.04, 0.05, COLS * PZ + 0.10), MAT.dark, face,+ [x0 + (r - 0.5) * PXP, -0.10, 0]);+ }+ // boresight / IFF fittings on the face+ part('BoresightHorn', cylX(0.10, 0.34, 12), MAT.steel, face, [PL - 0.14, -0.30, 0], [0, 0, -Math.PI / 2]);+ part('BoresightPlate', boxGeo(0.22, 0.06, 0.34), MAT.dark, face, [PL - 0.14, -0.20, 0]);++ // ============================================================ lift rams+ // Attach point on the panel: hinge + 1.80 along the panel, 0.30 behind it.+ // Panel local axes in world: +X -> (-0.5, 0.866), +Y -> (-0.866, -0.5).+ const dirX = -0.5, dirY = Math.sqrt(3) / 2;+ const bx = HX + 1.80 * dirX + 0.30 * (-dirY);+ const by = HY + 1.80 * dirY + 0.30 * (dirX);+ buildRam('LiftRamL', root, 0.55, 1.48, -1.20, bx, by);+ buildRam('LiftRamR', root, 0.55, 1.48, 1.20, bx, by);++ // hydraulic power pack feeding the rams+ part('HydPack', await rbox(0.70, 0.50, 0.60, 0.03), MAT.dark, root, [0.55, 1.60, 0.72]);+ part('HydPackMotor', cylX(0.16, 0.42, 12), MAT.steel, root, [0.95, 1.60, 0.72]);+ part('HydPackHoseA', cylX(0.045, 0.90, 8), MAT.rubberDark, root, [0.10, 1.46, 0.72]);+ part('HydPackHoseB', cylZ(0.045, 2.10, 8), MAT.rubberDark, root, [0.55, 1.34, 0]);++ return root;+}diff --git a/examples/aircraft-carrier.kiln.js b/examples/aircraft-carrier.kiln.jsnew file mode 100644index 00000000..efd76ef0--- /dev/null+++ b/examples/aircraft-carrier.kiln.js@@ -0,0 +1,739 @@+// Authored by: opus, via claude.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.+//+// Refined later, in this repository, with `kiln_edit`. First the lower hull+// strakes were brought back onto the plating they sit on and the two satcom+// plates onto the whip masts beside them -- 46 floating parts, none of them+// visible at ship scale and all of them fatal to a structural gate. Then the+// hull, the flight deck and the deck-edge netting were rebuilt off their own+// planform curves instead of out of slabs squared to the keel, which is what+// the teeth around the counter and down both deck edges had always been.+// The attribution above is for the authoring run, which had none of this in+// scope. Both passes went through the same tools; only the second one could+// see the gallery it was going into.++const meta = { name: 'AircraftCarrier', category: 'prop' };++// Nuclear supercarrier, Nimitz-class proportions.+// LOA 330 m (x from -165 stern to +165 bow)+// Flight deck 78 m max beam (port edge -44, starboard edge +34)+// Draft 12 m (hull bottom at Y = -12; the asset sits on Y = 0 at the WATERLINE,+// so the keel is intentionally below grade)+// Flight deck Y = 20 (top surface)+// Frame: +X forward (bow), +Y up, +Z starboard.++const LOA_FWD = 165;+const LOA_AFT = -165;+const DECK_Y = 20.0; // top of the flight deck+const DECK_T = 1.7; // flight deck slab thickness+const KEEL_Y = -12.0; // draft++function lerp(a, b, t) {+ const c = t < 0 ? 0 : (t > 1 ? 1 : t);+ return a + (b - a) * c;+}++// ---------------------------------------------------------------- planform+// Starboard edge of the flight deck as a function of x.+function deckStb(x) {+ if (x >= 152) return lerp(18, 4, (x - 152) / 13); // flared bow point+ if (x >= 118) return lerp(34, 18, (x - 118) / 34); // bow taper+ if (x >= -142) return 34; // constant starboard edge+ return lerp(13, 34, (x - LOA_AFT) / 23); // stern round-in+}++// Port edge of the flight deck as a function of x. The bulge from x -60..+85 is+// the angled landing area sponson, which is what pushes max beam to 78 m.+function deckPort(x) {+ if (x >= 152) return lerp(-16, -4, (x - 152) / 13);+ if (x >= 112) return lerp(-30, -16, (x - 112) / 40);+ if (x >= 85) return lerp(-44, -30, (x - 85) / 27);+ if (x >= -60) return -44; // angled-deck sponson+ if (x >= -95) return lerp(-30, -44, (x + 95) / 35);+ if (x >= -142) return -30;+ return lerp(-12, -30, (x - LOA_AFT) / 23);+}++// Hull half-beam at the waterline.+function hullHB(x) {+ if (x >= 142) return lerp(13, 2.2, (x - 142) / 23); // fine entry+ if (x >= 104) return lerp(20.5, 13, (x - 104) / 38);+ if (x >= -138) return 20.5;+ return lerp(15.5, 20.5, (x - LOA_AFT) / 27); // transom run+}++// Hull half-width at station x and height y: the whole shell in one function,+// from the flat of keel at Y=-12 up through the turn of bilge, the parallel+// side, and the flare out to the deck-edge knuckle. It is piecewise linear in+// both x and y, which is what lets the loft below be exact with a handful of+// stations -- every breakpoint is a station, and between breakpoints a straight+// line is the right answer rather than an approximation of one.+function hullZ(x, y) {+ const hb = hullHB(x);+ const ub = Math.min(hb + 3.2, 23.6);+ if (y <= -8) return hb * lerp(0.34, 0.88, (y - KEEL_Y) / 4); // rise of floor+ if (y <= -1) return hb * lerp(0.88, 1.0, (y + 8) / 7); // turn of bilge+ if (y <= 8) return hb; // parallel side+ if (y <= 11) return lerp(hb, ub, (y - 8) / 3); // knuckle flare+ return ub;+}++// Skinned loft over a series of equal-length rings, capped at both ends and+// wound outward by signed volume. Same helper the fighter jet uses for its+// fuselage; a hull is the same problem at forty times the scale.+function loftGeo(sections) {+ const M = sections.length;+ const N = sections[0].length;+ const verts = [];+ for (let s = 0; s < M; s++) {+ for (let i = 0; i < N; i++) {+ verts.push(sections[s][i][0], sections[s][i][1], sections[s][i][2]);+ }+ }+ const idx = [];+ for (let s = 0; s < M - 1; s++) {+ for (let i = 0; i < N; i++) {+ const j = (i + 1) % N;+ const a = s * N + i;+ const b = s * N + j;+ const c = (s + 1) * N + i;+ const d = (s + 1) * N + j;+ idx.push(a, c, d, a, d, b);+ }+ }+ for (let e = 0; e < 2; e++) {+ const base = e === 0 ? 0 : (M - 1) * N;+ let cx = 0;+ let cy = 0;+ let cz = 0;+ for (let i = 0; i < N; i++) {+ cx += sections[e === 0 ? 0 : M - 1][i][0];+ cy += sections[e === 0 ? 0 : M - 1][i][1];+ cz += sections[e === 0 ? 0 : M - 1][i][2];+ }+ const ci = verts.length / 3;+ verts.push(cx / N, cy / N, cz / N);+ for (let i = 0; i < N; i++) {+ const j = (i + 1) % N;+ if (e === 0) idx.push(ci, base + j, base + i);+ else idx.push(ci, base + i, base + j);+ }+ }+ let vol = 0;+ for (let t = 0; t < idx.length; t += 3) {+ const i0 = idx[t] * 3;+ const i1 = idx[t + 1] * 3;+ const i2 = idx[t + 2] * 3;+ vol += verts[i0] * (verts[i1 + 1] * verts[i2 + 2] - verts[i1 + 2] * verts[i2 + 1]);+ vol += verts[i0 + 1] * (verts[i1 + 2] * verts[i2] - verts[i1] * verts[i2 + 2]);+ vol += verts[i0 + 2] * (verts[i1] * verts[i2 + 1] - verts[i1 + 1] * verts[i2]);+ }+ if (vol < 0) {+ for (let t = 0; t < idx.length; t += 3) {+ const tmp = idx[t + 1];+ idx[t + 1] = idx[t + 2];+ idx[t + 2] = tmp;+ }+ }+ const geo = new THREE.BufferGeometry();+ geo.setAttribute('position', new THREE.Float32BufferAttribute(verts, 3));+ geo.setIndex(idx);+ geo.computeVertexNormals();+ return geo;+}++const ANGLE_DEG = 9; // angled deck, to port+const D2R = Math.PI / 180;++function build() {+ const root = createRoot('AircraftCarrier');++ // ------------------------------------------------------------- materials+ const matHullGray = gameMaterial(0x4a5259); // topside haze gray+ const matHullRed = gameMaterial(0x6d2b24); // antifouling, below waterline+ const matDeck = gameMaterial(0x33373b); // nonskid flight deck+ const matDeckWorn = gameMaterial(0x3d4247); // elevator platforms / patches+ const matIsland = gameMaterial(0x545c63); // island superstructure+ const matDark = gameMaterial(0x1b1e21); // glass, netting, wires, tracks+ const matWhite = gameMaterial(0xd6d9d4); // deck markings+ const matYellow = gameMaterial(0xb99a2c); // centerline / cat markings+ const matRed = gameMaterial(0x8c3b2f); // foul lines, JBD faces+ const matRadar = gameMaterial(0x9aa0a4); // phased-array faces++ function box(name, parent, sx, sy, sz, px, py, pz, mat, rx, ry, rz) {+ const p = createPart(name, boxGeo(sx, sy, sz), mat, {+ parent: parent,+ position: [px, py, pz]+ });+ if (rx || ry || rz) p.rotation.set(rx || 0, ry || 0, rz || 0);+ return p;+ }++ // =====================================================================+ // HULL+ // =====================================================================+ const hull = createPivot('Hull', [0, 0, 0], root);++ // The shell is lofted, not stacked.+ //+ // It used to be a run of axis-aligned slabs, one per station, each held at the+ // half-beam of its own centre. Where the beam changes -- the fine entry, the+ // whole counter -- every join left an end cap facing aft, and an end cap is+ // lit as a different surface from the plating either side of it. So the ship+ // wore a comb of red teeth around the stern, and halving the station spacing+ // only ever doubled the number of teeth, because the discontinuity was in the+ // normals and not in the size of the step. A loft shares its vertices, so+ // there is no cap to catch the light and no step to refine.+ //+ // Ten stations, placed on every breakpoint in hullHB with a few spares on the+ // straight runs. hullZ is piecewise linear in x and in y, so between two+ // breakpoints the straight line the loft draws is the exact answer.+ const HSTATIONS = [-165, -152, -138, -60, 20, 104, 124, 142, 154, 165];++ // One ring of the shell between two heights: up the starboard side through+ // `levels`, across the top, down the port side, closed along the bottom.+ // `bulge` pushes the ring outboard, which is how the boot topping stands proud+ // of the plating instead of fighting it for the same surface.+ function shellRing(x, levels, bulge) {+ const ring = [];+ for (let i = 0; i < levels.length; i++) {+ ring.push([x, levels[i], hullZ(x, levels[i]) + bulge]);+ }+ for (let i = levels.length - 1; i >= 0; i--) {+ ring.push([x, levels[i], -(hullZ(x, levels[i]) + bulge)]);+ }+ return ring;+ }++ function shellBand(name, levels, bulge, mat) {+ const sections = [];+ for (let i = 0; i < HSTATIONS.length; i++) {+ sections.push(shellRing(HSTATIONS[i], levels, bulge));+ }+ createPart(name, loftGeo(sections), mat, { parent: hull });+ }++ // Every crease is doubled 0.2 m apart rather than shared, and that includes+ // the top and bottom edge of each band. A vertex on the edge of a band belongs+ // to the vertical plating and to the horizontal face that closes the band off,+ // so sharing it tilts the averaged normal 45 degrees and then bleeds that all+ // the way up the next crease -- six and a half metres of topside shaded as a+ // curve. Doubling confines the blend to a hand's width and the flat of the+ // side stays flat.+ shellBand('HullUnderbody', [KEEL_Y, -8, -1.1, -0.9, -0.2, 0], 0, matHullRed);+ shellBand('HullBoot', [0, 0.2, 1, 1.2], 0.12, matDark);+ shellBand('HullTopside', [1.2, 1.4, 7.9, 8.1, 10.9, 11.1, 18.1, 18.3], 0, matHullGray);++ // Bulbous bow and forefoot (kept inside the 330 m LOA)+ box('BulbousBow', hull, 18, 8, 8.5, 156, -7.5, 0, matHullRed);+ box('BowStem', hull, 6, 20, 5.0, 162, 6, 0, matHullGray);+ box('BowFlareStb', hull, 34, 9.2, 7, 146, 13.6, 12.5, matHullGray, 0, 0, 0);+ box('BowFlarePort', hull, 34, 9.2, 7, 146, 13.6, -12.5, matHullGray, 0, 0, 0);+ // Transom+ box('Transom', hull, 2, 24, 32, -164, 3, 0, matHullGray);+ box('TransomShelf', hull, 6, 2.2, 34, -161, 15.5, 0, matHullGray);++ // Hull plating strakes -- long thin ribs that break up the slab sides.+ for (let s = 0; s < 3; s++) {+ const sy = [3.0, 8.0, 12.6][s];+ for (let k = 0; k < 10; k++) {+ // Confined to the parallel midbody, which is where a strake runs on a+ // real hull and, more to the point, the only place a straight one can.+ // These were fourteen 22 m boxes on a 23 m pitch spanning the whole 330 m,+ // each held at the half-beam of its own centre. That is exact amidships+ // and wrong at both ends: the entry narrows 11 m over a single strake's+ // length, so every forward one stood out past the plating and the ship+ // grew a row of teeth along the bow. Between -136 and +102 the beam is+ // flat 20.5 m, so a straight rib is straight.+ //+ // The offsets: the lower two rows stood 0.44 m off the plating they are+ // welded to -- 44 floating-part warnings, invisible at ship scale and+ // fatal to a structural gate -- because the outward offset was larger+ // than the rib is deep. Asking the shell itself where its surface is at+ // that height settles it for every row at once, including the one above+ // the knuckle where the plating has already flared out.+ const xc = -125 + k * 24;+ const hb = hullZ(xc, sy) + 0.15;+ box('StrakeStb_' + s + '_' + k, hull, 22, 0.55, 0.5, xc, sy, hb, matHullGray);+ box('StrakePort_' + s + '_' + k, hull, 22, 0.55, 0.5, xc, sy, -hb, matHullGray);+ }+ }++ // Anchor pockets and hawse+ box('AnchorPocketStb', hull, 5, 4, 1.2, 150, 9, 10.6, matDark);+ box('AnchorPocketPort', hull, 5, 4, 1.2, 150, 9, -10.6, matDark);++ // =====================================================================+ // SPONSONS -- the shelves that carry the flight-deck overhang+ // =====================================================================+ const spons = createPivot('Sponsons', [0, 0, 0], root);+ let si = 0;+ for (let x = -150; x <= 130; x += 11) {+ const outStb = deckStb(x) - 1.0;+ const outPort = deckPort(x) + 1.0;+ // The shelf is 8.5 m long and the shell is not parallel under all of it, so+ // the inner edge has to reach the narrowest point of the run, not the+ // half-beam at its centre. Anything less leaves the forward or after corner+ // hanging in air over the counter.+ const hb = Math.min(hullZ(x - 4.25, 16.6), hullZ(x + 4.25, 16.6)) - 0.3;++ if (outStb - hb > 1.5) {+ const w = outStb - hb;+ box('SponsonStb_' + si, spons, 8.5, 2.4, w, x, 16.6, hb + w / 2, matHullGray);+ // knee brace under the shelf+ box('SponsonBraceStb_' + si, spons, 1.0, 5.0, w * 0.85, x, 13.2,+ hb + w / 2, matHullGray, 0, 0, 0);+ }+ if (outPort + hb < -1.5) {+ const w = -outPort - hb;+ box('SponsonPort_' + si, spons, 8.5, 2.4, w, x, 16.6, -(hb + w / 2), matHullGray);+ box('SponsonBracePort_' + si, spons, 1.0, 5.0, w * 0.85, x, 13.2,+ -(hb + w / 2), matHullGray, 0, 0, 0);+ }+ si++;+ }++ // Weapon / CIWS sponsons at the four quarters+ // Tubs sit under the deck overhang, so their tops stay clear of the deck soffit (Y 18.3).+ const gunSpots = [+ [146, 15, 'BowStb'], [146, -13, 'BowPort'],+ [-152, 22, 'QuarterStb'], [-152, -21, 'QuarterPort'],+ [40, 33, 'MidStb'], [-20, -43, 'MidPort']+ ];+ for (let g = 0; g < gunSpots.length; g++) {+ const gx = gunSpots[g][0];+ const gz = gunSpots[g][1];+ const nm = gunSpots[g][2];+ const sgn = gz > 0 ? 1 : -1;+ const ghb = Math.min(hullZ(gx - 4.5, 12.6), hullZ(gx + 4.5, 12.6)) - 0.3;+ // Shelf spanning hull side out to the tub, so no tub is left floating.+ const span = Math.abs(gz) + 4 - ghb;+ if (span > 0.5) {+ box('GunShelf_' + nm, spons, 9, 2.6, span, gx, 12.6,+ sgn * (ghb + span / 2), matHullGray);+ }+ box('GunSponson_' + nm, spons, 11, 2.6, 8, gx, 12.6, gz, matHullGray);+ box('GunTub_' + nm, spons, 8, 2.4, 6, gx, 15.1, gz, matHullGray);+ box('GunMount_' + nm, spons, 2.4, 2.4, 2.4, gx, 17.1, gz, matDark);+ box('GunBarrel_' + nm, spons, 4.2, 0.9, 0.9, gx + 3, 17.6, gz, matDark);+ }++ // =====================================================================+ // FLIGHT DECK+ // =====================================================================+ const deck = createPivot('FlightDeck', [0, 0, 0], root);++ // The slab is lofted along its own planform, for the same reason the shell is.+ // Three-metre plates each squared to the keel turned the stern round-in --+ // where the starboard edge sweeps 21 m outboard in 23 -- into a staircase with+ // treads nearly three metres deep, and no amount of coaming laid over the top+ // of it hid the tread ends. deckPort and deckStb are piecewise linear, so a+ // station on every breakpoint draws both edges exactly, in nine sections+ // instead of a hundred and ten plates.+ const DSTATIONS = [-165, -142, -95, -60, 85, 112, 118, 152, 165];+ const deckSections = [];+ for (let i = 0; i < DSTATIONS.length; i++) {+ const x = DSTATIONS[i];+ const zS = deckStb(x);+ const zP = deckPort(x);+ deckSections.push([+ [x, DECK_Y, zS],+ [x, DECK_Y, zP],+ [x, DECK_Y - DECK_T, zP],+ [x, DECK_Y - DECK_T, zS]+ ]);+ }+ createPart('FlightDeckSlab', loftGeo(deckSections), matDeck, { parent: deck });++ // Lay a run of boxes along a planform edge.+ //+ // The coaming and the catwalks were axis-aligned boxes dropped at edge(x),+ // which is exact only where the edge is parallel to the keel. It is not+ // parallel at the bow taper, at the round-down aft, or anywhere along the+ // angled deck, so each run climbed its own staircase and the ship carried a+ // comb of dark teeth down both sides -- the single most visible thing in the+ // hero render, and nothing a six-view sheet at ship scale shows you. A+ // segment now spans station to station and is yawed onto the chord between+ // them, so the same part count draws a polyline that follows the shape.+ //+ // A Y rotation of `a` carries +X to (cos a, 0, -sin a), so aligning a box's+ // length with (dx, 0, dz) wants -atan2(dz, dx).+ function edgeStrip(name, parent, edge, inset, step, x0, x1, h, d, y, mat) {+ let i = 0;+ for (let x = x0; x < x1; x += step) {+ const xa = x;+ const xb = Math.min(x + step, x1);+ const za = edge(xa) + inset;+ const zb = edge(xb) + inset;+ const dx = xb - xa;+ const dz = zb - za;+ box(name + i, parent, Math.sqrt(dx * dx + dz * dz) + 0.02, h, d,+ (xa + xb) / 2, y, (za + zb) / 2, mat, 0, -Math.atan2(dz, dx), 0);+ i++;+ }+ }++ // Deck-edge coaming strip (reads as the deck edge from any angle)+ edgeStrip('CoamingStb_', deck, deckStb, -0.4, 6, LOA_AFT + 2, LOA_FWD - 2, 0.5, 0.8, DECK_Y + 0.2, matDark);+ edgeStrip('CoamingPort_', deck, deckPort, 0.4, 6, LOA_AFT + 2, LOA_FWD - 2, 0.5, 0.8, DECK_Y + 0.2, matDark);++ // =====================================================================+ // CATWALKS -- continuous walkway one level below the deck edge+ // =====================================================================+ const cats = createPivot('Catwalks', [0, 0, 0], root);+ edgeStrip('CatwalkStb_', cats, deckStb, 0.0, 6, -156, 140, 0.35, 2.6, 17.9, matDark);+ edgeStrip('CatwalkPort_', cats, deckPort, 0.0, 6, -156, 140, 0.35, 2.6, 17.9, matDark);+ edgeStrip('CatwalkRailStb_', cats, deckStb, 1.1, 6, -156, 140, 0.18, 0.18, 19.2, matDark);+ edgeStrip('CatwalkRailPort_', cats, deckPort, -1.1, 6, -156, 140, 0.18, 0.18, 19.2, matDark);++ // =====================================================================+ // DECK-EDGE SAFETY NETTING -- sloping panels + stanchions all round+ // =====================================================================+ const nets = createPivot('SafetyNetting', [0, 0, 0], root);+ // A panel spans station to station along the deck edge, is offset along the+ // outboard NORMAL to that edge rather than straight out in Z, and is yawed+ // onto the chord. Squared to the keel, the same panels stepped 3.6 m per 4 m+ // section around the round-in and laid a second comb of teeth directly under+ // the first one.+ //+ // Euler order matters here. The default XYZ applies the outboard tilt after+ // the yaw and rolls the panel out of its own plane; YXZ tilts first, about the+ // panel's own length, and then yaws, which is the order the bracket is welded.+ function netRun(name, edge, side, x0, x1, step) {+ let i = 0;+ for (let x = x0; x < x1; x += step) {+ const xa = x;+ const xb = Math.min(x + step, x1);+ const za = edge(xa);+ const zb = edge(xb);+ const dx = xb - xa;+ const dz = zb - za;+ const len = Math.sqrt(dx * dx + dz * dz);+ const nx = (-dz / len) * side;+ const nz = (dx / len) * side;+ const yaw = -Math.atan2(dz, dx);+ const p = box(name + i, nets, len + 0.02, 0.14, 3.4,+ (xa + xb) / 2 + nx * 1.5, DECK_Y - 0.9, (za + zb) / 2 + nz * 1.5, matDark);+ p.rotation.set(side * 0.62, yaw, 0, 'YXZ');+ const q = box(name + 'Post' + i, nets, 0.22, 0.22, 3.6,+ xa + nx * 1.5, DECK_Y - 0.9, za + nz * 1.5, matDark);+ q.rotation.set(side * 0.62, yaw, 0, 'YXZ');+ i++;+ }+ }+ netRun('NetStb_', deckStb, 1, -152, 138, 4);+ netRun('NetPort_', deckPort, -1, -152, 138, 4);+ // Bow and stern netting runs (transverse)+ for (let k = 0; k < 8; k++) {+ const z = -13 + k * 3.8;+ box('NetStern_' + k, nets, 3.4, 0.14, 3.6, LOA_AFT + 1.5, DECK_Y - 0.9, z,+ matDark, 0, 0, -0.62);+ }++ // =====================================================================+ // DECK-EDGE ELEVATORS (4) -- 3 starboard, 1 port+ // =====================================================================+ const elevs = createPivot('Elevators', [0, 0, 0], root);+ const elevDefs = [+ ['Stb1', 95, 1], ['Stb2', 55, 1], ['Stb3', -35, 1], ['Port1', -45, -1]+ ];+ for (let e = 0; e < elevDefs.length; e++) {+ const nm = elevDefs[e][0];+ const ex = elevDefs[e][1];+ const side = elevDefs[e][2];+ const edge = side > 0 ? deckStb(ex) : deckPort(ex);+ const zc = edge - side * 8.0; // 16 m platform, outer edge flush with deck edge+ box('Elevator_' + nm, elevs, 26, 0.45, 16, ex, DECK_Y + 0.2, zc, matDeckWorn);+ // seam gap markings+ box('ElevSeamF_' + nm, elevs, 0.4, 0.5, 16, ex + 13, DECK_Y + 0.22, zc, matDark);+ box('ElevSeamA_' + nm, elevs, 0.4, 0.5, 16, ex - 13, DECK_Y + 0.22, zc, matDark);+ box('ElevSeamI_' + nm, elevs, 26, 0.5, 0.4, ex, DECK_Y + 0.22, zc - side * 8, matDark);+ // outboard support arms below the platform+ for (let a = 0; a < 3; a++) {+ box('ElevArm_' + nm + '_' + a, elevs, 1.6, 3.0, 12, ex - 10 + a * 10, 16.6,+ zc + side * 2, matHullGray);+ }+ box('ElevRail_' + nm, elevs, 26, 0.9, 0.5, ex, DECK_Y + 0.7, edge - side * 0.3, matDark);+ }++ // =====================================================================+ // ANGLED LANDING AREA (offset to port, 9 degrees)+ // =====================================================================+ const angled = createPivot('AngledDeck', [-30, DECK_Y, -6], root);+ angled.rotation.set(0, ANGLE_DEG * D2R, 0); // +Ry sends +X forward-and-to-port++ // Landing area surface patch (sits just proud of the deck so it reads in top view)+ box('LandingArea', angled, 250, 0.12, 27, 2, 0.16, 0, matDeckWorn);+ // Runway edge lines+ box('LandingEdgePort', angled, 250, 0.14, 0.7, 2, 0.24, -13.0, matWhite);+ box('LandingEdgeStb', angled, 250, 0.14, 0.7, 2, 0.24, 13.0, matWhite);+ // Dashed centreline+ for (let k = 0; k < 26; k++) {+ box('LandingCL_' + k, angled, 6, 0.14, 0.65, -120 + k * 9.6, 0.24, 0, matWhite);+ }+ // Touchdown box+ box('TouchdownFwd', angled, 0.8, 0.14, 27, -60, 0.24, 0, matWhite);+ box('TouchdownAft', angled, 0.8, 0.14, 27, -112, 0.24, 0, matWhite);++ // Arresting wires (4) across the landing area, with deck sheaves+ for (let w = 0; w < 4; w++) {+ const wx = -105 + w * 13;+ box('ArrestWire_' + w, angled, 0.32, 0.28, 27.5, wx, 0.5, 0, matDark);+ box('WireSheavePort_' + w, angled, 1.8, 0.7, 2.2, wx, 0.4, -14.2, matDark);+ box('WireSheaveStb_' + w, angled, 1.8, 0.7, 2.2, wx, 0.4, 14.2, matDark);+ box('WireMark_' + w, angled, 1.2, 0.14, 27, wx, 0.22, 0, matYellow);+ }++ // Landing-area edge lighting+ for (let k = 0; k < 34; k++) {+ box('LandLightP_' + k, angled, 0.5, 0.3, 0.5, -122 + k * 7.4, 0.32, -13.4, matWhite);+ box('LandLightS_' + k, angled, 0.5, 0.3, 0.5, -122 + k * 7.4, 0.32, 13.4, matWhite);+ }++ // Foul line (red, port of the landing area)+ for (let k = 0; k < 22; k++) {+ box('FoulLine_' + k, angled, 6, 0.13, 0.55, -118 + k * 11, 0.22, 16.5, matRed);+ }++ // =====================================================================+ // CATAPULTS -- two bow tracks (parallel to centreline) + two waist tracks+ // =====================================================================+ const catapults = createPivot('Catapults', [0, DECK_Y, 0], root);++ // bothGuides=false paints only the inboard guide line, for the waist tracks+ // that already sit hard against the port deck edge.+ function buildCatapult(nm, parent, x0, x1, z, jbdBack, bothGuides) {+ const len = x1 - x0;+ const xc = (x0 + x1) / 2;+ // slotted track: two rails with the shuttle slot between them+ box('CatRailA_' + nm, parent, len, 0.35, 0.55, xc, 0.25, z - 0.55, matDark);+ box('CatRailB_' + nm, parent, len, 0.35, 0.55, xc, 0.25, z + 0.55, matDark);+ box('CatSlot_' + nm, parent, len, 0.3, 0.55, xc, 0.2, z, matDark);+ // guide markings either side of the track+ box('CatGuideStb_' + nm, parent, len, 0.13, 0.45, xc, 0.2, z + 5.5, matWhite);+ if (bothGuides) {+ box('CatGuidePort_' + nm, parent, len, 0.13, 0.45, xc, 0.2, z - 5.5, matWhite);+ }+ // shuttle at the aft (start) end+ box('CatShuttle_' + nm, parent, 2.4, 0.6, 1.6, x0 + 6, 0.45, z, matDark);+ // holdback / launch bar detail+ box('CatHoldback_' + nm, parent, 1.4, 0.5, 2.6, x0 + 2, 0.4, z, matDark);+ box('CatBridle_' + nm, parent, 3.0, 0.35, 3.4, x1 - 3, 0.35, z, matDark);++ // Jet blast deflector behind the catapult start, leaning aft+ const jx = x0 - jbdBack;+ for (let s = 0; s < 3; s++) {+ const sz = z - 7.0 + s * 7.0;+ box('JBD_' + nm + '_' + s, parent, 1.0, 6.6, 6.6, jx, 3.0, sz, matRed, 0, 0, 0.62);+ box('JBDFrame_' + nm + '_' + s, parent, 1.3, 0.5, 6.8, jx - 1.6, 5.9, sz,+ matDark, 0, 0, 0.62);+ box('JBDHinge_' + nm + '_' + s, parent, 2.2, 0.7, 6.8, jx + 1.8, 0.35, sz, matDark);+ }+ box('JBDRecess_' + nm, parent, 8, 0.14, 21, jx + 1, 0.16, z, matDark);+ }++ // Bow catapults 1 and 2 -- parallel to the centreline+ buildCatapult('Cat1', catapults, 34, 152, -6, 5, true);+ buildCatapult('Cat2', catapults, 34, 152, 14, 5, true);+ // Waist catapults 3 and 4, built inside the angled-deck pivot so they share its axis+ const waist = createPivot('WaistCatapults', [0, 0.02, 0], angled);+ buildCatapult('Cat3', waist, -36, 58, -17, 5, false);+ buildCatapult('Cat4', waist, -36, 58, -26, 5, false);++ // Bow deck markings (kept inboard of the narrowing bow deck edge)+ for (let k = 0; k < 12; k++) {+ box('BowMarkA_' + k, deck, 4, 0.13, 0.5, 40 + k * 8, DECK_Y + 0.06, 20, matYellow);+ }++ // =====================================================================+ // ISLAND SUPERSTRUCTURE (starboard)+ // =====================================================================+ const island = createPivot('Island', [14, DECK_Y, 25], root);++ // Main tower stack+ box('IslandBase', island, 44, 7.5, 14, 0, 3.75, 0, matIsland);+ box('IslandLevel2', island, 40, 5.5, 13, -1, 10.2, 0, matIsland);+ box('IslandLevel3', island, 34, 5.0, 12, -2, 15.4, 0, matIsland);+ box('IslandLevel4', island, 22, 4.6, 11, -4, 20.2, 0, matIsland);+ box('IslandCap', island, 14, 3.4, 9.5, -5, 24.2, 0, matIsland);++ // Navigation bridge -- projects forward and outboard, glazed+ box('NavBridge', island, 15, 4.4, 16, 15, 12.6, 0.5, matIsland);+ box('NavBridgeGlassF', island, 0.5, 2.6, 16, 22.6, 13.2, 0.5, matDark);+ box('NavBridgeGlassStb', island, 15, 2.6, 0.5, 15, 13.2, 8.5, matDark);+ box('NavBridgeGlassPort', island, 15, 2.6, 0.5, 15, 13.2, -7.5, matDark);+ box('NavBridgeWingStb', island, 6, 0.4, 4, 20, 10.4, 10, matIsland);+ box('NavBridgeWingPort', island, 6, 0.4, 4, 20, 10.4, -9, matIsland);+ box('NavBridgeRoof', island, 16, 0.6, 17, 15, 15.1, 0.5, matIsland);++ // Flag bridge, one level down+ box('FlagBridge', island, 13, 4.0, 15, 14, 7.8, 0.5, matIsland);+ box('FlagBridgeGlass', island, 0.5, 2.2, 15, 20.6, 8.2, 0.5, matDark);++ // Primary Flight Control -- aft-facing, overhangs the deck+ box('PriFly', island, 11, 4.4, 15, -14, 17.8, 0.5, matIsland);+ box('PriFlyGlassAft', island, 0.5, 2.8, 15, -19.6, 18.4, 0.5, matDark);+ box('PriFlyGlassPort', island, 11, 2.8, 0.5, -14, 18.4, -7.2, matDark);+ box('PriFlyRoof', island, 12, 0.6, 16, -14, 20.3, 0.5, matIsland);++ // Level window bands on the main stack+ for (let k = 0; k < 3; k++) {+ const wy = [4.5, 10.6, 15.6][k];+ const wl = [42, 38, 32][k];+ const wx = [0, -1, -2][k];+ box('IslandBandPort_' + k, island, wl, 1.5, 0.4, wx, wy, -6.6, matDark);+ box('IslandBandStb_' + k, island, wl, 1.5, 0.4, wx, wy, 6.6, matDark);+ }++ // Island catwalks and ladders+ for (let k = 0; k < 4; k++) {+ const cy = [7.6, 13.0, 18.2, 23.0][k];+ const cl = [42, 36, 24, 15][k];+ const cx = [0, -1, -3, -5][k];+ box('IslandCatwalk_' + k, island, cl, 0.3, 15.4, cx, cy, 0, matDark);+ box('IslandRailPort_' + k, island, cl, 1.1, 0.16, cx, cy + 0.7, -7.6, matDark);+ box('IslandRailStb_' + k, island, cl, 1.1, 0.16, cx, cy + 0.7, 7.6, matDark);+ }+ for (let k = 0; k < 4; k++) {+ box('IslandLadder_' + k, island, 3.4, 5.4, 1.0, -18, 3.0 + k * 5.2, 7.4,+ matDark, 0, 0, 0.5);+ }++ // Island deck-edge fairing where it meets the flight deck+ box('IslandFairingFwd', island, 6, 1.2, 14, 24, 0.6, 0, matIsland);+ box('IslandFairingAft', island, 6, 1.2, 14, -24, 0.6, 0, matIsland);++ // ---------------------------------------------- flat phased-array radars+ // Four fixed faces: forward, aft, outboard (stb), inboard (port).+ const arrays = createPivot('PhasedArrays', [0, 0, 0], island);+ box('ArrayFwd', arrays, 0.9, 7.5, 7.5, 17.4, 20.0, 3.0, matRadar, 0, 0, -0.16);+ box('ArrayFwdFrame', arrays, 0.4, 8.4, 8.4, 17.9, 20.0, 3.0, matIsland, 0, 0, -0.16);+ box('ArrayAft', arrays, 0.9, 7.5, 7.5, -12.4, 20.0, 3.0, matRadar, 0, 0, 0.16);+ box('ArrayAftFrame', arrays, 0.4, 8.4, 8.4, -12.9, 20.0, 3.0, matIsland, 0, 0, 0.16);+ box('ArrayStb', arrays, 7.5, 7.5, 0.9, 2.0, 20.0, 6.2, matRadar, -0.16, 0, 0);+ box('ArrayStbFrame', arrays, 8.4, 8.4, 0.4, 2.0, 20.0, 6.7, matIsland, -0.16, 0, 0);+ box('ArrayPort', arrays, 7.5, 7.5, 0.9, 2.0, 20.0, -5.2, matRadar, 0.16, 0, 0);+ box('ArrayPortFrame', arrays, 8.4, 8.4, 0.4, 2.0, 20.0, -5.7, matIsland, 0.16, 0, 0);+ // Smaller fire-control panels lower down+ box('FCPanelFwd', arrays, 0.7, 3.4, 3.4, 20.4, 6.5, 5.0, matRadar, 0, 0, -0.18);+ box('FCPanelAft', arrays, 0.7, 3.4, 3.4, -20.4, 6.5, 5.0, matRadar, 0, 0, 0.18);++ // ---------------------------------------------------------- lattice mast+ // Base sits ON the island cap (island-local Y 25.9), not floating above it.+ const mast = createPivot('LatticeMast', [-3, 25.9, 0], island);+ const MAST_H = 26;+ const legs = [[2.4, 2.4], [2.4, -2.4], [-2.4, 2.4], [-2.4, -2.4]];+ for (let l = 0; l < 4; l++) {+ const lx = legs[l][0];+ const lz = legs[l][1];+ // legs taper inboard as they rise -- built as three stacked segments+ for (let s = 0; s < 3; s++) {+ const t0 = s / 3, t1 = (s + 1) / 3;+ const k0 = lerp(1.0, 0.45, t0);+ const k1 = lerp(1.0, 0.45, t1);+ const km = (k0 + k1) / 2;+ box('MastLeg_' + l + '_' + s, mast, 0.55, MAST_H / 3 + 0.1, 0.55,+ lx * km, MAST_H * (t0 + t1) / 2, lz * km, matIsland);+ }+ }+ // Cross bracing -- horizontal rings plus diagonals, 9 bays+ for (let b = 0; b <= 9; b++) {+ const t = b / 9;+ const k = lerp(1.0, 0.45, t);+ const y = MAST_H * t;+ const sp = 4.8 * k;+ box('MastRingF_' + b, mast, 0.35, 0.35, sp, 2.4 * k, y, 0, matIsland);+ box('MastRingA_' + b, mast, 0.35, 0.35, sp, -2.4 * k, y, 0, matIsland);+ box('MastRingP_' + b, mast, sp, 0.35, 0.35, 0, y, -2.4 * k, matIsland);+ box('MastRingS_' + b, mast, sp, 0.35, 0.35, 0, y, 2.4 * k, matIsland);+ if (b < 9) {+ const yd = MAST_H / 9;+ const kd = lerp(1.0, 0.45, (b + 0.5) / 9);+ const diag = Math.sqrt(yd * yd + (4.8 * kd) * (4.8 * kd));+ const ang = Math.atan2(4.8 * kd, yd);+ box('MastDiagP_' + b, mast, 0.3, diag, 0.3, 0, y + yd / 2, -2.4 * kd,+ matIsland, b % 2 ? ang : -ang, 0, 0);+ box('MastDiagS_' + b, mast, 0.3, diag, 0.3, 0, y + yd / 2, 2.4 * kd,+ matIsland, b % 2 ? -ang : ang, 0, 0);+ box('MastDiagF_' + b, mast, 0.3, diag, 0.3, 2.4 * kd, y + yd / 2, 0,+ matIsland, 0, 0, b % 2 ? ang : -ang);+ box('MastDiagA_' + b, mast, 0.3, diag, 0.3, -2.4 * kd, y + yd / 2, 0,+ matIsland, 0, 0, b % 2 ? -ang : ang);+ }+ }+ // Yardarms and mast-head fit+ box('YardarmLower', mast, 0.5, 0.5, 22, 0, 14, 0, matIsland);+ box('YardarmUpper', mast, 0.5, 0.5, 15, 0, 20, 0, matIsland);+ box('YardarmStay', mast, 0.35, 6.2, 0.35, 0, 17, 0, matIsland);+ for (let k = 0; k < 6; k++) {+ const zz = -9 + k * 3.6;+ box('YardLight_' + k, mast, 0.6, 0.9, 0.6, 0, 14.7, zz, matDark);+ }+ // Flat air-search array on the mast head, plus whip antennas+ box('AirSearchArray', mast, 0.6, 5.0, 8.5, 0, 24, 0, matRadar, 0, 0, 0);+ box('AirSearchFrame', mast, 1.0, 0.5, 9.2, 0, 21.3, 0, matIsland);+ box('MastHead', mast, 0.4, 5.0, 0.4, 0, 28.5, 0, matIsland);+ // Whips stand on the topmost island catwalk (island-local Y 23.0)+ for (let k = 0; k < 6; k++) {+ box('Whip_' + k, island, 0.22, 9.0, 0.22, -11 + k * 2.6, 27.5,+ (k % 2 ? 6.2 : -6.2), matIsland, 0, 0, (k % 2 ? 0.12 : -0.12));+ }+ // Aft island antenna dome-frames (flat plates, no dishes)+ // Moved out to +/-5.8 so each plate reaches the whip mast beside it at+ // +/-6.2. At 5.6 they hung 0.19 m clear of anything and were the only two+ // parts on the ship attached to nothing at all.+ box('SatPlateA', island, 3.2, 3.2, 0.6, -8, 27.5, 5.8, matRadar);+ box('SatPlateB', island, 3.2, 3.2, 0.6, -8, 27.5, -5.8, matRadar);++ // =====================================================================+ // FLIGHT DECK LIGHTING AND MISC DECK FURNITURE+ // =====================================================================+ const furniture = createPivot('DeckFurniture', [0, 0, 0], root);+ let li = 0;+ for (let x = -150; x <= 140; x += 6) {+ box('DeckLightStb_' + li, furniture, 0.5, 0.3, 0.5, x, DECK_Y + 0.15,+ deckStb(x) - 1.6, matWhite);+ box('DeckLightPort_' + li, furniture, 0.5, 0.3, 0.5, x, DECK_Y + 0.15,+ deckPort(x) + 1.6, matWhite);+ li++;+ }+ // Tie-down pad rows -- only where the deck actually exists at that station+ for (let r = 0; r < 6; r++) {+ for (let k = 0; k < 16; k++) {+ const tx = -130 + k * 17;+ const tz = -34 + r * 12;+ if (tz < deckPort(tx) + 3 || tz > deckStb(tx) - 3) continue;+ // Seated 3 cm into the deck rather than balanced 2 cm above it. The pads+ // amidships happened to overlap a taxi line or a tractor and passed on+ // that; the two rows forward of the last marking sat on bare deck and+ // showed the gap for what it always was.+ box('TieDown_' + r + '_' + k, furniture, 0.7, 0.16, 0.7,+ tx, DECK_Y + 0.05, tz, matDeckWorn);+ }+ }+ // Optical landing system, on the port sponson abreast the touchdown area+ box('OLS_Platform', furniture, 7, 1.4, 6, -70, DECK_Y - 0.4, -37, matHullGray);+ box('OLS_Mirror', furniture, 1.0, 2.2, 5.2, -70, DECK_Y + 1.6, -37, matDark);+ for (let k = 0; k < 5; k++) {+ box('OLS_Cell_' + k, furniture, 1.2, 0.8, 0.8, -70, DECK_Y + 1.6, -39.4 + k * 1.2,+ matWhite);+ }+ // Deck-edge crane, starboard aft+ box('CraneBase', furniture, 6, 2.0, 6, -120, DECK_Y + 1.0, 29, matHullGray);+ box('CraneTower', furniture, 3, 8.0, 3, -120, DECK_Y + 6.0, 29, matIsland);+ box('CraneJib', furniture, 18, 1.0, 1.6, -112, DECK_Y + 10.5, 29, matIsland, 0, 0, -0.18);+ box('CraneHook', furniture, 0.8, 3.0, 0.8, -104, DECK_Y + 7.5, 29, matDark);+ // Deck tractors / support equipment ranged along the starboard aft deck+ for (let k = 0; k < 4; k++) {+ box('DeckTractor_' + k, furniture, 4.4, 1.6, 2.2, -95 + k * 9, DECK_Y + 0.9,+ 26, matDeckWorn);+ }++ return root;+}diff --git a/examples/anglerfish.kiln.js b/examples/anglerfish.kiln.jsnew file mode 100644index 00000000..265907d6--- /dev/null+++ b/examples/anglerfish.kiln.js@@ -0,0 +1,487 @@+// Authored by: opus, via claude.+//+// Written by the model itself through the Kiln MCP tools, and cut off+// mid-run rather than finished -- by a provider limit, or by the+// dispatch deadline. The program below is what was on disk when the+// session ended; how many times it had looked at its own contact sheet+// by then is not recorded, so this one does not make the claim the+// others do.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'Anglerfish', category: 'prop', role: 'prop' };++// ---------------------------------------------------------------------------+// Deep-sea anglerfish (Melanocetus-like). +X = snout, +Y = up, +Z = right.+// Hard bounds: 0.42 long, 0.20 tall, 0.13 wide, belly resting on Y = 0.+//+// The body is one swept tube. Past u = RIM the tube folds back on itself and+// runs inward to the throat, so the gaping mouth is real cavity geometry+// rather than a boolean cut. `tilt` pushes the bottom of each head ring+// forward, which is what gives the jaw its dropped, under-shot profile.+// ---------------------------------------------------------------------------++// [u, x, halfHeight, halfWidth, xTilt, centreLift]+const STATIONS = [+ [0.000, -0.1630, 0.0035, 0.0025, 0.0000, 0.0000],+ [0.030, -0.1585, 0.0100, 0.0072, 0.0000, 0.0000],+ [0.080, -0.1490, 0.0165, 0.0110, 0.0000, 0.0000],+ [0.150, -0.1345, 0.0245, 0.0160, 0.0000, 0.0000],+ [0.230, -0.1150, 0.0345, 0.0225, 0.0000, 0.0000],+ [0.310, -0.0930, 0.0450, 0.0290, 0.0000, 0.0000],+ [0.390, -0.0680, 0.0555, 0.0350, 0.0000, 0.0000],+ [0.470, -0.0400, 0.0655, 0.0405, 0.0000, 0.0000],+ [0.550, -0.0090, 0.0740, 0.0445, 0.0000, 0.0000],+ [0.630, 0.0240, 0.0800, 0.0470, -0.0010, 0.0000],+ [0.700, 0.0530, 0.0825, 0.0480, -0.0020, 0.0000],+ [0.760, 0.0790, 0.0820, 0.0478, -0.0040, 0.0010],+ [0.810, 0.1010, 0.0790, 0.0465, -0.0080, 0.0020],+ [0.850, 0.1200, 0.0730, 0.0440, -0.0120, 0.0030],+ [0.880, 0.1350, 0.0650, 0.0405, -0.0150, 0.0070],+ [0.900, 0.1425, 0.0575, 0.0372, -0.0160, 0.0100],+ [0.910, 0.1460, 0.0530, 0.0348, -0.0170, 0.0120],+ [0.920, 0.1462, 0.0490, 0.0325, -0.0170, 0.0135], // jaw rim / fold+ [0.940, 0.1345, 0.0370, 0.0255, -0.0140, 0.0180],+ [0.965, 0.1120, 0.0250, 0.0175, -0.0100, 0.0240],+ [0.985, 0.0850, 0.0140, 0.0100, -0.0050, 0.0300],+ [1.000, 0.0620, 0.0040, 0.0030, 0.0000, 0.0340],+];++const RIM = 0.920;+const BELLY_POW = 0.65;++function lerp(a, b, t) { return a + (b - a) * t; }+function clamp(v, a, b) { return v < a ? a : (v > b ? b : v); }++function bellyY(u) {+ const t = u >= 0.42 ? 0 : (0.42 - u) / 0.42;+ return 0.004 + 0.045 * t * t;+}++function stationByU(uRaw) {+ const u = clamp(uRaw, 0, 1);+ let i = 0;+ while (i < STATIONS.length - 2 && STATIONS[i + 1][0] < u) i++;+ const a = STATIONS[i], b = STATIONS[i + 1];+ const t = (u - a[0]) / (b[0] - a[0]);+ const ry = lerp(a[2], b[2], t);+ return {+ u,+ x: lerp(a[1], b[1], t),+ ry,+ rz: lerp(a[3], b[3], t),+ tilt: lerp(a[4], b[4], t),+ cy: bellyY(u) + ry + lerp(a[5], b[5], t),+ };+}++// Deterministic warty relief; suppressed on the lip and inside the mouth.+function wartAmount(x, y, z, st) {+ const n1 = Math.sin(x * 118 + 0.7) * Math.sin(y * 133 + 2.1) * Math.sin(z * 126 + 4.2);+ const n2 = Math.sin(x * 213 + 1.9) * Math.sin(y * 238 + 0.4) * Math.sin(z * 226 + 3.3);+ const w = 0.62 * n1 + 0.38 * n2;+ const fade = st.u > 0.855 ? clamp((0.905 - st.u) / 0.050, 0, 1) : 1;+ return 0.0042 * (Math.max(0, w - 0.10) / 0.90) * clamp(st.ry / 0.030, 0.15, 1) * fade;+}++function basePoint(u, theta) {+ const st = stationByU(u);+ const ny = Math.cos(theta), nz = Math.sin(theta);+ const f = ny >= 0 ? ny : -Math.pow(-ny, BELLY_POW);+ return [st.x + st.tilt * ny, st.cy + st.ry * f, st.rz * nz];+}++function sub(a, b) { return [a[0] - b[0], a[1] - b[1], a[2] - b[2]]; }+function add(a, b) { return [a[0] + b[0], a[1] + b[1], a[2] + b[2]]; }+function scl(a, k) { return [a[0] * k, a[1] * k, a[2] * k]; }+function cross(a, b) {+ return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];+}+function norm(v) {+ const l = Math.hypot(v[0], v[1], v[2]) || 1;+ return [v[0] / l, v[1] / l, v[2] / l];+}++function baseNormal(u, theta) {+ const du = 0.003, dt = 0.01;+ const pu = sub(basePoint(clamp(u + du, 0, 1), theta), basePoint(clamp(u - du, 0, 1), theta));+ const pt = sub(basePoint(u, theta + dt), basePoint(u, theta - dt));+ const n = norm(cross(pt, pu));+ return u > RIM ? scl(n, -1) : n; // cavity rings face inward+}++function surfacePoint(u, theta) {+ const p = basePoint(u, theta);+ const st = stationByU(u);+ const a = wartAmount(p[0], p[1], p[2], st);+ if (a === 0) return p;+ const n = baseNormal(u, theta);+ return add(p, scl(n, a));+}++// ---------------------------------------------------------------------------++function buildTube(u0, u1, rings, NT, capStart, capEnd) {+ const pos = [], uvs = [], idx = [];+ for (let i = 0; i <= rings; i++) {+ const u = lerp(u0, u1, i / rings);+ for (let j = 0; j < NT; j++) {+ const p = surfacePoint(u, (j / NT) * Math.PI * 2);+ pos.push(p[0], p[1], p[2]);+ uvs.push(i / rings, j / NT);+ }+ }+ for (let i = 0; i < rings; i++) {+ for (let j = 0; j < NT; j++) {+ const j2 = (j + 1) % NT;+ const a = i * NT + j, b = i * NT + j2;+ const c = (i + 1) * NT + j, d = (i + 1) * NT + j2;+ idx.push(a, b, c, b, d, c);+ }+ }+ if (capStart) {+ const st = stationByU(u0);+ const p = (pos.length / 3);+ pos.push(st.x + st.tilt - 0.005, st.cy, 0); uvs.push(0, 0.5);+ for (let j = 0; j < NT; j++) idx.push(p, (j + 1) % NT, j);+ }+ if (capEnd) {+ const st = stationByU(u1);+ const p = (pos.length / 3);+ pos.push(st.x - 0.006, st.cy, 0); uvs.push(1, 0.5);+ for (let j = 0; j < NT; j++) idx.push(p, rings * NT + j, rings * NT + (j + 1) % NT);+ }+ const geo = new THREE.BufferGeometry();+ geo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(pos), 3));+ geo.setAttribute('uv', new THREE.BufferAttribute(new Float32Array(uvs), 2));+ geo.setIndex(idx);+ geo.computeVertexNormals();+ return geo;+}++// Needle tooth: base at origin, axis +Y, curls toward +X.+function toothGeometry(len, rad, bend, seg) {+ const geo = mergeVertices(coneYGeo(rad, len, seg));+ const p = geo.getAttribute('position');+ for (let i = 0; i < p.count; i++) {+ const yf = clamp((p.getY(i) + len / 2) / len, 0, 1);+ p.setX(i, p.getX(i) + bend * yf * yf);+ }+ geo.translate(0, len / 2, 0);+ geo.computeVertexNormals();+ return geo;+}++function basis(obj, X, Y, Z) {+ obj.quaternion.setFromRotationMatrix(new THREE.Matrix4().makeBasis(X, Y, Z));+}+// Align the part's local +X with xDir (fins, whose fan runs along local X).+function orientX(obj, xDir, zHint) {+ const X = new THREE.Vector3(xDir[0], xDir[1], xDir[2]).normalize();+ const Z = new THREE.Vector3(zHint[0], zHint[1], zHint[2]);+ Z.addScaledVector(X, -Z.dot(X)).normalize();+ basis(obj, X, new THREE.Vector3().crossVectors(Z, X).normalize(), Z);+}+// Align the part's local +Y with yDir (cones: teeth, tubercles, spines).+function orientY(obj, yDir, xHint) {+ const Y = new THREE.Vector3(yDir[0], yDir[1], yDir[2]).normalize();+ const X = new THREE.Vector3(xHint[0], xHint[1], xHint[2]);+ X.addScaledVector(Y, -X.dot(Y));+ if (X.lengthSq() < 1e-9) X.set(1, 0, 0).addScaledVector(Y, -Y.x);+ X.normalize();+ basis(obj, X, Y, new THREE.Vector3().crossVectors(X, Y).normalize());+}++// Tapered tube along a planar (constant-Z) path.+function planarTube(points, r0, r1, radial) {+ const pos = [], idx = [];+ const B = [0, 0, 1];+ const n = points.length;+ for (let i = 0; i < n; i++) {+ const a = points[Math.max(0, i - 1)], b = points[Math.min(n - 1, i + 1)];+ const T = norm(sub(b, a));+ const N = norm(cross(T, B));+ const t = i / (n - 1);+ const r = lerp(r0, r1, t * t * (3 - 2 * t));+ for (let j = 0; j < radial; j++) {+ const th = (j / radial) * Math.PI * 2;+ const c = Math.cos(th) * r, s = Math.sin(th) * r;+ pos.push(+ points[i][0] + N[0] * c + B[0] * s,+ points[i][1] + N[1] * c + B[1] * s,+ points[i][2] + N[2] * c + B[2] * s,+ );+ }+ }+ for (let i = 0; i < n - 1; i++) {+ for (let j = 0; j < radial; j++) {+ const j2 = (j + 1) % radial;+ const a = i * radial + j, b = i * radial + j2;+ const c = (i + 1) * radial + j, d = (i + 1) * radial + j2;+ idx.push(a, b, c, b, d, c);+ }+ }+ const geo = new THREE.BufferGeometry();+ geo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(pos), 3));+ geo.setIndex(idx);+ geo.computeVertexNormals();+ return geo;+}++// Ragged ray-fin: scalloped web plus the rays that carry it.+async function buildFin(name, rays, thickness, webMat, rayMat, parent) {+ const grp = new THREE.Object3D();+ grp.name = name;+ parent.add(grp);+ const pts = [[0.003, -0.0050]];+ for (let i = 0; i < rays.length; i++) {+ const r = rays[i];+ pts.push([r.len * Math.cos(r.a), r.len * Math.sin(r.a)]);+ if (i < rays.length - 1) {+ const mid = (r.a + rays[i + 1].a) / 2;+ const ml = ((r.len + rays[i + 1].len) / 2) * (0.84 + 0.06 * (i % 3));+ pts.push([ml * Math.cos(mid), ml * Math.sin(mid)]);+ }+ }+ pts.push([0.003, 0.0050]);+ const geo = await extrudeProfile(pts, {+ depth: thickness, bevel: 0.0007, bevelStyle: 'round', segments: 2, center: true,+ });+ createPart(name + '_Web', geo, webMat, { parent: grp });+ for (let i = 0; i < rays.length; i++) {+ const r = rays[i];+ beamBetween(name + '_Ray' + i, [0, 0, 0],+ [r.len * 0.99 * Math.cos(r.a), r.len * 0.99 * Math.sin(r.a), 0],+ 0.0015, rayMat, { segments: 6, parent: grp });+ }+ return grp;+}++function fanRays(count, a0, a1, lBase, lTip, wobble) {+ const out = [];+ for (let i = 0; i < count; i++) {+ const t = count === 1 ? 0.5 : i / (count - 1);+ const bell = Math.sin(Math.PI * (0.18 + 0.64 * t));+ out.push({+ a: lerp(a0, a1, t),+ len: lerp(lTip, lBase, bell) * (1 + wobble * Math.sin(i * 2.399 + 1.1)),+ });+ }+ return out;+}++// ---------------------------------------------------------------------------++async function build() {+ const root = createRoot('AnglerfishOpus');+ const fish = new THREE.Object3D();+ fish.name = 'Anglerfish';+ root.add(fish);++ const skin = gameMaterial(0x3d352e, { roughness: 0.90, metalness: 0.0, flatShading: false });+ const mouthMat = gameMaterial(0x6e3032, { roughness: 0.55, flatShading: false });+ const toothMat = gameMaterial(0xe8e2d0, { roughness: 0.30, flatShading: false });+ const finMat = gameMaterial(0x4d4239, { roughness: 0.92, flatShading: false });+ const eyeMat = gameMaterial(0x0b0b0e, { roughness: 0.12, flatShading: false });+ const glowMat = gameMaterial(0xcafbe9, {+ roughness: 0.35, emissive: 0x62e9c2, emissiveIntensity: 2.6, flatShading: false,+ });+ const bulbMat = glassMaterial(0x9ff0e0, { opacity: 0.32, roughness: 0.22 });++ const NT = 48;++ // ---- body shell and buccal cavity -----------------------------------------+ createPart('Body', buildTube(0, RIM, 58, NT, true, false), skin, { parent: fish });+ createPart('MouthCavity', buildTube(RIM, 1, 12, NT, false, true), mouthMat, { parent: fish });+ createPart('Gullet', sphereGeo(0.0165, 16, 12), mouthMat, {+ parent: fish, position: [0.0700, stationByU(1).cy + 0.002, 0], scale: [1.0, 1.0, 0.9],+ });++ // ---- jaw rim, hinge knobs -------------------------------------------------+ const rimPts = [];+ for (let j = 0; j < 40; j++) rimPts.push(surfacePoint(RIM, (j / 40) * Math.PI * 2));+ createPart('JawRim', pipeAlongPath(rimPts, 0.0038, {+ closed: true, tubularSegments: 64, radialSegments: 7,+ }), skin, { parent: fish });++ const lowerArc = [];+ for (let k = 0; k <= 16; k++) {+ const th = lerp(Math.PI * 0.42, Math.PI * 1.58, k / 16);+ const p = surfacePoint(RIM - 0.004, th);+ lowerArc.push([p[0] + 0.0016, p[1] - 0.0022, p[2]]);+ }+ createPart('LowerJawBone', pipeAlongPath(lowerArc, 0.0056, {+ tubularSegments: 30, radialSegments: 7,+ }), skin, { parent: fish });++ for (const s of [-1, 1]) {+ const p = surfacePoint(RIM - 0.012, s > 0 ? Math.PI / 2 : -Math.PI / 2);+ createPart('JawHinge' + (s > 0 ? 'R' : 'L'), sphereGeo(0.0088, 12, 9), skin, {+ parent: fish, position: [p[0] - 0.004, p[1], p[2]], scale: [1.3, 1.0, 0.75],+ });+ }++ // ---- teeth: two rows of inward-curving needles ----------------------------+ const teeth = new THREE.Object3D();+ teeth.name = 'Teeth';+ fish.add(teeth);+ const toothCache = {};+ function getTooth(len) {+ const key = Math.round(len * 2500);+ if (!toothCache[key]) toothCache[key] = toothGeometry(len, 0.0024, len * 0.34, 8);+ return toothCache[key];+ }++ function toothRow(tag, uRow, count, phase, lenTop, lenSide, lenBottom, back) {+ const st = stationByU(uRow);+ const centre = [st.x, st.cy, 0];+ for (let i = 0; i < count; i++) {+ const th = ((i + phase) / count) * Math.PI * 2;+ const p = surfacePoint(uRow, th);+ const radial = norm(sub(p, centre));+ const up = Math.cos(th);+ const len = up > 0+ ? lerp(lenSide, lenTop, up)+ : lerp(lenSide, lenBottom, -up);+ const jitter = 1 + 0.11 * Math.sin(i * 2.7 + 0.8);+ const dir = norm(add(scl(radial, -1), [-back, 0, 0]));+ const part = createPart(tag + i, getTooth(len * jitter), toothMat, {+ parent: teeth, position: [p[0], p[1], p[2]],+ });+ orientY(part, dir, [-1, 0, 0]);+ }+ }+ toothRow('ToothOuter', RIM - 0.0035, 26, 0.5, 0.0250, 0.0165, 0.0285, 0.42);+ toothRow('ToothInner', RIM + 0.0090, 19, 0.0, 0.0150, 0.0105, 0.0175, 0.62);++ // ---- warty tuberculate skin ----------------------------------------------+ const warts = new THREE.Object3D();+ warts.name = 'Tubercles';+ fish.add(warts);+ const wartA = coneYGeo(0.0052, 0.0072, 7);+ const wartB = coneYGeo(0.0035, 0.0048, 6);+ const wartC = coneYGeo(0.0060, 0.0115, 7);+ wartA.translate(0, 0.0036, 0);+ wartB.translate(0, 0.0024, 0);+ wartC.translate(0, 0.0058, 0);+ let wc = 0;+ for (let iu = 0; iu < 28; iu++) {+ const u = 0.055 + (iu / 27) * 0.845;+ const st = stationByU(u);+ const ring = Math.max(3, Math.round(12 * clamp(st.rz / 0.048, 0.22, 1)));+ for (let j = 0; j < ring; j++) {+ const th = ((j + 0.5 * (iu % 2)) / ring) * Math.PI * 2 + 0.35 * Math.sin(iu * 1.7 + j * 2.3);+ const p = surfacePoint(u, th);+ if (p[1] < 0.007) continue;+ const n = baseNormal(u, th);+ const big = ((iu * 7 + j * 3) % 5) === 0;+ const part = createPart('Tubercle' + (wc++), big ? wartA : wartB, skin, {+ parent: warts, position: [p[0] - n[0] * 0.0012, p[1] - n[1] * 0.0012, p[2] - n[2] * 0.0012],+ });+ orientY(part, n, [1, 0, 0]);+ }+ }+ // dorsal ridge of larger spines+ for (let i = 0; i < 13; i++) {+ const u = 0.16 + (i / 12) * 0.68;+ const th = 0.20 * Math.sin(i * 1.9);+ const p = surfacePoint(u, th);+ const n = baseNormal(u, th);+ const part = createPart('DorsalSpine' + i, wartC, skin, {+ parent: warts, position: [p[0] - n[0] * 0.002, p[1] - n[1] * 0.002, p[2] - n[2] * 0.002],+ });+ orientY(part, norm(add(n, [-0.45, 0, 0])), [1, 0, 0]);+ }++ // ---- eyes ----------------------------------------------------------------+ for (const s of [-1, 1]) {+ const th = s > 0 ? 0.92 : -0.92;+ const p = surfacePoint(0.842, th);+ const n = baseNormal(0.842, th);+ createPart('EyeRidge' + (s > 0 ? 'R' : 'L'), sphereGeo(0.0112, 14, 10), skin, {+ parent: fish,+ position: [p[0] - n[0] * 0.005, p[1] - n[1] * 0.005, p[2] - n[2] * 0.005],+ scale: [1.05, 1.0, 0.7],+ });+ createPart('Eye' + (s > 0 ? 'R' : 'L'), sphereGeo(0.0066, 16, 12), eyeMat, {+ parent: fish, position: [p[0] + n[0] * 0.0012, p[1] + n[1] * 0.0012, p[2] + n[2] * 0.0012],+ scale: [1, 1, 0.9],+ });+ createPart('EyeGlint' + (s > 0 ? 'R' : 'L'), sphereGeo(0.0018, 8, 6), glowMat, {+ parent: fish, position: [p[0] + 0.0038, p[1] + 0.0032, p[2] + s * 0.0028],+ });+ }++ // ---- illicium and esca ----------------------------------------------------+ const lureTip = [0.1830, 0.1580, 0];+ const path = bezierCurve(+ [[0.1000, 0.1560, 0], [0.1120, 0.1960, 0], [0.1650, 0.1920, 0], lureTip], 42,+ );+ createPart('Illicium', planarTube(path, 0.0060, 0.0026, 10), skin, { parent: fish });+ createPart('EscaBulb', sphereGeo(0.0172, 20, 14), bulbMat, { parent: fish, position: lureTip });+ createPart('EscaCore', sphereGeo(0.0126, 20, 14), glowMat, { parent: fish, position: lureTip });+ for (let i = 0; i < 9; i++) {+ const a = (i / 9) * Math.PI * 2;+ const d = norm([0.50 + 0.32 * Math.cos(a), 0.48 * Math.sin(a), 0.78 * Math.cos(a + 1.1)]);+ beamBetween('EscaFilament' + i,+ [lureTip[0] + d[0] * 0.012, lureTip[1] + d[1] * 0.012, lureTip[2] + d[2] * 0.012],+ [lureTip[0] + d[0] * 0.0215, lureTip[1] + d[1] * 0.0215, lureTip[2] + d[2] * 0.0215],+ 0.0011, glowMat, { segments: 5, parent: fish });+ }++ // ---- fins -----------------------------------------------------------------+ for (const s of [-1, 1]) {+ const th = s > 0 ? 1.80 : -1.80;+ const p = surfacePoint(0.505, th);+ const n = baseNormal(0.505, th);+ const fin = await buildFin('PectoralFin' + (s > 0 ? 'R' : 'L'),+ fanRays(9, -0.66, 0.74, 0.0385, 0.0215, 0.07), 0.0028, finMat, skin, fish);+ fin.position.set(p[0] - n[0] * 0.003, p[1] - n[1] * 0.003, p[2] - n[2] * 0.003);+ orientX(fin, norm([-0.78, -0.12, 0.50 * s]), [0.06, 1, 0.12 * s]);+ }++ for (const s of [-1, 1]) {+ const th = s > 0 ? 2.44 : -2.44;+ const p = surfacePoint(0.640, th);+ const fin = await buildFin('PelvicFin' + (s > 0 ? 'R' : 'L'),+ fanRays(7, -0.58, 0.62, 0.0245, 0.0135, 0.08), 0.0024, finMat, skin, fish);+ fin.position.set(p[0], Math.max(p[1], 0.0080), p[2]);+ orientX(fin, norm([-0.84, 0.06, 0.48 * s]), [0.10, 1, 0.05 * s]);+ }++ {+ const p = surfacePoint(0.215, 0);+ const dorsal = await buildFin('DorsalFin',+ fanRays(7, -0.30, 0.95, 0.0250, 0.0115, 0.09), 0.0024, finMat, skin, fish);+ dorsal.position.set(p[0] + 0.003, p[1] - 0.0015, 0);+ orientX(dorsal, norm([-0.36, 0.93, 0]), [0, 0, 1]);+ }+ {+ const p = surfacePoint(0.230, Math.PI);+ const anal = await buildFin('AnalFin',+ fanRays(6, -0.26, 0.60, 0.0205, 0.0105, 0.09), 0.0024, finMat, skin, fish);+ anal.position.set(p[0] + 0.003, Math.max(p[1], 0.0065), 0);+ orientX(anal, norm([-0.94, -0.12, 0]), [0, 0, 1]);+ }+ {+ const st = stationByU(0.060);+ const caudal = await buildFin('CaudalFin',+ fanRays(13, -0.92, 0.92, 0.0625, 0.0415, 0.055), 0.0026, finMat, skin, fish);+ caudal.position.set(st.x + 0.002, st.cy, 0);+ orientX(caudal, [-1, 0.03, 0], [0, 0, 1]);+ }++ // ---- fit strictly inside the shoebox --------------------------------------+ const box = new THREE.Box3().setFromObject(fish);+ const size = new THREE.Vector3();+ box.getSize(size);+ fish.scale.setScalar(Math.min(0.42 / size.x, 0.20 / size.y, 0.13 / size.z));+ const fitted = new THREE.Box3().setFromObject(fish);+ const c = new THREE.Vector3();+ fitted.getCenter(c);+ fish.position.set(-c.x, -fitted.min.y, -c.z);++ meta.tris = countTriangles(root);+ return root;+}diff --git a/examples/astronomical-clock.kiln.js b/examples/astronomical-clock.kiln.jsnew file mode 100644index 00000000..c0a58399--- /dev/null+++ b/examples/astronomical-clock.kiln.js@@ -0,0 +1,623 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'AstronomicalClock', category: 'prop' };++function build() {+ const root = createRoot('AstronomicalClock');++ // --- Shared Materials ---+ const stoneLight = gameMaterial(0xa09a8f, { roughness: 0.85, metalness: 0.04 });+ const stoneMid = gameMaterial(0x7e786e, { roughness: 0.88, metalness: 0.05 });+ const stoneDark = gameMaterial(0x48443e, { roughness: 0.92, metalness: 0.06 });+ const stoneRoof = gameMaterial(0x3e4244, { roughness: 0.8, metalness: 0.1 }); // slate roofing+ const gilt = gameMaterial(0xdfb43a, { roughness: 0.32, metalness: 0.88 }); // polished gold leaf+ const brass = gameMaterial(0xba8f30, { roughness: 0.38, metalness: 0.82 });+ const dialBlue = gameMaterial(0x13274e, { roughness: 0.42, metalness: 0.18 }); // deep lapis/cobalt+ const dialDark = gameMaterial(0x0a1426, { roughness: 0.5, metalness: 0.15 }); // night horizon+ const dialEarth = gameMaterial(0x2d4838, { roughness: 0.6, metalness: 0.1 }); // terra centrum+ const iron = gameMaterial(0x1f2024, { roughness: 0.68, metalness: 0.72 }); // wrought iron+ const moonLight = gameMaterial(0xe8e5db, { roughness: 0.35, metalness: 0.35 });+ const moonDark = gameMaterial(0x151618, { roughness: 0.75, metalness: 0.2 });++ // =========================================================================+ // 1. PLINTH & FOUNDATION (sitting firmly on Y=0)+ // =========================================================================+ createPart('PlinthStep1', boxGeo(1.0, 0.25, 3.4), stoneDark, {+ position: [-0.15, 0.125, 0],+ parent: root+ });+ createPart('PlinthStep2', boxGeo(0.92, 0.2, 3.2), stoneMid, {+ position: [-0.15, 0.35, 0],+ parent: root+ });+ createPart('PlinthMoulding', boxGeo(0.86, 0.1, 3.08), stoneLight, {+ position: [-0.13, 0.5, 0],+ parent: root+ });++ for (const side of [-1, 1]) {+ createPart(`PlinthButtress_${side}`, boxGeo(0.96, 0.48, 0.36), stoneDark, {+ position: [-0.15, 0.24, side * 1.55],+ parent: root+ });+ }++ createPart('TowerBackWall', boxGeo(0.5, 5.0, 2.9), stoneDark, {+ position: [-0.4, 3.05, 0],+ parent: root+ });+ createPart('TowerBackGable', boxGeo(0.48, 1.4, 2.7), stoneDark, {+ position: [-0.38, 6.2, 0],+ parent: root+ });++ // =========================================================================+ // 2. LOWER NICHE: CLOCKWORK & PENDULUM CHAMBER (Y = 0.55 to 2.3)+ // =========================================================================+ createPart('ChamberBack', boxGeo(0.1, 1.7, 1.5), stoneDark, {+ position: [-0.22, 1.45, 0],+ parent: root+ });+ createPart('ChamberFloor', boxGeo(0.4, 0.08, 1.5), stoneMid, {+ position: [-0.05, 0.58, 0],+ parent: root+ });+ createPart('ChamberWallLeft', boxGeo(0.45, 1.7, 0.3), stoneMid, {+ position: [-0.05, 1.45, -0.85],+ parent: root+ });+ createPart('ChamberWallRight', boxGeo(0.45, 1.7, 0.3), stoneMid, {+ position: [-0.05, 1.45, 0.85],+ parent: root+ });++ for (const side of [-1, 1]) {+ createPart(`NicheJamb_${side}`, boxGeo(0.12, 1.3, 0.14), stoneLight, {+ position: [0.12, 1.25, side * 0.7],+ parent: root+ });+ createPart(`NicheJambCap_${side}`, boxGeo(0.16, 0.08, 0.18), stoneLight, {+ position: [0.12, 1.94, side * 0.7],+ parent: root+ });+ }+ createPart('NicheLintel', boxGeo(0.18, 0.18, 1.6), stoneLight, {+ position: [0.11, 2.05, 0],+ parent: root+ });+ createPart('NicheKeystone', boxGeo(0.22, 0.24, 0.16), stoneLight, {+ position: [0.13, 2.08, 0],+ parent: root+ });++ // Clockwork Mechanism inside chamber+ createPart('GearBigDisc', cylinderXGeo(0.32, 0.32, 0.03, 16), brass, {+ position: [-0.15, 1.65, 0.25],+ parent: root+ });+ createPart('GearBigRim', torusGeo(0.32, 0.015, 6, 20), gilt, {+ position: [-0.15, 1.65, 0.25],+ rotation: [0, 90, 0],+ parent: root+ });+ for (let t = 0; t < 12; t++) {+ const tAng = (t / 12) * Math.PI * 2;+ createPart(`GearBigTooth_${t}`, boxGeo(0.03, 0.06, 0.03), brass, {+ position: [-0.15, 1.65 + Math.cos(tAng) * 0.33, 0.25 + Math.sin(tAng) * 0.33],+ rotation: [0, 0, -(tAng * 180 / Math.PI)],+ parent: root+ });+ }++ createPart('GearPinionDisc', cylinderXGeo(0.14, 0.14, 0.04, 12), iron, {+ position: [-0.13, 1.65, -0.22],+ parent: root+ });+ for (let p = 0; p < 8; p++) {+ const pAng = (p / 8) * Math.PI * 2;+ createPart(`GearPinTooth_${p}`, boxGeo(0.04, 0.04, 0.025), iron, {+ position: [-0.13, 1.65 + Math.cos(pAng) * 0.15, -0.22 + Math.sin(pAng) * 0.15],+ rotation: [0, 0, -(pAng * 180 / Math.PI)],+ parent: root+ });+ }++ createPart('GearArborBig', cylinderXGeo(0.03, 0.03, 0.18, 8), iron, {+ position: [-0.14, 1.65, 0.25],+ parent: root+ });+ createPart('GearArborSmall', cylinderXGeo(0.025, 0.025, 0.18, 8), iron, {+ position: [-0.13, 1.65, -0.22],+ parent: root+ });+ // The movement frame, bolted to the back wall rather than standing 30 mm in+ // front of it. The wall face is at x = -0.15 and these uprights were centred+ // at -0.10, which left the left-hand one touching nothing at all -- the right+ // one only escaped the warning because a gear arbor happened to reach it.+ // At -0.14 both bite 10 mm into the stone, which is where a clock frame is+ // actually fixed.+ createPart('FrameStrutLeft', boxGeo(0.04, 1.2, 0.04), iron, {+ position: [-0.14, 1.45, -0.45],+ parent: root+ });+ createPart('FrameStrutRight', boxGeo(0.04, 1.2, 0.04), iron, {+ position: [-0.14, 1.45, 0.45],+ parent: root+ });++ // PENDULUM ASSEMBLY (Lifted cleanly above the chamber floor)+ const pendulumPivot = createPivot('Pendulum', [0.02, 2.15, 0], root);+ createPart('SuspensionBlock', boxGeo(0.06, 0.08, 0.08), iron, {+ position: [0, 0, 0],+ parent: pendulumPivot+ });+ createPart('PendulumRod', cylinderGeo(0.014, 0.014, 1.2, 8), iron, {+ position: [0, -0.6, 0],+ parent: pendulumPivot+ });+ createPart('PendulumBobLens', cylinderXGeo(0.24, 0.24, 0.05, 20), brass, {+ position: [0, -1.12, 0],+ parent: pendulumPivot+ });+ createPart('PendulumBobRim', torusGeo(0.24, 0.02, 6, 20), gilt, {+ position: [0, -1.12, 0],+ rotation: [0, 90, 0],+ parent: pendulumPivot+ });+ createPart('PendulumBobCenter', sphereGeo(0.07, 10, 8), gilt, {+ position: [0.028, -1.12, 0],+ parent: pendulumPivot+ });+ createPart('PendulumRatingNut', cylinderGeo(0.022, 0.022, 0.08, 8), brass, {+ position: [0, -1.28, 0],+ parent: pendulumPivot+ });++ // =========================================================================+ // 3. MAIN STONE SURROUND & FLANKING PILASTERS (Y = 2.1 to 5.3)+ // =========================================================================+ const dialCenterY = 3.8;+ const dialRadius = 1.22;++ createPart('MidCornice', boxGeo(0.72, 0.16, 3.0), stoneLight, {+ position: [-0.08, 2.22, 0],+ parent: root+ });++ createPart('DialSurroundWall', boxGeo(0.3, 2.9, 2.8), stoneMid, {+ position: [-0.15, dialCenterY, 0],+ parent: root+ });++ for (const side of [-1, 1]) {+ const z = side * 1.4;+ createPart(`PilasterPlinth_${side}`, boxGeo(0.5, 0.35, 0.38), stoneDark, {+ position: [-0.02, 2.45, z],+ parent: root+ });+ createPart(`PilasterBaseMould_${side}`, boxGeo(0.46, 0.12, 0.34), stoneLight, {+ position: [0.01, 2.68, z],+ parent: root+ });+ createPart(`PilasterShaft_${side}`, cylinderGeo(0.14, 0.15, 2.25, 12), stoneLight, {+ position: [0.06, 3.85, z],+ parent: root+ });+ for (let f = -2; f <= 2; f++) {+ const fAng = (f * 25) * Math.PI / 180;+ createPart(`Flute_${side}_${f}`, boxGeo(0.02, 2.15, 0.02), stoneDark, {+ position: [0.06 + Math.cos(fAng) * 0.14, 3.85, z + Math.sin(fAng) * 0.14],+ parent: root+ });+ }+ createPart(`PilasterCapitalMould_${side}`, boxGeo(0.42, 0.12, 0.36), stoneLight, {+ position: [0.03, 5.03, z],+ parent: root+ });+ createPart(`PilasterAbacus_${side}`, boxGeo(0.48, 0.12, 0.42), stoneDark, {+ position: [0.02, 5.15, z],+ parent: root+ });+ }++ createPart('ArchivoltOuter', torusGeo(1.36, 0.07, 6, 24), stoneLight, {+ position: [0.02, dialCenterY, 0],+ rotation: [0, 90, 0],+ parent: root+ });+ createPart('ArchivoltInner', torusGeo(1.26, 0.04, 6, 24), stoneDark, {+ position: [0.03, dialCenterY, 0],+ rotation: [0, 90, 0],+ parent: root+ });++ const spandrelR = 1.32;+ for (const sy of [-1, 1]) {+ for (const sz of [-1, 1]) {+ createPart(`SpandrelBoss_${sy}_${sz}`, cylinderXGeo(0.08, 0.08, 0.04, 10), gilt, {+ position: [0.04, dialCenterY + sy * spandrelR * 0.72, sz * spandrelR * 0.72],+ parent: root+ });+ }+ }++ // =========================================================================+ // 4. CANOPY, ENTABLATURE & GOTHIC PEDIMENT (Y = 5.2 to 6.8)+ // =========================================================================+ createPart('Architrave', boxGeo(0.56, 0.14, 3.2), stoneLight, {+ position: [0.02, 5.28, 0],+ parent: root+ });+ createPart('Frieze', boxGeo(0.52, 0.2, 3.12), stoneMid, {+ position: [0.01, 5.45, 0],+ parent: root+ });+ for (let c = -4; c <= 4; c++) {+ createPart(`Corbel_${c}`, boxGeo(0.18, 0.12, 0.08), stoneLight, {+ position: [0.15, 5.46, c * 0.35],+ parent: root+ });+ }+ createPart('CorniceBand', boxGeo(0.66, 0.14, 3.38), stoneLight, {+ position: [0.06, 5.62, 0],+ parent: root+ });++ createPart('TympanumWall', boxGeo(0.4, 0.9, 2.5), stoneMid, {+ position: [0.02, 6.1, 0],+ parent: root+ });+ createPart('TympanumSun', cylinderXGeo(0.2, 0.2, 0.04, 12), gilt, {+ position: [0.22, 6.1, 0],+ parent: root+ });+ for (let tr = 0; tr < 8; tr++) {+ const trAng = (tr / 8) * Math.PI * 2;+ createPart(`TympanumRay_${tr}`, coneGeo(0.04, 0.16, 5), gilt, {+ position: [0.23, 6.1 + Math.cos(trAng) * 0.26, Math.sin(trAng) * 0.26],+ rotation: [0, 0, (-tr * 45)],+ parent: root+ });+ }++ const rakeLength = 1.7;+ createPart('GableRakeLeft', boxGeo(0.5, 0.14, rakeLength), stoneLight, {+ position: [0.06, 6.15, -0.75],+ rotation: [36, 0, 0],+ parent: root+ });+ createPart('GableRakeRight', boxGeo(0.5, 0.14, rakeLength), stoneLight, {+ position: [0.06, 6.15, 0.75],+ rotation: [-36, 0, 0],+ parent: root+ });++ createPart('RoofSlopeLeft', boxGeo(0.46, 0.08, rakeLength), stoneRoof, {+ position: [-0.08, 6.16, -0.75],+ rotation: [36, 0, 0],+ parent: root+ });+ createPart('RoofSlopeRight', boxGeo(0.46, 0.08, rakeLength), stoneRoof, {+ position: [-0.08, 6.16, 0.75],+ rotation: [-36, 0, 0],+ parent: root+ });++ createPart('PinnacleApexBase', boxGeo(0.3, 0.2, 0.3), stoneLight, {+ position: [0.06, 6.7, 0],+ parent: root+ });+ createPart('PinnacleApexSpire', coneGeo(0.18, 0.65, 8), stoneLight, {+ position: [0.06, 7.1, 0],+ parent: root+ });+ createPart('ApexGiltCross', boxGeo(0.04, 0.22, 0.14), gilt, {+ position: [0.08, 7.45, 0],+ parent: root+ });++ for (const side of [-1, 1]) {+ const pz = side * 1.45;+ createPart(`PinnacleBase_${side}`, boxGeo(0.28, 0.3, 0.28), stoneLight, {+ position: [0.04, 5.8, pz],+ parent: root+ });+ createPart(`PinnacleShaft_${side}`, cylinderGeo(0.1, 0.12, 0.45, 8), stoneLight, {+ position: [0.04, 6.15, pz],+ parent: root+ });+ createPart(`PinnacleSpire_${side}`, coneGeo(0.13, 0.55, 8), stoneLight, {+ position: [0.04, 6.6, pz],+ parent: root+ });+ createPart(`PinnacleBall_${side}`, sphereGeo(0.06, 10, 8), gilt, {+ position: [0.04, 6.9, pz],+ parent: root+ });+ }++ // =========================================================================+ // 5. ASTRONOMICAL CLOCK FACE (Facing +X, normal along +X)+ // =========================================================================+ createPart('DialSkyDisc', cylinderXGeo(dialRadius, dialRadius, 0.035, 32), dialBlue, {+ position: [0.02, dialCenterY, 0],+ parent: root+ });+ createPart('DialHorizonDisc', cylinderXGeo(0.72, 0.72, 0.04, 24), dialDark, {+ position: [0.024, dialCenterY - 0.1, 0],+ parent: root+ });+ createPart('DialEarthDisc', cylinderXGeo(0.24, 0.24, 0.045, 16), dialEarth, {+ position: [0.028, dialCenterY, 0],+ parent: root+ });++ createPart('RingTropicCancer', torusGeo(1.18, 0.015, 6, 28), gilt, {+ position: [0.03, dialCenterY, 0],+ rotation: [0, 90, 0],+ parent: root+ });+ createPart('RingEquator', torusGeo(0.88, 0.012, 6, 24), gilt, {+ position: [0.03, dialCenterY, 0],+ rotation: [0, 90, 0],+ parent: root+ });+ createPart('RingTropicCapricorn', torusGeo(0.55, 0.012, 6, 24), gilt, {+ position: [0.03, dialCenterY, 0],+ rotation: [0, 90, 0],+ parent: root+ });++ createPart('DialOuterGiltBezel', torusGeo(dialRadius, 0.038, 8, 32), gilt, {+ position: [0.035, dialCenterY, 0],+ rotation: [0, 90, 0],+ parent: root+ });+ createPart('DialInnerGiltBezel', torusGeo(1.04, 0.024, 6, 28), gilt, {+ position: [0.035, dialCenterY, 0],+ rotation: [0, 90, 0],+ parent: root+ });++ for (let h = 0; h < 12; h++) {+ const hAngle = (h / 12) * Math.PI * 2;+ const hy = dialCenterY + Math.cos(hAngle) * 1.11;+ const hz = Math.sin(hAngle) * 1.11;+ const rotDeg = -h * 30;++ createPart(`HourCartouche_${h}`, cylinderXGeo(0.06, 0.06, 0.018, 10), gilt, {+ position: [0.038, hy, hz],+ parent: root+ });++ if (h === 0) {+ createPart('Num_XII_L', boxGeo(0.022, 0.07, 0.015), iron, {+ position: [0.048, hy, hz - 0.02],+ parent: root+ });+ createPart('Num_XII_R', boxGeo(0.022, 0.07, 0.015), iron, {+ position: [0.048, hy, hz + 0.02],+ parent: root+ });+ } else if (h === 3) {+ createPart('Num_III_1', boxGeo(0.022, 0.07, 0.012), iron, {+ position: [0.048, hy, hz - 0.02],+ parent: root+ });+ createPart('Num_III_2', boxGeo(0.022, 0.07, 0.012), iron, {+ position: [0.048, hy, hz + 0.02],+ parent: root+ });+ } else if (h === 6) {+ createPart('Num_VI_V', boxGeo(0.022, 0.07, 0.02), iron, {+ position: [0.048, hy, hz - 0.015],+ parent: root+ });+ createPart('Num_VI_I', boxGeo(0.022, 0.07, 0.012), iron, {+ position: [0.048, hy, hz + 0.02],+ parent: root+ });+ } else if (h === 9) {+ createPart('Num_IX_I', boxGeo(0.022, 0.07, 0.012), iron, {+ position: [0.048, hy, hz - 0.02],+ parent: root+ });+ createPart('Num_IX_X', boxGeo(0.022, 0.07, 0.02), iron, {+ position: [0.048, hy, hz + 0.015],+ parent: root+ });+ } else {+ createPart(`HourStud_${h}`, coneGeo(0.03, 0.035, 4), gilt, {+ position: [0.048, hy, hz],+ rotation: [0, 0, rotDeg + 45],+ parent: root+ });+ }+ }++ // =========================================================================+ // 6. INNER ROTATING ZODIAC RING (Eccentric Astrolabe Ecliptic Circle)+ // =========================================================================+ const zodiacCenterY = dialCenterY + 0.18;+ const zodiacCenterZ = -0.14;+ const zodiacR = 0.65;+ const zodiacBandWidth = 0.14;++ createPart('ZodiacOuterRim', torusGeo(zodiacR, 0.02, 6, 28), gilt, {+ position: [0.042, zodiacCenterY, zodiacCenterZ],+ rotation: [0, 90, 0],+ parent: root+ });+ createPart('ZodiacInnerRim', torusGeo(zodiacR - zodiacBandWidth, 0.016, 6, 24), brass, {+ position: [0.042, zodiacCenterY, zodiacCenterZ],+ rotation: [0, 90, 0],+ parent: root+ });++ for (let z = 0; z < 12; z++) {+ const zAng = (z / 12) * Math.PI * 2;+ const midRad = zodiacR - (zodiacBandWidth * 0.5);+ const zy = zodiacCenterY + Math.cos(zAng) * midRad;+ const zz = zodiacCenterZ + Math.sin(zAng) * midRad;+ const zRot = -z * 30;++ createPart(`ZodiacDivider_${z}`, boxGeo(0.018, zodiacBandWidth, 0.014), gilt, {+ position: [0.044, zy, zz],+ rotation: [0, 0, zRot],+ parent: root+ });++ const starAng = zAng + (Math.PI / 12);+ const starY = zodiacCenterY + Math.cos(starAng) * midRad;+ const starZ = zodiacCenterZ + Math.sin(starAng) * midRad;+ createPart(`ZodiacStar_${z}`, sphereGeo(0.022, 8, 6), gilt, {+ position: [0.046, starY, starZ],+ parent: root+ });+ createPart(`ZodiacPointer_${z}`, coneGeo(0.016, 0.07, 4), brass, {+ position: [0.044, zodiacCenterY + Math.cos(starAng) * (zodiacR + 0.035), zodiacCenterZ + Math.sin(starAng) * (zodiacR + 0.035)],+ rotation: [0, 0, -(starAng * 180 / Math.PI) - 90],+ parent: root+ });+ }++ // =========================================================================+ // 7. ARBOR, SUN HAND, MOON PHASE SPHERE & IRON HANDS+ // =========================================================================+ createPart('CenterArborBase', cylinderXGeo(0.14, 0.16, 0.06, 16), brass, {+ position: [0.05, dialCenterY, 0],+ parent: root+ });+ createPart('CenterArborBezel', torusGeo(0.14, 0.018, 6, 16), gilt, {+ position: [0.075, dialCenterY, 0],+ rotation: [0, 90, 0],+ parent: root+ });+ createPart('CenterArborDome', sphereGeo(0.075, 10, 8), gilt, {+ position: [0.09, dialCenterY, 0],+ parent: root+ });++ const sunAngle = -Math.PI * 0.28;+ const sunPivot = createPivot('SunHand', [0.056, dialCenterY, 0], root);+ createPart('SunHandArm', boxGeo(0.022, 0.96, 0.026), gilt, {+ position: [0, 0.48 * Math.cos(sunAngle), 0.48 * Math.sin(sunAngle)],+ rotation: [0, 0, (sunAngle * 180 / Math.PI) + 90],+ parent: sunPivot+ });+ const sunDist = 0.94;+ const sunPosY = sunDist * Math.cos(sunAngle);+ const sunPosZ = sunDist * Math.sin(sunAngle);++ createPart('SunDiscCore', cylinderXGeo(0.11, 0.11, 0.022, 16), gilt, {+ position: [0.01, sunPosY, sunPosZ],+ parent: sunPivot+ });+ createPart('SunFaceEmboss', sphereGeo(0.07, 10, 8), gilt, {+ position: [0.02, sunPosY, sunPosZ],+ parent: sunPivot+ });+ for (let r = 0; r < 12; r++) {+ const rAng = (r / 12) * Math.PI * 2;+ const rayR = 0.14;+ const ry = sunPosY + Math.cos(rAng) * rayR;+ const rz = sunPosZ + Math.sin(rAng) * rayR;+ if (r % 2 === 0) {+ createPart(`SunRayLong_${r}`, coneGeo(0.028, 0.14, 5), gilt, {+ position: [0.01, ry, rz],+ rotation: [0, 0, (-r * 30)],+ parent: sunPivot+ });+ } else {+ createPart(`SunRayShort_${r}`, coneGeo(0.022, 0.09, 4), brass, {+ position: [0.01, ry, rz],+ rotation: [0, 0, (-r * 30) + 45],+ parent: sunPivot+ });+ }+ }++ const moonAngle = Math.PI * 0.42;+ const moonPivot = createPivot('MoonHand', [0.065, dialCenterY, 0], root);+ createPart('MoonHandArm', boxGeo(0.02, 0.8, 0.02), brass, {+ position: [0, 0.4 * Math.cos(moonAngle), 0.4 * Math.sin(moonAngle)],+ rotation: [0, 0, (moonAngle * 180 / Math.PI) + 90],+ parent: moonPivot+ });+ const moonDist = 0.78;+ const moonY = moonDist * Math.cos(moonAngle);+ const moonZ = moonDist * Math.sin(moonAngle);++ createPart('MoonSphereDark', sphereGeo(0.082, 12, 10), moonDark, {+ position: [0.01, moonY, moonZ],+ parent: moonPivot+ });+ createPart('MoonPhaseLightCap', cylinderXGeo(0.084, 0.084, 0.025, 16), moonLight, {+ position: [0.02, moonY, moonZ],+ parent: moonPivot+ });+ createPart('MoonPhaseGiltBezel', torusGeo(0.086, 0.012, 6, 16), gilt, {+ position: [0.02, moonY, moonZ],+ rotation: [0, 90, 0],+ parent: moonPivot+ });+ createPart('MoonCrescentTip', coneGeo(0.018, 0.11, 5), brass, {+ position: [0.01, (moonDist + 0.13) * Math.cos(moonAngle), (moonDist + 0.13) * Math.sin(moonAngle)],+ rotation: [0, 0, (moonAngle * 180 / Math.PI) - 90],+ parent: moonPivot+ });++ const ironHourAng = Math.PI * 0.78;+ const hourPivot = createPivot('IronHourHand', [0.076, dialCenterY, 0], root);+ createPart('IronHourStem', boxGeo(0.018, 0.62, 0.03), iron, {+ position: [0, 0.28 * Math.cos(ironHourAng), 0.28 * Math.sin(ironHourAng)],+ rotation: [0, 0, (ironHourAng * 180 / Math.PI) + 90],+ parent: hourPivot+ });+ createPart('IronHourRing', torusGeo(0.09, 0.016, 6, 16), iron, {+ position: [0, 0.52 * Math.cos(ironHourAng), 0.52 * Math.sin(ironHourAng)],+ rotation: [0, 90, 0],+ parent: hourPivot+ });+ createPart('IronHourSpadeTip', coneGeo(0.042, 0.15, 4), iron, {+ position: [0, 0.68 * Math.cos(ironHourAng), 0.68 * Math.sin(ironHourAng)],+ rotation: [0, 0, (ironHourAng * 180 / Math.PI) - 90],+ parent: hourPivot+ });+ createPart('IronHourCounter', sphereGeo(0.045, 8, 6), iron, {+ position: [0, -0.16 * Math.cos(ironHourAng), -0.16 * Math.sin(ironHourAng)],+ parent: hourPivot+ });++ const ironMinAng = -Math.PI * 0.08;+ const minPivot = createPivot('IronMinuteHand', [0.086, dialCenterY, 0], root);+ createPart('IronMinStem', boxGeo(0.016, 1.05, 0.024), iron, {+ position: [0, 0.45 * Math.cos(ironMinAng), 0.45 * Math.sin(ironMinAng)],+ rotation: [0, 0, (ironMinAng * 180 / Math.PI) + 90],+ parent: minPivot+ });+ createPart('IronMinSpear', coneGeo(0.032, 0.16, 4), iron, {+ position: [0, 1.02 * Math.cos(ironMinAng), 1.02 * Math.sin(ironMinAng)],+ rotation: [0, 0, (ironMinAng * 180 / Math.PI) - 90],+ parent: minPivot+ });+ createPart('IronMinCrossbar', boxGeo(0.014, 0.02, 0.14), iron, {+ position: [0, 0.88 * Math.cos(ironMinAng), 0.88 * Math.sin(ironMinAng)],+ rotation: [0, 0, (ironMinAng * 180 / Math.PI) + 90],+ parent: minPivot+ });+ createPart('IronMinCounter', coneGeo(0.036, 0.15, 5), iron, {+ position: [0, -0.22 * Math.cos(ironMinAng), -0.22 * Math.sin(ironMinAng)],+ rotation: [0, 0, (ironMinAng * 180 / Math.PI) + 90],+ parent: minPivot+ });++ return root;+}diff --git a/examples/beam-engine.kiln.js b/examples/beam-engine.kiln.jsdeleted file mode 100644index d86aac2b..00000000--- a/examples/beam-engine.kiln.js+++ /dev/null@@ -1,382 +0,0 @@-// A Cornish rotative beam engine.-//-// Authored by: Claude Opus 5, via Claude Code. Every part below was written by-// the model itself, looking at its own renders through the Kiln tools and-// revising. Not a line of it is hand-authored.-//-// This is the only asset in the repository that MOVES, and it is here because-// `kiln_screenshot_animation` shipped with no example exercising it. An asset-// with an `animate()` is a different problem from a static one: the geometry-// has to be built in joints that can turn, and the joints have to turn in a way-// that survives being looked at.-//-// The interesting part is that the linkage is SOLVED, not eyeballed. A beam-// engine is a four-bar: the crank turns at constant speed, the beam rocks, and-// a connecting rod of fixed length joins them. Animating that by picking a-// plausible beam angle for each crank angle produces a rod that visibly-// stretches and shortens -- the single most obvious way to make a mechanism-// look fake. So `animate()` below bisects for the beam angle that holds the rod-// length exactly constant at every keyframe, then derives the connecting rod's-// own angle from the two endpoints it has to reach. Twenty-four keyframes of-// that read as a machine; twenty-four keyframes of guessing read as a toy.-//-// crank angle -> solve beam angle (rod length invariant) -> derive rod angle-// -> derive piston lift-//-// Known simplification, stated because the render will not show it: a real-// beam engine needs Watt's parallel motion to keep the piston rod vertical-// while the beam end swings through an arc. That linkage is here as geometry-// but is not articulated. The horizontal excursion it would correct is 33 mm-// over a 1.3 m beam, which is below what these views resolve.-const meta = { name: 'BeamEngine', category: 'prop', role: 'wonder' };--// Linkage constants. `animate()` needs the same numbers `build()` used, so they-// live at module scope rather than inside either one.-const BEAM_PIVOT = [0, 2.86, 0];-const BEAM_HALF = 1.30; // beam pivot to either end-const CRANK = [-1.30, 1.12, 0.30];-const CRANK_THROW = 0.30;-const FLYWHEEL_Z = 0.74;-const CYL_X = 1.30;-// Rod length that makes the beam rock symmetrically: the beam end must travel-// exactly as far as the crank pin does, so sin(phiMax) = throw / halfLength.-const PHI_MAX = Math.asin(CRANK_THROW / BEAM_HALF);-const ROD_LEN = Math.hypot(- -BEAM_HALF * Math.cos(PHI_MAX) - CRANK[0],- BEAM_PIVOT[1] + BEAM_HALF * Math.sin(PHI_MAX) - (CRANK[1] + CRANK_THROW),-);--async function build() {- const root = createRoot('BeamEngine');- const uv = (g) => autoUnwrap(g, { resolution: 1024 });-- // ---------- Materials ----------- // Cast iron, painted the dark bottle green every preserved engine wears.- // Painted iron is a DIELECTRIC; run it metallic and the whole frame becomes a- // mirror and every moulding on the columns disappears.- const ironAlbedo = proceduralTexture({- schemaVersion: 2, size: 1024, usage: 'albedo', name: 'EngineGreen',- layers: [- { op: 'solid', color: 0x1f3b32 },- { op: 'gradient', from: 0x2a4d42, to: 0x162b24, angleDeg: 90, blend: 'overlay', opacity: 0.5 },- { op: 'noise', colorA: 0x18302a, colorB: 0x2d5347, scale: 38, octaves: 4, seed: 9, blend: 'overlay', opacity: 0.40 },- ],- });- const iron = pbrMaterial({- albedo: ironAlbedo, normal: normalMapFromHeight(ironAlbedo, { strength: 1.8 }),- roughness: 0.46, metalness: 0.12,- });-- // Bearings, oilers, the governor. Polished brass is what the eye goes to, so- // it is spent only on the parts that actually rotate or need attention.- const brassAlbedo = proceduralTexture({- schemaVersion: 2, size: 512, usage: 'albedo', name: 'Brass',- layers: [- { op: 'solid', color: 0xb08d3c },- { op: 'noise', colorA: 0x8d6f2d, colorB: 0xd6b055, scale: 44, octaves: 3, seed: 21, blend: 'overlay', opacity: 0.45 },- ],- });- const brass = pbrMaterial({- albedo: brassAlbedo, normal: normalMapFromHeight(brassAlbedo, { strength: 1.0 }),- roughness: 0.24, metalness: 0.94,- });-- const steelAlbedo = proceduralTexture({- schemaVersion: 2, size: 512, usage: 'albedo', name: 'PolishedSteel',- layers: [- { op: 'solid', color: 0xb9bec4 },- { op: 'noise', colorA: 0xa4a9af, colorB: 0xd2d7dd, scale: 58, octaves: 2, seed: 5, blend: 'overlay', opacity: 0.30 },- ],- });- const steel = pbrMaterial({- albedo: steelAlbedo, normal: normalMapFromHeight(steelAlbedo, { strength: 0.7 }),- roughness: 0.16, metalness: 0.95,- });-- const stoneAlbedo = proceduralTexture({- schemaVersion: 2, size: 1024, usage: 'albedo', name: 'Ashlar',- layers: [- { op: 'solid', color: 0x8d8578 },- { op: 'bricks', brick: 0x9a9284, mortar: 0x6f685d, rows: 10, cols: 5, blend: 'overlay', opacity: 0.55 },- { op: 'noise', colorA: 0x6e675c, colorB: 0xa39b8d, scale: 30, octaves: 4, seed: 13, blend: 'overlay', opacity: 0.40 },- ],- });- const stone = pbrMaterial({- albedo: stoneAlbedo, normal: normalMapFromHeight(stoneAlbedo, { strength: 2.6 }),- roughness: 0.88, metalness: 0.0,- });-- // Cylinder lagging: wooden staves under brass bands, which is how a Victorian- // engine insulated a hot cylinder.- const laggingAlbedo = proceduralTexture({- schemaVersion: 2, size: 512, usage: 'albedo', name: 'Lagging',- layers: [- { op: 'solid', color: 0x5c4128 },- { op: 'stripes', colorA: 0x4a3320, colorB: 0x6d4e31, count: 30, angleDeg: 90, blend: 'overlay', opacity: 0.55 },- { op: 'noise', colorA: 0x3d2a1a, colorB: 0x6d4e31, scale: 40, octaves: 3, seed: 31, blend: 'overlay', opacity: 0.30 },- ],- });- const lagging = pbrMaterial({- albedo: laggingAlbedo, normal: normalMapFromHeight(laggingAlbedo, { strength: 2.0 }),- roughness: 0.80, metalness: 0.0,- });-- const box = async (name, w, h, d, r, position, mat, rotation, parent) =>- createPart(name, await uv(await roundedBoxGeo(w, h, d, r)), mat, {- position, rotation, parent: parent ?? root,- });-- // ---------- Bedplate ----------- await box('Plinth', 3.90, 0.30, 1.90, 0.03, [0, 0.15, 0], stone);- await box('Bedplate', 3.60, 0.14, 1.62, 0.02, [0, 0.37, 0], iron);- // Hold-down bolts around the bedplate edge.- for (let i = 0; i < 10; i++) {- const x = -1.62 + (i / 9) * 3.24;- for (const sz of [-1, 1]) {- createPart(`BedBolt_${i}${sz > 0 ? 'R' : 'L'}`, cylinderGeo(0.032, 0.032, 0.06, 8), steel, {- position: [x, 0.46, sz * 0.72], parent: root,- });- }- }-- // ---------- Entablature columns ----------- // Four Doric columns carrying the beam. The engine house style is the whole- // charm of these machines: they were built to be looked at.- for (const sx of [-1, 1]) {- for (const sz of [-1, 1]) {- const nm = `${sx > 0 ? 'F' : 'B'}${sz > 0 ? 'R' : 'L'}`;- const at = [sx * 0.46, 0, sz * 0.56];- await box(`ColBase_${nm}`, 0.34, 0.12, 0.34, 0.02, [at[0], 0.50, at[2]], iron);- createPart(`Column_${nm}`, await uv(await revolveProfile([- [0.000, 0.00], [0.132, 0.00], [0.126, 0.10], [0.112, 1.00],- [0.104, 1.78], [0.118, 1.86], [0.116, 1.94], [0.000, 1.94],- ], { segments: 24, axis: 'y', smooth: true })), iron, {- position: [at[0], 0.56, at[2]], parent: root,- });- await box(`ColCap_${nm}`, 0.30, 0.10, 0.30, 0.018, [at[0], 2.55, at[2]], iron);- }- }- // Entablature: the frame the beam bearing sits in.- for (const sz of [-1, 1]) {- await box(`Entab_${sz > 0 ? 'R' : 'L'}`, 1.36, 0.18, 0.26, 0.025, [0, 2.69, sz * 0.56], iron);- }- await box('EntabCross', 0.36, 0.16, 1.38, 0.025, [0, 2.69, 0], iron);- // Trunnion bearing pedestal and its brass caps.- await box('TrunnionBlock', 0.46, 0.24, 0.62, 0.03, [0, 2.86, 0], iron);- for (const sz of [-1, 1]) {- createPart(`TrunnionCap_${sz > 0 ? 'R' : 'L'}`, cylinderZGeo(0.098, 0.098, 0.10, 20), brass, {- position: [0, 2.86, sz * 0.32], parent: root,- });- createPart(`Oiler_${sz > 0 ? 'R' : 'L'}`, revolveProfile ? sphereGeo(0.036, 12, 8) : sphereGeo(0.036, 12, 8), brass, {- position: [0, 2.99, sz * 0.32], parent: root,- });- }-- // ---------- The beam ----------- // Everything that rocks lives under this pivot, so the animation moves one- // node and the strapwork, end pins and bolts come with it.- const beam = createPivot('Beam', BEAM_PIVOT, root);- const beamProfile = [- [-1.30, 0.030], [-1.06, 0.170], [0, 0.290], [1.06, 0.170], [1.30, 0.030],- [1.30, -0.030], [1.06, -0.170], [0, -0.290], [-1.06, -0.170], [-1.30, -0.030],- ];- createPart('BeamWeb', await uv(await extrudeProfile(beamProfile, {- depth: 0.20, axis: 'z', bevel: 0.014,- })), iron, { parent: beam });- // Strapwork: the wrought-iron straps a cast beam was reinforced with.- for (const sx of [-1, 1]) {- await box(`BeamStrap_${sx > 0 ? 'F' : 'B'}`, 0.06, 0.30, 0.24, 0.012,- [sx * 0.72, 0, 0], steel, undefined, beam);- createPart(`BeamEndPin_${sx > 0 ? 'F' : 'B'}`, cylinderZGeo(0.062, 0.062, 0.34, 16), brass, {- position: [sx * BEAM_HALF, 0, 0], parent: beam,- });- createPart(`BeamEndBoss_${sx > 0 ? 'F' : 'B'}`, cylinderZGeo(0.098, 0.098, 0.22, 16), iron, {- position: [sx * BEAM_HALF, 0, 0], parent: beam,- });- }- createPart('BeamHubBoss', cylinderZGeo(0.130, 0.130, 0.26, 20), iron, { parent: beam });- // Bolt rows down the beam web, the detail that says cast and bolted.- for (let i = 0; i < 7; i++) {- const x = -0.90 + i * 0.30;- for (const sy of [-1, 1]) {- createPart(`BeamBolt_${i}${sy > 0 ? 'T' : 'B'}`, cylinderZGeo(0.020, 0.020, 0.23, 8), steel, {- position: [x, sy * (0.115 - Math.abs(x) * 0.055), 0], parent: beam,- });- }- }-- // ---------- Cylinder ----------- // Lagged, banded, and standing on its own base. The piston rod comes out of- // the top and runs up to the beam.- await box('CylBase', 0.78, 0.16, 0.78, 0.025, [CYL_X, 0.52, 0], iron);- createPart('CylBody', await uv(await revolveProfile([- [0.000, 0.00], [0.330, 0.00], [0.330, 0.10], [0.300, 0.14],- [0.300, 1.06], [0.330, 1.10], [0.330, 1.20], [0.000, 1.20],- ], { segments: 32, axis: 'y', smooth: true })), lagging, {- position: [CYL_X, 0.60, 0], parent: root,- });- for (let i = 0; i < 4; i++) {- createPart(`CylBand_${i}`, torusGeo(0.312, 0.020, 8, 32), brass, {- position: [CYL_X, 0.82 + i * 0.24, 0], rotation: [90, 0, 0], parent: root,- });- }- createPart('CylTopCover', cylinderGeo(0.345, 0.345, 0.09, 32), iron,- { position: [CYL_X, 1.84, 0], parent: root });- createPart('CylStuffingBox', cylinderGeo(0.115, 0.140, 0.16, 20), brass,- { position: [CYL_X, 1.94, 0], parent: root });- // Cover bolts.- for (let i = 0; i < 12; i++) {- const a = (i / 12) * Math.PI * 2;- createPart(`CylCoverBolt_${i}`, cylinderGeo(0.020, 0.020, 0.05, 8), steel, {- position: [CYL_X + Math.cos(a) * 0.295, 1.90, Math.sin(a) * 0.295], parent: root,- });- }- // Steam chest and pipework on the outboard face.- await box('SteamChest', 0.20, 0.72, 0.30, 0.025, [CYL_X + 0.40, 1.16, 0], iron);- createPart('SteamPipe', cylinderGeo(0.070, 0.070, 0.90, 16), brass,- { position: [CYL_X + 0.40, 0.98, 0.34], rotation: [12, 0, 0], parent: root });- createPart('SteamElbow', torusGeo(0.070, 0.070, 8, 18), brass,- { position: [CYL_X + 0.40, 1.54, 0.28], rotation: [0, 90, 0], parent: root });-- // ---------- Piston rod and crosshead ----------- const pist = createPivot('PistonRod', [CYL_X, 0, 0], root);- createPart('PistonRod', cylinderGeo(0.048, 0.048, 1.05, 16), steel,- { position: [0, 2.36, 0], parent: pist });- await box('Crosshead', 0.20, 0.16, 0.30, 0.03, [0, 2.79, 0], iron, undefined, pist);- createPart('CrossheadPin', cylinderZGeo(0.052, 0.052, 0.40, 14), brass,- { position: [0, 2.79, 0], parent: pist });- // Watt's parallel motion, as geometry. See the header: it is not articulated.- for (const sz of [-1, 1]) {- beamBetween(`ParallelLink_${sz > 0 ? 'R' : 'L'}`,- [CYL_X - 0.02, 2.76, sz * 0.13], [CYL_X - 0.46, 2.56, sz * 0.13], 0.022, iron, { parent: root });- }-- // ---------- Flywheel and crank ----------- const fly = createPivot('Flywheel', [CRANK[0], CRANK[1], FLYWHEEL_Z], root);- // No solid web between the spokes: the first pass had a full disc face here,- // which hid all eight spokes and turned the flywheel into a plate.- createPart('FlywheelRim', torusGeo(0.700, 0.070, 12, 56), iron, { parent: fly });- createPart('FlywheelRimInner', torusGeo(0.640, 0.030, 8, 48), iron, { parent: fly });- createPart('FlywheelHub', cylinderZGeo(0.140, 0.140, 0.28, 22), iron, { parent: fly });- const flySpoke = createPart('FlywheelSpoke0',- await uv(await roundedBoxGeo(0.075, 0.58, 0.075, 0.020)), iron,- { position: [0, 0.40, 0], parent: fly });- arrayRadial('FlywheelSpoke', flySpoke, 8, 'z', fly);-- // Main shaft runs from the flywheel through its bearing to the crank.- createPart('MainShaft', cylinderZGeo(0.075, 0.075, 0.90, 20), steel,- { position: [CRANK[0], CRANK[1], 0.42], parent: root });- await box('ShaftPedestal', 0.42, 0.66, 0.30, 0.03, [CRANK[0], 0.78, 0.16], iron);- createPart('ShaftBearing', cylinderZGeo(0.115, 0.115, 0.22, 20), brass,- { position: [CRANK[0], CRANK[1], 0.16], parent: root });-- // The crank turns with the flywheel; the connecting rod hangs off its pin.- const crank = createPivot('Crank', CRANK, root);- await box('CrankWeb', 0.44, 0.16, 0.09, 0.025, [CRANK_THROW / 2, 0, 0], steel, undefined, crank);- createPart('CrankPin', cylinderZGeo(0.055, 0.055, 0.20, 16), brass,- { position: [CRANK_THROW, 0, 0], parent: crank });-- // The connecting rod is a CHILD of the crank, so it inherits the pin's orbit- // and only needs to correct its own angle. Built pointing +Y from the pin.- const rod = createPivot('ConRod', [CRANK_THROW, 0, 0], crank);- createPart('ConRodShaft', cylinderGeo(0.052, 0.064, ROD_LEN - 0.16, 16), steel,- { position: [0, ROD_LEN / 2, 0], parent: rod });- createPart('ConRodBigEnd', cylinderZGeo(0.090, 0.090, 0.16, 18), brass, { parent: rod });- createPart('ConRodSmallEnd', cylinderZGeo(0.072, 0.072, 0.15, 18), brass,- { position: [0, ROD_LEN, 0], parent: rod });- for (const sy of [0, 1]) {- createPart(`ConRodStrap_${sy}`, await uv(await roundedBoxGeo(0.15, 0.09, 0.19, 0.020)), steel,- { position: [0, sy * ROD_LEN + (sy ? -0.10 : 0.10), 0], parent: rod });- }-- // ---------- Governor ----------- // Watt's centrifugal governor, on its own pedestal, belt-driven off the- // shaft. It spins, which is most of why these engines look alive.- await box('GovPedestal', 0.26, 0.92, 0.26, 0.03, [-0.30, 1.00, -0.62], iron);- const gov = createPivot('Governor', [-0.30, 1.46, -0.62], root);- createPart('GovSpindle', cylinderGeo(0.030, 0.030, 0.44, 12), steel, { position: [0, 0.10, 0], parent: gov });- createPart('GovCollar', cylinderGeo(0.070, 0.070, 0.05, 16), brass, { position: [0, 0.30, 0], parent: gov });- for (const sx of [-1, 1]) {- beamBetween(`GovArm_${sx > 0 ? 'A' : 'B'}`,- [0, 0.30, 0], [sx * 0.20, -0.02, 0], 0.014, steel, { parent: gov });- createPart(`GovBall_${sx > 0 ? 'A' : 'B'}`, sphereGeo(0.062, 16, 12), brass,- { position: [sx * 0.23, -0.06, 0], parent: gov });- beamBetween(`GovLink_${sx > 0 ? 'A' : 'B'}`,- [sx * 0.16, 0.06, 0], [0, -0.10, 0], 0.010, steel, { parent: gov });- }- createPart('GovCap', cylinderGeo(0.045, 0.045, 0.05, 14), brass, { position: [0, 0.34, 0], parent: gov });-- return root;-}--// The four-bar solve. For a crank angle, find the beam angle that keeps the-// connecting rod exactly ROD_LEN long, then read the rod's own angle off the-// two endpoints. Bisection, because the distance function is monotonic in the-// beam angle over the range the beam can physically reach and 40 halvings is-// far more precision than a keyframe needs.-function animate() {- const FRAMES = 24;- const DUR = 3.0;- const DEG = 180 / Math.PI;-- const pinAt = (theta) => [- CRANK[0] + CRANK_THROW * Math.cos(theta),- CRANK[1] + CRANK_THROW * Math.sin(theta),- ];- const beamEndAt = (phi) => [- -BEAM_HALF * Math.cos(phi),- BEAM_PIVOT[1] - BEAM_HALF * Math.sin(phi),- ];- const solvePhi = (theta) => {- const P = pinAt(theta);- // f decreases as phi grows, because the beam end swings down toward the pin.- const f = (phi) => {- const E = beamEndAt(phi);- return Math.hypot(E[0] - P[0], E[1] - P[1]) - ROD_LEN;- };- let lo = -0.6;- let hi = 0.6;- for (let i = 0; i < 40; i++) {- const m = (lo + hi) / 2;- if (f(m) > 0) lo = m; else hi = m;- }- return (lo + hi) / 2;- };-- const beamKeys = [];- const flyKeys = [];- const crankKeys = [];- const rodKeys = [];- const pistonKeys = [];- const govKeys = [];-- for (let i = 0; i <= FRAMES; i++) {- const t = (i / FRAMES) * DUR;- const theta = (i / FRAMES) * Math.PI * 2;- const phi = solvePhi(theta);- const P = pinAt(theta);- const E = beamEndAt(phi);- // World angle of the rod, then strip the parent crank's rotation. A part- // built along +Y and turned by a about Z points at (-sin a, cos a), so- // reaching heading psi needs a = psi - 90 degrees.- const psi = Math.atan2(E[1] - P[1], E[0] - P[0]);- const rodLocal = (psi - Math.PI / 2 - theta) * DEG;-- beamKeys.push({ time: t, rotation: [0, 0, phi * DEG] });- flyKeys.push({ time: t, rotation: [0, 0, theta * DEG] });- crankKeys.push({ time: t, rotation: [0, 0, theta * DEG] });- rodKeys.push({ time: t, rotation: [0, 0, rodLocal] });- // The far beam end lifts as the near end falls, and the piston rod follows.- pistonKeys.push({ time: t, position: [0, BEAM_HALF * Math.sin(phi), 0] });- govKeys.push({ time: t, rotation: [0, theta * 2 * DEG, 0] });- }-- return [createClip('Run', DUR, [- rotationTrack('Joint_Beam', beamKeys),- rotationTrack('Joint_Flywheel', flyKeys),- rotationTrack('Joint_Crank', crankKeys),- rotationTrack('Joint_ConRod', rodKeys),- positionTrack('Joint_PistonRod', pistonKeys),- rotationTrack('Joint_Governor', govKeys),- ])];-}diff --git a/examples/blast-furnace.kiln.js b/examples/blast-furnace.kiln.jsnew file mode 100644index 00000000..489666d1--- /dev/null+++ b/examples/blast-furnace.kiln.js@@ -0,0 +1,122 @@+// Authored by: gpt-6-astra, via codex.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'BlastFurnace', category: 'architecture' };++function build() {+ const root = createRoot('BlastFurnace');+ const steel = gameMaterial(0x536168, {metalness:0.6, roughness:0.65});+ const dark = gameMaterial(0x2e3639, {metalness:0.5, roughness:0.8});+ const rust = gameMaterial(0x89523a, {metalness:0.35, roughness:0.85});+ const brick = gameMaterial(0x784b3d);+ const concrete = gameMaterial(0x77766c);+ const rail = gameMaterial(0xc29b48, {metalness:0.35, roughness:0.65});+ const molten = gameMaterial(0xeb641c,{emissive:0xff4308,emissiveIntensity:0.6});+ let id=0;+ const part=(n,g,m,p=[0,0,0],r=[0,0,0])=>createPart(n+'_'+id++,g,m,{position:p,rotation:r,parent:root});+ const box=(n,s,p,m=steel)=>part(n,boxGeo(...s),m,p);+ const cyl=(n,rt,rb,h,p,m=steel,segs=16)=>part(n,cylinderGeo(rt,rb,h,segs),m,p);+ const beam=(n,a,b,r=0.06,m=steel,segs=3)=>beamBetween(n+'_'+id++,a,b,r,m,{segments:segs,parent:root});+ const pipe=(n,points,r)=>part(n,pipeAlongPath(points,r,{bendRadius:0.5,tubularSegments:14,radialSegments:6}),steel);+ const ring=(n,r,y,t=0.07,m=rust,x=0,z=0)=>part(n,torusGeo(r,t,4,16),m,[x,y,z],[90,0,0]);+ box('Foundation',[24,0.5,22],[-1,0.25,3],concrete);+ cyl('Hearth',2.3,2.3,3,[0,2,0],brick);+ cyl('RefractoryBosh',3.3,2.3,3,[0,5,0],brick);+ cyl('FurnaceStack',1.65,3.3,12,[0,12.5,0]);+ cyl('Throat',1.65,1.65,2,[0,19.5,0]);+ cyl('ChargingBell',0.45,1.6,0.9,[0,20.95,0],rust);+ for(let i=0;i<8;i++){+ const a=i*Math.PI/4, b=a+Math.PI/4;+ box('RingColumn',[0.45,6,0.45],[3.4*Math.cos(a),3.5,3.4*Math.sin(a)]);+ beam('ColumnRingBrace',[3.4*Math.cos(a),1.2,3.4*Math.sin(a)],[3.4*Math.cos(b),6.4,3.4*Math.sin(b)],0.1);+ }+ for(const y of [7,12,17]){+ const inner=3.3-(y-6.5)*1.65/12;+ part('AnnularWalkway',lathe([[inner,y-0.14],[4,y-0.14],[4,y],[inner,y],[inner,y-0.14]],16),dark);+ ring('WalkwayHandrail',4,y+1.05,0.055,rail);+ ring('WalkwayMidrail',4,y+0.52,0.04,rail);+ for(let j=0;j<16;j++){+ const a=j*Math.PI/8;+ beam('HandrailPost',[4*Math.cos(a),y,4*Math.sin(a)],[4*Math.cos(a),y+1.05,4*Math.sin(a)],0.045,rail);+ beam('WalkwayBracket',[inner*Math.cos(a),y-0.85,inner*Math.sin(a)],[3.9*Math.cos(a),y-0.14,3.9*Math.sin(a)],0.065);+ }+ }+ for(let i=0;i<3;i++){+ const x=-5+i*4.5;+ cyl('StoveFooting',1.85,1.85,0.4,[x,0.7,8],concrete);+ cyl('HotBlastStove',1.65,1.65,10.6,[x,6.2,8]);+ part('StoveDomedCrown',lathe([[1.65,0],[1.52,0.65],[1.1,1.2],[0.5,1.55],[0,1.65]],16),steel,[x,11.5,8]);+ for(const y of [1.1,4,7,10.8])ring('StoveSeam',1.66,y,0.045,rust,x,8);+ pipe('StoveHotOutlet',[[x,2.8,6.5],[x,2.8,5.5],[x,4.8,5.2]],0.38);+ box('StoveAccessDoor',[0.8,1.3,0.15],[x,1.6,9.66],dark);+ }+ pipe('HotBlastHeader',[[-5,4.8,5.2],[4.5,4.8,5.2],[4.5,4.8,1],[3.25,4.8,0]],0.48);+ ring('BustleMain',3.15,4.8,0.3,steel);+ for(let i=0;i<8;i++){const a=i*Math.PI/4;beam('Tuyere',[3.15*Math.cos(a),4.8,3.15*Math.sin(a)],[2.4*Math.cos(a),3.3,2.4*Math.sin(a)],0.15,rust,8);}+ pipe('MainDowncomer',[[0,19.7,1.3],[0,21.7,2.5],[1,21.7,3.8],[5.8,14,4],[7,8,4]],0.55);+ pipe('SecondaryOfftake',[[1.2,19.7,-0.3],[2.3,21.3,0],[3.5,20.7,2.5],[5.8,14,4]],0.35);+ cyl('DustCatcher',1.25,1.25,4,[7,6,4]);+ cyl('DustHopper',1.25,0.35,2,[7,3,4],rust);+ for(const x of [6,8])for(const z of [3.2,4.8])box('DustCatcherLeg',[0.2,3.5,0.2],[x,2.25,z]);+ pipe('CleanGasMain',[[7,7,4],[8,7,5.5],[8,6,10],[4,6,10]],0.35);+ // Incline truss: common interpolation keeps all bays on the two rails.+ const at=(t,z,low=0)=>[-10+9*t,0.85+20*t-low,z];+ for(const z of [-0.9,0.9]){+ beam('SkipUpperChord',at(0,z),at(1,z),0.12);+ beam('SkipLowerChord',at(0,z,0.7),at(1,z,0.7),0.12);+ for(let i=0;i<10;i++){beam('SkipWeb',at(i/10,z),at((i+1)/10,z,0.7),0.065);beam('SkipCrossTie',at(i/10,-0.9),at(i/10,0.9),0.07);}+ }+ for(const t of [0.3,0.65])for(const z of [-0.9,0.9])beam('InclineTrestle',[-10+9*t,0.5,z],at(t,z,0.7),0.14);+ box('SkipCar',[1.3,1,2],at(0.67,0),rust);+ for(const x of [-2.4,2.4])for(const z of [-2,2]){+ box('ChargingGantryLeg',[0.24,5.4,0.24],[x,19.7,z]);+ beam('GantryKnee',[x,21.4,z],[0,22.3,z],0.09);+ }+ box('ChargingGantryCrosshead',[5.4,0.35,4.6],[0,22.55,0]);+ cyl('ChargingWinch',0.35,0.35,0.8,[0,22,0],rust);+ beam('BellSuspension',[0,21.3,0],[0,22.3,0],0.06,dark);+ // Riveted plate courses follow the taper of the shell.+ for(const y of [8.4,10.5,13.5,15.5,18.3]){+ const r=3.3-(y-6.5)*1.65/12;+ ring('ShellPlateSeam',r+0.025,y,0.045,rust);+ for(let j=0;j<12;j++){+ const a=j*Math.PI/6;+ part('ShellRivet',sphereGeo(0.075,4,3),rust,[(r+0.04)*Math.cos(a),y+0.13,(r+0.04)*Math.sin(a)]);+ }+ }+ // Three connected flights, consistently five metres between service decks.+ for(let level=0;level<3;level++){+ const startY=level===0?0.92:7+(level-1)*5;+ const rise=level===0?6.08:5;+ const sign=level%2===0?1:-1;+ const x0=-3*sign;+ const stairs=createStairs('ServiceStairs'+level,dark,{steps:22,totalRise:rise,totalRun:6,width:0.95,axis:'x',treadThickness:0.09,parent:root});+ stairs.root.position.set(x0,startY,-4.35);+ stairs.root.rotation.y=sign===1?0:Math.PI;+ for(const z of [-4.83,-3.87]){+ beam('StairStringer',[x0,startY-0.1,z],[-x0,startY+rise-0.1,z],0.09);+ beam('StairHandrail',[x0,startY+1,z],[-x0,startY+rise+1,z],0.045,rail);+ for(let j=0;j<=4;j++)beam('StairBaluster',[x0+sign*1.5*j,startY+rise*j/4,z],[x0+sign*1.5*j,startY+rise*j/4+1,z],0.04,rail);+ }+ box('StairLanding',[1.25,0.16,2.3],[-x0,startY+rise-0.08,-3.8],dark);+ }+ for(const x of [-3,3])box('StairTowerColumn',[0.18,16.5,0.18],[x,8.75,-4.65]);+ pipe('IronTapConnection',[[2.05,1.4,-0.6],[2.5,1,-1],[2.8,0.74,-2.7]],0.16);+ pipe('SlagTapConnection',[[2.15,2,0.6],[2.65,1.25,1],[2.8,0.74,0.7]],0.14);+ // Open cast house, front faces +X. Floor strips leave two real recessed channels.+ box('CastHouseSubfloor',[8,0.2,8],[6.2,0.6,-1],concrete);+ for(const [z,w] of [[-4,2],[-1,3],[2,2]])box('CastFloorBank',[8,0.22,w],[6.2,0.81,z],concrete);+ for(const z of [-2.7,0.7])box('RecessedRunner',[7.6,0.035,0.35],[6.2,0.72,z],molten);+ for(const x of [3,6.5,10])for(const z of [-5,3])box('CastHouseColumn',[0.22,5.1,0.22],[x,3.05,z]);+ for(const x of [3,6.5,10])box('CastHouseRoofBeam',[0.25,0.25,8.4],[x,5.5,-1]);+ const roof=createRoofPlanes('CastHouseRoof',rust,{width:7.5,depth:8.2,height:1.1,overhang:0.3,ridgeAxis:'x',thickness:0.12,parent:root});+ roof.root.position.set(6.5,5.625,-1);+ return root;+}+diff --git a/examples/cable-stayed-bridge.kiln.js b/examples/cable-stayed-bridge.kiln.jsnew file mode 100644index 00000000..20d6371d--- /dev/null+++ b/examples/cable-stayed-bridge.kiln.js@@ -0,0 +1,178 @@+// Authored by: opencode-go/omen-alpha, via opencode.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'CableStayedBridge', category: 'architecture' };++async function build() {+ const root = createRoot('CableStayedBridge');++ // ---------- one set of driving numbers ----------+ const DECK_HALF = 45; // deck runs X -45..+45+ const GIRDER_BOT = 6.9; // girder underside+ const GIRDER_TOP = 8.05; // top of box girder webs+ const SLAB_TOP = 8.3; // deck slab / road base+ const ROAD_W = 3.3; // road half width (two 3.3 lanes)+ const SLAB_HALF_W = 3.9; // slab half width+ const GIRDER_HALF_W = 3.2; // box girder half width+ const PYLON_H = 30; // pylon top+ const PYLON_LEG_Z = 5.05; // leg centreline Z+ const LEG_HALF_BOT = 0.95, LEG_HALF_TOP = 0.7;+ const CABLE_Z_DECK = 3.5; // deck anchor plane+ const CABLE_Z_TOP = 4.55; // pylon anchor plane (leg centre)+ const ANCHOR_X = [4.5, 9, 13.5, 18, 22.5, 27];+ const ANCHOR_TOP_Y = [29.6, 28.4, 27.0, 25.6, 24.4, 23.4];++ // ---------- materials ----------+ const conc = gameMaterial(0xc9c5bb, { roughness: 0.95 });+ const concDark = gameMaterial(0xa9a59b, { roughness: 0.95 });+ const asphalt = gameMaterial(0x35363a, { roughness: 1 });+ const paint = gameMaterial(0xe8e6e0, { roughness: 0.6 });+ const steel = gameMaterial(0x555b63, { metalness: 0.75, roughness: 0.4 });+ const lampMetal = gameMaterial(0x4b5560, { metalness: 0.6, roughness: 0.5 });+ const lampGlow = gameMaterial(0xfff2cc, { emissive: 0xffe9b0, emissiveIntensity: 1.2 });+ const beaconRed = gameMaterial(0xd23a2a, { emissive: 0xd22a1a, emissiveIntensity: 1.5 });++ // ---------- pylon pier (stepped river pier) ----------+ createPart('PylonPierFooting', await roundedBoxGeo(11.4, 0.7, 14.0, 0.15), concDark, { position: [0, 0.35, 0], parent: root });+ createPart('PylonPierBody', await roundedBoxGeo(9.2, 1.6, 12.4, 0.3), concDark, { position: [0, 1.5, 0], parent: root });+ createPart('PylonPierCap', await roundedBoxGeo(10.4, 0.55, 12.8, 0.05), conc, { position: [0, 2.55, 0], parent: root });++ // ---------- H-shaped pylon legs (tapered square prisms with tapered face ribs) ----------+ const legH = PYLON_H - 2.2;+ const legGeo = cylinderGeo(LEG_HALF_TOP * Math.SQRT2, LEG_HALF_BOT * Math.SQRT2, legH, 4);+ const ribGeo = await extrudeProfile(+ [[-1.3, 0], [1.3, 0], [0.95, legH], [-0.95, legH]],+ { depth: 1.1, axis: 'z', center: true });+ for (const s of [-1, 1]) {+ createPart('PylonLeg' + (s < 0 ? 'Port' : 'Starboard'), legGeo, conc, { position: [0, (2.2 + PYLON_H) / 2, s * PYLON_LEG_Z], rotation: [0, 45, 0], parent: root });+ createPart('PylonLegRib' + (s < 0 ? 'Port' : 'Starboard'), ribGeo, conc, { position: [0, 2.2, s * PYLON_LEG_Z], parent: root });+ }++ // crossbeams between the legs (lower strut / upper strut / head beam)+ const beamDef = [+ { name: 'LowerStrut', y: 4.4, h: 1.2, len: 9.0, d: 1.4 },+ { name: 'UpperStrut', y: 13.2, h: 1.4, len: 9.2, d: 1.6 },+ { name: 'HeadBeam', y: 29.4, h: 1.6, len: 9.4, d: 2.8 },+ ];+ for (const b of beamDef) {+ createPart('Pylon' + b.name, boxGeo(b.d, b.h, b.len), conc, { position: [0, b.y, 0], parent: root });+ }++ // aviation beacon on the head beam+ createPart('BeaconPost', cylinderGeo(0.16, 0.2, 0.5, 8), lampMetal, { position: [0, 30.45, 0], parent: root });+ createPart('BeaconLight', sphereGeo(0.13, 8, 6), beaconRed, { position: [0, 30.78, 0], parent: root });++ // pylon anchor brackets (lower cable anchors; top two sit inside the head beam)+ const bracketGeo = boxGeo(0.9, 0.8, 0.9);+ for (let i = 2; i < ANCHOR_X.length; i++) {+ for (const s of [-1, 1]) {+ createPart('PylonBracket' + s + '_' + i, bracketGeo, steel, { position: [0, ANCHOR_TOP_Y[i], s * 4.4], parent: root });+ }+ }++ // ---------- deck: trapezoid box girder + slab ----------+ const girderLen = DECK_HALF * 2;+ createPart('GirderBottomSlab', boxGeo(girderLen, 0.3, GIRDER_HALF_W * 2), conc, { position: [0, GIRDER_BOT + 0.15, 0], parent: root });+ const webGeo = boxGeo(girderLen, 1.3, 0.32);+ createPart('GirderWebPort', webGeo, conc, { position: [0, 7.46, -3.08], rotation: [-23, 0, 0], parent: root });+ createPart('GirderWebStarboard', webGeo, conc, { position: [0, 7.46, 3.08], rotation: [23, 0, 0], parent: root });+ createPart('DeckSlab', boxGeo(girderLen, SLAB_TOP - GIRDER_TOP, SLAB_HALF_W * 2), conc, { position: [0, (GIRDER_TOP + SLAB_TOP) / 2, 0], parent: root });++ // road plate + markings+ createPart('RoadPlate', boxGeo(girderLen, 0.07, ROAD_W * 2), asphalt, { position: [0, SLAB_TOP + 0.035, 0], parent: root });+ const markY = SLAB_TOP + 0.08;+ const edgeGeo = boxGeo(girderLen - 1, 0.02, 0.12);+ createPart('EdgeLinePort', edgeGeo, paint, { position: [0, markY, -3.1], parent: root });+ createPart('EdgeLineStarboard', edgeGeo, paint, { position: [0, markY, 3.1], parent: root });+ const dashGeo = boxGeo(2, 0.02, 0.14);+ for (let x = -43; x <= 43; x += 4.5) {+ createPart('LaneDash' + x.toFixed(1), dashGeo, paint, { position: [x, markY, 0], parent: root });+ }++ // parapets + steel handrail with posts set into the parapet top+ const parapetGeo = boxGeo(girderLen, 0.95, 0.3);+ const railGeo = cylinderXGeo(0.035, 0.035, girderLen - 0.4, 6);+ const railPostGeo = boxGeo(0.07, 0.36, 0.07);+ createPart('ParapetPort', parapetGeo, conc, { position: [0, SLAB_TOP + 0.475, -3.75], parent: root });+ createPart('ParapetStarboard', parapetGeo, conc, { position: [0, SLAB_TOP + 0.475, 3.75], parent: root });+ createPart('HandrailPort', railGeo, steel, { position: [0, SLAB_TOP + 1.3, -3.75], parent: root });+ createPart('HandrailStarboard', railGeo, steel, { position: [0, SLAB_TOP + 1.3, 3.75], parent: root });+ for (let x = -43 + 2.25; x <= 43; x += 4.5) {+ createPart('RailPost' + x.toFixed(2) + 'P', railPostGeo, steel, { position: [x, SLAB_TOP + 1.13, -3.75], parent: root });+ createPart('RailPost' + x.toFixed(2) + 'S', railPostGeo, steel, { position: [x, SLAB_TOP + 1.13, 3.75], parent: root });+ }++ // deck cable anchor stubs+ const anchorGeo = boxGeo(0.7, 0.5, 0.35);+ for (const sx of [-1, 1]) {+ for (const ax of ANCHOR_X) {+ for (const sz of [-1, 1]) {+ createPart('DeckAnchor' + sx + '_' + ax + '_' + sz, anchorGeo, steel, { position: [sx * ax, 8.15, sz * 3.38], parent: root });+ }+ }+ }++ // ---------- stay cables: two fans ----------+ for (const sx of [-1, 1]) {+ for (const sz of [-1, 1]) {+ for (let i = 0; i < ANCHOR_X.length; i++) {+ beamBetween('Cable' + sx + '_' + sz + '_' + i,+ [sx * ANCHOR_X[i], 8.3, sz * CABLE_Z_DECK],+ [0, ANCHOR_TOP_Y[i], sz * CABLE_Z_TOP],+ 0.08, steel, { segments: 8, parent: root });+ }+ }+ }++ // ---------- approach piers ----------+ const pierFootGeo = boxGeo(3.4, 0.9, 6.4);+ const pierColGeo = boxGeo(1.8, 5.2, 4.6);+ const pierCapGeo = boxGeo(3.0, 1.0, 5.6);+ for (const px of [30, 40]) {+ for (const sx of [-1, 1]) {+ const x = sx * px;+ const tag = sx + '_' + px;+ createPart('PierFooting' + tag, pierFootGeo, concDark, { position: [x, 0.45, 0], parent: root });+ createPart('PierColumn' + tag, pierColGeo, concDark, { position: [x, 3.5, 0], parent: root });+ createPart('PierCap' + tag, pierCapGeo, conc, { position: [x, 6.5, 0], parent: root });+ }+ }++ // ---------- abutments ----------+ const abutGeo = boxGeo(3.0, 8.3, 9.4);+ const abutRoadGeo = boxGeo(3.0, 0.07, ROAD_W * 2);+ const wingGeo = boxGeo(3.0, 3.0, 0.35);+ for (const sx of [-1, 1]) {+ const x = sx * 46.5;+ const tag = sx < 0 ? 'Port' : 'Starboard';+ createPart('Abutment' + tag, abutGeo, concDark, { position: [x, 4.15, 0], parent: root });+ createPart('AbutmentRoad' + tag, abutRoadGeo, asphalt, { position: [x, SLAB_TOP + 0.035, 0], parent: root });+ createPart('WingWall' + tag, wingGeo, concDark, { position: [x, 1.5, sx * 4.875], parent: root });+ }++ // ---------- lamp standards ----------+ const poleGeo = cylinderGeo(0.07, 0.1, 3.6, 8);+ const armGeoPort = pipeAlongPath([[0, 12.75, -3.75], [0, 13.15, -2.95], [0, 13.3, -2.25]], 0.06, { radialSegments: 6 });+ const armGeoStar = pipeAlongPath([[0, 12.75, 3.75], [0, 13.15, 2.95], [0, 13.3, 2.25]], 0.06, { radialSegments: 6 });+ const headGeo = await roundedBoxGeo(0.55, 0.16, 0.3, 0.05);+ const glowGeo = boxGeo(0.45, 0.02, 0.24);+ const lampXs = [+ { x: 10, s: 1 }, { x: 22, s: -1 }, { x: 34, s: 1 }, { x: 44, s: -1 },+ { x: -10, s: -1 }, { x: -22, s: 1 }, { x: -34, s: -1 }, { x: -44, s: 1 },+ ];+ for (const L of lampXs) {+ const z = L.s * 3.75;+ createPart('LampPole' + L.x, poleGeo, lampMetal, { position: [L.x, 11.05, z], parent: root });+ createPart('LampArm' + L.x, L.s < 0 ? armGeoPort : armGeoStar, lampMetal, { position: [L.x, 0, 0], parent: root });+ createPart('LampHead' + L.x, headGeo, lampMetal, { position: [L.x, 13.32, z - L.s * 1.55], parent: root });+ createPart('LampGlow' + L.x, glowGeo, lampGlow, { position: [L.x, 13.23, z - L.s * 1.55], parent: root });+ }++ return root;+}diff --git a/examples/cafe-racer.kiln.js b/examples/cafe-racer.kiln.jsindex 5aceb15b..18c793d7 100644--- a/examples/cafe-racer.kiln.js+++ b/examples/cafe-racer.kiln.js@@ -157,7 +157,13 @@ async function build() {}return p;};- const frontWheel = wheel('Front', FRONT_AXLE, 0.268, 0.052, 20);+ // The tyre's outer radius is declared once here and shared with the mudguard,+ // so the guard's clearance is derived from the tyre it has to clear instead of+ // being typed a second time and left free to drift away from it.+ const FRONT_RIM_R = 0.268;+ const FRONT_TUBE = 0.052;+ const FRONT_TYRE_OUTER = FRONT_RIM_R + 0.021 + FRONT_TUBE * 2;+ const frontWheel = wheel('Front', FRONT_AXLE, FRONT_RIM_R, FRONT_TUBE, 20);const rearWheel = wheel('Rear', REAR_AXLE, 0.258, 0.068, 20);// Brake disc and caliper, front only, on the left as it should be.createPart('BrakeDisc', cylinderZGeo(0.145, 0.145, 0.010, 30), chrome,@@ -340,13 +346,74 @@ async function build() {position: [0.553, 1.019, sz * 0.058], rotation: [0, 0, -16], parent: root,});}- // Front mudguard, hugging the tyre.- createPart('Mudguard', await uv(await extrudeProfile([- [0.20, 0.34], [0.30, 0.28], [0.34, 0.16], [0.30, 0.02],- [0.26, 0.02], [0.30, 0.15], [0.26, 0.26], [0.18, 0.31],- ], { depth: 0.15, axis: 'z', bevel: 0.006 })), chrome, {- position: [FRONT_AXLE[0] - 0.02, FRONT_AXLE[1], 0], parent: root,- });+ // ---------- Front mudguard ----------+ // A mudguard is the TYRE'S OWN SURFACE, offset outward. That one sentence is+ // the whole construction: the tyre is a torus, so the guard is a concentric+ // torus shell standing off it by a declared clearance, cut to an arc and to+ // the wrap angle it covers. Nothing about it is plotted by hand, so it cannot+ // drift away from the wheel it belongs to.+ //+ // Two earlier versions got this wrong in two different ways, and both are+ // worth naming because they are the two ways a guard usually fails:+ //+ // 1. A typed outline. Its radii ran 0.26 to 0.41 against a tyre whose outer+ // radius is 0.393, and it was positioned 0.02 m off the axle -- so it was+ // not hovering over the tyre, it was buried in it, and not concentric.+ // 2. A generated arc, but extruded FLAT along z. Concentric and correctly+ // clear, and still wrong: a guard bent in one direction only is a plank+ // lying on the tread. What makes it read as a guard is the CHANNEL+ // section -- edges that curve down over the tyre's shoulders.+ //+ // Offsetting the tyre torus gives both at once, for free.+ const RAD = Math.PI / 180;+ const GUARD_GAP = 0.026; // clearance over the tyre, the same everywhere+ const GUARD_THICK = 0.009; // sheet+ const GUARD_WRAP = 135; // degrees of the tyre's section the blade covers+ const GUARD_A0 = 40; // leading edge, CCW from straight ahead+ const GUARD_A1 = 118; // trailing edge, roughly on the fork axis+ const TYRE_MAJOR = FRONT_RIM_R + 0.021 + FRONT_TUBE;+ const GUARD_R = TYRE_MAJOR + FRONT_TUBE + GUARD_GAP; // outer edge, at the crown+ {+ const shellTube = (t) => new THREE.Mesh(torusGeo(TYRE_MAJOR, t, 12, 72), chrome);+ // Cutting the inner part of the section away is what sets the wrap: keep+ // only the material further from the axle than the chord at WRAP/2.+ const coreR = TYRE_MAJOR + (FRONT_TUBE + GUARD_GAP) * Math.cos((GUARD_WRAP / 2) * RAD);+ const core = new THREE.Mesh(cylinderZGeo(coreR, coreR, 0.60, 72), chrome);+ // Each wedge is a half-space whose cut face lies exactly on a ray from the+ // axle: the box is pushed one half-size along its own rotated +/-Y, so the+ // face lands on the origin however the ray is angled.+ const wedge = (deg, sign) => {+ const a = deg * RAD;+ const m = new THREE.Mesh(boxGeo(2.4, 2.4, 0.8), chrome);+ m.position.set(sign * Math.sin(a) * 1.2, -sign * Math.cos(a) * 1.2, 0);+ m.rotation.z = a;+ return m;+ };+ const blade = await boolDiff('Mudguard',+ shellTube(FRONT_TUBE + GUARD_GAP + GUARD_THICK),+ shellTube(FRONT_TUBE + GUARD_GAP),+ core, wedge(GUARD_A0, 1), wedge(GUARD_A1, -1),+ { smooth: true });+ blade.name = 'Mudguard';+ blade.geometry = await uv(blade.geometry);+ blade.position.set(FRONT_AXLE[0], FRONT_AXLE[1], FRONT_AXLE[2]);+ root.add(blade);+ }+ // Stays. A guard is not cantilevered off thin air -- it is bolted to the fork+ // legs, and with the clearance corrected the blade reads as floating without+ // them. Each stay lands on the fork leg at its own height, solved off the same+ // two nodes the leg itself is built from rather than measured off the render.+ for (const sz of [-1, 1]) {+ for (const deg of [52, 108]) {+ const r = TYRE_MAJOR + (FRONT_TUBE + GUARD_GAP) * Math.cos((GUARD_WRAP / 2 - 8) * RAD);+ const gx = FRONT_AXLE[0] + Math.cos(deg * RAD) * r;+ const gy = FRONT_AXLE[1] + Math.sin(deg * RAD) * r;+ const t = (0.88 - gy) / (0.88 - FRONT_AXLE[1]);+ const fx = 0.585 + (FRONT_AXLE[0] - 0.585) * t;+ beamBetween(`GuardStay_${deg}_${sz > 0 ? 'R' : 'L'}`,+ [gx, gy, sz * 0.062], [fx, gy, sz * 0.100], 0.0065, chrome, { parent: root });+ }+ }return root;}diff --git a/examples/carousel.kiln.js b/examples/carousel.kiln.jsnew file mode 100644index 00000000..ccb57292--- /dev/null+++ b/examples/carousel.kiln.js@@ -0,0 +1,557 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Refined later, in this repository, with `kiln_edit`: the horses were turned+// to face along their track instead of across it.+// The attribution above is for the authoring run, which had none of this in+// scope. Both passes went through the same tools; only the second one could+// see the gallery it was going into.++const meta = { name: 'Carousel', category: 'prop' };++function build() {+ const root = createRoot('Carousel');++ // =========================================================================+ // Materials Palette+ // =========================================================================+ const gold = gameMaterial(0xdfaf37, { metalness: 0.85, roughness: 0.25 });+ const mirror = gameMaterial(0xd8e4ec, { metalness: 0.95, roughness: 0.05 });+ const crimson = gameMaterial(0xb81824, { roughness: 0.45 });+ const cream = gameMaterial(0xf6eedb, { roughness: 0.55 });+ const darkWood = gameMaterial(0x3e2415, { roughness: 0.8 });+ const deckPlank = gameMaterial(0x6e4324, { roughness: 0.7 });+ const baseMaroon = gameMaterial(0x3a1017, { roughness: 0.85 });+ const darkLeather = gameMaterial(0x482818, { roughness: 0.75 });+ const darkDetail = gameMaterial(0x221a16, { roughness: 0.9 });+ const lightBulb = gameMaterial(0xfff3b0, { emissive: 0xffdf70, emissiveIntensity: 1.5, roughness: 0.3 });++ // Blanket accent colors+ const blanketSapphire = gameMaterial(0x1d4e89, { roughness: 0.45 });+ const blanketEmerald = gameMaterial(0x1e6b45, { roughness: 0.45 });+ const blanketPurple = gameMaterial(0x5e2b6d, { roughness: 0.45 });++ // Horse coat colors+ const coatWhite = gameMaterial(0xf4f1eb, { roughness: 0.6 });+ const coatChestnut = gameMaterial(0x7a361c, { roughness: 0.65 });+ const coatBlack = gameMaterial(0x282626, { roughness: 0.7 });+ const coatPalomino = gameMaterial(0xdca55c, { roughness: 0.65 });++ // =========================================================================+ // 1. Static Foundation Base (sitting on Y = 0)+ // =========================================================================+ // Sub-base plinth (Y: 0.00 to 0.08, radius 3.38m)+ createPart('BaseRingLower', cylinderGeo(3.38, 3.42, 0.08, 24), baseMaroon, {+ position: [0, 0.04, 0],+ parent: root,+ });+ // Stepped surround plinth (Y: 0.08 to 0.16, radius 3.28m)+ createPart('BaseRingUpper', cylinderGeo(3.28, 3.32, 0.08, 24), darkWood, {+ position: [0, 0.12, 0],+ parent: root,+ });+ // Outer perimeter brass trim+ createPart('BaseGoldTrim', torusGeo(3.32, 0.022, 6, 24), gold, {+ position: [0, 0.16, 0],+ rotation: [90, 0, 0],+ parent: root,+ });++ // =========================================================================+ // 2. Main Rotating Assembly (Joint_Carousel)+ // =========================================================================+ const carousel = createPivot('Carousel', [0, 0, 0], root);++ // Rotating Deck platform (Y: 0.16 to 0.32, radius 3.16m)+ createPart('DeckPlatform', cylinderGeo(3.16, 3.16, 0.16, 24), deckPlank, {+ position: [0, 0.24, 0],+ parent: carousel,+ });+ // Bullnose brass rim around deck edge+ createPart('DeckRim', torusGeo(3.17, 0.020, 6, 24), gold, {+ position: [0, 0.32, 0],+ rotation: [90, 0, 0],+ parent: carousel,+ });+ // Concentric deck plank inlay ring+ createPart('DeckInnerRing', torusGeo(2.25, 0.015, 6, 24), darkWood, {+ position: [0, 0.325, 0],+ rotation: [90, 0, 0],+ parent: carousel,+ });++ // =========================================================================+ // 3. Mirrored Centre Drum (Y: 0.32 to 2.65, radius 1.05m)+ // =========================================================================+ createPart('DrumCore', cylinderGeo(1.02, 1.02, 2.25, 12), darkWood, {+ position: [0, 1.485, 0],+ parent: carousel,+ });+ createPart('DrumPlinth', cylinderGeo(1.08, 1.12, 0.40, 12), baseMaroon, {+ position: [0, 0.52, 0],+ parent: carousel,+ });+ createPart('DrumPlinthTrim', torusGeo(1.09, 0.02, 6, 24), gold, {+ position: [0, 0.72, 0],+ rotation: [90, 0, 0],+ parent: carousel,+ });++ const mirrorWidth = 0.46;+ const mirrorHeight = 1.45;+ const drumR = 1.04;++ const geoMirror = boxGeo(mirrorWidth, mirrorHeight, 0.02);+ const geoFrameTop = boxGeo(mirrorWidth + 0.06, 0.06, 0.03);+ const geoFrameBot = boxGeo(mirrorWidth + 0.06, 0.06, 0.03);+ const geoPilaster = cylinderGeo(0.032, 0.032, 1.62, 6);+ const geoCap = boxGeo(0.08, 0.05, 0.08);+ const geoRosette = cylinderGeo(0.04, 0.04, 0.02, 6);+ geoRosette.rotateX(Math.PI / 2);+ const geoDrumLight = cylinderGeo(0.026, 0.026, 0.025, 6);+ geoDrumLight.rotateX(Math.PI / 2);++ for (let i = 0; i < 12; i++) {+ const angleDeg = i * 30;+ const rad = (angleDeg * Math.PI) / 180;+ const facePivot = createPivot('DrumFace' + i, [0, 0, 0], carousel);+ facePivot.rotation.y = -rad;++ // Mirrored glass panel+ createPart('Mirror' + i, geoMirror, mirror, {+ position: [0, 1.55, drumR],+ parent: facePivot,+ });+ // Gilded top & bottom frame+ createPart('FrameTop' + i, geoFrameTop, gold, {+ position: [0, 1.55 + mirrorHeight / 2 + 0.03, drumR + 0.01],+ parent: facePivot,+ });+ createPart('FrameBot' + i, geoFrameBot, gold, {+ position: [0, 1.55 - mirrorHeight / 2 - 0.03, drumR + 0.01],+ parent: facePivot,+ });++ // Fluted pilaster column+ const colX = mirrorWidth / 2 + 0.04;+ createPart('Pilaster' + i, geoPilaster, gold, {+ position: [colX, 1.55, drumR + 0.015],+ parent: facePivot,+ });+ createPart('ColCap' + i, geoCap, gold, {+ position: [colX, 1.55 + 0.81, drumR + 0.015],+ parent: facePivot,+ });+ createPart('ColBase' + i, geoCap, gold, {+ position: [colX, 1.55 - 0.81, drumR + 0.015],+ parent: facePivot,+ });++ // Rosette crest & cabochon carnival light+ createPart('Rosette' + i, geoRosette, crimson, {+ position: [0, 1.55 + mirrorHeight / 2 + 0.10, drumR + 0.02],+ parent: facePivot,+ });+ createPart('DrumLight' + i, geoDrumLight, lightBulb, {+ position: [0, 1.55 + mirrorHeight / 2 + 0.18, drumR + 0.02],+ parent: facePivot,+ });+ }++ // Upper drum cornice+ createPart('DrumCornice', cylinderGeo(1.15, 1.06, 0.16, 12), baseMaroon, {+ position: [0, 2.53, 0],+ parent: carousel,+ });+ createPart('DrumCorniceTrim', torusGeo(1.15, 0.022, 6, 24), gold, {+ position: [0, 2.61, 0],+ rotation: [90, 0, 0],+ parent: carousel,+ });++ // =========================================================================+ // 4. Overhead Structure: Ceiling & Radial Rafters+ // =========================================================================+ createPart('CeilingPlate', cylinderGeo(3.18, 3.18, 0.08, 24), darkWood, {+ position: [0, 2.68, 0],+ parent: carousel,+ });++ const geoRafter = boxGeo(0.08, 0.08, 2.15);+ const geoCrankBox = boxGeo(0.18, 0.14, 0.18);++ for (let i = 0; i < 8; i++) {+ const angleDeg = i * 45;+ const rad = (angleDeg * Math.PI) / 180;+ const rafterPivot = createPivot('RafterPivot' + i, [0, 0, 0], carousel);+ rafterPivot.rotation.y = -rad;++ createPart('Rafter' + i, geoRafter, gold, {+ position: [0, 2.64, 2.12],+ parent: rafterPivot,+ });+ createPart('CrankBox' + i, geoCrankBox, baseMaroon, {+ position: [0, 2.64, 2.25],+ parent: rafterPivot,+ });+ }++ // =========================================================================+ // 5. Striped Canopy (24 red & cream wedges) & Scalloped Valance+ // =========================================================================+ function makeWedgeGeo(rBot, rTop, yBot, yTop, dAngleDeg) {+ const geo = new THREE.BufferGeometry();+ const halfA = ((dAngleDeg * Math.PI) / 180) / 2;+ const cosA = Math.cos(halfA);+ const sinA = Math.sin(halfA);++ const x0 = -rBot * sinA, z0 = rBot * cosA, y0 = yBot;+ const x1 = rBot * sinA, z1 = rBot * cosA, y1 = yBot;+ const x2 = rTop * sinA, z2 = rTop * cosA, y2 = yTop;+ const x3 = -rTop * sinA, z3 = rTop * cosA, y3 = yTop;++ const pos = [+ x0, y0, z0, x1, y1, z1, x2, y2, z2,+ x0, y0, z0, x2, y2, z2, x3, y3, z3,+ x0, y0, z0, x2, y2, z2, x1, y1, z1,+ x0, y0, z0, x3, y3, z3, x2, y2, z2,+ ];+ geo.setAttribute('position', new THREE.Float32BufferAttribute(pos, 3));+ geo.computeVertexNormals();+ return geo;+ }++ const canopyWedgeGeo = makeWedgeGeo(3.25, 0.35, 2.76, 4.38, 15);++ const geoValance = boxGeo(0.82, 0.28, 0.03);+ const geoValTrim = boxGeo(0.84, 0.04, 0.04);+ const geoValCrest = cylinderGeo(0.038, 0.038, 0.02, 6);+ geoValCrest.rotateX(Math.PI / 2);+ const geoValLight = cylinderGeo(0.024, 0.024, 0.025, 6);+ geoValLight.rotateX(Math.PI / 2);+ const geoCanopySeam = cylinderGeo(0.014, 0.014, 3.25, 4);+ const seamPitch = 27.6;++ for (let i = 0; i < 24; i++) {+ const angleDeg = i * 15;+ const rad = (angleDeg * Math.PI) / 180;+ const isEven = i % 2 === 0;+ const mat = isEven ? crimson : cream;++ // Wedge+ const wedge = createPart('CanopyWedge' + i, canopyWedgeGeo, mat, { parent: carousel });+ wedge.rotation.y = -rad;++ // Valance panel+ const valancePivot = createPivot('ValPivot' + i, [0, 0, 0], carousel);+ valancePivot.rotation.y = -rad;++ createPart('Valance' + i, geoValance, isEven ? crimson : cream, {+ position: [0, 2.62, 3.26],+ parent: valancePivot,+ });+ createPart('ValTrim' + i, geoValTrim, gold, {+ position: [0, 2.48, 3.26],+ parent: valancePivot,+ });+ createPart('ValCrest' + i, geoValCrest, isEven ? gold : crimson, {+ position: [0, 2.62, 3.28],+ parent: valancePivot,+ });+ createPart('ValLight' + i, geoValLight, lightBulb, {+ position: [0, 2.50, 3.28],+ parent: valancePivot,+ });++ createPart('CanopySeam' + i, geoCanopySeam, gold, {+ position: [0, 3.57, 1.80],+ rotation: [-(90 - seamPitch), 0, 0],+ parent: valancePivot,+ });+ }++ // =========================================================================+ // 6. Canopy Cupola, Spire & Finial (Y: 4.38 to 5.80)+ // =========================================================================+ createPart('ApexRing', cylinderGeo(0.42, 0.42, 0.12, 16), gold, {+ position: [0, 4.42, 0],+ parent: carousel,+ });+ createPart('CupolaDrum', cylinderGeo(0.38, 0.38, 0.35, 12), baseMaroon, {+ position: [0, 4.65, 0],+ parent: carousel,+ });+ const geoCupCol = cylinderGeo(0.025, 0.025, 0.35, 6);+ for (let j = 0; j < 6; j++) {+ const cupA = (j * 60 * Math.PI) / 180;+ createPart('CupCol' + j, geoCupCol, gold, {+ position: [0.38 * Math.sin(cupA), 4.65, 0.38 * Math.cos(cupA)],+ parent: carousel,+ });+ }+ // Safe spire cone with non-zero top radius+ createPart('SpireCone', cylinderGeo(0.015, 0.44, 0.65, 16), gold, {+ position: [0, 5.15, 0],+ parent: carousel,+ });+ createPart('FinialOrb', cylinderGeo(0.06, 0.08, 0.14, 8), gold, {+ position: [0, 5.54, 0],+ parent: carousel,+ });+ createPart('FinialSpike', cylinderGeo(0.008, 0.018, 0.32, 6), gold, {+ position: [0, 5.72, 0],+ parent: carousel,+ });+ createPart('PennantFlag', boxGeo(0.32, 0.16, 0.015), crimson, {+ position: [0.18, 5.76, 0],+ parent: carousel,+ });++ // =========================================================================+ // 7. 8 Animated Horses & Brass Poles+ // =========================================================================+ // Reusable horse geometry set+ const geoTorso = cylinderXGeo(0.18, 0.19, 0.44, 8);+ const geoChest = cylinderXGeo(0.19, 0.13, 0.16, 8);+ const geoRump = cylinderXGeo(0.13, 0.18, 0.16, 8);+ const geoNeck = cylinderGeo(0.10, 0.15, 0.42, 8);+ const geoMane1 = boxGeo(0.08, 0.18, 0.05);+ const geoMane2 = boxGeo(0.08, 0.18, 0.05);+ const geoMane3 = boxGeo(0.07, 0.14, 0.05);+ const geoHead = boxGeo(0.16, 0.15, 0.15);+ const geoMuzzle = cylinderXGeo(0.06, 0.08, 0.18, 8);+ const geoNose = boxGeo(0.06, 0.07, 0.10);+ // Non-degenerate ear cylinder+ const geoEar = cylinderGeo(0.005, 0.028, 0.09, 6);+ const geoEye = boxGeo(0.03, 0.03, 0.02);++ const geoBlanket = boxGeo(0.40, 0.22, 0.42);+ const geoBlanketTrim = boxGeo(0.42, 0.03, 0.44);+ const geoSaddle = boxGeo(0.25, 0.06, 0.25);+ const geoPommel = boxGeo(0.06, 0.09, 0.16);+ const geoCantle = boxGeo(0.06, 0.11, 0.18);+ const geoStirrup = boxGeo(0.03, 0.08, 0.08);+ const geoBreastplate = boxGeo(0.18, 0.04, 0.32);+ const geoMedallion = cylinderGeo(0.035, 0.035, 0.02, 6);+ geoMedallion.rotateZ(Math.PI / 2);++ const geoLegUpper = cylinderGeo(0.04, 0.032, 0.22, 6);+ const geoLegLower = cylinderGeo(0.032, 0.026, 0.20, 6);+ const geoJoint = cylinderGeo(0.036, 0.036, 0.05, 6);+ const geoHoof = cylinderGeo(0.028, 0.036, 0.06, 6);+ const geoHaunch = cylinderGeo(0.07, 0.09, 0.18, 6);+ const geoThigh = cylinderGeo(0.055, 0.04, 0.24, 6);++ const geoTail1 = cylinderGeo(0.04, 0.03, 0.22, 6);+ const geoTail2 = cylinderGeo(0.035, 0.025, 0.24, 6);+ const geoTail3 = cylinderGeo(0.03, 0.015, 0.20, 6);++ const geoPole = cylinderGeo(0.024, 0.024, 2.38, 6);+ const geoPoleRing = torusGeo(0.038, 0.012, 6, 12);+ const geoPoleFinial = cylinderGeo(0.02, 0.045, 0.08, 6);++ const horseRingR = 2.25;+ const horseConfigs = [+ { coat: coatWhite, blanket: crimson, mane: darkDetail },+ { coat: coatChestnut, blanket: blanketSapphire, mane: coatWhite },+ { coat: coatBlack, blanket: blanketEmerald, mane: coatBlack },+ { coat: coatPalomino, blanket: blanketPurple, mane: coatWhite },+ { coat: coatWhite, blanket: blanketSapphire, mane: darkDetail },+ { coat: coatChestnut, blanket: crimson, mane: coatWhite },+ { coat: coatBlack, blanket: blanketPurple, mane: coatBlack },+ { coat: coatPalomino, blanket: blanketEmerald, mane: coatWhite },+ ];++ for (let i = 0; i < 8; i++) {+ const angleDeg = i * 45;+ const rad = (angleDeg * Math.PI) / 180;+ const cfg = horseConfigs[i];++ const mount = createPivot('Mount' + i, [+ horseRingR * Math.sin(rad),+ 0,+ horseRingR * Math.cos(rad),+ ], carousel);+ // Face each horse along the track, not across it. The horse is modelled+ // nose-at-+X, and a Y rotation of `a` carries +X to (cos a, 0, -sin a) --+ // which is exactly the tangent at (R sin a, 0, R cos a). Adding a quarter+ // turn on top of that pointed every nose at the centre pole instead.+ mount.rotation.y = rad;++ // Fixed Brass Pole+ createPart('Pole' + i, geoPole, gold, {+ position: [0, 1.51, 0],+ parent: mount,+ });+ createPart('PoleBase' + i, geoPoleRing, gold, {+ position: [0, 0.33, 0],+ rotation: [90, 0, 0],+ parent: mount,+ });+ createPart('PoleTop' + i, geoPoleRing, gold, {+ position: [0, 2.67, 0],+ rotation: [90, 0, 0],+ parent: mount,+ });+ createPart('PoleBall' + i, geoPoleFinial, gold, {+ position: [0, 2.64, 0],+ parent: mount,+ });++ // Moving Horse Joint+ const baseY = 1.20;+ const horseJoint = createPivot('Horse' + i, [0, baseY, 0], mount);++ // Torso & Body+ createPart('Torso' + i, geoTorso, cfg.coat, { parent: horseJoint });+ createPart('Chest' + i, geoChest, cfg.coat, { position: [0.24, 0.02, 0], parent: horseJoint });+ createPart('Rump' + i, geoRump, cfg.coat, { position: [-0.24, 0.02, 0], parent: horseJoint });++ // Neck & Mane+ createPart('Neck' + i, geoNeck, cfg.coat, {+ position: [0.30, 0.22, 0],+ rotation: [0, 0, -38],+ parent: horseJoint,+ });+ createPart('ManeA' + i, geoMane1, cfg.mane, { position: [0.22, 0.28, 0], rotation: [0, 0, -35], parent: horseJoint });+ createPart('ManeB' + i, geoMane2, cfg.mane, { position: [0.30, 0.38, 0], rotation: [0, 0, -35], parent: horseJoint });+ createPart('ManeC' + i, geoMane3, cfg.mane, { position: [0.37, 0.48, 0], rotation: [0, 0, -30], parent: horseJoint });++ // Head+ createPart('Head' + i, geoHead, cfg.coat, { position: [0.44, 0.45, 0], parent: horseJoint });+ createPart('Muzzle' + i, geoMuzzle, cfg.coat, { position: [0.55, 0.41, 0], parent: horseJoint });+ createPart('Nose' + i, geoNose, darkDetail, { position: [0.64, 0.41, 0], parent: horseJoint });+ createPart('EarL' + i, geoEar, cfg.coat, { position: [0.41, 0.55, 0.055], rotation: [10, -5, -15], parent: horseJoint });+ createPart('EarR' + i, geoEar, cfg.coat, { position: [0.41, 0.55, -0.055], rotation: [-10, 5, -15], parent: horseJoint });+ createPart('EyeL' + i, geoEye, gold, { position: [0.47, 0.47, 0.085], parent: horseJoint });+ createPart('EyeR' + i, geoEye, gold, { position: [0.47, 0.47, -0.085], parent: horseJoint });++ // Saddle & Trappings+ createPart('Blanket' + i, geoBlanket, cfg.blanket, { position: [0, 0.02, 0], parent: horseJoint });+ createPart('BlanketTrim' + i, geoBlanketTrim, gold, { position: [0, -0.08, 0], parent: horseJoint });+ createPart('Saddle' + i, geoSaddle, darkLeather, { position: [0, 0.15, 0], parent: horseJoint });+ createPart('Pommel' + i, geoPommel, gold, { position: [0.10, 0.18, 0], parent: horseJoint });+ createPart('Cantle' + i, geoCantle, gold, { position: [-0.10, 0.19, 0], parent: horseJoint });+ createPart('StirrupL' + i, geoStirrup, gold, { position: [0, -0.16, 0.21], parent: horseJoint });+ createPart('StirrupR' + i, geoStirrup, gold, { position: [0, -0.16, -0.21], parent: horseJoint });+ createPart('Breastplate' + i, geoBreastplate, gold, { position: [0.25, 0.05, 0], parent: horseJoint });+ createPart('Medallion' + i, geoMedallion, crimson, { position: [0.35, 0.05, 0], parent: horseJoint });++ // Front Legs+ createPart('FL_Up' + i, geoLegUpper, cfg.coat, {+ position: [0.22, -0.12, 0.11],+ rotation: [-5, 0, -35],+ parent: horseJoint,+ });+ createPart('FL_Kn' + i, geoJoint, cfg.coat, { position: [0.28, -0.22, 0.11], parent: horseJoint });+ createPart('FL_Lo' + i, geoLegLower, cfg.coat, {+ position: [0.22, -0.31, 0.11],+ rotation: [0, 0, 30],+ parent: horseJoint,+ });+ createPart('FL_Hf' + i, geoHoof, gold, { position: [0.17, -0.40, 0.11], parent: horseJoint });++ createPart('FR_Up' + i, geoLegUpper, cfg.coat, {+ position: [0.22, -0.13, -0.11],+ rotation: [5, 0, -25],+ parent: horseJoint,+ });+ createPart('FR_Kn' + i, geoJoint, cfg.coat, { position: [0.27, -0.24, -0.11], parent: horseJoint });+ createPart('FR_Lo' + i, geoLegLower, cfg.coat, {+ position: [0.32, -0.34, -0.11],+ rotation: [0, 0, -20],+ parent: horseJoint,+ });+ createPart('FR_Hf' + i, geoHoof, gold, { position: [0.36, -0.44, -0.11], parent: horseJoint });++ // Hind Legs+ createPart('HL_Hn' + i, geoHaunch, cfg.coat, { position: [-0.22, -0.04, 0.12], parent: horseJoint });+ createPart('HL_Th' + i, geoThigh, cfg.coat, {+ position: [-0.28, -0.15, 0.12],+ rotation: [-5, 0, 30],+ parent: horseJoint,+ });+ createPart('HL_Hk' + i, geoJoint, cfg.coat, { position: [-0.34, -0.26, 0.12], parent: horseJoint });+ createPart('HL_Lo' + i, geoLegLower, cfg.coat, {+ position: [-0.31, -0.36, 0.12],+ rotation: [0, 0, -15],+ parent: horseJoint,+ });+ createPart('HL_Hf' + i, geoHoof, gold, { position: [-0.28, -0.45, 0.12], parent: horseJoint });++ createPart('HR_Hn' + i, geoHaunch, cfg.coat, { position: [-0.22, -0.04, -0.12], parent: horseJoint });+ createPart('HR_Th' + i, geoThigh, cfg.coat, {+ position: [-0.30, -0.16, -0.12],+ rotation: [5, 0, 40],+ parent: horseJoint,+ });+ createPart('HR_Hk' + i, geoJoint, cfg.coat, { position: [-0.38, -0.27, -0.12], parent: horseJoint });+ createPart('HR_Lo' + i, geoLegLower, cfg.coat, {+ position: [-0.44, -0.37, -0.12],+ rotation: [0, 0, 25],+ parent: horseJoint,+ });+ createPart('HR_Hf' + i, geoHoof, gold, { position: [-0.49, -0.47, -0.12], parent: horseJoint });++ // Tail+ createPart('TailA' + i, geoTail1, cfg.mane, {+ position: [-0.34, 0.04, 0],+ rotation: [0, 0, 45],+ parent: horseJoint,+ });+ createPart('TailB' + i, geoTail2, cfg.mane, {+ position: [-0.44, -0.08, 0],+ rotation: [0, 0, 20],+ parent: horseJoint,+ });+ createPart('TailC' + i, geoTail3, cfg.mane, {+ position: [-0.49, -0.22, 0],+ rotation: [0, 0, -10],+ parent: horseJoint,+ });+ }++ return root;+}++function animate() {+ const duration = 4;+ const tracks = [];++ // Full 360-degree rotation of the carousel assembly+ const carouselRotations = [];+ for (let step = 0; step <= 4; step++) {+ const angle = (step * 90) % 360;+ carouselRotations.push({+ time: (step * duration) / 4,+ rotation: [0, angle, 0],+ });+ }+ tracks.push(rotationTrack('Joint_Carousel', carouselRotations));++ // Sinusoidal rise-and-fall for each of the 8 horses+ const baseY = 1.20;+ const bobAmp = 0.16;+ const sampleCount = 8;++ for (let i = 0; i < 8; i++) {+ const phase = (i * Math.PI) / 2;+ const horsePositions = [];++ for (let s = 0; s <= sampleCount; s++) {+ const t = (s * duration) / sampleCount;+ const y = baseY + bobAmp * Math.sin(2 * Math.PI * (t / 2) + phase);+ horsePositions.push({+ time: t,+ position: [0, y, 0],+ });+ }++ tracks.push(positionTrack('Joint_Horse' + i, horsePositions));+ }++ return [createClip('ride', duration, tracks)];+}diff --git a/examples/cathedral.kiln.js b/examples/cathedral.kiln.jsnew file mode 100644index 00000000..e9bcbca9--- /dev/null+++ b/examples/cathedral.kiln.js@@ -0,0 +1,957 @@+// A Gothic cathedral, at dusk, with the lamps lit inside.+//+// Authored by: Claude Opus 5, via Claude Code. Every part below was written by+// the model itself, looking at its own renders through the Kiln tools and+// revising. Not a line of it is hand-authored.+//+// This is the REPETITION example, and it is here because a cathedral is the+// thing a code-first modeller is actually better at than a mouse.+//+// A Gothic building is not a collection of unique shapes. It is one bay,+// resolved once and then repeated with variation: pier, window, flyer,+// pinnacle, cornice, repeat. Every real one was built that way, from templates+// held by a master mason, because that is the only way a workshop of four+// hundred people builds a coherent object over eighty years. In a viewport you+// copy-paste geometry and then discover, three hundred copies later, that the+// sill height was wrong. Written down, the sill height is a number in one+// place. Move BAY and the windows, the piers, the flyers and the pinnacles all+// move with it, because none of them knows where it is -- each one is told.+//+// Three things make this read as a cathedral rather than as a shed with+// pointed windows:+//+// 1. THE ARCH IS EQUILATERAL. Both arcs of a lancet are struck from the+// opposite springing point at a radius equal to the full span. That is not+// a stylistic choice, it is the compass construction, and it means an+// arch's height is not a free parameter -- it falls out of its width, at+// w * sqrt(3)/2. Every opening here obeys it, which is why they all look+// like they belong to the same building.+// 2. THE BUTTRESSING IS STRUCTURAL. The flyers land on the clerestory wall+// where the vault pushes, and the pinnacles are not ornament -- they are+// dead weight stacked on the pier head to turn the flyer's diagonal thrust+// down into the pier. That relationship is most of what separates a+// cathedral silhouette from a castle silhouette.+// 3. THE WEST FRONT IS SYMMETRIC AND THE REST OF THE BUILDING IS NOT. A+// facade faces the city and the two towers are a pair, so they match:+// Cologne, Westminster and Notre-Dame all read as one composition for+// that reason. Two earlier passes here tried to buy character by making+// the towers differ -- first by leaving one unbuilt with a crane on it,+// then by giving one a taller crocketed spire and the other a plain lead+// pyramid. Both produced a building with a good half and a bad half, and+// the eye goes straight to the bad half every time. Asymmetry has to come+// from the PLAN instead, where it costs nothing: the crossing fleche+// stands off the tower axis, the apse is only at the east end, and the+// aisle bays run a rhythm the front never repeats.+//+// Lighting: it is dusk and the building is lit from inside, so the glass is the+// only emissive thing here. The windows are a small fraction of the elevation,+// so they run HOT -- small area, high intensity, the rule the vending machine+// example sets out. The rose is the exception. It is nearly 8 m across, so it+// runs cooler and takes its punch from the black tracery laid over it.+//+// Known limit: no interior. Every mass is solid and every opening is a recess+// cut about a metre into it with glass at the back. From outside that is the+// same picture as a modelled interior for a fraction of the triangles; walk the+// camera through the west door and there is nothing in there.+const meta = { name: 'Cathedral', category: 'architecture', role: 'hero' };++async function build() {+ const root = createRoot('Cathedral');+ const uv = (g) => autoUnwrap(g, { resolution: 1024 });+ const RAD = Math.PI / 180;++ // ---------- Plan ----------+ // +X is west, so the front faces the camera and the building runs away east.+ const Z_NAVE = 5.5; // nave wall line+ const Z_AISLE = 9.5; // aisle outer wall line+ const Z_PIER = 10.6; // buttress piers, 1.1 m proud of the aisle+ const Z_TRANS = 13.0; // transept gable ends+ const X_WEST = 16.0; // west face+ const X_NAVE = 11.0; // east face of the west block+ const X_CROSS = -11.5; // crossing centre+ const X_EAST = -18.0; // apse springing+ const APSE_R = 7.0;+ const T_HALF = 3.4; // half the transept's depth along X++ // Cornices. A Gothic elevation is three storeys and these are the three.+ const Y_GROUND = 1.0; // top of the podium; everything starts here+ const Y_AISLE = 10.0; // aisle eaves+ const Y_LEAN = 13.8; // where the aisle roof dies into the nave wall+ const Y_CORNICE = 20.5; // nave eaves+ const Y_RIDGE = 27.0; // nave ridge+ const Y_TOWER = 32.0; // tower belfry cornice++ // Five nave bays and one choir bay. The crossing has no bay -- the transept+ // is there. Piers stand on the bay DIVISIONS, not the centres, because that+ // is where a rib vault puts its load.+ const BAYS = [9, 5, 1, -3, -7, -16];+ const PIERS = [7, 3, -1, -5, -18];++ // ---------- The arch ----------+ // An equilateral arch: both arcs at radius = span, struck from the opposite+ // springing point. The profile's sill sits at v = 0, so a window is placed by+ // its sill and its height takes care of itself.+ const lancet = (w, spring, seg = 7) => {+ const hw = w / 2;+ const pts = [+ [-hw, 0],+ [hw, 0],+ ];+ for (let i = 0; i <= seg; i++) {+ const a = (i / seg) * 60 * RAD;+ pts.push([-hw + w * Math.cos(a), spring + w * Math.sin(a)]);+ }+ for (let i = 1; i <= seg; i++) {+ const a = (120 + (i / seg) * 60) * RAD;+ pts.push([hw + w * Math.cos(a), spring + w * Math.sin(a)]);+ }+ return pts;+ };+ const lancetTop = (w, spring) => spring + (w * Math.sqrt(3)) / 2;++ // ---------- Materials ----------+ // Limestone. Two things matter: it is a DIELECTRIC (metalness 0, or the whole+ // building goes to pewter under a low sun), and it is BEDDED. The horizontal+ // courses are what give a 30 m wall its sense of scale; without them the+ // towers read as extruded plastic however good the silhouette is.+ const stoneAlbedo = proceduralTexture({+ schemaVersion: 2,+ size: 1024,+ usage: 'albedo',+ name: 'Limestone',+ layers: [+ // Mid-value, not cream. The first pass sat at 0xc9c0ac and the whole+ // west front went flat: four archivolts, eight jamb shafts, a tympanum+ // and a trumeau were all modelled and none of them read, because carving+ // is legible by VALUE and a near-white wall has none left to spend.+ // Two stops down, with the course variance widened to match.+ { op: 'solid', color: 0x9a968c },+ { op: 'noise', colorA: 0x7c786e, colorB: 0xb4b0a6, scale: 9, octaves: 5, seed: 11, blend: 'overlay', opacity: 0.62 },+ // 34 courses over the tile. A mason's joint is a shadow line 5 mm wide,+ // not a drawn stripe -- but at 30 m it is the only thing giving scale.+ { op: 'stripes', colorA: 0x9a968c, colorB: 0x757165, count: 34, angleDeg: 0, blend: 'multiply', opacity: 0.30 },+ { op: 'noise', colorA: 0x6d695f, colorB: 0x9a968c, scale: 42, octaves: 4, seed: 3, blend: 'multiply', opacity: 0.30 },+ ],+ });+ const stone = pbrMaterial({+ albedo: stoneAlbedo,+ normal: normalMapFromHeight(stoneAlbedo, { strength: 0.85 }),+ roughness: 0.86,+ metalness: 0.0,+ });++ // The same stone lower down and wetter. Rain runs off a cathedral in+ // predictable places, and the bottom four metres of one is always darker.+ const stoneWetAlbedo = proceduralTexture({+ schemaVersion: 2,+ size: 512,+ usage: 'albedo',+ name: 'LimestoneWet',+ layers: [+ { op: 'solid', color: 0x6d6a62 },+ { op: 'noise', colorA: 0x53504a, colorB: 0x827e74, scale: 12, octaves: 5, seed: 27, blend: 'overlay', opacity: 0.60 },+ { op: 'stripes', colorA: 0x6d6a62, colorB: 0x565249, count: 22, angleDeg: 0, blend: 'multiply', opacity: 0.32 },+ ],+ });+ const stoneWet = pbrMaterial({+ albedo: stoneWetAlbedo,+ normal: normalMapFromHeight(stoneWetAlbedo, { strength: 0.75 }),+ roughness: 0.92,+ metalness: 0.0,+ });++ // Lead roofing: rolled sheet, seamed, and dark enough that the roofs read as+ // the negative space the towers stand out of.+ const leadAlbedo = proceduralTexture({+ schemaVersion: 2,+ size: 512,+ usage: 'albedo',+ name: 'Lead',+ layers: [+ { op: 'solid', color: 0x4a5058 },+ { op: 'stripes', colorA: 0x4a5058, colorB: 0x373d45, count: 40, angleDeg: 90, blend: 'multiply', opacity: 0.45 },+ { op: 'noise', colorA: 0x3a4048, colorB: 0x5b626b, scale: 30, octaves: 4, seed: 9, blend: 'overlay', opacity: 0.35 },+ ],+ });+ const lead = pbrMaterial({+ albedo: leadAlbedo,+ normal: normalMapFromHeight(leadAlbedo, { strength: 0.6 }),+ roughness: 0.58,+ metalness: 0.45,+ });++ // Bright lead for the crossing flèche. This one has been through three+ // hues. Verdigris copper at 0x4f8b78 read as a kelly green party hat behind+ // the gable; toned to 0x4e5f58 it was still the only green thing on a stone+ // and slate building. Then the roof lead was tried, and a steep cone in a+ // dark metal turns into a black spike, because almost none of its faces+ // catch the light -- it went from the wrong hue to the wrong VALUE, which is+ // worse. What a flèche actually is, is new sheet on a roof that is old, so+ // it belongs three stops ABOVE the roof beside it.+ const flecheAlbedo = proceduralTexture({+ schemaVersion: 2,+ size: 512,+ usage: 'albedo',+ name: 'LeadBright',+ layers: [+ { op: 'solid', color: 0x7f858c },+ { op: 'noise', colorA: 0x6b7178, colorB: 0x959da4, scale: 16, octaves: 5, seed: 41, blend: 'overlay', opacity: 0.55 },+ { op: 'stripes', colorA: 0x7f858c, colorB: 0x6e747b, count: 26, angleDeg: 90, blend: 'multiply', opacity: 0.30 },+ ],+ });+ const flecheLead = pbrMaterial({+ albedo: flecheAlbedo,+ normal: normalMapFromHeight(flecheAlbedo, { strength: 0.55 }),+ roughness: 0.60,+ metalness: 0.40,+ });++ const oak = gameMaterial(0x3b2a1c, { roughness: 0.80, metalness: 0.05 });+ const iron = gameMaterial(0x2a2c30, { roughness: 0.55, metalness: 0.80 });+ const shadow = gameMaterial(0x141210, { roughness: 0.95, metalness: 0.0 });+ // One stop up from `shadow`. A window reveal is a hole and should go black;+ // a blind arcade is a RECESS, and at 0x141210 eleven of them in a row read as+ // a set of teeth bitten out of the front rather than as depth in the wall.+ const recess = gameMaterial(0x342f27, { roughness: 0.95, metalness: 0.0 });+ const plaza = gameMaterial(0x3a3733, { roughness: 0.94, metalness: 0.0 });++ // Glass. Small area, so HOT. THREE hues and no more. An earlier pass had five+ // -- gold, amber, sapphire, ruby, emerald -- and the building read as a+ // stained-glass sampler: a green apse, an orange transept and a rainbow rose+ // all competing at once. The discipline that fixes it is not subtlety, it is+ // ARITHMETIC: warm at the ground where the candles are, cool up at the+ // clerestory where the sky is, and one saturated accent held in reserve.+ const glassGold = gameMaterial(0x8a7040, { emissive: 0xffca6a, emissiveIntensity: 2.8, roughness: 0.40 });+ const glassSapphire = gameMaterial(0x2c3f6b, { emissive: 0x4d86ff, emissiveIntensity: 2.4, roughness: 0.40 });+ const glassRuby = gameMaterial(0x6b2430, { emissive: 0xff3a4e, emissiveIntensity: 2.5, roughness: 0.40 });+ // The rose runs cooler than the lancets: it is 40x their area, and an+ // emissive that size with no GI behind it clips to white long before a+ // lancet does.+ const rose = (m, k) =>+ gameMaterial(m.color.getHex(), { emissive: m.emissive.getHex(), emissiveIntensity: k, roughness: 0.42 });+ const roseSapphire = rose(glassSapphire, 1.15);+ const roseRuby = rose(glassRuby, 1.00);+ const roseEye = rose(glassGold, 1.60);++ // ---------- Helpers ----------+ const slab = (name, w, h, d, position, mat, opts = {}) =>+ createPart(name, boxGeo(w, h, d), mat, {+ position,+ rotation: opts.rotation,+ parent: opts.parent ?? root,+ });+ const solid = (geo, mat = stone) => new THREE.Mesh(geo, mat);++ // A lancet prism, oriented to cut a wall whose normal runs along Z or X.+ // extrudeProfile on axis 'z' maps the profile's (u, v) straight to (x, y),+ // which is what a Z-facing wall wants. An X-facing wall is the same prism+ // turned a quarter turn about Y: local +X lands on world -Z, and the+ // extrusion (local +Z) lands on world +X.+ const lancetPrism = async (w, spring, depth, facing) => {+ const m = solid(await extrudeProfile(lancet(w, spring), { depth, axis: 'z' }));+ if (facing === 'x') m.rotation.y = Math.PI / 2;+ return m;+ };++ // ---------- Ground ----------+ slab('Plaza', 54, 0.4, 38, [-5, 0.2, 0], plaza);+ slab('Podium', 46, 0.6, 30, [-5, 0.7, 0], stoneWet);+ for (let i = 0; i < 3; i++) {+ slab(`Step_${i}`, 0.8, 0.22 * (3 - i), 15.0 - i * 0.8, [16.4 + i * 0.8, 0.4 + 0.11 * (3 - i), 0], stoneWet);+ }++ // ---------- Nave and aisles ----------+ // Everything is solid; see the known limit in the header. REVEAL is how deep+ // an opening is cut into a wall, and the glass goes at the back of the cut.+ const REVEAL = 1.15;+ // ...but the GLASS does not go to the back of the cut. A window set a metre+ // inside a wall is a window you cannot see: at the 55-degree azimuth a hero+ // shot is taken from, a 1.15 m reveal occludes 1.6 m of a 2.4 m opening and+ // every lancet on the flank goes black. The reveal is deep for the SHADOW it+ // casts on the elevation; the glass sits 0.35 m in, which is where a real+ // one is -- the splay that makes the wall look thick is on the inside, where+ // nobody outside is looking.+ const GLAZE = 0.35;++ const naveCutters = [];+ for (const bx of BAYS) {+ for (const sz of [1, -1]) {+ const c = await lancetPrism(2.8, 3.0, REVEAL * 2, 'z');+ c.position.set(bx, 14.5, sz * Z_NAVE);+ naveCutters.push(c);+ }+ }+ const naveBody = solid(boxGeo(X_NAVE - X_EAST, Y_CORNICE - Y_GROUND, Z_NAVE * 2));+ naveBody.position.set((X_NAVE + X_EAST) / 2, (Y_CORNICE + Y_GROUND) / 2, 0);+ const naveMass = await boolDiff('NaveWall', naveBody, ...naveCutters);+ naveMass.geometry = await uv(naveMass.geometry);+ root.add(naveMass);++ for (const sz of [1, -1]) {+ const cutters = [];+ for (const bx of BAYS) {+ const c = await lancetPrism(2.4, 2.5, REVEAL * 2, 'z');+ c.position.set(bx, 3.5, sz * Z_AISLE);+ cutters.push(c);+ }+ const body = solid(boxGeo(X_NAVE - X_EAST, Y_AISLE - Y_GROUND, Z_AISLE - Z_NAVE));+ body.position.set((X_NAVE + X_EAST) / 2, (Y_AISLE + Y_GROUND) / 2, (sz * (Z_AISLE + Z_NAVE)) / 2);+ const m = await boolDiff(`Aisle_${sz > 0 ? 'S' : 'N'}`, body, ...cutters);+ m.geometry = await uv(m.geometry);+ root.add(m);+ }++ // Glass and tracery at the back of every recess. A window is glass plus a+ // MULLION plus a transom: an undivided sheet of light reads as a hole in the+ // wall, and the bars are what make it read as a window.+ const glazeZ = async (name, w, spring, sillY, x, z, mat) => {+ const inner = w - 0.34;+ createPart(name, await uv(await extrudeProfile(lancet(inner, spring), { depth: 0.10, axis: 'z' })), mat, {+ position: [x, sillY, z],+ parent: root,+ });+ const top = lancetTop(inner, spring);+ slab(`${name}_Mullion`, 0.13, top - 0.25, 0.16, [x, sillY + (top - 0.25) / 2, z], stone);+ slab(`${name}_Transom`, inner - 0.1, 0.13, 0.16, [x, sillY + spring * 0.62, z], stone);+ };++ for (const bx of BAYS) {+ for (const sz of [1, -1]) {+ const tag = `${bx < 0 ? 'e' : 'w'}${Math.abs(bx)}${sz > 0 ? 'S' : 'N'}`;+ // A dark plate at the back of each cut, so the glass is never silhouetted+ // against raw daylight-coloured stone.+ slab(`ClerRev_${tag}`, 3.2, 6.4, 0.10, [bx, 17.6, sz * (Z_NAVE - GLAZE - 0.07)], shadow);+ await glazeZ(`ClerGlass_${tag}`, 2.8, 3.0, 14.5, bx, sz * (Z_NAVE - GLAZE), glassSapphire);+ slab(`AisleRev_${tag}`, 2.8, 5.6, 0.10, [bx, 6.0, sz * (Z_AISLE - GLAZE - 0.07)], shadow);+ await glazeZ(`AisleGlass_${tag}`, 2.4, 2.5, 3.5, bx, sz * (Z_AISLE - GLAZE), glassGold);+ }+ }++ // ---------- Transept ----------+ const T_RUN = T_HALF + 0.4;+ const naveRun = Z_NAVE + 0.6;+ const naveRise = Y_RIDGE - Y_CORNICE;+ const naveSlope = Math.atan2(naveRise, naveRun);+ const T_RISE = T_RUN * Math.tan(naveSlope); // same pitch, narrower span, lower ridge++ for (const sz of [1, -1]) {+ const tag = sz > 0 ? 'S' : 'N';+ const zEnd = sz * Z_TRANS;+ const cz = (sz * (Z_TRANS + Z_NAVE)) / 2;+ // Cut, like the nave and the aisles. The first pass built this arm as a+ // plain slab and then placed its window inside it, which sealed the glass+ // in solid stone -- the same mistake the vending machine's display made,+ // and just as invisible until you look at the elevation it faces.+ {+ const body = solid(boxGeo(T_HALF * 2, Y_CORNICE - Y_GROUND, Z_TRANS - Z_NAVE));+ body.position.set(X_CROSS, (Y_CORNICE + Y_GROUND) / 2, cz);+ const win = await lancetPrism(3.6, 4.0, REVEAL * 2, 'z');+ win.position.set(X_CROSS, 8.8, zEnd);+ const wheel = solid(cylinderZGeo(1.68, 1.68, REVEAL * 2, 20));+ wheel.position.set(X_CROSS, 18.3, zEnd);+ const m = await boolDiff(`Transept_${tag}`, body, win, wheel);+ m.geometry = await uv(m.geometry);+ root.add(m);+ }+ createPart(+ `TranseptGable_${tag}`,+ await uv(+ await extrudeProfile(+ [+ [-T_HALF, 0],+ [T_HALF, 0],+ [0, T_RISE],+ ],+ { depth: 1.0, axis: 'z' },+ ),+ ),+ stone,+ { position: [X_CROSS, Y_CORNICE, zEnd - sz * 0.5], parent: root },+ );++ // The end front: a triplet under a wheel window. The wheel lies in XY,+ // which is the plane a Z-facing wall lives in, so torusGeo needs no+ // rotation at all and cylinderZGeo is the disc that fits behind it.+ slab(`TranseptRev_${tag}`, 4.0, 7.6, 0.10, [X_CROSS, 12.4, sz * (Z_TRANS - GLAZE - 0.07)], shadow);+ createPart(+ `TranseptGlass_${tag}`,+ await uv(await extrudeProfile(lancet(3.6, 4.0), { depth: 0.10, axis: 'z' })),+ glassGold,+ { position: [X_CROSS, 8.8, sz * (Z_TRANS - GLAZE)], parent: root },+ );+ slab(`TranseptMullion_${tag}`, 0.16, 6.8, 0.14, [X_CROSS, 12.0, sz * (Z_TRANS - GLAZE + 0.07)], stone);+ createPart(`TranseptWheel_${tag}`, cylinderZGeo(1.5, 1.5, 0.12, 20), glassRuby, {+ position: [X_CROSS, 18.3, sz * (Z_TRANS - GLAZE + 0.06)],+ parent: root,+ });+ for (let i = 0; i < 6; i++) {+ slab(`TranseptSpoke_${tag}_${i}`, 0.16, 3.1, 0.16, [X_CROSS, 18.3, sz * (Z_TRANS - GLAZE + 0.14)], stone, {+ rotation: [0, 0, i * 30],+ });+ }+ createPart(`TranseptRing_${tag}`, torusGeo(1.62, 0.17, 6, 24), stone, {+ position: [X_CROSS, 18.3, sz * (Z_TRANS - GLAZE + 0.14)],+ parent: root,+ });+ }++ // ---------- Apse ----------+ // A half-octagon drum, the western half of it buried in the choir -- which is+ // how a real chevet meets its straight bays. The -22.5 turn puts a facet+ // CENTRE on the building's axis instead of an edge; with an edge on the axis+ // the east end comes to a point like a boat.+ // The drum's apothem, not its radius: an octagon's flat face is R*cos(22.5)+ // from the centre, and putting a window at R buries it 0.53 m inside the wall.+ const APSE_FACE = APSE_R * Math.cos(22.5 * RAD);+ const APSE_DIRS = [-1, 0, 1].map((i) => 180 + i * 45);+ {+ const drum = solid(cylinderGeo(APSE_R, APSE_R, Y_CORNICE - Y_GROUND, 8));+ drum.position.set(X_EAST, (Y_CORNICE + Y_GROUND) / 2, 0);+ drum.rotation.y = -22.5 * RAD;+ const cutters = [];+ for (const a of APSE_DIRS) {+ const c = await lancetPrism(2.4, 4.2, REVEAL * 2, 'z');+ c.rotation.y = (90 - a) * RAD;+ c.position.set(X_EAST + Math.cos(a * RAD) * APSE_FACE, 6.2, Math.sin(a * RAD) * APSE_FACE);+ cutters.push(c);+ }+ const m = await boolDiff('Apse', drum, ...cutters);+ m.geometry = await uv(m.geometry);+ root.add(m);+ }+ for (let i = 0; i < APSE_DIRS.length; i++) {+ const a = APSE_DIRS[i];+ const nx = Math.cos(a * RAD);+ const nz = Math.sin(a * RAD);+ const r = APSE_FACE - GLAZE;+ // Sized to the opening. A reveal plate three metres taller than the window+ // it backs is not a reveal, it is a black rectangle on the elevation.+ slab(`ApseRev_${i}`, 0.14, 7.0, 2.8, [X_EAST + nx * (r - 0.07), 9.4, nz * (r - 0.07)], shadow, {+ rotation: [0, -a, 0],+ });+ createPart(+ `ApseGlass_${i}`,+ await uv(await extrudeProfile(lancet(2.06, 4.2), { depth: 0.12, axis: 'z' })),+ glassGold,+ { position: [X_EAST + nx * r, 6.2, nz * r], rotation: [0, 90 - a, 0], parent: root },+ );+ }+ createPart('ApseRoof', await uv(coneGeo(APSE_R + 0.7, 6.8, 8)), lead, {+ position: [X_EAST, Y_CORNICE + 3.4, 0],+ rotation: [0, -22.5, 0],+ parent: root,+ });++ // ---------- Roofs ----------+ // A slab rotated about X by +t drops its +Z edge, so the south slope takes a+ // positive angle and the north slope a negative one.+ const naveLen = Math.hypot(naveRun, naveRise);+ for (const sz of [1, -1]) {+ slab(`NaveRoof_${sz > 0 ? 'S' : 'N'}`, X_NAVE - X_EAST + 0.5, 0.4, naveLen, [+ (X_NAVE + X_EAST) / 2,+ Y_CORNICE + naveRise / 2,+ (sz * naveRun) / 2,+ ], lead, { rotation: [(sz * naveSlope) / RAD, 0, 0] });+ }+ slab('NaveRidge', X_NAVE - X_EAST + 0.5, 0.36, 0.8, [(X_NAVE + X_EAST) / 2, Y_RIDGE + 0.12, 0], lead);++ // Aisles: a lean-to from the aisle eaves into the nave wall, broken at the+ // crossing because the transept is there.+ const leanRun = Z_AISLE - Z_NAVE + 0.5;+ const leanRise = Y_LEAN - Y_AISLE;+ const leanLen = Math.hypot(leanRun, leanRise);+ const leanSlope = Math.atan2(leanRise, leanRun) / RAD;+ const leanRuns = [+ [X_NAVE + 0.2, X_CROSS + T_HALF + 0.4],+ [X_CROSS - T_HALF - 0.4, X_EAST - 0.2],+ ];+ for (const sz of [1, -1]) {+ for (let i = 0; i < leanRuns.length; i++) {+ const [x0, x1] = leanRuns[i];+ slab(`AisleRoof_${sz > 0 ? 'S' : 'N'}${i}`, x0 - x1, 0.35, leanLen, [+ (x0 + x1) / 2,+ (Y_AISLE + Y_LEAN) / 2,+ sz * (Z_NAVE + leanRun / 2 - 0.25),+ ], lead, { rotation: [sz * leanSlope, 0, 0] });+ }+ }++ // Transept: the same pitch turned across the nave. Rotating about Z lifts the+ // +X edge, so the west slope takes a negative angle.+ const tLen = Math.hypot(T_RUN, T_RISE);+ for (const sz of [1, -1]) {+ for (const dx of [1, -1]) {+ slab(`TranseptRoof_${sz > 0 ? 'S' : 'N'}${dx > 0 ? 'w' : 'e'}`, tLen, 0.36, Z_TRANS - Z_NAVE + 1.0, [+ X_CROSS + (dx * T_RUN) / 2,+ Y_CORNICE + T_RISE / 2,+ (sz * (Z_TRANS + Z_NAVE)) / 2,+ ], lead, { rotation: [0, 0, (-dx * naveSlope) / RAD] });+ }+ }++ // ---------- Flying buttresses ----------+ // Pier, flyer and pinnacle are one assembly, built once and placed ten times.+ // The flyer's section is the honest one: a curved intrados carrying the load+ // and a STRAIGHT extrados above it, because the top of a flyer is a gutter+ // and the water has to run off it.+ const flyProfile = () => {+ const z0 = Z_NAVE + 0.4;+ const z1 = Z_PIER - 0.5;+ const y0 = 17.9;+ const y1 = 14.6;+ const pts = [];+ for (let i = 0; i <= 8; i++) {+ const t = i / 8;+ pts.push([z0 + (z1 - z0) * t, y0 + (y1 - y0) * t - 1.15 * Math.sin(Math.PI * t)]);+ }+ pts.push([z1, y1 + 1.45]);+ pts.push([z0, y0 + 2.05]);+ return pts;+ };+ const flyGeo = await uv(await extrudeProfile(flyProfile(), { depth: 0.75, axis: 'z' }));+ const pinnacleGeo = await uv(+ await revolveProfile(+ [+ [0.0, 0.0],+ [0.80, 0.0],+ [0.80, 1.1],+ [0.64, 1.4],+ [0.64, 1.8],+ [0.0, 5.6],+ ],+ { segments: 8, axis: 'y' },+ ),+ );++ let flySource = null;+ let pinSource = null;+ for (const px of PIERS) {+ for (const sz of [1, -1]) {+ const tag = `${px < 0 ? 'e' : 'w'}${Math.abs(px)}${sz > 0 ? 'S' : 'N'}`;+ const pz = sz * (Z_PIER - 0.3);+ // Three stages, each set back from the one below: that is how a buttress+ // sheds water, and it is what makes it read at thirty metres.+ slab(`PierBase_${tag}`, 2.1, 4.2, 2.9, [px, Y_GROUND + 2.1, pz], stoneWet);+ slab(`PierSet_${tag}`, 1.9, 0.5, 2.7, [px, Y_GROUND + 4.3, pz], stone);+ slab(`Pier_${tag}`, 1.7, 15.5, 2.4, [px, Y_GROUND + 7.75, pz], stone);+ slab(`PierCap_${tag}`, 2.0, 0.55, 2.7, [px, 16.9, pz], stone);+ createPart(`PierWeather_${tag}`, coneGeo(1.5, 1.5, 4), stone, {+ position: [px, 17.7, pz],+ rotation: [0, 45, 0],+ parent: root,+ });++ // Dead weight on the pier head, not ornament. See the header.+ if (!pinSource) pinSource = createPart(`Pinnacle_${tag}`, pinnacleGeo, stone, { position: [px, 17.4, pz], parent: root });+ else createInstance(`Pinnacle_${tag}`, pinSource, { position: [px, 17.4, pz], parent: root });++ // The flyer, built in the (z, y) plane and turned a quarter turn -- the+ // same trick as the window prisms.+ // A quarter turn about Y sends the profile's u to world -z, so the+ // SOUTH flyer takes the negative rotation. The first pass had these the+ // other way round and every flyer sprang from the pier on the far side.+ const opts = { position: [px, 0, 0], rotation: [0, sz > 0 ? -90 : 90, 0], parent: root };+ if (!flySource) flySource = createPart(`Flyer_${tag}`, flyGeo, stone, opts);+ else createInstance(`Flyer_${tag}`, flySource, opts);+ }+ }++ // ---------- West front ----------+ const westCutters = [];+ const portal = await lancetPrism(6.4, 5.6, 5.0, 'x');+ portal.position.set(X_WEST, Y_GROUND + 0.3, 0);+ westCutters.push(portal);+ const roseHole = solid(cylinderXGeo(3.8, 3.8, 6.0, 24));+ roseHole.position.set(X_WEST, 21.0, 0);+ westCutters.push(roseHole);+ const westBody = solid(boxGeo(X_WEST - 10.2, 26.0 - Y_GROUND, Z_NAVE * 2 + 0.2));+ westBody.position.set((X_WEST + 10.2) / 2, (26.0 + Y_GROUND) / 2, 0);+ const westMass = await boolDiff('WestFront', westBody, ...westCutters);+ westMass.geometry = await uv(westMass.geometry);+ root.add(westMass);++ // The rose. A big emissive disc would be a white hole in the front of the+ // building; what makes a rose read is the STONE laid over it, so the glass+ // runs cool and the tracery does the work.+ //+ // The first pass got the geometry wrong in a way worth recording: twelve+ // wedges running centre-to-rim, hues cycling round them. That is a parasol,+ // not a window. A rose is built as concentric RINGS of small lights, each+ // ring separated from the next by stone, because the tracery is what carries+ // the load -- the glass is only filling what the mason left. So: sixteen+ // lights in the outer ring, eight inside it, one eye at the centre, and+ // eight full-diameter bars whose sixteen arms land exactly on the outer+ // ring's joints. Blue outside, red inside, gold only in the eye.+ {+ const RX = X_WEST - 0.55;+ // An annular sector: out along one radius, round at r1, back at r0.+ const ringPane = (i, count, r0, r1) => {+ const step = 360 / count;+ const a0 = (i * step + step * 0.15) * RAD;+ const a1 = ((i + 1) * step - step * 0.15) * RAD;+ const pts = [];+ for (let k = 0; k <= 5; k++) {+ const a = a0 + ((a1 - a0) * k) / 5;+ pts.push([Math.cos(a) * r1, Math.sin(a) * r1]);+ }+ for (let k = 5; k >= 0; k--) {+ const a = a0 + ((a1 - a0) * k) / 5;+ pts.push([Math.cos(a) * r0, Math.sin(a) * r0]);+ }+ return pts;+ };+ for (let i = 0; i < 16; i++) {+ createPart(+ `RoseOuter_${i}`,+ await uv(await extrudeProfile(ringPane(i, 16, 2.55, 3.45), { depth: 0.14, axis: 'z' })),+ i % 4 === 2 ? roseRuby : roseSapphire,+ { position: [RX, 21.0, 0], rotation: [0, 90, 0], parent: root },+ );+ }+ for (let i = 0; i < 8; i++) {+ createPart(+ `RoseInner_${i}`,+ await uv(await extrudeProfile(ringPane(i, 8, 1.10, 1.95), { depth: 0.14, axis: 'z' })),+ roseRuby,+ { position: [RX, 21.0, 0], rotation: [0, 90, 0], parent: root },+ );+ }+ createPart('RoseHub', cylinderXGeo(0.62, 0.62, 0.30, 16), roseEye, { position: [RX + 0.12, 21.0, 0], parent: root });+ // The spokes are boxes standing on their long Y axis, swung about X --+ // which is the rose's own axis, so no second rotation is needed. Eight+ // bars, 22.5 degrees apart, give sixteen arms: one per outer joint.+ for (let i = 0; i < 8; i++) {+ slab(`RoseSpoke_${i}`, 0.26, 7.2, 0.28, [RX + 0.22, 21.0, 0], stoneWet, { rotation: [i * 22.5, 0, 0] });+ }+ createPart('RoseRingInner', torusGeo(1.15, 0.22, 6, 20), stone, { position: [RX + 0.26, 21.0, 0], rotation: [0, 90, 0], parent: root });+ createPart('RoseRingMid', torusGeo(2.35, 0.20, 6, 28), stone, { position: [RX + 0.26, 21.0, 0], rotation: [0, 90, 0], parent: root });+ createPart('RoseRingOuter', torusGeo(3.8, 0.42, 8, 32), stone, { position: [RX + 0.32, 21.0, 0], rotation: [0, 90, 0], parent: root });+ }++ // The great door. Recessed orders are the whole point of a Gothic portal: one+ // flat arch reads as a hole punched in a wall, four stepped ones read as a+ // doorway you could walk through.+ {+ for (let i = 0; i < 4; i++) {+ const w = 6.4 - i * 0.44;+ const band = await boolDiff(+ `Archivolt_${i}`,+ await lancetPrism(w, 5.6, 0.50, 'x'),+ await lancetPrism(w - 0.48, 5.6, 0.9, 'x'),+ );+ band.geometry = await uv(band.geometry);+ band.position.set(X_WEST - 0.22 - i * 0.55, Y_GROUND + 0.3, 0);+ root.add(band);+ }+ slab('Tympanum', 0.35, 3.0, 4.6, [X_WEST - 2.35, Y_GROUND + 7.2, 0], stoneWet);+ slab('Lintel', 0.55, 0.55, 4.9, [X_WEST - 2.25, Y_GROUND + 5.5, 0], stone);+ slab('Trumeau', 0.7, 5.4, 0.6, [X_WEST - 2.25, Y_GROUND + 2.8, 0], stone);+ for (const s of [1, -1]) {+ slab(`Door_${s > 0 ? 'a' : 'b'}`, 0.22, 5.2, 1.85, [X_WEST - 2.4, Y_GROUND + 2.75, s * 1.1], oak);+ for (let i = 0; i < 3; i++) {+ slab(`DoorBand_${s > 0 ? 'a' : 'b'}${i}`, 0.1, 0.18, 1.75, [X_WEST - 2.5, Y_GROUND + 1.2 + i * 1.7, s * 1.1], iron);+ }+ // Jamb shafts. Eight thin columns are the cheapest thing on this model+ // and they are what make the doorway look carved rather than punched.+ for (let i = 0; i < 4; i++) {+ createPart(`Jamb_${s > 0 ? 'a' : 'b'}${i}`, cylinderGeo(0.19, 0.19, 5.2, 8), stone, {+ position: [X_WEST - 0.45 - i * 0.55, Y_GROUND + 3.0, s * (2.95 + i * 0.24)],+ parent: root,+ });+ }+ }+ }++ createPart(+ 'PortalGable',+ await uv(await extrudeProfile([[-3.9, 0], [3.9, 0], [0, 3.0]], { depth: 0.7, axis: 'z' })),+ stone,+ { position: [X_WEST - 0.35, Y_GROUND + 11.4, 0], rotation: [0, 90, 0], parent: root },+ );+ slab('WestString', 0.5, 0.5, Z_NAVE * 2 + 0.4, [X_WEST - 0.05, Y_GROUND + 11.2, 0], stone);++ // The gallery: a blind arcade across the front between the door and the rose.+ // One arch, built once, placed eleven times.+ {+ // Eleven arches at 1.0 m across a 1.15 m opening left 0.15 m of stone+ // between them, and the whole band collapsed into one dark stripe. Nine at+ // 1.22 across 0.88 leaves 0.34 -- a third of the opening -- which is what+ // makes the rhythm read as columns rather than as a gap.+ let arcSource = null;+ const arcGeo = await uv(await extrudeProfile(lancet(0.88, 1.7), { depth: 0.4, axis: 'z' }));+ for (let i = 0; i < 9; i++) {+ const z = -4.88 + i * 1.22;+ const opts = { position: [X_WEST - 0.15, 13.6, z], rotation: [0, 90, 0], parent: root };+ if (!arcSource) arcSource = createPart(`Gallery_${i}`, arcGeo, recess, opts);+ else createInstance(`Gallery_${i}`, arcSource, opts);+ slab(`GalleryShaft_${i}`, 0.46, 3.4, 0.30, [X_WEST - 0.02, 13.2, z - 0.61], stone);+ }+ slab('GalleryShaft_end', 0.46, 3.4, 0.30, [X_WEST - 0.02, 13.2, 4.88 + 0.61], stone);+ slab('GallerySill', 0.6, 0.45, 11.4, [X_WEST - 0.12, 13.2, 0], stone);+ slab('GalleryCap', 0.6, 0.45, 11.4, [X_WEST - 0.12, 16.8, 0], stone);+ }++ slab('WestCornice', 0.9, 0.6, Z_NAVE * 2 + 1.4, [X_WEST - 0.1, 26.2, 0], stone);+ createPart(+ 'WestGable',+ await uv(+ await extrudeProfile(+ [+ [-5.6, 0],+ [5.6, 0],+ [0, 4.6],+ ],+ { depth: 2.2, axis: 'z' },+ ),+ ),+ stone,+ { position: [X_WEST - 1.1, 26.5, 0], rotation: [0, 90, 0], parent: root },+ );+ createPart('GableFinial', await uv(coneGeo(0.6, 2.8, 6)), stone, { position: [X_WEST - 1.1, 32.0, 0], parent: root });++ // ---------- Towers ----------+ // One tower, cut once for its belfry openings, then placed twice. The+ // openings sit on all four faces, so the same solid serves both sides.+ const TOWER_HALF = 2.8;+ const TOWER_Z = 8.3;+ const TOWER_X = X_WEST - TOWER_HALF;+ const BELFRY_SILL = 23.5;+ const BELFRY_H = lancetTop(1.5, 3.0);+ const belfryCut = [];+ for (const face of ['x', 'z']) {+ for (const s of [1, -1]) {+ for (const off of [-1.0, 1.0]) {+ const c = await lancetPrism(1.5, 3.0, 3.4, face);+ const local = BELFRY_SILL - (Y_TOWER + Y_GROUND) / 2;+ if (face === 'x') c.position.set(s * TOWER_HALF, local, off);+ else c.position.set(off, local, s * TOWER_HALF);+ belfryCut.push(c);+ }+ }+ }+ const towerSolid = await boolDiff(+ 'Tower',+ solid(boxGeo(TOWER_HALF * 2, Y_TOWER - Y_GROUND, TOWER_HALF * 2)),+ ...belfryCut,+ );+ towerSolid.geometry = await uv(towerSolid.geometry);++ for (const sz of [1, -1]) {+ const tag = sz > 0 ? 'S' : 'N';+ const tz = sz * TOWER_Z;+ createInstance(`Tower_${tag}`, towerSolid, {+ position: [TOWER_X, (Y_TOWER + Y_GROUND) / 2, tz],+ parent: root,+ });+ // A belfry is OPEN, so its openings are dark, not lit. This is the one+ // place on the building where a hole must not glow.+ for (const face of ['x', 'z']) {+ for (const s of [1, -1]) {+ for (const off of [-1.0, 1.0]) {+ const at = face === 'x'+ ? [TOWER_X + s * (TOWER_HALF - 0.45), BELFRY_SILL + BELFRY_H / 2, tz + off]+ : [TOWER_X + off, BELFRY_SILL + BELFRY_H / 2, tz + s * (TOWER_HALF - 0.45)];+ slab(`Belfry_${tag}${face}${s > 0 ? 'p' : 'n'}${off > 0 ? 'a' : 'b'}`,+ face === 'x' ? 0.2 : 1.4, BELFRY_H, face === 'x' ? 1.4 : 0.2, at, shadow);+ }+ }+ }+ // Corner buttresses clasping the angles. Every real tower has them, and+ // they are most of what stops a tower reading as a chimney.+ for (const cx of [1, -1]) {+ for (const cz of [1, -1]) {+ const bx = TOWER_X + cx * TOWER_HALF;+ const bz = tz + cz * TOWER_HALF;+ slab(`TowerButBase_${tag}${cx > 0 ? 'p' : 'n'}${cz > 0 ? 'p' : 'n'}`, 1.9, 4.6, 1.9, [bx, Y_GROUND + 2.3, bz], stoneWet);+ slab(`TowerBut_${tag}${cx > 0 ? 'p' : 'n'}${cz > 0 ? 'p' : 'n'}`, 1.5, Y_TOWER - Y_GROUND - 2.0, 1.5, [+ bx,+ (Y_TOWER + Y_GROUND) / 2 - 1.0,+ bz,+ ], stone);+ }+ }+ for (const sy of [12.2, 18.4, 22.6]) {+ slab(`TowerString_${tag}_${sy}`, 6.6, 0.45, 6.6, [TOWER_X, sy, tz], stone);+ }+ slab(`TowerCornice_${tag}`, 7.2, 0.7, 7.2, [TOWER_X, Y_TOWER, tz], stone);+ }++ // ---------- Tower crowns ----------+ // One crown, placed on both towers. Everything above the belfry cornice is a+ // second campaign: a parapet with pinnacles at its corners, a pierced+ // octagonal lantern, then the spire. See principle 3 -- the two towers are a+ // pair and are built as one.+ //+ // The lantern's openings are CUT, for the same reason every other opening on+ // this building is: a drum with window plates stuck on its faces is a drum+ // with pictures of windows on it, and it reads as one the moment the light+ // moves. Rotating the octagon by -22.5 puts a face CENTRE on each cardinal+ // azimuth, so the eight face normals land on multiples of 45 degrees, and a+ // cutter driven through the middle takes out the near face and the far one+ // together -- four of them do all eight lights.+ const LANT_R = 2.85;+ const LANT_H = 5.0;+ const LANT_Y0 = Y_TOWER + 2.35;+ const SP_R = 2.55;+ const SP_H = 14.0;+ const SP_Y0 = LANT_Y0 + LANT_H + 0.8;++ for (const csz of [1, -1]) {+ const tag = csz > 0 ? 'S' : 'N';+ const tz = csz * TOWER_Z;++ slab(`ParapetDeck_${tag}`, 6.6, 0.4, 6.6, [TOWER_X, Y_TOWER + 0.55, tz], stoneWet);+ for (const [ox, oz, w, d] of [+ [0, 3.2, 7.0, 0.6],+ [0, -3.2, 7.0, 0.6],+ [3.2, 0, 0.6, 7.0],+ [-3.2, 0, 0.6, 7.0],+ ]) {+ const px = ox > 0 ? 'p' : ox < 0 ? 'n' : 'c';+ const pz = oz > 0 ? 'p' : oz < 0 ? 'n' : 'c';+ slab(`Parapet_${tag}${px}${pz}`, w, 2.0, d, [TOWER_X + ox, Y_TOWER + 1.35, tz + oz], stone);+ }+ for (const cx of [1, -1]) {+ for (const cz of [1, -1]) {+ createInstance(`TowerPinnacle_${tag}${cx > 0 ? 'p' : 'n'}${cz > 0 ? 'p' : 'n'}`, pinSource, {+ position: [TOWER_X + cx * 3.2, Y_TOWER + 2.2, tz + cz * 3.2],+ parent: root,+ });+ }+ }++ const lantern = solid(cylinderGeo(LANT_R, LANT_R, LANT_H, 8));+ lantern.position.set(TOWER_X, LANT_Y0 + LANT_H / 2, tz);+ lantern.rotation.y = -22.5 * RAD;+ const lantCut = [];+ for (let k = 0; k < 4; k++) {+ const a = k * 45;+ const cut = solid(await extrudeProfile(lancet(1.55, 1.85), { depth: LANT_R * 2.4, axis: 'z' }));+ cut.position.set(TOWER_X, LANT_Y0 + 0.95, tz);+ cut.rotation.y = (90 - a) * RAD;+ lantCut.push(cut);+ }+ const lanternMass = await boolDiff(`Lantern_${tag}`, lantern, ...lantCut);+ lanternMass.geometry = await uv(lanternMass.geometry);+ root.add(lanternMass);+ // A belfry is open, so what stands behind its lights is the dark of the+ // bell chamber. Same rule as the openings in the tower shaft below.+ createPart(`LanternDark_${tag}`, cylinderGeo(2.34, 2.34, LANT_H - 0.5, 8), shadow, {+ position: [TOWER_X, LANT_Y0 + LANT_H / 2, tz],+ rotation: [0, -22.5, 0],+ parent: root,+ });+ // Colonnettes on the arrises, which sit at 22.5 + k*45 -- between the+ // faces, not on them.+ for (let k = 0; k < 8; k++) {+ const a = (22.5 + k * 45) * RAD;+ createPart(`LanternShaft_${tag}${k}`, cylinderGeo(0.20, 0.20, LANT_H, 6), stone, {+ position: [TOWER_X + Math.cos(a) * LANT_R, LANT_Y0 + LANT_H / 2, tz + Math.sin(a) * LANT_R],+ parent: root,+ });+ }++ // The spire is stone, not lead. A lead spire on one tower and a stone one+ // on the other was the single ugliest thing on this model: the pair read as+ // two buildings that happened to touch.+ createPart(`SpireCornice_${tag}`, await uv(cylinderGeo(2.95, 3.15, 0.8, 8)), stone, {+ position: [TOWER_X, SP_Y0 - 0.4, tz],+ rotation: [0, -22.5, 0],+ parent: root,+ });+ createPart(`Spire_${tag}`, await uv(coneGeo(SP_R, SP_H, 8)), stone, {+ position: [TOWER_X, SP_Y0 + SP_H / 2, tz],+ rotation: [0, -22.5, 0],+ parent: root,+ });++ // Lucarnes at the spire foot: the little gabled dormers that let a mason+ // out onto the stonework. Four, on the cardinal faces.+ for (const a of [0, 90, 180, 270]) {+ const rad = a * RAD;+ const at = (r) => [TOWER_X + Math.cos(rad) * r, SP_Y0 + 0.95, tz + Math.sin(rad) * r];+ createPart(+ `Lucarne_${tag}${a}`,+ await uv(+ await extrudeProfile(+ [+ [-0.52, 0],+ [0.52, 0],+ [0.52, 0.62],+ [0, 1.30],+ [-0.52, 0.62],+ ],+ { depth: 0.72, axis: 'z' },+ ),+ ),+ stone,+ { position: at(2.10), rotation: [0, 90 - a, 0], parent: root },+ );+ createPart(+ `LucarneLight_${tag}${a}`,+ await uv(await extrudeProfile(lancet(0.40, 0.34), { depth: 0.10, axis: 'z' })),+ recess,+ { position: at(2.47), rotation: [0, 90 - a, 0], parent: root },+ );+ }++ // Crockets up the arrises. They are 0.26 m knobs on a 14 m cone, so they do+ // not read as carving -- they read as an EDGE that is not straight, which+ // is most of what separates a spire from a traffic cone. Set at 0.88 of the+ // surface radius so each one bites into the stone rather than hovering off+ // a face the geometry does not have there.+ for (let k = 0; k < 8; k++) {+ const a = (22.5 + k * 45) * RAD;+ for (const t of [0.16, 0.34, 0.52, 0.70]) {+ const r = SP_R * (1 - t) * 0.88;+ createPart(`Crocket_${tag}${k}_${Math.round(t * 100)}`, coneGeo(0.26, 0.55, 4), stone, {+ position: [TOWER_X + Math.cos(a) * r, SP_Y0 + t * SP_H, tz + Math.sin(a) * r],+ rotation: [0, 45, 0],+ parent: root,+ });+ }+ }++ createPart(`SpireFinial_${tag}`, cylinderGeo(0.13, 0.13, 2.4, 6), iron, {+ position: [TOWER_X, SP_Y0 + SP_H + 1.0, tz],+ parent: root,+ });+ createPart(`SpireCross_${tag}`, boxGeo(0.13, 0.13, 1.0), iron, {+ position: [TOWER_X, SP_Y0 + SP_H + 1.5, tz],+ parent: root,+ });+ }++ // ---------- Crossing flèche ----------+ // Timber and lead over the crossing, far slimmer than the stone spires,+ // because it stands on a vault and not on a tower. It is also the one thing+ // on this building that is deliberately off-axis: the west front is a+ // symmetric pair, and the flèche is what stops the whole silhouette from+ // being one.+ createPart('FlecheBase', await uv(cylinderGeo(2.4, 2.6, 2.6, 8)), lead, {+ position: [X_CROSS, Y_RIDGE + 0.9, 0],+ rotation: [0, -22.5, 0],+ parent: root,+ });+ createPart('FlecheStage', await uv(cylinderGeo(1.9, 2.2, 3.4, 8)), flecheLead, {+ position: [X_CROSS, Y_RIDGE + 3.9, 0],+ rotation: [0, -22.5, 0],+ parent: root,+ });+ createPart('Fleche', await uv(coneGeo(1.9, 11.0, 8)), flecheLead, {+ position: [X_CROSS, Y_RIDGE + 11.1, 0],+ rotation: [0, -22.5, 0],+ parent: root,+ });+ createPart('FlecheFinial', cylinderGeo(0.11, 0.11, 1.9, 6), iron, { position: [X_CROSS, Y_RIDGE + 17.4, 0], parent: root });+ for (let i = 0; i < 4; i++) {+ const a = (i * 90 + 45) * RAD;+ createPart(`FlecheLucarne_${i}`, coneGeo(0.6, 1.6, 4), flecheLead, {+ position: [X_CROSS + Math.cos(a) * 1.7, Y_RIDGE + 7.6, Math.sin(a) * 1.7],+ rotation: [0, i * 90, 0],+ parent: root,+ });+ }++ return root;+}diff --git a/examples/clock-tower.kiln.js b/examples/clock-tower.kiln.jsnew file mode 100644index 00000000..f2d5bd97--- /dev/null+++ b/examples/clock-tower.kiln.js@@ -0,0 +1,132 @@+// Authored by: gpt-6-astra, via codex.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'ClockTower', category: 'architecture' };+function build() {+ const root=createRoot('ClockTower');+ const stone=gameMaterial(0x9b927f,{roughness:.95}), trim=gameMaterial(0xc7baa0,{roughness:.85}), shadow=gameMaterial(0x242a29), lead=gameMaterial(0x465359,{metalness:.55,roughness:.65}), gold=gameMaterial(0xc7a04e,{metalness:.75,roughness:.35}), wood=gameMaterial(0x493726), bronze=gameMaterial(0x917044,{metalness:.7,roughness:.5});+ let id=0;+ function part(n,g,m,pos,p=root,rot=[0,0,0]){g=g.clone();g.applyMatrix4(new THREE.Matrix4().makeRotationFromEuler(new THREE.Euler(rot[0]*Math.PI/180,rot[1]*Math.PI/180,rot[2]*Math.PI/180)));g.computeBoundingBox();return createPart(n+'_'+id++,g,m,{position:pos,parent:p});}+ function box(n,w,h,d,x,y,z,m=stone,p=root,rot=[0,0,0]){return part(n,boxGeo(w,h,d),m,[x,y,z],p,rot);}+ function beam(n,a,b,r,m,p=root){return beamBetween(n+'_'+id++,a,b,r,m,{segments:4,parent:p});}+ function group(n,p=root){const g=createRoot(n);p.add(g);return g;}+ function prism(n,pts,x,depth,m,p){+ const v=[],idx=[],N=pts.length;+ for(const xx of [x-depth/2,x+depth/2])for(const q of pts)v.push(xx,q[0],q[1]);+ for(let i=1;i<N-1;i++){idx.push(0,i+1,i,N,N+i,N+i+1);}+ for(let i=0;i<N;i++){const j=(i+1)%N;idx.push(i,j,N+j,i,N+j,N+i);}+ const g=new THREE.BufferGeometry();g.setAttribute('position',new THREE.Float32BufferAttribute(v,3));g.setIndex(idx);g.computeVertexNormals();return part(n,g,m,[0,0,0],p);+ }+ box('GroundPlinth',6.8,.4,6.8,0,.2,0,trim);+ box('BaseMoulding',6.45,.22,6.45,0,.51,0,trim);+ const stages=[{base:.62,height:4.18},{base:4.8,height:4.6},{base:9.4,height:4.6}];+ for(let f=0;f<4;f++){+ const face=group('Facade_'+f);face.rotation.y=f*Math.PI/2;+ for(let s=0;s<3;s++){+ const st=stages[s], rows=8, rh=st.height/rows;+ for(let r=0;r<rows;r++){+ const low=st.base+r*rh, high=low+rh;+ let gap=0;+ if(s===1 && high>5.65 && low<8.9)gap=.72;+ if(s===0 && f===0 && low<3.2)gap=.85;+ const ranges=gap?[[-2.8,-gap],[gap,2.8]]:[[-2.8,0],[0,2.8]];+ for(const range of ranges){const len=range[1]-range[0];for(let b=0;b<1;b++)box('Ashlar',.48,rh-.016,len-.015,2.56,low+rh/2,range[0]+len*(b+.5),stone,face);}+ }+ box('CourseLower',.65,.12,5.95,2.66,st.base+st.height-.05,0,trim,face);+ box('CourseDrip',.77,.15,6.05,2.68,st.base+st.height+.075,0,trim,face);+ }+ // True void through the middle stage, closed to a pointed lancet by spandrels.+ prism('LancetSpandrelL',[[8.02,-.72],[8.95,-.72],[8.95,0]],2.56,.48,stone,face);+ prism('LancetSpandrelR',[[8.02,.72],[8.95,0],[8.95,.72]],2.56,.48,stone,face);+ for(const z of [-.79,.79])box('LancetJamb',.65,2.55,.15,2.64,6.76,z,trim,face);+ for(const side of [-1,1])beam('PointedArchivolt',[2.92,8.04,side*.79],[2.92,9.02,0],.105,trim,face);+ box('LancetSill',.83,.16,1.82,2.66,5.5,0,trim,face);+ box('StoneMullion',.18,2.73,.085,2.6,6.91,0,trim,face);+ box('Transom',.18,.07,1.4,2.6,7.13,0,trim,face);+ if(f===0){+ for(const side of [-1,1])box('DoorJamb',.7,2.55,.2,2.7,1.72,side*.94,trim,face);+ prism('DoorHeadLeft',[[2.4,-.85],[3.3,-.85],[3.3,0]],2.56,.48,stone,face);+ prism('DoorHeadRight',[[2.4,.85],[3.3,0],[3.3,.85]],2.56,.48,stone,face);+ for(const side of [-1,1])beam('DoorArch',[2.95,2.43,side*.95],[2.95,3.38,0],.13,trim,face);+ }+ const clock=group('Clock_'+f,face);clock.position.set(0,11.65,0);+ part('ClockStoneBed',cylinderXGeo(1.68,1.68,.18,20),trim,[2.85,0,0],clock);+ part('ClockDial',cylinderXGeo(1.45,1.45,.12,20),shadow,[2.98,0,0],clock);+ part('OuterMoulding',torusGeo(1.58,.075,4,20),trim,[2.99,0,0],clock,[0,90,0]);+ part('GiltRim',torusGeo(1.4,.035,4,20),gold,[3.065,0,0],clock,[0,90,0]);+ const nums=['XII','I','II','III','IIII','V','VI','VII','VIII','IX','X','XI'];+ for(let k=0;k<12;k++){+ const a=k*Math.PI/6, cy=1.16*Math.cos(a),cz=-1.16*Math.sin(a),str=nums[k];+ for(let j=0;j<str.length;j++){+ const z=cz-(j-(str.length-1)/2)*.095;+ if(str[j]==='I')box('RomanI',.03,.23,.032,3.071,cy,z,gold,clock);+ if(str[j]==='V'){beam('RomanV',[3.071,cy+.115,z-.035],[3.071,cy-.115,z],.016,gold,clock);beam('RomanV',[3.071,cy-.115,z],[3.071,cy+.115,z+.035],.016,gold,clock);}+ if(str[j]==='X'){beam('RomanX',[3.071,cy+.115,z-.035],[3.071,cy-.115,z+.035],.016,gold,clock);beam('RomanX',[3.071,cy-.115,z-.035],[3.071,cy+.115,z+.035],.016,gold,clock);}+ }+ }+ beam('MinuteHand',[3.11,0,0],[3.11,.76,.44],.037,gold,clock);+ beam('HourHand',[3.12,0,0],[3.12,.32,-.56],.052,gold,clock);+ part('HandBoss',cylinderXGeo(.1,.1,.07,12),gold,[3.14,0,0],clock);+ // Open belfry: side louvre banks leave the hanging bell visible in the centre.+ for(const z of [-2.45,2.45])box('BelfryPier',.65,3.05,.7,2.45,15.55,z,stone,face);+ box('BelfryArchitrave',.65,.3,4.4,2.45,16.9,0,trim,face);+ for(const side of [-1,1])for(const edge of [.7,2.03])box('LouvreFrameStile',.38,2.65,.15,2.47,15.4,side*edge,wood,face);+ for(const side of [-1,1])for(let j=0;j<7;j++)box('Louvre',.42,.12,1.22,2.47,14.4+j*.33,side*1.35,lead,face,[0,0,-24]);+ box('ParapetBase',.48,.18,5.65,2.6,17.25,0,trim,face);+ box('ParapetCap',.55,.17,5.75,2.6,18.05,0,trim,face);+ for(let j=-4;j<=4;j++)box('PiercedParapetUpright',.35,.7,.16,2.6,17.66,j*.57,trim,face);+ // Lucarne seated on the sloping lead roof.+ box('LucarneCheek',.78,.82, .85,1.98,19.15,0,lead,face);+ box('LucarneOpening',.045,.59,.5,2.39,19.16,0,shadow,face);+ for(const z of [-.33,.33])box('LucarneJamb',.14,.75,.1,2.42,19.16,z,trim,face);+ prism('LucarneGable',[[19.53,-.49],[20.15,0],[19.53,.49]],2.15,.7,lead,face);+ for(const side of [-1,1])beam('LucarneVerge',[2.52,19.5,side*.49],[2.52,20.17,0],.065,trim,face);+ }+ for(let s=0;s<3;s++)for(const x of [-1,1])for(const z of [-1,1]){+ const st=stages[s], width=1.05-s*.19, y=st.base+st.height/2;+ box('ClaspButtressX',width,st.height,.67,x*(2.8+width/2-.28),y,z*2.46);+ box('ClaspButtressZ',.67,st.height,width,x*2.46,y,z*(2.8+width/2-.28));+ box('ButtressWeathering',width+.12,.2,width+.12,x*2.89,st.base+st.height-.03,z*2.89,trim);+ }+ box('GroundFloor',5.15,.14,5.15,0,.47,0,shadow);+ for(const y of [4.78,9.38,14.05])box('FloorDeck',5.1,.16,5.1,0,y,0,wood);+ const bell=group('BellAndTimberFrame');+ for(const z of [-1.15,1.15])box('BellFramePost',.24,2.6,.25,0,15.43,z,wood,bell);+ box('BellHeadstock',.42,.32,2.8,0,16.52,0,wood,bell);+ for(const z of [-1,1])beam('TimberBrace',[0,15.45,z*1.15],[0,16.36,z*.45],.1,wood,bell);+ part('BronzeBell',lathe([[.66,0],[.81,.08],[.8,.19],[.57,.34],[.4,.77],[.33,1.08],[.18,1.19],[.12,1.2],[.12,1.07],[.27,.99],[.33,.69],[.49,.26],[.68,.13],[.66,0]],20),bronze,[0,14.78,0],bell);+ beam('BellHanger',[0,15.92,0],[0,16.53,0],.07,bronze,bell);+ beam('ClapperStem',[0,15.38,0],[0,14.72,0],.045,shadow,bell);+ part('Clapper',sphereGeo(.12,8,6),bronze,[0,14.71,0],bell);+ box('RoofCornice',5.9,.25,5.9,0,17.12,0,trim);+ const roof=group('Roof');+ part('LeadSpire',coneGeo(3.65,7.2,4),lead,[0,20.85,0],roof,[0,45,0]);+ for(let f=0;f<4;f++){+ const seams=group('LeadSeams_'+f,roof);seams.rotation.y=f*Math.PI/2;+ for(const z of [-1.8,-.9,0,.9,1.8])beam('StandingLeadSeam',[2.585,17.28,z],[.025,24.43,z*.009],.022,lead,seams);+ for(const y of [18.6,20.2,21.8,23.4]){const w=(24.45-y)*2.581/7.2;beam('LeadPanelJoint',[w+.014,y,-w],[w+.014,y,w],.018,lead,seams);}+ }+ for(const x of [-1,1])for(const z of [-1,1]){+ box('PinnaclePedestal',.63,.95,.63,x*2.63,17.81,z*2.63,trim);+ part('PinnacleSpire',coneGeo(.48,1.7,4),trim,[x*2.63,19.12,z*2.63],root,[0,45,0]);+ for(let level=0;level<3;level++)for(const side of [-1,1]){+ const y=18.57+level*.4,offset=.28-level*.07;+ part('PinnacleCrocket',coneGeo(.115,.25,4),trim,[x*2.63+side*offset,y,z*2.63],root,[0,0,-side*35]);+ part('PinnacleCrocket',coneGeo(.115,.25,4),trim,[x*2.63,y,z*2.63+side*offset],root,[side*35,0,0]);+ }+ part('PinnacleFinial',sphereGeo(.085,6,4),trim,[x*2.63,19.99,z*2.63]);+ }+ beam('VaneMast',[0,24.35,0],[0,25.6,0],.04,gold);+ beam('VaneArrow',[0,25.12,-.7],[0,25.12,.75],.035,gold);+ prism('VaneFlag',[[25.12,-.12],[25.42,-.6],[25.12,-.6]],0,.05,gold,root);+ prism('ArrowHead',[[25.12,.87],[25.25,.6],[24.99,.6]],0,.05,gold,root);+ return root;+}++diff --git a/examples/comms-satellite.kiln.js b/examples/comms-satellite.kiln.jsnew file mode 100644index 00000000..1f6fb8e5--- /dev/null+++ b/examples/comms-satellite.kiln.js@@ -0,0 +1,443 @@+// Authored by: opus, via claude.+//+// Written by the model itself through the Kiln MCP tools, and cut off+// mid-run rather than finished -- by a provider limit, or by the+// dispatch deadline. The program below is what was on disk when the+// session ended; how many times it had looked at its own contact sheet+// by then is not recorded, so this one does not make the claim the+// others do.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.+//+// Refined later, in this repository, with `kiln_edit`: two materials that were+// right in source and wrong in the render, and the same mistake in opposite+// directions. The comments at each one say what the render showed.++const meta = { name: 'CommsSatellite', category: 'prop', role: 'prop' };++// Geostationary communications satellite, deployed configuration.+// +X = antenna boresight (earth face), +Y = up, +Z = asset right.+// Solar wings run along +/-Z; apogee engine bell is the lowest part, resting on Y=0.++const BUS = 2.6; // cubic bus edge+const BUS_Y0 = 0.95; // bus underside+const CY = BUS_Y0 + BUS / 2; // bus centre height+const HALF = BUS / 2;++function rng(seed) {+ let s = seed >>> 0;+ return () => {+ s = (s * 1664525 + 1013904223) >>> 0;+ return s / 4294967296;+ };+}++function dishProfile(R, f, t, n) {+ const pts = [];+ for (let i = 0; i <= n; i++) {+ const r = (R * i) / n;+ pts.push([r, (r * r) / (4 * f)]);+ }+ for (let i = n; i >= 0; i--) {+ const r = (R * i) / n;+ pts.push([r, (r * r) / (4 * f) - t]);+ }+ return pts;+}++async function build() {+ const root = createRoot('CommsSatellite');+ const rand = rng(20260904);++ // ---- materials (kept few so draw calls stay low) ----+ // Multi-layer insulation, in two shades so the blanket is not one flat sheet.+ // The two were 0xd8a13c at metalness 0.95 and 0xc6320 at 0.9, which is far+ // enough apart that the facets did not read as one blanket at all: under the+ // studio dome the light shade clipped to a flat saturated yellow wherever a+ // facet faced the key, the dark shade stayed brown, and a satellite came back+ // wearing a chessboard. Metalness down to where the highlight still rolls off+ // instead of clamping, and the two shades brought within a stop of each other.+ const gold = gameMaterial(0xc09244, { metalness: 0.45, roughness: 0.5, flatShading: true });+ const goldDark = gameMaterial(0x9a7433, { metalness: 0.45, roughness: 0.6, flatShading: true });+ const struct = gameMaterial(0x33363c, { metalness: 0.6, roughness: 0.6, flatShading: true });+ const alum = gameMaterial(0xc9ccd1, { metalness: 0.85, roughness: 0.35, flatShading: true });+ // Reflector faces, radiator tiles and the sun sensor. 0xe9e7e1 is within a few+ // percent of white, and a rough near-white surface under the studio dome+ // returns nearly all of what it is given: the three dishes came back as blank+ // discs with the feed struts drawn on them and no bowl visible at all.+ const white = gameMaterial(0xbcb9b1, { metalness: 0.1, roughness: 0.75 });+ const black = gameMaterial(0x15161a, { metalness: 0.3, roughness: 0.85, flatShading: true });+ const cell = gameMaterial(0x1c2b60, { metalness: 0.45, roughness: 0.22, flatShading: true });++ // =====================================================================+ // BUS+ // =====================================================================+ const busGroup = createPivot('Bus', [0, CY, 0], root);++ createPart('Mesh_BusCore', boxGeo(BUS - 0.12, BUS - 0.12, BUS - 0.12), struct, { parent: busGroup });++ // corner longerons+ const longeronY = boxGeo(0.11, BUS, 0.11);+ const longeronZ = boxGeo(0.11, 0.11, BUS);+ const longeronX = boxGeo(BUS, 0.11, 0.11);+ for (const sx of [-1, 1]) {+ for (const sz of [-1, 1]) {+ createPart(`Mesh_LongeronY_${sx > 0 ? 'F' : 'A'}${sz > 0 ? 'R' : 'L'}`, longeronY, struct, {+ position: [sx * (HALF - 0.05), 0, sz * (HALF - 0.05)], parent: busGroup,+ });+ }+ for (const sy of [-1, 1]) {+ createPart(`Mesh_LongeronZ_${sx > 0 ? 'F' : 'A'}${sy > 0 ? 'U' : 'D'}`, longeronZ, struct, {+ position: [sx * (HALF - 0.05), sy * (HALF - 0.05), 0], parent: busGroup,+ });+ createPart(`Mesh_LongeronX_${sx > 0 ? 'R' : 'L'}${sy > 0 ? 'U' : 'D'}`, longeronX, struct, {+ position: [0, sy * (HALF - 0.05), sx * (HALF - 0.05)], parent: busGroup,+ });+ }+ }++ // ---- faceted gold thermal blanket panels on +X / -X / +Y / -Y ----+ const blanketX = await roundedBoxGeo(0.07, 0.83, 0.83, 0.03, { style: 'chamfer', segments: 1 });+ const blanketY = await roundedBoxGeo(0.83, 0.07, 0.83, 0.03, { style: 'chamfer', segments: 1 });+ const offs = [-0.865, 0, 0.865];+ const faces = [+ { id: 'Fwd', geo: blanketX, axis: 'x', s: 1 },+ { id: 'Aft', geo: blanketX, axis: 'x', s: -1 },+ { id: 'Top', geo: blanketY, axis: 'y', s: 1 },+ { id: 'Btm', geo: blanketY, axis: 'y', s: -1 },+ ];+ for (const f of faces) {+ for (let i = 0; i < 3; i++) {+ for (let j = 0; j < 3; j++) {+ // leave the underside centre clear for the apogee engine+ if (f.id === 'Btm' && i === 1 && j === 1) continue;+ const jitter = 0.010 + rand() * 0.055;+ const t1 = (rand() - 0.5) * 9;+ const t2 = (rand() - 0.5) * 9;+ let pos, rot;+ if (f.axis === 'x') {+ pos = [f.s * (HALF - 0.03 + jitter), offs[i], offs[j]];+ rot = [t1, 0, t2];+ } else {+ pos = [offs[i], f.s * (HALF - 0.03 + jitter), offs[j]];+ rot = [t1, 0, t2];+ }+ createPart(`Mesh_Blanket_${f.id}_${i}${j}`, f.geo, rand() > 0.78 ? goldDark : gold, {+ position: pos, rotation: rot, parent: busGroup,+ });+ }+ }+ }++ // blanket tie-down tapes+ const tapeX = boxGeo(0.03, 2.55, 0.08);+ const tapeY = boxGeo(0.08, 0.03, 2.55);+ for (const s of [-1, 1]) {+ for (const o of [-0.44, 0.44]) {+ createPart(`Mesh_Tape_X${s > 0 ? 'F' : 'A'}${o > 0 ? 'a' : 'b'}`, tapeX, goldDark, {+ position: [s * (HALF + 0.055), 0, o], parent: busGroup,+ });+ createPart(`Mesh_Tape_Y${s > 0 ? 'U' : 'D'}${o > 0 ? 'a' : 'b'}`, tapeY, goldDark, {+ position: [o, s * (HALF + 0.055), 0], parent: busGroup,+ });+ }+ }++ // radiator faces on +/-Z (north/south panels): dark backing plate under a+ // 4x4 array of optical-solar-reflector tiles, so the face reads as tiled+ // hardware rather than one blank slab.+ const radBack = boxGeo(2.44, 2.44, 0.06);+ const osrGeo = boxGeo(0.55, 0.55, 0.045);+ const osrOff = [-0.87, -0.29, 0.29, 0.87];+ for (const s of [-1, 1]) {+ const sd = s > 0 ? 'R' : 'L';+ createPart(`Mesh_RadiatorBack_${sd}`, radBack, struct, {+ position: [0, 0, s * (HALF - 0.03)], parent: busGroup,+ });+ for (let a = 0; a < 4; a++) {+ for (let b = 0; b < 4; b++) {+ createPart(`Mesh_OSRTile_${sd}${a}${b}`, osrGeo, white, {+ position: [osrOff[a], osrOff[b], s * (HALF + 0.02)], parent: busGroup,+ });+ }+ }+ }++ // =====================================================================+ // APOGEE ENGINE (underside, bell exit rests on Y=0)+ // =====================================================================+ const engine = createPivot('ApogeeEngine', [0, 0, 0], root);+ const bellPts = [];+ const NB = 12, BELL_H = 0.78, R_EXIT = 0.44, R_TH = 0.10, WALL = 0.035;+ const rAt = (u) => R_TH + (R_EXIT - R_TH) * Math.pow(1 - u, 1.9);+ for (let i = 0; i <= NB; i++) bellPts.push([rAt(i / NB), (i / NB) * BELL_H]);+ bellPts.push([R_TH + 0.045, BELL_H + 0.20]); // throat -> chamber+ bellPts.push([R_TH + 0.045 + WALL, BELL_H + 0.20]);+ for (let i = NB; i >= 0; i--) bellPts.push([rAt(i / NB) + WALL, (i / NB) * BELL_H]);+ const bellGeo = await revolveProfile(bellPts, { segments: 24, axis: 'y', smooth: true });+ createPart('Mesh_EngineBell', bellGeo, alum, { position: [0, 0, 0], parent: engine });++ // cooling-tube wrap on the bell+ for (let i = 0; i < 3; i++) {+ const u = 0.16 + i * 0.24;+ createPart(`Mesh_BellBand${i}`, torusGeo(rAt(u) + 0.045, 0.018, 5, 18), alum, {+ position: [0, u * BELL_H, 0], rotation: [90, 0, 0], parent: engine,+ });+ }+ createPart('Mesh_EngineChamber', cylinderGeo(0.15, 0.19, 0.30, 12), struct, {+ position: [0, BELL_H + 0.30, 0], parent: engine,+ });+ createPart('Mesh_EngineValveBlock', boxGeo(0.30, 0.16, 0.24), black, {+ position: [0, BELL_H + 0.50, 0], parent: engine,+ });+ // engine skirt / interface ring+ createPart('Mesh_EngineSkirt', cylinderGeo(0.42, 0.30, 0.14, 16), goldDark, {+ position: [0, BUS_Y0 - 0.07, 0], parent: engine,+ });+ // propellant feed lines+ for (const s of [-1, 1]) {+ createPart(`Mesh_FeedLine${s > 0 ? 'R' : 'L'}`, pipeAlongPath(+ [[0.13 * s, BUS_Y0 + 0.05, 0.18 * s], [0.20 * s, BELL_H + 0.42, 0.26 * s], [0.08 * s, BELL_H + 0.26, 0.14 * s]],+ 0.022, { bendRadius: 0.06, tubularSegments: 12, radialSegments: 5 }), alum, { parent: engine });+ }++ // =====================================================================+ // ATTITUDE-CONTROL THRUSTER CLUSTERS (four bus corners)+ // =====================================================================+ const thrBase = await roundedBoxGeo(0.30, 0.22, 0.30, 0.04, { style: 'chamfer', segments: 1 });+ const nozGeo = taperConeGeo(0.035, 0.10, 0.26, 'y', 10);+ for (const sx of [-1, 1]) {+ for (const sz of [-1, 1]) {+ const tag = `${sx > 0 ? 'F' : 'A'}${sz > 0 ? 'R' : 'L'}`;+ const cl = createPivot(`ThrusterCluster_${tag}`, [sx * 1.02, BUS_Y0 + 0.02, sz * 1.02], root);+ createPart(`Mesh_ThrBase_${tag}`, thrBase, black, { parent: cl });+ // two canted nozzles: one axial-down, one radial-out+ const n1 = createPivot(`Nozzle_${tag}_A`, [sx * 0.06, -0.14, sz * 0.06], cl);+ n1.rotation.set(0, 0, 0);+ createPart(`Mesh_Nozzle_${tag}_A`, nozGeo, alum, { position: [0, -0.13, 0], rotation: [180, 0, 0], parent: n1 });+ const n2 = createPivot(`Nozzle_${tag}_B`, [sx * 0.13, -0.02, sz * 0.13], cl);+ n2.rotation.set(sz * -0.62, 0, sx * 0.62);+ createPart(`Mesh_Nozzle_${tag}_B`, nozGeo, alum, { position: [0, -0.13, 0], rotation: [180, 0, 0], parent: n2 });+ createPart(`Mesh_ThrMani_${tag}`, cylinderGeo(0.05, 0.05, 0.22, 8), alum, {+ position: [sx * 0.02, 0.16, sz * 0.02], parent: cl,+ });+ }+ }++ // =====================================================================+ // SOLAR WINGS (5 hinged panels per wing, ~21 m tip to tip)+ // =====================================================================+ const PW_X = 2.40, PW_Z = 1.52, PT = 0.05, GAP = 0.08;+ const Z_YOKE_END = 2.60;+ const subGeo = await roundedBoxGeo(PW_X, PT, PW_Z, 0.02, { style: 'chamfer', segments: 1 });+ const cellGeo = boxGeo(0.300, 0.014, 0.268);+ const ribGeo = boxGeo(PW_X - 0.08, 0.05, 0.05);+ const hingeGeo = cylinderXGeo(0.045, 0.045, 0.20, 8);+ const hingeLug = boxGeo(0.10, 0.13, 0.10);++ for (const s of [-1, 1]) {+ const side = s > 0 ? 'R' : 'L';+ const wing = createPivot(`SolarWing_${side}`, [0, CY, 0], root);++ // BAPTA drive drum on the bus radiator face+ createPart(`Mesh_BAPTA_${side}`, cylinderZGeo(0.30, 0.30, 0.42, 16), alum, {+ position: [0, 0, s * 1.52], parent: wing,+ });+ createPart(`Mesh_BAPTARing_${side}`, cylinderZGeo(0.36, 0.36, 0.07, 16), goldDark, {+ position: [0, 0, s * 1.68], parent: wing,+ });++ // truss yoke: two diverging booms + spar + diagonals+ for (const b of [-1, 1]) {+ beamBetween(`YokeBoom_${side}${b > 0 ? 'A' : 'B'}`,+ [b * 0.22, 0, s * 1.72], [b * 0.98, 0, s * Z_YOKE_END], 0.055, alum, { parent: wing, segments: 8 });+ beamBetween(`YokeDiag_${side}${b > 0 ? 'A' : 'B'}`,+ [b * 0.22, 0, s * 1.72], [-b * 0.55, 0, s * (Z_YOKE_END - 0.06)], 0.03, alum, { parent: wing, segments: 6 });+ }+ createPart(`Mesh_YokeSpar_${side}`, cylinderXGeo(0.06, 0.06, 2.16, 10), alum, {+ position: [0, 0, s * Z_YOKE_END], parent: wing,+ });+ // yoke cable harness+ createPart(`Mesh_YokeHarness_${side}`, pipeAlongPath(+ [[0.30, -0.10, s * 1.70], [0.55, -0.22, s * 2.05], [0.72, -0.10, s * 2.55]],+ 0.028, { bendRadius: 0.12, tubularSegments: 14, radialSegments: 5 }), black, { parent: wing });++ for (let k = 0; k < 5; k++) {+ const zc = s * (Z_YOKE_END + PW_Z / 2 + k * (PW_Z + GAP));+ const pan = createPivot(`SolarPanel_${side}${k + 1}`, [0, 0, zc], wing);++ createPart(`Mesh_Substrate_${side}${k + 1}`, subGeo, struct, { parent: pan });++ // photovoltaic cell grid, sun side (+Y): 7 strings x 5 rows+ for (let i = 0; i < 7; i++) {+ for (let j = 0; j < 5; j++) {+ createPart(`Mesh_Cell_${side}${k + 1}_${i}${j}`, cellGeo, cell, {+ position: [-1.029 + i * 0.343, PT / 2 + 0.006, -0.608 + j * 0.304],+ parent: pan,+ });+ }+ }+ // interconnect bus bars between the cell strings+ for (let i = 0; i < 6; i++) {+ createPart(`Mesh_BusBar_${side}${k + 1}_${i}`, boxGeo(0.028, 0.016, PW_Z - 0.09), alum, {+ position: [-0.858 + i * 0.343, PT / 2 + 0.006, 0], parent: pan,+ });+ }+ // per-panel edge rails (they stop at each hinge line, as on a real wing)+ for (const hx of [-1.16, 1.16]) {+ createPart(`Mesh_PanelEdge_${side}${k + 1}_${hx > 0 ? 'a' : 'b'}`,+ cylinderZGeo(0.032, 0.032, PW_Z, 6), alum, { position: [hx, 0, 0], parent: pan });+ }+ // back-side stiffener ribs+ for (const r of [-0.44, 0.44]) {+ createPart(`Mesh_Rib_${side}${k + 1}_${r > 0 ? 'a' : 'b'}`, ribGeo, alum, {+ position: [0, -PT / 2 - 0.025, r], parent: pan,+ });+ }++ // hinge line on the inboard edge of this panel+ const zh = s * (Z_YOKE_END + k * (PW_Z + GAP)) + s * (k === 0 ? 0 : -GAP / 2);+ for (const hx of [-0.92, 0, 0.92]) {+ createPart(`Mesh_Hinge_${side}${k + 1}_${hx < 0 ? 'a' : hx > 0 ? 'c' : 'b'}`, hingeGeo, struct, {+ position: [hx, 0, zh], parent: wing,+ });+ createPart(`Mesh_HingeLug_${side}${k + 1}_${hx < 0 ? 'a' : hx > 0 ? 'c' : 'b'}`, hingeLug, struct, {+ position: [hx, -0.02, zh + s * 0.10], parent: wing,+ });+ }+ }++ // outboard tip frame+ const zTip = s * (Z_YOKE_END + 5 * PW_Z + 4 * GAP);+ createPart(`Mesh_WingTipSpar_${side}`, cylinderXGeo(0.05, 0.05, PW_X, 8), alum, {+ position: [0, 0, zTip - s * 0.03], parent: wing,+ });+ for (const hx of [-1.16, 1.16]) {+ createPart(`Mesh_WingTipCap_${side}${hx > 0 ? 'a' : 'b'}`, boxGeo(0.09, 0.09, 0.09), struct, {+ position: [hx, 0, zTip - s * 0.03], parent: wing,+ });+ }+ }++ // =====================================================================+ // PARABOLIC DISH ANTENNAS on gimbal arms (boresight +X)+ // =====================================================================+ async function makeDish(name, R, f, mountPos, yawDeg, pitchDeg, armFrom) {+ const gimbal = createPivot(`Gimbal_${name}`, mountPos, root);+ gimbal.rotation.set(0, (yawDeg * Math.PI) / 180, (pitchDeg * Math.PI) / 180);++ // dish frame: local +Y is the boresight, rotated to +X+ const frame = createPivot(`DishFrame_${name}`, [0, 0, 0], gimbal);+ frame.rotation.z = -Math.PI / 2;++ const geo = await revolveProfile(dishProfile(R, f, 0.035, 8), { segments: 22, axis: 'y', smooth: true });+ createPart(`Mesh_Reflector_${name}`, geo, white, { parent: frame });+ const rimY = (R * R) / (4 * f);+ createPart(`Mesh_DishRim_${name}`, torusGeo(R, 0.035, 5, 22), alum, {+ position: [0, rimY - 0.02, 0], rotation: [90, 0, 0], parent: frame,+ });+ // radial back ribs + hub+ createPart(`Mesh_DishHub_${name}`, cylinderGeo(0.16, 0.20, 0.20, 10), struct, {+ position: [0, -0.14, 0], parent: frame,+ });+ for (let i = 0; i < 6; i++) {+ const a = (i / 6) * Math.PI * 2;+ beamBetween(`DishRib_${name}${i}`,+ [Math.cos(a) * 0.15, -0.10, Math.sin(a) * 0.15],+ [Math.cos(a) * (R - 0.06), rimY - 0.05, Math.sin(a) * (R - 0.06)],+ 0.022, struct, { parent: frame, segments: 6 });+ }+ // feed tripod + horn at the focus+ for (let i = 0; i < 3; i++) {+ const a = (i / 3) * Math.PI * 2 + 0.4;+ beamBetween(`FeedLeg_${name}${i}`,+ [Math.cos(a) * R * 0.82, (R * 0.82) * (R * 0.82) / (4 * f), Math.sin(a) * R * 0.82],+ [0, f, 0], 0.02, alum, { parent: frame, segments: 6 });+ }+ createPart(`Mesh_FeedHorn_${name}`, taperConeGeo(0.055, 0.13, 0.26, 'y', 12), goldDark, {+ position: [0, f + 0.04, 0], rotation: [180, 0, 0], parent: frame,+ });+ createPart(`Mesh_FeedCan_${name}`, cylinderGeo(0.075, 0.075, 0.18, 10), alum, {+ position: [0, f + 0.24, 0], parent: frame,+ });++ // gimbal head + two-axis arm back to the bus+ createPart(`Mesh_GimbalHead_${name}`, await roundedBoxGeo(0.26, 0.24, 0.24, 0.04, { style: 'chamfer', segments: 1 }),+ black, { position: [-0.16, 0, 0], parent: gimbal });+ createPart(`Mesh_GimbalAxis_${name}`, cylinderZGeo(0.055, 0.055, 0.36, 8), alum, {+ position: [-0.16, 0, 0], parent: gimbal });+ beamBetween(`GimbalArm_${name}`, armFrom, [mountPos[0] - 0.30, mountPos[1], mountPos[2]], 0.075, alum,+ { parent: root, segments: 8 });+ beamBetween(`GimbalStrut_${name}`,+ [armFrom[0], armFrom[1] - 0.42, armFrom[2]], [mountPos[0] - 0.34, mountPos[1] - 0.06, mountPos[2]], 0.04, alum,+ { parent: root, segments: 6 });+ return gimbal;+ }++ await makeDish('Main', 1.15, 0.46, [2.75, 3.32, -0.86], -8, 7, [1.30, 3.10, -0.66]);+ await makeDish('Ku', 0.85, 0.34, [2.50, 2.22, 1.06], 12, -4, [1.30, 2.30, 0.80]);+ await makeDish('Tx', 0.55, 0.22, [2.12, 1.12, -0.98], -18, -12, [1.30, 1.35, -0.66]);++ // sub-reflector on the main dish (dual-reflector feed)+ const mainSub = createPivot('SubReflector_Main', [3.36, 3.32, -0.86], root);+ mainSub.rotation.z = Math.PI / 2;+ createPart('Mesh_SubReflector', await revolveProfile(dishProfile(0.26, 0.22, 0.03, 6), { segments: 16, axis: 'y', smooth: true }),+ alum, { parent: mainSub });++ // =====================================================================+ // HORN FEED CLUSTER on the +X face+ // =====================================================================+ const horns = createPivot('HornCluster', [1.34, 1.80, 0.28], root);+ createPart('Mesh_HornBox', await roundedBoxGeo(0.42, 0.62, 0.74, 0.05, { style: 'chamfer', segments: 1 }), black, {+ position: [0.20, 0, 0], parent: horns,+ });+ createPart('Mesh_HornBoxTrim', boxGeo(0.05, 0.66, 0.78), goldDark, { position: [0.42, 0, 0], parent: horns });+ let hi = 0;+ for (const hy of [-0.17, 0.17]) {+ for (const hz of [-0.20, 0.20]) {+ const len = 0.34 + (hi % 2) * 0.14;+ createPart(`Mesh_Horn${hi}`, taperConeGeo(0.075, 0.155, len, 'x', 4), goldDark, {+ position: [0.44 + len / 2, hy, hz], rotation: [45, 0, 0], parent: horns,+ });+ createPart(`Mesh_HornThroat${hi}`, cylinderXGeo(0.055, 0.055, 0.12, 8), alum, {+ position: [0.40, hy, hz], parent: horns,+ });+ hi++;+ }+ }++ // =====================================================================+ // OMNI WHIP ANTENNA+ // =====================================================================+ const whip = createPivot('OmniWhip', [-0.86, BUS_Y0 + BUS, 0.88], root);+ whip.rotation.z = 0.16;+ createPart('Mesh_WhipBase', cylinderGeo(0.09, 0.11, 0.12, 10), black, { position: [0, 0.06, 0], parent: whip });+ createPart('Mesh_WhipInsulator', cylinderGeo(0.055, 0.055, 0.14, 8), white, { position: [0, 0.19, 0], parent: whip });+ createPart('Mesh_WhipRod', cylinderGeo(0.022, 0.03, 1.55, 8), alum, { position: [0, 1.03, 0], parent: whip });+ createPart('Mesh_WhipTip', sphereGeo(0.045, 8, 6), alum, { position: [0, 1.82, 0], parent: whip });+ for (let i = 0; i < 3; i++) {+ createPart(`Mesh_WhipCollar${i}`, cylinderGeo(0.038, 0.038, 0.04, 8), goldDark, {+ position: [0, 0.55 + i * 0.42, 0], parent: whip,+ });+ }++ // =====================================================================+ // STAR TRACKER + SUN SENSORS+ // =====================================================================+ const star = createPivot('StarTracker', [-0.72, BUS_Y0 + BUS, -0.62], root);+ star.rotation.x = 0.34;+ star.rotation.z = -0.22;+ createPart('Mesh_StarBody', await roundedBoxGeo(0.34, 0.24, 0.30, 0.04, { style: 'chamfer', segments: 1 }), black, {+ position: [0, 0.12, 0], parent: star,+ });+ createPart('Mesh_StarBaffle', taperConeGeo(0.13, 0.17, 0.46, 'y', 12), black, { position: [0, 0.48, 0], parent: star });+ createPart('Mesh_StarBaffleRim', torusGeo(0.17, 0.02, 5, 14), alum, { position: [0, 0.70, 0], rotation: [90, 0, 0], parent: star });+ createPart('Mesh_StarMount', boxGeo(0.30, 0.06, 0.26), alum, { position: [0, -0.01, 0], parent: star });++ const sun = createPivot('SunSensor', [1.30, BUS_Y0 + BUS - 0.30, 0.98], root);+ createPart('Mesh_SunSensor', boxGeo(0.12, 0.16, 0.16), white, { parent: sun });+ createPart('Mesh_SunSensorHead', cylinderXGeo(0.05, 0.05, 0.10, 8), black, { position: [0.10, 0, 0], parent: sun });++ return root;+}diff --git a/examples/crate.kiln.js b/examples/crate.kiln.jsindex 02db50e1..2ce608e6 100644--- a/examples/crate.kiln.js+++ b/examples/crate.kiln.js@@ -15,7 +15,12 @@ function build() {const plank = gameMaterial(0x8a6a43, { roughness: 0.85 });const plankDark = gameMaterial(0x6f5335, { roughness: 0.9 });- const iron = gameMaterial(0x4a4a4f, { metalness: 0.8, roughness: 0.45 });+ // Metal albedo is reflectance, not paint. A metal has no diffuse term at all,+ // so its entire appearance is a specular reflection tinted by its base colour+ // -- and 0x4a4a4f, which looks like a reasonable dark iron as a swatch,+ // returns almost nothing under a neutral studio dome and rendered these bands+ // as black stripes. Real iron sits near 0x8f8f94.+ const iron = gameMaterial(0x8f8f94, { metalness: 0.8, roughness: 0.45 });const S = 0.9; // crate edge lengthconst H = S / 2;@@ -43,6 +48,15 @@ function build() {}}+ // A liner just inside the boards. The 12 mm gaps between planks are what+ // makes this read as a crate rather than a cube, but with nothing behind them+ // they render as black slots -- the background showing through, which the eye+ // reads as a hole rather than as shadow. A real crate has its contents there.+ createPart('Liner', boxGeo(S - 2 * T, S - 2 * T, S - 2 * T), plankDark, {+ position: [0, H, 0],+ parent: root,+ });+// Lid and floor.createPart('Lid', boxGeo(S - 0.01, T, S - 0.01), plank, {position: [0, S - T / 2, 0],diff --git a/examples/crawler-crane.kiln.js b/examples/crawler-crane.kiln.jsnew file mode 100644index 00000000..6cb46a75--- /dev/null+++ b/examples/crawler-crane.kiln.js@@ -0,0 +1,282 @@+// Authored by: opencode-go/minimax-m3, via opencode.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'CrawlerCrane', category: 'prop', role: 'vehicle' };++async function build() {+ const root = createRoot('CrawlerCrane');++ // ========== MATERIALS ==========+ const yellow = gameMaterial(0xe0a020, { roughness: 0.55, metalness: 0.3 });+ const yellowLite = gameMaterial(0xf0c840, { roughness: 0.5, metalness: 0.25 });+ const darkSteel = gameMaterial(0x1f1f1f, { roughness: 0.55, metalness: 0.7 });+ const steel = gameMaterial(0x5a5a5a, { roughness: 0.5, metalness: 0.8 });+ const rubber = gameMaterial(0x1a1a1a, { roughness: 0.95 });+ const cabGlass = glassMaterial(0x99ccee, { opacity: 0.5 });+ const cable = gameMaterial(0x1a1a1a, { roughness: 0.7, metalness: 0.3 });+ const counterMat = gameMaterial(0x3a3a3a, { roughness: 0.75, metalness: 0.4 });+ const hubMat = gameMaterial(0xc8a830, { roughness: 0.5, metalness: 0.6 });+ const black = gameMaterial(0x0a0a0a, { roughness: 0.7, metalness: 0.5 });+ const warnYellow = gameMaterial(0xff8800, { roughness: 0.6, metalness: 0.2 });+ const chrome = gameMaterial(0xc0c0c0, { roughness: 0.2, metalness: 0.9 });++ // ========== UNDERCARRIAGE ==========+ const undercarriage = createPivot('Undercarriage', [0, 0, 0], root);++ createPart('CarbodyPlate', boxGeo(5.4, 0.08, 2.7), darkSteel, { position: [0, 0.6, 0], parent: undercarriage });+ createPart('Carbody', boxGeo(4.6, 0.3, 1.2), darkSteel, { position: [0, 0.92, 0], parent: undercarriage });+ createPart('Bearing', cylinderYGeo(1.15, 1.15, 0.06, 24), steel, { position: [0, 1.08, 0], parent: undercarriage });++ for (const side of [-1, 1]) {+ const sName = side > 0 ? 'R' : 'L';+ const trackSide = createPivot('TrackSide_' + sName, [0, 0, side * 1.5], undercarriage);++ createPart('TrackFrame_' + sName, boxGeo(5.5, 0.4, 0.45), darkSteel, { position: [0, 0.5, 0], parent: trackSide });+ createPart('TrackSideGuard_' + sName, boxGeo(5.5, 0.08, 0.04), yellow, { position: [0, 0.95, side * 0.23], parent: trackSide });+ createPart('TrackSideGuard2_' + sName, boxGeo(5.5, 0.04, 0.02), yellow, { position: [0, 0.3, side * 0.23], parent: trackSide });++ for (let i = 0; i < 7; i++) {+ const x = -2.1 + i * 0.7;+ createPart('RoadTire_' + sName + '_' + i, cylinderZGeo(0.34, 0.34, 0.55, 18), rubber, { position: [x, 0.34, 0], parent: trackSide });+ createPart('RoadHub_' + sName + '_' + i, cylinderZGeo(0.13, 0.13, 0.6, 12), hubMat, { position: [x, 0.34, 0], parent: trackSide });+ for (let a = 0; a < 3; a++) {+ const ang = (a / 3) * Math.PI * 2;+ createPart('HubBolt_' + sName + '_' + i + '_' + a, cylinderZGeo(0.025, 0.025, 0.62, 6), steel, { position: [x, 0.34 + Math.cos(ang) * 0.08, Math.sin(ang) * 0.08], parent: trackSide });+ }+ }++ createPart('SprocketDisc_' + sName, cylinderZGeo(0.46, 0.46, 0.4, 22), hubMat, { position: [2.4, 0.62, 0], parent: trackSide });+ for (let t = 0; t < 14; t++) {+ const ta = (t / 14) * Math.PI * 2;+ createPart('SprocketTooth_' + sName + '_' + t, boxGeo(0.06, 0.08, 0.42), hubMat, { position: [2.4 + Math.cos(ta) * 0.48, 0.62 + Math.sin(ta) * 0.48, 0], rotation: [0, 0, ta * 180 / Math.PI], parent: trackSide });+ }+ createPart('SprocketHub_' + sName, cylinderZGeo(0.16, 0.16, 0.48, 12), darkSteel, { position: [2.4, 0.62, 0], parent: trackSide });++ createPart('Idler_' + sName, cylinderZGeo(0.4, 0.4, 0.42, 18), hubMat, { position: [-2.4, 0.62, 0], parent: trackSide });+ createPart('IdlerHub_' + sName, cylinderZGeo(0.14, 0.14, 0.46, 10), darkSteel, { position: [-2.4, 0.62, 0], parent: trackSide });++ for (let i = 0; i < 3; i++) {+ const x = -1.5 + i * 1.5;+ createPart('CarrierRoller_' + sName + '_' + i, cylinderZGeo(0.22, 0.22, 0.4, 12), hubMat, { position: [x, 1.05, 0], parent: trackSide });+ }++ const numStraight = 12, numArc = 6, arcR = 0.5;+ for (let i = 0; i < numStraight; i++) {+ const t = i / numStraight;+ const x = -2.4 + t * 4.8;+ createPart('TS_B_' + sName + '_' + i, boxGeo(0.42, 0.13, 0.55), black, { position: [x, 0.13, 0], parent: trackSide });+ createPart('TS_B_Grouser_' + sName + '_' + i, boxGeo(0.42, 0.02, 0.08), steel, { position: [x, 0.22, 0], parent: trackSide });+ }+ for (let i = 0; i < numArc; i++) {+ const t = i / numArc;+ const ang = -Math.PI / 2 + t * Math.PI;+ const x = 2.4 + Math.cos(ang) * arcR;+ const y = 0.65 + Math.sin(ang) * arcR;+ const rotDeg = (ang + Math.PI / 2) * 180 / Math.PI;+ createPart('TS_R_' + sName + '_' + i, boxGeo(0.42, 0.13, 0.55), black, { position: [x, y, 0], rotation: [0, 0, rotDeg], parent: trackSide });+ }+ for (let i = 0; i < numStraight; i++) {+ const t = i / numStraight;+ const x = 2.4 - t * 4.8;+ createPart('TS_T_' + sName + '_' + i, boxGeo(0.42, 0.13, 0.55), black, { position: [x, 1.18, 0], parent: trackSide });+ }+ for (let i = 0; i < numArc; i++) {+ const t = i / numArc;+ const ang = Math.PI / 2 + t * Math.PI;+ const x = -2.4 + Math.cos(ang) * arcR;+ const y = 0.65 + Math.sin(ang) * arcR;+ const rotDeg = (ang + Math.PI / 2) * 180 / Math.PI;+ createPart('TS_L_' + sName + '_' + i, boxGeo(0.42, 0.13, 0.55), black, { position: [x, y, 0], rotation: [0, 0, rotDeg], parent: trackSide });+ }+ createPart('TrackTension_' + sName, cylinderYGeo(0.08, 0.08, 0.5, 8), yellow, { position: [-1.7, 0.5, side * 0.1], parent: trackSide });+ }++ // ========== HOUSE (Upper Structure) ==========+ const house = createPivot('House', [0, 1.13, 0], root);+ createPart('Turntable', cylinderYGeo(1.3, 1.3, 0.16, 32), darkSteel, { position: [0, 0, 0], parent: house });+ createPart('SlewingRing', cylinderYGeo(1.38, 1.38, 0.05, 32), steel, { position: [0, 0.06, 0], parent: house });++ const engineDeckGeo = await roundedBoxGeo(2.4, 0.85, 2.4, 0.05);+ createPart('EngineDeck', engineDeckGeo, yellow, { position: [-0.3, 0.5, 0], parent: house });++ for (let i = -1; i <= 1; i += 2) {+ for (let j = 0; j < 4; j++) {+ createPart('Louver_' + i + '_' + j, boxGeo(0.5, 0.04, 0.02), darkSteel, { position: [-0.3 - 0.4, 0.4 + j * 0.12, i * 1.22], parent: house });+ }+ }++ createPart('EngineHatch', boxGeo(0.7, 0.04, 0.7), darkSteel, { position: [-0.3, 0.95, 0.4], parent: house });+ createPart('EngineHatch2', boxGeo(0.4, 0.04, 0.5), darkSteel, { position: [-0.3, 0.95, -0.5], parent: house });+ createPart('Exhaust', cylinderYGeo(0.06, 0.06, 0.8, 8), darkSteel, { position: [-0.6, 1.15, 0.7], parent: house });+ createPart('ExhaustCap', cylinderYGeo(0.1, 0.1, 0.04, 8), steel, { position: [-0.6, 1.58, 0.7], parent: house });++ for (let i = 0; i < 3; i++) {+ const slabH = 0.45;+ const slabY = 0.2 + i * (slabH + 0.04);+ const slabGeo = await roundedBoxGeo(1.15, slabH, 2.55, 0.04);+ createPart('CounterSlab_' + i, slabGeo, counterMat, { position: [-1.6, slabY, 0], parent: house });+ for (let j = -1; j <= 1; j += 2) {+ createPart('CounterTie_' + i + '_' + (j > 0 ? 'R' : 'L'), boxGeo(1.05, 0.05, 0.05), yellow, { position: [-1.6, slabY + slabH / 2, j * 1.2], parent: house });+ }+ for (let bx = -1; bx <= 1; bx += 2) {+ for (let by = -1; by <= 1; by += 2) {+ createPart('CounterBolt_' + i + '_' + bx + '_' + by, cylinderYGeo(0.035, 0.035, 0.5, 6), steel, { position: [-1.6 + bx * 0.45, slabY + slabH / 2, by * 1.15], rotation: [90, 0, 0], parent: house });+ }+ }+ }++ createPart('CounterFrameBack', boxGeo(1.1, 1.5, 0.08), yellow, { position: [-1.6, 1.45, 0], parent: house });++ const cabGeo = await roundedBoxGeo(1.3, 1.4, 1.5, 0.07);+ createPart('Cab', cabGeo, yellow, { position: [1.5, 1.0, -0.9], parent: house });+ createPart('CabWindowFront', boxGeo(1.22, 0.95, 1.44), cabGlass, { position: [1.53, 1.3, -0.9], parent: house });+ createPart('CabWindowSide', boxGeo(1.22, 0.7, 0.02), cabGlass, { position: [1.5, 1.25, -1.65], parent: house });+ createPart('CabRoof', boxGeo(1.35, 0.07, 1.55), yellow, { position: [1.5, 1.72, -0.9], parent: house });+ createPart('CabBeacon', cylinderYGeo(0.07, 0.07, 0.08, 8), warnYellow, { position: [1.5, 1.8, -0.9], parent: house });+ createPart('CabDoor', boxGeo(0.04, 1.0, 0.6), yellow, { position: [1.5 + 0.66, 0.95, -0.6], parent: house });+ createPart('CabDoorHandle', boxGeo(0.03, 0.05, 0.12), steel, { position: [1.5 + 0.68, 1.05, -0.4], parent: house });+ createPart('CabStep', boxGeo(0.6, 0.06, 1.0), darkSteel, { position: [1.9, 0.3, -0.4], parent: house });++ // Side mirror+ createPart('MirrorArm', boxGeo(0.02, 0.02, 0.4), steel, { position: [2.16, 1.35, -0.7], parent: house });+ createPart('Mirror', boxGeo(0.12, 0.18, 0.04), chrome, { position: [2.16, 1.35, -0.9], parent: house });++ createLadder('CabLadder', { bottom: [1.9, 0.3, -0.05], top: [1.9, 1.7, -0.05], width: 0.45, rungCount: 6, railRadius: 0.025, rungRadius: 0.022, parent: house });++ // Rear handrail - posts taller so rails attach properly+ for (let i = -1; i <= 1; i++) {+ createPart('RailPost_' + i, cylinderYGeo(0.03, 0.03, 0.65, 6), yellow, { position: [-0.3, 1.07, i * 1.05], parent: house });+ }+ // Top horizontal rails+ for (let i = 0; i < 2; i++) {+ createPart('RailTop_' + i, cylinderZGeo(0.028, 0.028, 2.1, 6), yellow, { position: [-0.3, 1.35, 0], rotation: [0, 90, 0], parent: house });+ createPart('RailMid_' + i, cylinderZGeo(0.022, 0.022, 2.1, 6), yellow, { position: [-0.3, 1.18, 0], rotation: [0, 90, 0], parent: house });+ }+ // End rails connecting front to back+ for (let i = -1; i <= 1; i += 2) {+ createPart('RailEnd_' + i, cylinderXGeo(0.022, 0.022, 0.95, 6), yellow, { position: [0.16, 1.35, i * 1.05], parent: house });+ }++ // ========== A-FRAME MAST (gantry for pendant lines) ==========+ // Positioned BETWEEN counterweight and cab (not overlapping cab)+ const aFrameX = 0.3;+ const aFrameBaseY = 0.3, aFrameTipY = 3.0, aFrameBaseZ = 1.1;++ beamBetween('AFrameLeg_L', [aFrameX, aFrameBaseY, -aFrameBaseZ], [aFrameX, aFrameTipY, 0], 0.06, yellow, { parent: house });+ beamBetween('AFrameLeg_R', [aFrameX, aFrameBaseY, aFrameBaseZ], [aFrameX, aFrameTipY, 0], 0.06, yellow, { parent: house });+ beamBetween('AFrameCross1', [aFrameX, aFrameBaseY + 0.5, -0.9], [aFrameX, aFrameBaseY + 0.5, 0.9], 0.035, yellow, { parent: house });+ beamBetween('AFrameCross2', [aFrameX, aFrameBaseY + 1.2, -0.65], [aFrameX, aFrameBaseY + 1.2, 0.65], 0.035, yellow, { parent: house });+ beamBetween('AFrameCross3', [aFrameX, aFrameBaseY + 1.9, -0.35], [aFrameX, aFrameBaseY + 1.9, 0.35], 0.035, yellow, { parent: house });++ createPart('PendantPin', cylinderZGeo(0.06, 0.06, 0.2, 8), steel, { position: [aFrameX, aFrameTipY + 0.05, 0], parent: house });+ createPart('PendantPinHouse', boxGeo(0.12, 0.12, 0.12), steel, { position: [aFrameX, aFrameTipY + 0.05, 0], parent: house });++ // ========== BOOM ==========+ const boomLength = 11.0;+ const boomPivot = createPivot('BoomFoot', [1.85, 2.0, 0], house);+ boomPivot.rotation.z = Math.PI / 180 * 62;+ const numSegs = 8;+ const segLen = boomLength / numSegs;+ const chordR = 0.055;++ for (let s = 0; s < numSegs; s++) {+ const x0 = s * segLen, x1 = (s + 1) * segLen, xc = (x0 + x1) / 2;+ const t0 = s / numSegs, t1 = (s + 1) / numSegs;+ const halfW0 = 0.5 - 0.32 * t0, halfW1 = 0.5 - 0.32 * t1;+ const topY0 = 0.6 - 0.38 * t0, topY1 = 0.6 - 0.38 * t1;++ createPart('BTopChord_' + s, cylinderXGeo(chordR, chordR, segLen, 6), yellow, { position: [xc, (topY0 + topY1) / 2, 0], parent: boomPivot });+ createPart('BBLChord_' + s, cylinderXGeo(chordR, chordR, segLen, 6), yellow, { position: [xc, 0, -(halfW0 + halfW1) / 2], parent: boomPivot });+ createPart('BBRChord_' + s, cylinderXGeo(chordR, chordR, segLen, 6), yellow, { position: [xc, 0, (halfW0 + halfW1) / 2], parent: boomPivot });++ const dr = chordR * 0.85;+ beamBetween('BLD1_' + s, [x0, topY0, -halfW0], [x1, 0, -halfW1], dr, yellow, { parent: boomPivot });+ beamBetween('BLD2_' + s, [x0, 0, -halfW0], [x1, topY1, -halfW1], dr, yellow, { parent: boomPivot });+ beamBetween('BRD1_' + s, [x0, topY0, halfW0], [x1, 0, halfW1], dr, yellow, { parent: boomPivot });+ beamBetween('BRD2_' + s, [x0, 0, halfW0], [x1, topY1, halfW1], dr, yellow, { parent: boomPivot });+ beamBetween('BBD1_' + s, [x0, 0, -halfW0], [x1, 0, halfW1], dr, yellow, { parent: boomPivot });+ beamBetween('BBD2_' + s, [x0, 0, halfW0], [x1, 0, -halfW1], dr, yellow, { parent: boomPivot });++ // Joint bolts at each chord crossing (every chord intersection)+ for (let pt of [+ [x0, topY0, -halfW0], [x0, 0, -halfW0], [x0, 0, halfW0],+ [x1, topY1, -halfW1], [x1, 0, -halfW1], [x1, 0, halfW1]+ ]) {+ if (pt[0] <= boomLength + 0.01) {+ const tag = pt[1] > 0 ? 'T' : (pt[2] < 0 ? 'BL' : 'BR');+ createPart('BJointBolt_' + s + '_' + pt[0].toFixed(1) + '_' + tag,+ sphereGeo(0.045, 6, 4),+ steel,+ { position: pt, parent: boomPivot });+ }+ }+ }++ // Boom tip cap+ const tipHW = 0.5 - 0.32, tipTopY = 0.6 - 0.38;+ createPart('BoomTipCap', boxGeo(0.18, tipTopY + 0.06, tipHW * 2 + 0.06), yellow, { position: [boomLength + 0.06, tipTopY / 2, 0], parent: boomPivot });+ createPart('BoomTipGusset_L', boxGeo(0.08, tipTopY, 0.05), yellow, { position: [boomLength - 0.04, tipTopY / 2, -tipHW], parent: boomPivot });+ createPart('BoomTipGusset_R', boxGeo(0.08, tipTopY, 0.05), yellow, { position: [boomLength - 0.04, tipTopY / 2, tipHW], parent: boomPivot });++ // Sheave at boom tip (the pulley for hoist cable)+ createPart('Sheave', cylinderZGeo(0.2, 0.2, 0.14, 18), steel, { position: [boomLength - 0.1, tipTopY * 0.6, 0], parent: boomPivot });+ createPart('SheaveRim', torusGeo(0.2, 0.025, 8, 18), steel, { position: [boomLength - 0.1, tipTopY * 0.6, 0], rotation: [0, 90, 0], parent: boomPivot });+ createPart('SheaveShaft', cylinderZGeo(0.04, 0.04, 0.25, 8), darkSteel, { position: [boomLength - 0.1, tipTopY * 0.6, 0], parent: boomPivot });++ // Top pendant bridle+ createPart('BoomBridle', boxGeo(0.15, 0.06, 0.3), steel, { position: [boomLength - 0.05, tipTopY + 0.06, 0], parent: boomPivot });+ createPart('BoomBridlePin', cylinderZGeo(0.04, 0.04, 0.3, 8), steel, { position: [boomLength - 0.05, tipTopY + 0.06, 0], parent: boomPivot });++ // Boom foot pin (connects boom to house)+ createPart('BoomFootPin', cylinderZGeo(0.08, 0.08, 0.4, 12), steel, { position: [0, 0, 0], parent: boomPivot });+ createPart('BoomFootPinCap', boxGeo(0.18, 0.18, 0.18), steel, { position: [0, 0, 0], parent: boomPivot });++ // Boom warning light (top of boom tip)+ createPart('BoomLight', boxGeo(0.08, 0.04, 0.08), warnYellow, { position: [boomLength - 0.3, tipTopY + 0.05, 0], parent: boomPivot });++ // ========== CABLE + HOOK BLOCK ==========+ // Boom tip world coords: pivot at (1.85, 2.0, 0) in house; house at (0, 1.13, 0)+ // Local (boomLength, tipTopY + 0.06, 0) rotated 62° around Z:+ // x_house = 11*0.4695 - 0.28*0.8829 = 5.165 - 0.247 = 4.918+ // y_house = 11*0.8829 + 0.28*0.4695 = 9.712 + 0.131 = 9.843+ // World: (1.85 + 4.918, 1.13 + 2.0 + 9.843, 0) = (6.768, 12.973, 0)+ const boomTipWorld = { x: 6.77, y: 12.97, z: 0 };+ const cableLength = 7.8;++ createPart('Cable', cylinderYGeo(0.03, 0.03, cableLength, 6), cable, { position: [boomTipWorld.x, boomTipWorld.y - cableLength / 2, boomTipWorld.z], parent: root });++ const hookBlockGeo = await roundedBoxGeo(0.65, 0.7, 0.5, 0.05);+ const hookY = boomTipWorld.y - cableLength - 0.35;+ createPart('HookBlock', hookBlockGeo, darkSteel, { position: [boomTipWorld.x, hookY, boomTipWorld.z], parent: root });+ createPart('HookBlockTop', cylinderYGeo(0.08, 0.08, 0.15, 8), steel, { position: [boomTipWorld.x, hookY + 0.42, boomTipWorld.z], parent: root });+ createPart('HookSheave', cylinderZGeo(0.18, 0.18, 0.55, 16), steel, { position: [boomTipWorld.x, hookY + 0.15, boomTipWorld.z], parent: root });+ createPart('HookCheek_L', boxGeo(0.55, 0.55, 0.04), yellow, { position: [boomTipWorld.x, hookY + 0.1, boomTipWorld.z - 0.27], parent: root });+ createPart('HookCheek_R', boxGeo(0.55, 0.55, 0.04), yellow, { position: [boomTipWorld.x, hookY + 0.1, boomTipWorld.z + 0.27], parent: root });+ createPart('HookShaft', cylinderZGeo(0.04, 0.04, 0.6, 8), steel, { position: [boomTipWorld.x, hookY + 0.1, boomTipWorld.z], parent: root });+ // Hook safety latch detail+ createPart('HookNeck', boxGeo(0.1, 0.4, 0.1), steel, { position: [boomTipWorld.x, hookY - 0.3, boomTipWorld.z], parent: root });+ createPart('HookCurve', torusGeo(0.13, 0.03, 8, 18), steel, { position: [boomTipWorld.x, hookY - 0.5, boomTipWorld.z], rotation: [0, 90, 0], parent: root });++ // ========== PENDANT LINES (boom support cables from A-frame to boom tip) ==========+ const aFrameTopWorld = { x: aFrameX, y: 1.13 + aFrameTipY + 0.05, z: 0 };++ for (const zs of [-0.4, 0.4]) {+ beamBetween('Pendant_' + (zs > 0 ? 'R' : 'L'),+ [boomTipWorld.x - 0.05, boomTipWorld.y + 0.05, zs],+ [aFrameTopWorld.x, aFrameTopWorld.y, 0],+ 0.03, cable, { parent: root });+ }+ // Backstay (centered)+ beamBetween('Backstay',+ [boomTipWorld.x - 0.05, boomTipWorld.y + 0.05, 0],+ [aFrameTopWorld.x, aFrameTopWorld.y, 0],+ 0.035, cable, { parent: root });++ return root;+}\ No newline at end of filediff --git a/examples/deep-sea-diver.kiln.js b/examples/deep-sea-diver.kiln.jsnew file mode 100644index 00000000..cf080646--- /dev/null+++ b/examples/deep-sea-diver.kiln.js@@ -0,0 +1,695 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'DeepSeaDiver', category: 'character' };++async function build() {+ const root = createRoot('DeepSeaDiver');++ // =========================================================================+ // MATERIALS+ // Authentic historical standard diving dress palette+ // =========================================================================+ // Spun copper bonnet and corselet bib+ const copper = gameMaterial(0xc26842, { metalness: 0.85, roughness: 0.32 });+ // Polished cast brass for viewports, neck ring, valves, scabbard, buckles+ const brass = gameMaterial(0xd8b248, { metalness: 0.90, roughness: 0.25 });+ // Heavy vulcanized double-twill canvas diving dress (weathered buff/khaki)+ const canvas = gameMaterial(0xcdbe9e, { roughness: 0.92, metalness: 0.04 });+ // Darker canvas for reinforced knee patches, seams, and folds+ const canvasDark = gameMaterial(0xb2a280, { roughness: 0.95, metalness: 0.04 });+ // Heavy vulcanized black rubber for wrist cuffs, collar gaskets, boot tops+ const rubber = gameMaterial(0x232528, { roughness: 0.80, metalness: 0.12 });+ // Dull cast lead for weighted breastplate, back counterweight, boot soles+ const lead = gameMaterial(0x4f545a, { roughness: 0.65, metalness: 0.55 });+ // Oiled harness leather for belt, weight harness, boot straps+ const leather = gameMaterial(0x482b18, { roughness: 0.84, metalness: 0.08 });+ // Tempered bullseye glass for helmet viewing ports+ const glass = glassMaterial(0x9fd0e8, { opacity: 0.55, roughness: 0.08, metalness: 0.15 });+ // Braided manila hemp rope for lifeline+ const rope = gameMaterial(0xc4af85, { roughness: 0.96, metalness: 0.02 });++ // =========================================================================+ // 1. BOOTS & LEGS (Grounded at Y = 0)+ // Anatomical lead-soled diving boots, contoured brass toe caps,+ // double instep buckles, baggy canvas trousers with knee reinforcements.+ // =========================================================================+ for (const side of [-1, 1]) {+ const z = side * 0.22;+ const sideSuffix = side === 1 ? 'R' : 'L';++ // --- Lead Sole (touching Y = 0) ---+ // Forward sole slab: length 0.22, height 0.045, width 0.15, resting on ground [0 .. 0.045]+ createPart(`SoleFore_${sideSuffix}`, await roundedBoxGeo(0.22, 0.045, 0.15, 0.01, { segments: 3 }), lead, {+ position: [0.08, 0.0225, z],+ parent: root,+ });+ // Raised heel block: length 0.12, height 0.055, width 0.14, resting on ground [0 .. 0.055]+ createPart(`SoleHeel_${sideSuffix}`, await roundedBoxGeo(0.12, 0.055, 0.14, 0.01, { segments: 3 }), lead, {+ position: [-0.07, 0.0275, z],+ parent: root,+ });+ // Brass sole welt / securing flange+ createPart(`SoleWelt_${sideSuffix}`, boxGeo(0.31, 0.012, 0.155), brass, {+ position: [0.025, 0.05, z],+ parent: root,+ });++ // --- Brass Toe Cap (curved shield over the toe) ---+ createPart(`ToeCap_${sideSuffix}`, cylinderGeo(0.075, 0.075, 0.10, 14), brass, {+ position: [0.14, 0.085, z],+ rotation: [0, 0, 90],+ parent: root,+ });+ createPart(`ToeCapTip_${sideSuffix}`, sphereGeo(0.074, 10, 8), brass, {+ position: [0.19, 0.085, z],+ scale: [0.35, 0.9, 0.9],+ parent: root,+ });++ // --- Boot Body (Heavy oiled leather upper) ---+ createPart(`BootBody_${sideSuffix}`, await roundedBoxGeo(0.24, 0.15, 0.13, 0.015, { segments: 3 }), leather, {+ position: [0.01, 0.135, z],+ parent: root,+ });+ // Boot tongue / instep curve+ createPart(`BootVamp_${sideSuffix}`, cylinderGeo(0.065, 0.060, 0.16, 10), leather, {+ position: [0.07, 0.15, z],+ rotation: [-20, 0, 0],+ parent: root,+ });+ // Vulcanized rubber ankle gaiter+ createPart(`BootGaiter_${sideSuffix}`, cylinderGeo(0.090, 0.082, 0.09, 14), rubber, {+ position: [-0.01, 0.24, z],+ parent: root,+ });++ // Leather instep straps & brass buckles securing boot+ createPart(`InstepStrap1_${sideSuffix}`, boxGeo(0.025, 0.035, 0.145), leather, {+ position: [0.05, 0.11, z],+ parent: root,+ });+ createPart(`InstepBuckle1_${sideSuffix}`, boxGeo(0.030, 0.022, 0.035), brass, {+ position: [0.05, 0.125, z + side * 0.070],+ parent: root,+ });+ createPart(`InstepStrap2_${sideSuffix}`, boxGeo(0.025, 0.035, 0.140), leather, {+ position: [-0.01, 0.17, z],+ parent: root,+ });+ createPart(`InstepBuckle2_${sideSuffix}`, boxGeo(0.030, 0.022, 0.035), brass, {+ position: [-0.01, 0.19, z + side * 0.068],+ parent: root,+ });++ // --- Lower Leg / Shin (Heavy canvas diving suit trousers) ---+ createPart(`ShinLower_${sideSuffix}`, cylinderGeo(0.102, 0.090, 0.20, 14), canvas, {+ position: [-0.01, 0.37, z],+ parent: root,+ });+ createPart(`ShinUpper_${sideSuffix}`, cylinderGeo(0.118, 0.102, 0.20, 14), canvas, {+ position: [0.00, 0.54, z],+ parent: root,+ });++ // Calf anti-ballooning cinch strap (keeps air from pooling in feet)+ createPart(`CalfStrap_${sideSuffix}`, cylinderGeo(0.110, 0.110, 0.035, 14), leather, {+ position: [0.0, 0.46, z],+ parent: root,+ });+ createPart(`CalfBuckle_${sideSuffix}`, boxGeo(0.035, 0.040, 0.020), brass, {+ position: [0.0, 0.46, z + side * 0.108],+ parent: root,+ });++ // --- Knee Joint & Heavy Reinforcement Patch ---+ createPart(`KneeJoint_${sideSuffix}`, sphereGeo(0.115, 12, 10), canvasDark, {+ position: [0.02, 0.70, z],+ scale: [1.08, 1.0, 0.95],+ parent: root,+ });+ // Stitched canvas/leather knee patch+ createPart(`KneePad_${sideSuffix}`, await roundedBoxGeo(0.07, 0.15, 0.16, 0.015, { segments: 3 }), canvasDark, {+ position: [0.10, 0.70, z],+ parent: root,+ });+ createPart(`KneeBorder_${sideSuffix}`, boxGeo(0.015, 0.16, 0.17), leather, {+ position: [0.07, 0.70, z],+ parent: root,+ });++ // --- Thigh (Bulky canvas tapering into pelvis) ---+ createPart(`ThighLower_${sideSuffix}`, cylinderGeo(0.135, 0.118, 0.22, 14), canvas, {+ position: [0.01, 0.83, z * 0.96],+ parent: root,+ });+ createPart(`ThighUpper_${sideSuffix}`, cylinderGeo(0.150, 0.135, 0.22, 14), canvas, {+ position: [0.00, 0.99, z * 0.92],+ parent: root,+ });+ }++ // =========================================================================+ // 2. PELVIS, TORSO, BELT & KNIFE SCABBARD (Y = 1.05 to 1.55)+ // Bulky canvas suit, leather diver's belt, brass scabbard, and crotch strap.+ // =========================================================================+ createPart('PelvisLower', cylinderGeo(0.23, 0.20, 0.15, 16), canvas, {+ position: [0.0, 1.08, 0],+ parent: root,+ });+ createPart('PelvisUpper', cylinderGeo(0.255, 0.23, 0.15, 16), canvas, {+ position: [0.0, 1.17, 0],+ parent: root,+ });++ // Torso / Suit body+ createPart('TorsoMid', cylinderGeo(0.275, 0.255, 0.18, 18), canvas, {+ position: [0.01, 1.29, 0],+ parent: root,+ });+ createPart('TorsoUpper', cylinderGeo(0.285, 0.275, 0.18, 18), canvas, {+ position: [0.01, 1.42, 0],+ parent: root,+ });++ // Diver's wide leather waist belt+ createPart('BeltBand', cylinderGeo(0.272, 0.272, 0.085, 20), leather, {+ position: [0.0, 1.16, 0],+ parent: root,+ });+ // Cast brass buckle+ createPart('BeltBuckleFrame', await roundedBoxGeo(0.035, 0.10, 0.12, 0.01, { segments: 3 }), brass, {+ position: [0.275, 1.16, 0],+ parent: root,+ });+ createPart('BeltBuckleProng', cylinderGeo(0.007, 0.007, 0.08, 8), brass, {+ position: [0.285, 1.16, 0],+ parent: root,+ });+ createPart('BeltTongue', boxGeo(0.07, 0.07, 0.018), leather, {+ position: [0.255, 1.16, 0.07],+ parent: root,+ });++ // Crotch strap (jock strap)+ createPart('CrotchStrapFront', boxGeo(0.035, 0.22, 0.07), leather, {+ position: [0.20, 1.05, 0],+ rotation: [-14, 0, 0],+ parent: root,+ });+ createPart('CrotchStrapBack', boxGeo(0.035, 0.22, 0.07), leather, {+ position: [-0.20, 1.05, 0],+ rotation: [14, 0, 0],+ parent: root,+ });++ // --- Diver's Knife & Brass Scabbard (Forward-right hip, clearly visible) ---+ // Belt frog / attachment bracket+ createPart('ScabbardBracket', boxGeo(0.035, 0.09, 0.04), leather, {+ position: [0.20, 1.16, 0.20],+ rotation: [0, 40, 0],+ parent: root,+ });+ // Cast brass threaded mouth+ createPart('ScabbardMouth', cylinderGeo(0.030, 0.028, 0.05, 12), brass, {+ position: [0.22, 1.12, 0.21],+ rotation: [8, 25, -12],+ parent: root,+ });+ // Brass sheath tube angled along upper right leg+ createPart('ScabbardTube', cylinderGeo(0.026, 0.018, 0.34, 12), brass, {+ position: [0.26, 0.94, 0.25],+ rotation: [8, 25, -12],+ parent: root,+ });+ createPart('ScabbardTip', sphereGeo(0.019, 8, 6), brass, {+ position: [0.30, 0.76, 0.29],+ parent: root,+ });+ // Knife hilt (turned brass / ribbed grip with pommel ring)+ createPart('KnifeGuard', cylinderGeo(0.032, 0.032, 0.012, 10), brass, {+ position: [0.21, 1.16, 0.20],+ rotation: [8, 25, -12],+ parent: root,+ });+ createPart('KnifeGrip', cylinderGeo(0.017, 0.015, 0.13, 10), brass, {+ position: [0.19, 1.23, 0.19],+ rotation: [8, 25, -12],+ parent: root,+ });+ createPart('KnifePommel', sphereGeo(0.020, 8, 6), brass, {+ position: [0.17, 1.30, 0.18],+ parent: root,+ });+ createPart('KnifePommelRing', torusGeo(0.014, 0.003, 6, 10), brass, {+ position: [0.16, 1.32, 0.175],+ rotation: [0, 60, 0],+ parent: root,+ });++ // =========================================================================+ // 3. WEIGHTED BREASTPLATE / CORSELET (Y = 1.35 to 1.62)+ // Spun copper corselet collar, brass brails, 12 bolted collar studs,+ // heavy lead chest weight and back weight with suspension lanyards.+ // =========================================================================+ // Copper corselet body (flared bell collar)+ createPart('CorseletBell', cylinderGeo(0.21, 0.30, 0.22, 18), copper, {+ position: [0.0, 1.48, 0],+ parent: root,+ });+ // Front bib plate+ createPart('CorseletBibFront', await roundedBoxGeo(0.10, 0.24, 0.38, 0.03, { segments: 3 }), copper, {+ position: [0.17, 1.42, 0],+ parent: root,+ });+ // Back bib plate+ createPart('CorseletBibBack', await roundedBoxGeo(0.10, 0.24, 0.38, 0.03, { segments: 3 }), copper, {+ position: [-0.17, 1.42, 0],+ parent: root,+ });++ // Brass brails (4 curved clamping bands)+ createPart('BrailFront', boxGeo(0.025, 0.025, 0.34), brass, {+ position: [0.225, 1.34, 0],+ parent: root,+ });+ createPart('BrailBack', boxGeo(0.025, 0.025, 0.34), brass, {+ position: [-0.225, 1.34, 0],+ parent: root,+ });+ for (const side of [-1, 1]) {+ createPart(`BrailSide_${side === 1 ? 'R' : 'L'}`, boxGeo(0.34, 0.025, 0.025), brass, {+ position: [0.0, 1.45, side * 0.25],+ parent: root,+ });+ }++ // Heavy Lead Chest Weight (hung from corselet studs)+ createPart('ChestWeightMain', await roundedBoxGeo(0.065, 0.24, 0.26, 0.015, { segments: 3 }), lead, {+ position: [0.255, 1.36, 0],+ parent: root,+ });+ createPart('ChestWeightBevel', boxGeo(0.015, 0.16, 0.18), lead, {+ position: [0.29, 1.36, 0],+ parent: root,+ });+ for (const side of [-1, 1]) {+ createPart(`WeightLugFront_${side === 1 ? 'R' : 'L'}`, torusGeo(0.022, 0.005, 6, 10), brass, {+ position: [0.26, 1.49, side * 0.09],+ rotation: [0, 90, 0],+ parent: root,+ });+ }++ // Matching Lead Back Weight+ createPart('BackWeightMain', await roundedBoxGeo(0.065, 0.24, 0.26, 0.015, { segments: 3 }), lead, {+ position: [-0.255, 1.36, 0],+ parent: root,+ });+ for (const side of [-1, 1]) {+ createPart(`WeightLugBack_${side === 1 ? 'R' : 'L'}`, torusGeo(0.022, 0.005, 6, 10), brass, {+ position: [-0.26, 1.49, side * 0.09],+ rotation: [0, 90, 0],+ parent: root,+ });+ }++ // Leather suspension straps across shoulders+ for (const side of [-1, 1]) {+ createPart(`WeightStrap_${side === 1 ? 'R' : 'L'}`, boxGeo(0.52, 0.022, 0.040), leather, {+ position: [0.0, 1.55, side * 0.11],+ parent: root,+ });+ createPart(`WeightStrapBuckle_${side === 1 ? 'R' : 'L'}`, boxGeo(0.025, 0.030, 0.045), brass, {+ position: [0.14, 1.51, side * 0.11],+ parent: root,+ });+ }++ // --- Bolted Neck Ring Flange ---+ createPart('NeckRingBase', cylinderGeo(0.205, 0.22, 0.035, 20), brass, {+ position: [0.0, 1.58, 0],+ parent: root,+ });+ createPart('NeckRingRim', torusGeo(0.21, 0.012, 6, 20), brass, {+ position: [0.0, 1.60, 0],+ rotation: [90, 0, 0],+ parent: root,+ });++ // 12 Neck Ring Hex Bolts+ const neckBolt = createPart('SampleNeckBolt', cylinderGeo(0.011, 0.011, 0.030, 6), brass, {+ position: [0.21, 1.61, 0],+ parent: root,+ });+ arrayRadial('NeckBolt', neckBolt, 12, 'y', root);++ // =========================================================================+ // 4. SPUN COPPER HELMET & 4 BULLSEYE PORTS (Y = 1.60 to 1.95)+ // Spun copper dome, front faceplate with 4-bar guard, 2 side ports with 3 bars,+ // top port with 2 bars, spitcock, regulating exhaust valve, and air fittings.+ // =========================================================================+ // Spun copper helmet bonnet+ createPart('BonnetDome', sphereGeo(0.22, 20, 16), copper, {+ position: [0.0, 1.75, 0],+ scale: [1.02, 1.05, 1.0],+ parent: root,+ });+ // Crown ring+ createPart('BonnetCrown', torusGeo(0.075, 0.010, 6, 16), copper, {+ position: [0.0, 1.97, 0],+ rotation: [90, 0, 0],+ parent: root,+ });++ // ----------------------------------------------------+ // PORT 1: FRONT FACEPLATE (Main Bullseye, +X)+ // ----------------------------------------------------+ createPart('FrontPortFrame', cylinderXGeo(0.095, 0.095, 0.045, 20), brass, {+ position: [0.205, 1.75, 0],+ parent: root,+ });+ createPart('FrontPortBezel', torusGeo(0.092, 0.010, 8, 20), brass, {+ position: [0.228, 1.75, 0],+ rotation: [0, 90, 0],+ parent: root,+ });+ createPart('FrontPortGlass', cylinderXGeo(0.080, 0.080, 0.025, 18), glass, {+ position: [0.215, 1.75, 0],+ parent: root,+ });+ // Faceplate hinge & wing-latch+ createPart('FrontPortHinge', cylinderGeo(0.014, 0.014, 0.06, 8), brass, {+ position: [0.205, 1.75, -0.10],+ parent: root,+ });+ createPart('FrontPortLatch', boxGeo(0.025, 0.035, 0.025), brass, {+ position: [0.205, 1.75, 0.10],+ parent: root,+ });+ // 4-Bar Protective Cross Grille+ createPart('FrontBarH', cylinderZGeo(0.006, 0.006, 0.17, 8), brass, {+ position: [0.236, 1.75, 0],+ parent: root,+ });+ createPart('FrontBarV', cylinderGeo(0.006, 0.006, 0.17, 8), brass, {+ position: [0.236, 1.75, 0],+ parent: root,+ });+ createPart('FrontBarD1', cylinderGeo(0.005, 0.005, 0.17, 8), brass, {+ position: [0.235, 1.75, 0],+ rotation: [0, 0, 45],+ parent: root,+ });+ createPart('FrontBarD2', cylinderGeo(0.005, 0.005, 0.17, 8), brass, {+ position: [0.235, 1.75, 0],+ rotation: [0, 0, -45],+ parent: root,+ });++ // ----------------------------------------------------+ // PORT 2: RIGHT SIDE BULLSEYE (+Z)+ // ----------------------------------------------------+ createPart('RightPortFrame', cylinderZGeo(0.075, 0.075, 0.045, 18), brass, {+ position: [0.02, 1.75, 0.205],+ parent: root,+ });+ createPart('RightPortBezel', torusGeo(0.073, 0.009, 6, 18), brass, {+ position: [0.02, 1.75, 0.228],+ parent: root,+ });+ createPart('RightPortGlass', cylinderZGeo(0.063, 0.063, 0.025, 16), glass, {+ position: [0.02, 1.75, 0.215],+ parent: root,+ });+ // 3 Horizontal Protective Bars+ for (const dy of [-0.030, 0.0, 0.030]) {+ createPart(`RightBar_${dy}`, cylinderXGeo(0.005, 0.005, 0.13, 8), brass, {+ position: [0.02, 1.75 + dy, 0.236],+ parent: root,+ });+ }++ // ----------------------------------------------------+ // PORT 3: LEFT SIDE BULLSEYE (-Z)+ // ----------------------------------------------------+ createPart('LeftPortFrame', cylinderZGeo(0.075, 0.075, 0.045, 18), brass, {+ position: [0.02, 1.75, -0.205],+ parent: root,+ });+ createPart('LeftPortBezel', torusGeo(0.073, 0.009, 6, 18), brass, {+ position: [0.02, 1.75, -0.228],+ parent: root,+ });+ createPart('LeftPortGlass', cylinderZGeo(0.063, 0.063, 0.025, 16), glass, {+ position: [0.02, 1.75, -0.215],+ parent: root,+ });+ // 3 Horizontal Protective Bars+ for (const dy of [-0.030, 0.0, 0.030]) {+ createPart(`LeftBar_${dy}`, cylinderXGeo(0.005, 0.005, 0.13, 8), brass, {+ position: [0.02, 1.75 + dy, -0.236],+ parent: root,+ });+ }++ // ----------------------------------------------------+ // PORT 4: TOP VIEWPORT (Angled upward & forward at +X/+Y)+ // ----------------------------------------------------+ createPart('TopPortFrame', cylinderGeo(0.070, 0.070, 0.045, 16), brass, {+ position: [0.11, 1.92, 0],+ rotation: [0, 0, -36],+ parent: root,+ });+ createPart('TopPortBezel', torusGeo(0.068, 0.008, 6, 16), brass, {+ position: [0.125, 1.938, 0],+ rotation: [0, 0, -36],+ parent: root,+ });+ createPart('TopPortGlass', cylinderGeo(0.058, 0.058, 0.025, 14), glass, {+ position: [0.115, 1.926, 0],+ rotation: [0, 0, -36],+ parent: root,+ });+ // 2 Protective Bars+ createPart('TopBar1', cylinderGeo(0.005, 0.005, 0.12, 6), brass, {+ position: [0.132, 1.950, -0.022],+ rotation: [0, 0, -36],+ parent: root,+ });+ createPart('TopBar2', cylinderGeo(0.005, 0.005, 0.12, 6), brass, {+ position: [0.132, 1.950, 0.022],+ rotation: [0, 0, -36],+ parent: root,+ });++ // ----------------------------------------------------+ // HELMET FITTINGS+ // ----------------------------------------------------+ // Spitcock valve on lower front-left+ createPart('SpitcockBody', cylinderGeo(0.014, 0.014, 0.045, 8), brass, {+ position: [0.18, 1.67, -0.10],+ rotation: [45, 30, 0],+ parent: root,+ });+ createPart('SpitcockLever', cylinderGeo(0.005, 0.003, 0.045, 6), brass, {+ position: [0.20, 1.65, -0.11],+ rotation: [0, 0, 90],+ parent: root,+ });++ // Regulating exhaust valve on right-rear (+Z, -X)+ createPart('ExhaustMount', cylinderGeo(0.035, 0.035, 0.035, 12), brass, {+ position: [-0.07, 1.73, 0.19],+ rotation: [25, 45, 0],+ parent: root,+ });+ createPart('ExhaustWheel', cylinderGeo(0.038, 0.038, 0.015, 10), brass, {+ position: [-0.09, 1.74, 0.22],+ rotation: [25, 45, 0],+ parent: root,+ });+ createPart('ExhaustDeflector', cylinderGeo(0.022, 0.032, 0.05, 10), copper, {+ position: [-0.12, 1.70, 0.18],+ rotation: [45, 0, -60],+ parent: root,+ });++ // Telephone / comms cup on left-rear (-Z, -X)+ createPart('CommsCup', cylinderGeo(0.028, 0.028, 0.025, 10), brass, {+ position: [-0.09, 1.79, -0.18],+ rotation: [-25, -45, 0],+ parent: root,+ });++ // Lifting eyes on top of helmet+ for (const side of [-1, 1]) {+ createPart(`LiftEye_${side === 1 ? 'R' : 'L'}`, torusGeo(0.020, 0.004, 6, 10), brass, {+ position: [0.0, 1.96, side * 0.11],+ rotation: [0, 90, 0],+ parent: root,+ });+ }++ // =========================================================================+ // 5. ARMS & DIVER'S MITTENS (Natural relaxed stance at sides)+ // Sleeves hang naturally slightly away from hips to prevent interpenetration.+ // =========================================================================+ for (const side of [-1, 1]) {+ const zSign = side;+ const sideSuffix = side === 1 ? 'R' : 'L';++ // Shoulder cloth bulge+ createPart(`ShoulderJoint_${sideSuffix}`, sphereGeo(0.13, 12, 10), canvasDark, {+ position: [0.0, 1.49, zSign * 0.34],+ parent: root,+ });++ // Upper arm (hanging down with 12° outward tilt, slight forward slant)+ createPart(`UpperArmTop_${sideSuffix}`, cylinderGeo(0.108, 0.098, 0.17, 12), canvas, {+ position: [0.01, 1.39, zSign * 0.38],+ rotation: [0, 0, zSign * 12],+ parent: root,+ });+ createPart(`UpperArmBot_${sideSuffix}`, cylinderGeo(0.098, 0.090, 0.17, 12), canvas, {+ position: [0.02, 1.25, zSign * 0.41],+ rotation: [0, 0, zSign * 12],+ parent: root,+ });++ // Elbow joint+ createPart(`ElbowJoint_${sideSuffix}`, sphereGeo(0.095, 10, 8), canvasDark, {+ position: [0.03, 1.14, zSign * 0.43],+ parent: root,+ });++ // Forearm (slanted slightly forward 8° and outward)+ createPart(`ForearmTop_${sideSuffix}`, cylinderGeo(0.090, 0.082, 0.15, 12), canvas, {+ position: [0.05, 1.03, zSign * 0.44],+ rotation: [-8 * zSign, 0, 8],+ parent: root,+ });+ createPart(`ForearmBot_${sideSuffix}`, cylinderGeo(0.082, 0.075, 0.15, 12), canvas, {+ position: [0.07, 0.90, zSign * 0.45],+ rotation: [-8 * zSign, 0, 8],+ parent: root,+ });++ // Heavy vulcanized rubber wrist cuff (seals gauntlet)+ createPart(`RubberCuffFlare_${sideSuffix}`, cylinderGeo(0.088, 0.078, 0.07, 14), rubber, {+ position: [0.09, 0.81, zSign * 0.455],+ rotation: [-8 * zSign, 0, 8],+ parent: root,+ });+ createPart(`RubberCuffRing_${sideSuffix}`, torusGeo(0.084, 0.008, 6, 14), rubber, {+ position: [0.095, 0.78, zSign * 0.46],+ rotation: [0, 90, 0],+ parent: root,+ });++ // Diver's 3-finger mitten+ createPart(`GlovePalm_${sideSuffix}`, await roundedBoxGeo(0.060, 0.10, 0.080, 0.012, { segments: 3 }), rubber, {+ position: [0.11, 0.71, zSign * 0.46],+ rotation: [0, 0, 6],+ parent: root,+ });+ createPart(`GloveFingers_${sideSuffix}`, cylinderGeo(0.035, 0.030, 0.08, 10), rubber, {+ position: [0.12, 0.63, zSign * 0.46],+ rotation: [0, 0, 6],+ parent: root,+ });+ createPart(`GloveThumb_${sideSuffix}`, cylinderGeo(0.018, 0.014, 0.06, 8), rubber, {+ position: [0.13, 0.70, zSign * 0.425],+ rotation: [25 * zSign, 0, -15],+ parent: root,+ });+ }++ // =========================================================================+ // 6. AIR HOSE & LIFELINE (Coiled gracefully behind helmet at -X)+ // Inlet elbow, lifeline bridle shackle, ribbed air hose and braided rope.+ // =========================================================================+ createPart('AirInletValve', cylinderGeo(0.028, 0.028, 0.07, 10), brass, {+ position: [-0.20, 1.76, -0.06],+ rotation: [0, 0, 90],+ parent: root,+ });+ createPart('AirInletElbow', cylinderGeo(0.024, 0.024, 0.045, 10), brass, {+ position: [-0.24, 1.74, -0.06],+ rotation: [0, 45, 90],+ parent: root,+ });++ createPart('LifelineShackle', torusGeo(0.020, 0.005, 6, 12), brass, {+ position: [-0.22, 1.67, 0.06],+ rotation: [0, 90, 0],+ parent: root,+ });++ // Supply air hose: smooth hanging loop descending from inlet into coiled turns+ const airHoseSpline = [+ [-0.25, 1.74, -0.06],+ [-0.32, 1.67, -0.08],+ [-0.36, 1.52, -0.11],+ [-0.35, 1.35, -0.15],+ [-0.31, 1.20, -0.20],+ [-0.25, 1.08, -0.24],+ [-0.18, 1.00, -0.22],+ [-0.17, 0.91, -0.17],+ [-0.22, 0.85, -0.12],+ [-0.29, 0.84, -0.11],+ [-0.34, 0.89, -0.14],+ [-0.35, 0.98, -0.20],+ [-0.31, 1.06, -0.26],+ [-0.23, 1.08, -0.27],+ [-0.17, 1.02, -0.24],+ [-0.16, 0.94, -0.18],+ [-0.21, 0.88, -0.13],+ [-0.27, 0.86, -0.10],+ ];+ const airHoseGeo = curveToMesh(airHoseSpline, 0.019, 36, 8);+ createPart('AirHose', airHoseGeo, rubber, { parent: root });++ // Lifeline rope: manila hemp line bundled alongside hose+ const lifelineSpline = [+ [-0.23, 1.67, 0.06],+ [-0.30, 1.57, 0.07],+ [-0.34, 1.40, 0.04],+ [-0.33, 1.25, -0.01],+ [-0.28, 1.13, -0.06],+ [-0.21, 1.03, -0.10],+ [-0.18, 0.95, -0.09],+ [-0.21, 0.88, -0.06],+ [-0.27, 0.86, -0.04],+ [-0.32, 0.90, -0.06],+ [-0.34, 0.98, -0.11],+ [-0.29, 1.05, -0.16],+ [-0.23, 1.06, -0.18],+ [-0.18, 1.00, -0.16],+ [-0.17, 0.93, -0.13],+ [-0.22, 0.87, -0.08],+ [-0.28, 0.85, -0.06],+ ];+ const lifelineGeo = curveToMesh(lifelineSpline, 0.012, 32, 6);+ createPart('LifelineRope', lifelineGeo, rope, { parent: root });++ // Leather binding lashings+ createPart('HoseLash1', torusGeo(0.040, 0.007, 6, 12), leather, {+ position: [-0.33, 0.93, -0.15],+ rotation: [25, 40, 0],+ parent: root,+ });+ createPart('HoseLash2', torusGeo(0.038, 0.007, 6, 12), leather, {+ position: [-0.19, 0.95, -0.18],+ rotation: [-20, 50, 0],+ parent: root,+ });++ return root;+}diff --git a/examples/drilling-rig.kiln.js b/examples/drilling-rig.kiln.jsnew file mode 100644index 00000000..e95d15fe--- /dev/null+++ b/examples/drilling-rig.kiln.js@@ -0,0 +1,746 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'DrillingRig', category: 'prop' };++function build() {+ const root = createRoot('DrillingRig');++ // Shared Materials (8 consistent PBR materials for optimal instanceability and draw-call batching)+ const mastYellow = gameMaterial(0xd97724, { metalness: 0.5, roughness: 0.4 }); // Industrial derrick orange/yellow+ const galvSteel = gameMaterial(0x8e969d, { metalness: 0.75, roughness: 0.35 }); // Galvanized structural steel+ const darkSteel = gameMaterial(0x272c33, { metalness: 0.85, roughness: 0.4 }); // Dark iron machinery & skids+ const pipeSteel = gameMaterial(0x4c555e, { metalness: 0.9, roughness: 0.25 }); // Machined alloy drill pipe+ const mudTankTeal = gameMaterial(0x1e4f60, { metalness: 0.45, roughness: 0.55 }); // Oilfield equipment teal+ const doghouseWhite = gameMaterial(0xcbd2d8, { metalness: 0.25, roughness: 0.65 }); // Painted sheet steel+ const cableBlack = gameMaterial(0x181a1c, { metalness: 0.8, roughness: 0.5 }); // Greased wire rope / hose+ const safetyRed = gameMaterial(0xb32821, { metalness: 0.5, roughness: 0.4, emissive: 0x330606 }); // Beacon / emergency++ // Helper: Railing with guaranteed vertical posts (no floating geometry)+ function createRailing(prefix, start, end, height, postCount, mat, parent) {+ const [x1, y1, z1] = start;+ const [x2, y2, z2] = end;+ // Top rail+ beamBetween(`${prefix}_Top`, [x1, y1 + height, z1], [x2, y2 + height, z2], 0.022, mat, { parent });+ // Mid rail+ beamBetween(`${prefix}_Mid`, [x1, y1 + height * 0.5, z1], [x2, y2 + height * 0.5, z2], 0.018, mat, { parent });+ // Vertical stanchions+ for (let i = 0; i <= postCount; i++) {+ const t = i / postCount;+ const px = x1 + t * (x2 - x1);+ const py = y1 + t * (y2 - y1);+ const pz = z1 + t * (z2 - z1);+ beamBetween(`${prefix}_Post_${i}`, [px, py, pz], [px, py + height, pz], 0.022, mat, { parent });+ }+ }++ // =========================================================================+ // 1. SUBSTRUCTURE & CELLAR (Y = 0 to 2.5m)+ // =========================================================================+ const subWidth = 5.2; // Z span (-2.6 to +2.6)+ const subLength = 6.4; // X span (-3.2 to +3.2)+ const floorY = 2.4; // Top of drill floor deck++ // Heavy foundation skid runners on ground (Y = 0.0 to 0.3)+ createPart('SkidBaseL', boxGeo(subLength + 0.8, 0.3, 0.45), darkSteel, { position: [0, 0.15, -subWidth / 2], parent: root });+ createPart('SkidBaseR', boxGeo(subLength + 0.8, 0.3, 0.45), darkSteel, { position: [0, 0.15, subWidth / 2], parent: root });+ createPart('SkidBaseM1', boxGeo(subLength + 0.8, 0.3, 0.35), darkSteel, { position: [0, 0.15, -1.1], parent: root });+ createPart('SkidBaseM2', boxGeo(subLength + 0.8, 0.3, 0.35), darkSteel, { position: [0, 0.15, 1.1], parent: root });+ // Cross skid spreaders+ createPart('SkidSpreaderRear', boxGeo(0.45, 0.3, subWidth + 0.45), darkSteel, { position: [-subLength / 2, 0.15, 0], parent: root });+ createPart('SkidSpreaderFront', boxGeo(0.45, 0.3, subWidth + 0.45), darkSteel, { position: [subLength / 2, 0.15, 0], parent: root });+ createPart('SkidSpreaderCenter', boxGeo(0.35, 0.3, subWidth), darkSteel, { position: [0, 0.15, 0], parent: root });++ // Substructure vertical support columns+ const subColumns = [+ [-subLength / 2, -subWidth / 2],+ [-subLength / 2, subWidth / 2],+ [subLength / 2, -subWidth / 2],+ [subLength / 2, subWidth / 2],+ [0, -subWidth / 2],+ [0, subWidth / 2],+ [-subLength / 2, -1.1],+ [-subLength / 2, 1.1],+ [subLength / 2, -1.1],+ [subLength / 2, 1.1],+ ];+ const colHeight = floorY - 0.3;+ for (let i = 0; i < subColumns.length; i++) {+ const [cx, cz] = subColumns[i];+ createPart(`SubCol_${i}`, boxGeo(0.28, colHeight, 0.28), galvSteel, {+ position: [cx, 0.3 + colHeight / 2, cz],+ parent: root,+ });+ }++ // Substructure diagonal truss braces (both sides)+ beamBetween('SubTruss_L1', [-subLength / 2, 0.3, -subWidth / 2], [0, floorY, -subWidth / 2], 0.065, galvSteel, { parent: root });+ beamBetween('SubTruss_L2', [0, 0.3, -subWidth / 2], [-subLength / 2, floorY, -subWidth / 2], 0.065, galvSteel, { parent: root });+ beamBetween('SubTruss_L3', [0, 0.3, -subWidth / 2], [subLength / 2, floorY, -subWidth / 2], 0.065, galvSteel, { parent: root });+ beamBetween('SubTruss_L4', [subLength / 2, 0.3, -subWidth / 2], [0, floorY, -subWidth / 2], 0.065, galvSteel, { parent: root });++ beamBetween('SubTruss_R1', [-subLength / 2, 0.3, subWidth / 2], [0, floorY, subWidth / 2], 0.065, galvSteel, { parent: root });+ beamBetween('SubTruss_R2', [0, 0.3, subWidth / 2], [-subLength / 2, floorY, subWidth / 2], 0.065, galvSteel, { parent: root });+ beamBetween('SubTruss_R3', [0, 0.3, subWidth / 2], [subLength / 2, floorY, subWidth / 2], 0.065, galvSteel, { parent: root });+ beamBetween('SubTruss_R4', [subLength / 2, 0.3, subWidth / 2], [0, floorY, subWidth / 2], 0.065, galvSteel, { parent: root });++ // Rear substructure X-brace+ beamBetween('SubTruss_Rear1', [-subLength / 2, 0.3, -subWidth / 2], [-subLength / 2, floorY, subWidth / 2], 0.06, galvSteel, { parent: root });+ beamBetween('SubTruss_Rear2', [-subLength / 2, 0.3, subWidth / 2], [-subLength / 2, floorY, -subWidth / 2], 0.06, galvSteel, { parent: root });++ // Cellar Wellhead & Blowout Preventer (BOP) Stack directly under drill floor+ createPart('WellheadFlange', cylinderGeo(0.5, 0.55, 0.35, 10), darkSteel, { position: [0, 0.175, 0], parent: root });+ createPart('BopPipeRam', cylinderGeo(0.42, 0.42, 0.5, 10), darkSteel, { position: [0, 0.6, 0], parent: root });+ createPart('BopBonnetL', boxGeo(1.4, 0.3, 0.35), darkSteel, { position: [0, 0.6, 0], parent: root });+ createPart('BopBlindRam', cylinderGeo(0.42, 0.42, 0.5, 10), darkSteel, { position: [0, 1.15, 0], parent: root });+ createPart('BopBonnetR', boxGeo(0.35, 0.3, 1.4), darkSteel, { position: [0, 1.15, 0], parent: root });+ createPart('BopAnnular', cylinderGeo(0.52, 0.44, 0.6, 10), darkSteel, { position: [0, 1.7, 0], parent: root });+ createPart('BellNipple', cylinderGeo(0.35, 0.35, 0.4, 10), darkSteel, { position: [0, 2.15, 0], parent: root });++ // Mud return flowline exiting below drill floor to mud tank+ beamBetween('MudFlowline1', [0, 2.1, 0.3], [0, 1.6, 2.6], 0.09, darkSteel, { parent: root });++ // Drill Floor Main Platform Deck+ createPart('DrillFloorDeck', boxGeo(subLength + 0.4, 0.18, subWidth + 0.4), darkSteel, {+ position: [0, floorY + 0.09, 0],+ parent: root,+ });+ // Floor perimeter toe-boards (kickplates)+ createPart('ToeBoardRear', boxGeo(0.04, 0.15, subWidth + 0.4), galvSteel, { position: [-subLength / 2 - 0.18, floorY + 0.25, 0], parent: root });+ createPart('ToeBoardL', boxGeo(subLength + 0.4, 0.15, 0.04), galvSteel, { position: [0, floorY + 0.25, -subWidth / 2 - 0.18], parent: root });+ createPart('ToeBoardR', boxGeo(subLength + 0.4, 0.15, 0.04), galvSteel, { position: [0, floorY + 0.25, subWidth / 2 + 0.18], parent: root });++ // Drill Floor Handrails (fully stanchioned)+ const deckY = floorY + 0.18;+ createRailing('Rail_Rear', [-subLength / 2 - 0.18, deckY, -subWidth / 2 - 0.18], [-subLength / 2 - 0.18, deckY, subWidth / 2 + 0.18], 1.0, 4, galvSteel, root);+ createRailing('Rail_SideL', [-subLength / 2 - 0.18, deckY, -subWidth / 2 - 0.18], [subLength / 2 + 0.18, deckY, -subWidth / 2 - 0.18], 1.0, 4, galvSteel, root);+ createRailing('Rail_SideR', [-subLength / 2 - 0.18, deckY, subWidth / 2 + 0.18], [subLength / 2 + 0.18, deckY, subWidth / 2 + 0.18], 1.0, 4, galvSteel, root);+ // Front rails leaving opening for V-door ramp (center open between Z = -0.9 and +0.9)+ createRailing('Rail_FrontL', [subLength / 2 + 0.18, deckY, -subWidth / 2 - 0.18], [subLength / 2 + 0.18, deckY, -0.9], 1.0, 2, galvSteel, root);+ createRailing('Rail_FrontR', [subLength / 2 + 0.18, deckY, 0.9], [subLength / 2 + 0.18, deckY, subWidth / 2 + 0.18], 1.0, 2, galvSteel, root);++ // =========================================================================+ // 2. DRILL FLOOR EQUIPMENT+ // =========================================================================+ // Rotary Table & Master Bushing+ createPart('RotaryTableBase', cylinderGeo(0.85, 0.9, 0.12, 12), galvSteel, {+ position: [0, deckY + 0.06, 0],+ parent: root,+ });+ createPart('RotaryTableRing', cylinderGeo(0.6, 0.6, 0.14, 12), darkSteel, {+ position: [0, deckY + 0.07, 0],+ parent: root,+ });+ createPart('MasterBushing', boxGeo(0.5, 0.16, 0.5), darkSteel, {+ position: [0, deckY + 0.08, 0],+ parent: root,+ });+ createPart('KellyDriveBushing', cylinderGeo(0.2, 0.2, 0.18, 6), galvSteel, {+ position: [0, deckY + 0.12, 0],+ parent: root,+ });++ // Iron Roughneck (Hydraulic pipe makeup / breakout wrench unit)+ const irX = 0.9;+ const irZ = -0.9;+ createPart('IronRoughneckPedestal', boxGeo(0.4, 0.8, 0.4), darkSteel, {+ position: [irX, deckY + 0.4, irZ],+ parent: root,+ });+ createPart('IronRoughneckArm', boxGeo(0.6, 0.35, 0.35), mastYellow, {+ position: [irX - 0.25, deckY + 0.9, irZ + 0.25],+ parent: root,+ });+ createPart('IronRoughneckJaw', cylinderGeo(0.18, 0.18, 0.4, 8), darkSteel, {+ position: [irX - 0.5, deckY + 0.9, irZ + 0.5],+ parent: root,+ });++ // Massive Drawworks Winch System (at rear of drill floor behind mast)+ const dwX = -2.1;+ const dwZ = 0.2;+ createPart('DrawworksBase', boxGeo(1.8, 0.35, 2.6), darkSteel, {+ position: [dwX, deckY + 0.175, dwZ],+ parent: root,+ });+ createPart('DrawworksHousing', boxGeo(1.4, 1.1, 2.3), mastYellow, {+ position: [dwX, deckY + 0.85, dwZ],+ parent: root,+ });+ // Winch drum & spooled drilling line+ createPart('WinchDrumWire', cylinderZGeo(0.42, 0.42, 1.4, 10), cableBlack, {+ position: [dwX + 0.2, deckY + 0.95, dwZ],+ parent: root,+ });+ createPart('WinchFlangeL', cylinderZGeo(0.62, 0.62, 0.08, 10), darkSteel, {+ position: [dwX + 0.2, deckY + 0.95, dwZ - 0.72],+ parent: root,+ });+ createPart('WinchFlangeR', cylinderZGeo(0.62, 0.62, 0.08, 10), darkSteel, {+ position: [dwX + 0.2, deckY + 0.95, dwZ + 0.72],+ parent: root,+ });+ // Electric drive motors behind drawworks+ createPart('DrawworksMotor1', cylinderXGeo(0.32, 0.32, 1.0, 8), darkSteel, {+ position: [dwX - 0.7, deckY + 0.6, dwZ - 0.6],+ parent: root,+ });+ createPart('DrawworksMotor2', cylinderXGeo(0.32, 0.32, 1.0, 8), darkSteel, {+ position: [dwX - 0.7, deckY + 0.6, dwZ + 0.6],+ parent: root,+ });++ // Driller's Console & Controls+ createPart('DrillerConsole', boxGeo(0.6, 0.9, 1.0), darkSteel, {+ position: [-0.6, deckY + 0.45, -1.8],+ parent: root,+ });+ createPart('BrakeLever', cylinderGeo(0.02, 0.02, 0.7, 6), galvSteel, {+ position: [-0.6, deckY + 0.95, -1.5],+ rotation: [15, 0, -20],+ parent: root,+ });++ // =========================================================================+ // 3. DOGHOUSE (Driller's Cabin on Floor)+ // =========================================================================+ const dogL = 2.4;+ const dogW = 1.8;+ const dogH = 2.2;+ const dogX = -1.4;+ const dogZ = -subWidth / 2 + dogW / 2 + 0.2; // -1.7+ const dogBaseY = deckY;++ createPart('DoghouseBody', boxGeo(dogL, dogH, dogW), doghouseWhite, {+ position: [dogX, dogBaseY + dogH / 2, dogZ],+ parent: root,+ });+ createPart('DoghouseRoof', boxGeo(dogL + 0.2, 0.08, dogW + 0.2), darkSteel, {+ position: [dogX, dogBaseY + dogH + 0.04, dogZ],+ parent: root,+ });+ createPart('DoghouseDoor', boxGeo(0.04, 1.8, 0.75), darkSteel, {+ position: [dogX + dogL / 2 + 0.02, dogBaseY + 0.9, dogZ + 0.2],+ parent: root,+ });+ createPart('DoghouseDoorHandle', boxGeo(0.06, 0.12, 0.04), galvSteel, {+ position: [dogX + dogL / 2 + 0.05, dogBaseY + 0.9, dogZ + 0.45],+ parent: root,+ });+ // Door rain awning & grab rail+ createPart('DoghouseAwning', boxGeo(0.45, 0.04, 0.95), darkSteel, {+ position: [dogX + dogL / 2 + 0.24, dogBaseY + 1.85, dogZ + 0.2],+ parent: root,+ });+ createPart('DogGrabStandoff1', boxGeo(0.08, 0.03, 0.03), galvSteel, {+ position: [dogX + dogL / 2 + 0.03, dogBaseY + 0.5, dogZ + 0.65],+ parent: root,+ });+ createPart('DogGrabStandoff2', boxGeo(0.08, 0.03, 0.03), galvSteel, {+ position: [dogX + dogL / 2 + 0.03, dogBaseY + 1.4, dogZ + 0.65],+ parent: root,+ });+ beamBetween('DogDoorGrabRail', [dogX + dogL / 2 + 0.06, dogBaseY + 0.5, dogZ + 0.65], [dogX + dogL / 2 + 0.06, dogBaseY + 1.4, dogZ + 0.65], 0.02, galvSteel, { parent: root });++ // Windows looking onto the drill floor (+Z side)+ createPart('DogWindowFrame1', boxGeo(0.8, 0.7, 0.04), darkSteel, {+ position: [dogX - 0.45, dogBaseY + 1.25, dogZ + dogW / 2 + 0.02],+ parent: root,+ });+ createPart('DogWindowGlass1', boxGeo(0.72, 0.62, 0.02), galvSteel, {+ position: [dogX - 0.45, dogBaseY + 1.25, dogZ + dogW / 2 + 0.03],+ parent: root,+ });+ createPart('DogWindowFrame2', boxGeo(0.8, 0.7, 0.04), darkSteel, {+ position: [dogX + 0.45, dogBaseY + 1.25, dogZ + dogW / 2 + 0.02],+ parent: root,+ });+ createPart('DogWindowGlass2', boxGeo(0.72, 0.62, 0.02), galvSteel, {+ position: [dogX + 0.45, dogBaseY + 1.25, dogZ + dogW / 2 + 0.03],+ parent: root,+ });+ // Roof A/C unit+ createPart('DoghouseAC', boxGeo(0.7, 0.45, 0.6), darkSteel, {+ position: [dogX - 0.5, dogBaseY + dogH + 0.25, dogZ],+ parent: root,+ });++ // =========================================================================+ // 4. DERRICK / MAST LATTICE STRUCTURE (Y = 2.5 to 19.5m)+ // =========================================================================+ const mastBaseY = deckY;+ const mastTopY = mastBaseY + 16.5; // Y = 19.08m+ const bHalfX = 1.7; // Base footprint half-extents+ const bHalfZ = 1.7;+ const tHalfX = 0.72; // Top footprint half-extents+ const tHalfZ = 0.72;+ const mastLegRad = 0.075;++ // Mast A-frame mounting shoes / pins on floor+ createPart('MastShoeFL', boxGeo(0.4, 0.3, 0.4), darkSteel, { position: [bHalfX, mastBaseY + 0.15, -bHalfZ], parent: root });+ createPart('MastShoeFR', boxGeo(0.4, 0.3, 0.4), darkSteel, { position: [bHalfX, mastBaseY + 0.15, bHalfZ], parent: root });+ createPart('MastShoeBL', boxGeo(0.4, 0.3, 0.4), darkSteel, { position: [-bHalfX, mastBaseY + 0.15, -bHalfZ], parent: root });+ createPart('MastShoeBR', boxGeo(0.4, 0.3, 0.4), darkSteel, { position: [-bHalfX, mastBaseY + 0.15, bHalfZ], parent: root });++ // 4 Main corner legs+ beamBetween('MastLeg_FL', [bHalfX, mastBaseY, -bHalfZ], [tHalfX, mastTopY, -tHalfZ], mastLegRad, mastYellow, { parent: root });+ beamBetween('MastLeg_FR', [bHalfX, mastBaseY, bHalfZ], [tHalfX, mastTopY, tHalfZ], mastLegRad, mastYellow, { parent: root });+ beamBetween('MastLeg_BL', [-bHalfX, mastBaseY, -bHalfZ], [-tHalfX, mastTopY, -tHalfZ], mastLegRad, mastYellow, { parent: root });+ beamBetween('MastLeg_BR', [-bHalfX, mastBaseY, bHalfZ], [-tHalfX, mastTopY, tHalfZ], mastLegRad, mastYellow, { parent: root });++ // Mast tiers: 7 panels of horizontal girths and cross-bracing+ const panels = 7;+ for (let p = 0; p <= panels; p++) {+ const t = p / panels;+ const py = mastBaseY + t * (mastTopY - mastBaseY);+ const px = bHalfX + t * (tHalfX - bHalfX);+ const pz = bHalfZ + t * (tHalfZ - bHalfZ);++ // Horizontal girth beams+ if (p > 0) {+ beamBetween(`Girth_B_${p}`, [-px, py, -pz], [-px, py, pz], 0.045, mastYellow, { parent: root });+ beamBetween(`Girth_L_${p}`, [-px, py, -pz], [px, py, -pz], 0.045, mastYellow, { parent: root });+ beamBetween(`Girth_R_${p}`, [-px, py, pz], [px, py, pz], 0.045, mastYellow, { parent: root });+ // Front face: lower 2 panels remain open for V-door pipe ramp entry+ if (p >= 2) {+ beamBetween(`Girth_F_${p}`, [px, py, -pz], [px, py, pz], 0.045, mastYellow, { parent: root });+ }+ }++ // Panel diagonal lattice trusses+ if (p < panels) {+ const tNext = (p + 1) / panels;+ const ny = mastBaseY + tNext * (mastTopY - mastBaseY);+ const nx = bHalfX + tNext * (tHalfX - bHalfX);+ const nz = bHalfZ + tNext * (tHalfZ - bHalfZ);++ // Back face X-braces+ beamBetween(`Diag_B1_${p}`, [-px, py, -pz], [-nx, ny, nz], 0.032, mastYellow, { parent: root });+ beamBetween(`Diag_B2_${p}`, [-px, py, pz], [-nx, ny, -nz], 0.032, mastYellow, { parent: root });++ // Left face X-braces+ beamBetween(`Diag_L1_${p}`, [-px, py, -pz], [nx, ny, -nz], 0.032, mastYellow, { parent: root });+ beamBetween(`Diag_L2_${p}`, [px, py, -pz], [-nx, ny, -nz], 0.032, mastYellow, { parent: root });++ // Right face X-braces+ beamBetween(`Diag_R1_${p}`, [-px, py, pz], [nx, ny, nz], 0.032, mastYellow, { parent: root });+ beamBetween(`Diag_R2_${p}`, [px, py, pz], [-nx, ny, nz], 0.032, mastYellow, { parent: root });++ // Front face X-braces (upper panels only)+ if (p >= 2) {+ beamBetween(`Diag_F1_${p}`, [px, py, -pz], [nx, ny, nz], 0.032, mastYellow, { parent: root });+ beamBetween(`Diag_F2_${p}`, [px, py, pz], [nx, ny, -nz], 0.032, mastYellow, { parent: root });+ }+ }+ }++ // Vertical climbing ladder up rear-left mast leg+ createLadder('MastLadder_Low', {+ bottom: [-bHalfX - 0.08, deckY, -bHalfZ + 0.3],+ top: [-1.15, mastBaseY + 9.5, -1.15 + 0.3],+ width: 0.42,+ rungCount: 18,+ material: galvSteel,+ parent: root,+ });+ createLadder('MastLadder_High', {+ bottom: [-1.15, mastBaseY + 9.5, -1.15 + 0.3],+ top: [-tHalfX - 0.08, mastTopY, -tHalfZ + 0.3],+ width: 0.42,+ rungCount: 16,+ material: galvSteel,+ parent: root,+ });++ // Standpipe and Gooseneck on front-right leg+ createPart('Standpipe', cylinderGeo(0.06, 0.06, 10.5, 8), darkSteel, {+ position: [bHalfX - 0.15, mastBaseY + 5.25, bHalfZ + 0.1],+ parent: root,+ });+ createPart('StandpipeGooseneck', torusGeo(0.18, 0.05, 6, 10), darkSteel, {+ position: [bHalfX - 0.15, mastBaseY + 10.5, bHalfZ + 0.1],+ rotation: [0, 0, 90],+ parent: root,+ });++ // Flexible Kelly Hose looping gracefully from standpipe down and up to Top Drive+ const hosePoints = [+ [bHalfX - 0.15, mastBaseY + 10.4, bHalfZ + 0.1],+ [bHalfX - 0.2, mastBaseY + 8.5, bHalfZ - 0.2],+ [0.6, mastBaseY + 6.0, 0.8],+ [0.2, mastBaseY + 6.8, 0.5],+ [0.0, mastBaseY + 8.6, 0.3],+ ];+ const hoseGeo = pipeAlongPath(hosePoints, 0.045, { bendRadius: 0.5, tubularSegments: 24, radialSegments: 6 });+ createPart('KellyHose', hoseGeo, cableBlack, { parent: root });++ // =========================================================================+ // 5. MONKEY BOARD & FINGERBOARD (PIPE RACKING)+ // =========================================================================+ const monkeyY = mastBaseY + 9.8;+ const mbW = 1.4;+ const mbD = 0.9;+ const mbX = -0.7;+ const mbZ = -0.2;++ // Derrickman racking board platform+ createPart('MonkeyBoardDeck', boxGeo(mbD, 0.06, mbW), galvSteel, {+ position: [mbX, monkeyY, mbZ],+ parent: root,+ });+ createRailing('MonkeyRailB', [mbX - mbD / 2, monkeyY, mbZ - mbW / 2], [mbX - mbD / 2, monkeyY, mbZ + mbW / 2], 1.0, 2, galvSteel, root);+ createRailing('MonkeyRailL', [mbX - mbD / 2, monkeyY, mbZ - mbW / 2], [mbX + mbD / 2, monkeyY, mbZ - mbW / 2], 1.0, 2, galvSteel, root);++ // Fingerboard tines (slotted steel racks holding pipe stands)+ const tineL = 1.1;+ createPart('FingerboardBeam', boxGeo(0.08, 0.12, 1.2), galvSteel, {+ position: [mbX + mbD / 2 + 0.05, monkeyY + 0.4, mbZ],+ parent: root,+ });+ for (let f = -2; f <= 2; f++) {+ createPart(`FingerTine_${f}`, boxGeo(tineL, 0.05, 0.03), galvSteel, {+ position: [mbX + mbD / 2 + tineL / 2 + 0.05, monkeyY + 0.4, mbZ + f * 0.22],+ parent: root,+ });+ }++ // Racked Drill Pipes standing in fingerboard setback area on drill floor+ const pipeStandH = monkeyY - mastBaseY + 0.8;+ const pipeRadius = 0.045;+ for (let row = 0; row < 2; row++) {+ for (let col = 0; col < 6; col++) {+ const px = -0.35 - row * 0.18;+ const pz = -0.45 + col * 0.18;+ createPart(`RackedPipe_${row}_${col}`, cylinderGeo(pipeRadius, pipeRadius, pipeStandH, 6), pipeSteel, {+ position: [px, mastBaseY + pipeStandH / 2, pz],+ parent: root,+ });+ }+ }+ // Drill Collars (heavier 8" diameter drill collars in rear rack)+ for (let dc = 0; dc < 3; dc++) {+ createPart(`DrillCollar_${dc}`, cylinderGeo(0.07, 0.07, pipeStandH, 6), darkSteel, {+ position: [-0.85, mastBaseY + pipeStandH / 2, -0.25 + dc * 0.25],+ parent: root,+ });+ }++ // =========================================================================+ // 6. CROWN BLOCK & WATER TABLE (MAST TOP)+ // =========================================================================+ const crownFrameY = mastTopY;+ createPart('CrownDeck', boxGeo(tHalfX * 2 + 0.6, 0.15, tHalfZ * 2 + 0.6), darkSteel, {+ position: [0, crownFrameY + 0.075, 0],+ parent: root,+ });+ const crW = tHalfZ + 0.28;+ const crL = tHalfX + 0.28;+ const crDeckY = crownFrameY + 0.15;+ createRailing('CrownRail_F', [crL, crDeckY, -crW], [crL, crDeckY, crW], 0.9, 2, galvSteel, root);+ createRailing('CrownRail_B', [-crL, crDeckY, -crW], [-crL, crDeckY, crW], 0.9, 2, galvSteel, root);+ createRailing('CrownRail_L', [-crL, crDeckY, -crW], [crL, crDeckY, -crW], 0.9, 2, galvSteel, root);+ createRailing('CrownRail_R', [-crL, crDeckY, crW], [crL, crDeckY, crW], 0.9, 2, galvSteel, root);++ // Crown sheave housing / arch+ createPart('CrownSheaveArchL', boxGeo(0.9, 1.0, 0.12), darkSteel, { position: [0, crDeckY + 0.5, -0.4], parent: root });+ createPart('CrownSheaveArchR', boxGeo(0.9, 1.0, 0.12), darkSteel, { position: [0, crDeckY + 0.5, 0.4], parent: root });+ createPart('CrownCenterShaft', cylinderZGeo(0.07, 0.07, 0.8, 8), darkSteel, { position: [0, crDeckY + 0.65, 0], parent: root });++ // 6 Main crown sheaves (pulleys)+ for (let s = -2; s <= 3; s++) {+ createPart(`CrownSheave_${s}`, cylinderZGeo(0.38, 0.38, 0.06, 10), galvSteel, {+ position: [0, crDeckY + 0.65, s * 0.11 - 0.05],+ parent: root,+ });+ }++ // Crown protective hood with support posts solidly welded to sheave arches+ createPart('CrownHoodPostL', boxGeo(0.08, 0.18, 0.08), darkSteel, { position: [0, crDeckY + 1.0, -0.35], parent: root });+ createPart('CrownHoodPostR', boxGeo(0.08, 0.18, 0.08), darkSteel, { position: [0, crDeckY + 1.0, 0.35], parent: root });+ createPart('CrownGuardHood', boxGeo(1.0, 0.1, 0.8), mastYellow, {+ position: [0, crDeckY + 1.08, 0],+ parent: root,+ });++ // Aviation obstruction warning beacon & lightning rod on crown top+ createPart('CrownBeaconStem', cylinderGeo(0.03, 0.03, 0.35, 6), darkSteel, {+ position: [0, crDeckY + 1.28, 0],+ parent: root,+ });+ createPart('CrownBeaconLight', cylinderGeo(0.08, 0.08, 0.16, 8), safetyRed, {+ position: [0, crDeckY + 1.5, 0],+ parent: root,+ });+ createPart('LightningRod', cylinderGeo(0.015, 0.015, 0.6, 6), galvSteel, {+ position: [-0.3, crDeckY + 1.35, -0.3],+ parent: root,+ });++ // =========================================================================+ // 7. TRAVELLING BLOCK & TOP DRIVE SYSTEM+ // =========================================================================+ const tbY = mastBaseY + 8.8;++ // Vertical torque guide rails in mast for top drive carriage+ beamBetween('TorqueRailL', [-0.45, mastBaseY, -0.3], [-0.3, mastTopY, -0.2], 0.035, galvSteel, { parent: root });+ beamBetween('TorqueRailR', [-0.45, mastBaseY, 0.3], [-0.3, mastTopY, 0.2], 0.035, galvSteel, { parent: root });++ // Travelling Block body+ createPart('TravBlockBody', boxGeo(0.55, 1.3, 0.65), mastYellow, {+ position: [0, tbY + 0.85, 0],+ parent: root,+ });+ createPart('TravBlockPlateL', boxGeo(0.6, 1.25, 0.06), darkSteel, { position: [0, tbY + 0.85, -0.34], parent: root });+ createPart('TravBlockPlateR', boxGeo(0.6, 1.25, 0.06), darkSteel, { position: [0, tbY + 0.85, 0.34], parent: root });++ // Top Drive System (integrated below travelling block)+ createPart('TopDriveMainBody', boxGeo(0.7, 0.85, 0.65), darkSteel, {+ position: [0, tbY - 0.2, 0],+ parent: root,+ });+ createPart('TopDriveMotor', cylinderGeo(0.24, 0.24, 0.7, 8), mastYellow, {+ position: [-0.15, tbY + 0.3, 0],+ parent: root,+ });+ createPart('TopDriveDolly', boxGeo(0.3, 0.9, 0.85), darkSteel, {+ position: [-0.4, tbY - 0.1, 0],+ parent: root,+ });++ // Pipe elevator links (bails) hanging below top drive+ beamBetween('ElevatorBailL', [0.05, tbY - 0.6, -0.25], [0.05, tbY - 1.4, -0.2], 0.03, galvSteel, { parent: root });+ beamBetween('ElevatorBailR', [0.05, tbY - 0.6, 0.25], [0.05, tbY - 1.4, 0.2], 0.03, galvSteel, { parent: root });+ createPart('ElevatorClamp', boxGeo(0.3, 0.2, 0.45), darkSteel, {+ position: [0.05, tbY - 1.4, 0],+ parent: root,+ });++ // Active drill pipe / quill passing through rotary table+ createPart('ActiveDrillPipe', cylinderGeo(0.06, 0.06, 8.5, 8), pipeSteel, {+ position: [0, mastBaseY + 4.25, 0],+ parent: root,+ });++ // Drilling Lines+ beamBetween('CableLine1', [-0.15, crDeckY + 0.65, -0.18], [-0.15, tbY + 1.5, -0.18], 0.016, cableBlack, { parent: root });+ beamBetween('CableLine2', [-0.15, crDeckY + 0.65, 0.18], [-0.15, tbY + 1.5, 0.18], 0.016, cableBlack, { parent: root });+ beamBetween('CableLine3', [0.15, crDeckY + 0.65, -0.18], [0.15, tbY + 1.5, -0.18], 0.016, cableBlack, { parent: root });+ beamBetween('CableLine4', [0.15, crDeckY + 0.65, 0.18], [0.15, tbY + 1.5, 0.18], 0.016, cableBlack, { parent: root });+ beamBetween('FastlineCable', [0, crDeckY + 0.65, 0.35], [dwX + 0.2, deckY + 1.0, dwZ + 0.5], 0.018, cableBlack, { parent: root });++ // =========================================================================+ // 8. MUD TANKS & SOLIDS CONTROL SYSTEM (+Z ground side)+ // =========================================================================+ const tankL = 4.8;+ const tankW = 2.0;+ const tankH = 1.4;+ const tankX = 0.2;+ const tankZ = subWidth / 2 + tankW / 2 + 0.6; // 4.2++ // Steel skid runners connecting Mud Tanks to main Substructure Base skids (rigid bridge)+ createPart('MudSkidTieL', boxGeo(0.3, 0.25, 1.2), darkSteel, {+ position: [-1.5, 0.125, subWidth / 2 + 0.5],+ parent: root,+ });+ createPart('MudSkidTieR', boxGeo(0.3, 0.25, 1.2), darkSteel, {+ position: [1.5, 0.125, subWidth / 2 + 0.5],+ parent: root,+ });++ // Mud Tanks Skid Base+ createPart('MudTankSkid1', boxGeo(tankL + 0.6, 0.25, 0.35), darkSteel, { position: [tankX, 0.125, tankZ - tankW / 2], parent: root });+ createPart('MudTankSkid2', boxGeo(tankL + 0.6, 0.25, 0.35), darkSteel, { position: [tankX, 0.125, tankZ + tankW / 2], parent: root });++ // Dual Compartment Mud Tanks (Active Tank & Suction Tank)+ createPart('MudTankComp1', boxGeo(tankL / 2 - 0.05, tankH - 0.2, tankW), mudTankTeal, {+ position: [tankX - tankL / 4, 0.25 + (tankH - 0.2) / 2, tankZ],+ parent: root,+ });+ createPart('MudTankComp2', boxGeo(tankL / 2 - 0.05, tankH - 0.2, tankW), mudTankTeal, {+ position: [tankX + tankL / 4, 0.25 + (tankH - 0.2) / 2, tankZ],+ parent: root,+ });+ // Equalizer connection pipe between compartments+ createPart('TankEqualizerPipe', cylinderXGeo(0.08, 0.08, 0.4, 8), darkSteel, {+ position: [tankX, 0.6, tankZ],+ parent: root,+ });++ // Top Walkway Grating+ createPart('MudTankDeck', boxGeo(tankL + 0.2, 0.08, tankW + 0.1), darkSteel, {+ position: [tankX, tankH + 0.04, tankZ],+ parent: root,+ });+ // Mud Tank Handrails with vertical stanchions directly into deck+ const mtDeckY = tankH + 0.08;+ createRailing('MTRail_Outer', [tankX - tankL / 2, mtDeckY, tankZ + tankW / 2], [tankX + tankL / 2, mtDeckY, tankZ + tankW / 2], 0.9, 4, galvSteel, root);+ createRailing('MTRail_Inner', [tankX - tankL / 2, mtDeckY, tankZ - tankW / 2], [tankX + tankL / 2, mtDeckY, tankZ - tankW / 2], 0.9, 4, galvSteel, root);+ createRailing('MTRail_EndL', [tankX - tankL / 2, mtDeckY, tankZ - tankW / 2], [tankX - tankL / 2, mtDeckY, tankZ + tankW / 2], 0.9, 2, galvSteel, root);++ // Shale Shaker Unit mounted on Tank 1 (+X end)+ const ssX = tankX + tankL / 2 - 0.6;+ const ssY = tankH + 0.1;+ createPart('ShakerFrame', boxGeo(1.3, 0.4, 1.2), darkSteel, {+ position: [ssX, ssY + 0.2, tankZ],+ parent: root,+ });+ createPart('ShakerScreen', boxGeo(1.1, 0.1, 1.0), galvSteel, {+ position: [ssX + 0.1, ssY + 0.4, tankZ],+ rotation: [0, 0, -12],+ parent: root,+ });+ createPart('ShakerMotor', cylinderXGeo(0.14, 0.14, 0.8, 8), mastYellow, {+ position: [ssX - 0.3, ssY + 0.6, tankZ],+ parent: root,+ });+ // Cuttings discharge chute sloping down from shaker+ createPart('ShakerChute', boxGeo(0.6, 0.06, 0.9), darkSteel, {+ position: [ssX + 0.7, ssY + 0.15, tankZ],+ rotation: [0, 0, -35],+ parent: root,+ });++ // Flowline connection from BOP to Shale Shaker header box+ beamBetween('MudFlowline2', [0, 1.6, 2.6], [ssX - 0.4, ssY + 0.6, tankZ], 0.09, darkSteel, { parent: root });++ // Mud Agitator Motors on top of tanks+ for (let m = -1; m <= 0; m++) {+ const ax = tankX + m * 1.3 - 0.4;+ createPart(`AgitatorMotor_${m}`, cylinderGeo(0.2, 0.2, 0.4, 8), darkSteel, {+ position: [ax, mtDeckY + 0.3, tankZ],+ parent: root,+ });+ createPart(`AgitatorGearbox_${m}`, boxGeo(0.35, 0.2, 0.35), darkSteel, {+ position: [ax, mtDeckY + 0.1, tankZ],+ parent: root,+ });+ }++ // Low pressure mud manifold pipe rigidly welded via mounting brackets to tank skid+ createPart('MudManifoldBracket1', boxGeo(0.12, 0.25, 0.3), darkSteel, {+ position: [tankX - 1.5, 0.35, tankZ - tankW / 2 - 0.1],+ parent: root,+ });+ createPart('MudManifoldBracket2', boxGeo(0.12, 0.25, 0.3), darkSteel, {+ position: [tankX + 1.5, 0.35, tankZ - tankW / 2 - 0.1],+ parent: root,+ });+ createPart('MudManifoldPipe', cylinderXGeo(0.08, 0.08, tankL, 8), darkSteel, {+ position: [tankX, 0.45, tankZ - tankW / 2 - 0.2],+ parent: root,+ });++ // Mud tank access ladder from ground (resting at Y=0.01)+ createLadder('MudTankLadder', {+ bottom: [tankX - tankL / 2 - 0.15, 0.01, tankZ],+ top: [tankX - tankL / 2 - 0.15, mtDeckY, tankZ],+ width: 0.4,+ rungCount: 5,+ material: galvSteel,+ parent: root,+ });++ // =========================================================================+ // 9. STAIRWAY TO DRILL FLOOR (+X Front Approach)+ // =========================================================================+ createStairs('FloorStairs', galvSteel, {+ steps: 12,+ totalRise: floorY + 0.18,+ totalRun: 3.2,+ width: 0.85,+ axis: 'x',+ parent: root,+ });+ const stairObj = root.getObjectByName('FloorStairs');+ if (stairObj) {+ stairObj.position.set(subLength / 2 + 3.2, 0, 1.6);+ stairObj.rotation.y = Math.PI;+ }++ // Stair railings with vertical stanchions into stringers+ const stairStartX = subLength / 2 + 3.2;+ const stairEndX = subLength / 2;+ const stairZ = 1.6;+ const stairW = 0.85;+ createRailing('StairRail_L', [stairStartX, 0, stairZ - stairW / 2], [stairEndX, deckY, stairZ - stairW / 2], 0.9, 4, galvSteel, root);+ createRailing('StairRail_R', [stairStartX, 0, stairZ + stairW / 2], [stairEndX, deckY, stairZ + stairW / 2], 0.9, 4, galvSteel, root);++ // =========================================================================+ // 10. V-DOOR PIPE RAMP & CATWALK SYSTEM (+X forward)+ // =========================================================================+ const rampTopX = subLength / 2;+ const rampTopY = deckY;+ const rampBottomX = 5.6;+ const rampBottomY = 0.35;+ const rampSpacing = 0.7;++ // Sloping structural stringers (lowest point remains safely above Y=0)+ beamBetween('PipeRampStringerL', [rampTopX, rampTopY, -rampSpacing], [rampBottomX, rampBottomY, -rampSpacing], 0.06, darkSteel, { parent: root });+ beamBetween('PipeRampStringerR', [rampTopX, rampTopY, rampSpacing], [rampBottomX, rampBottomY, rampSpacing], 0.06, darkSteel, { parent: root });++ // Sloped steel slide plate between stringers+ const rampMidX = (rampTopX + rampBottomX) / 2;+ const rampMidY = (rampTopY + rampBottomY) / 2;+ const rampAngleDeg = Math.atan2(rampTopY - rampBottomY, rampBottomX - rampTopX) * (180 / Math.PI);+ const rampLength = Math.hypot(rampBottomX - rampTopX, rampTopY - rampBottomY);+ createPart('PipeSlidePlate', boxGeo(rampLength, 0.04, rampSpacing * 2), darkSteel, {+ position: [rampMidX, rampMidY, 0],+ rotation: [0, 0, rampAngleDeg],+ parent: root,+ });++ // Catwalk Platform (Long horizontal runway for pipe handling, X = 5.4 to 10.8)+ const cwL = 5.4;+ const cwW = 1.6;+ const cwH = 0.35;+ const cwX = 5.5 + cwL / 2; // X = 8.2++ createPart('CatwalkDeck', boxGeo(cwL, cwH, cwW), darkSteel, {+ position: [cwX, cwH / 2, 0],+ parent: root,+ });+ createPart('CatwalkGrating', boxGeo(cwL, 0.04, cwW), galvSteel, {+ position: [cwX, cwH + 0.02, 0],+ parent: root,+ });+ // Catwalk connection tie to substructure skid (ensures continuous connected graph)+ createPart('CatwalkSkidTie', boxGeo(2.4, 0.25, 0.4), darkSteel, {+ position: [4.4, 0.125, 0],+ parent: root,+ });++ // Transverse pipe rack support skids connecting directly under catwalk (welds pipe racks to catwalk!)+ createPart('PipeRackTransverseSkid1', boxGeo(0.3, 0.25, 4.8), darkSteel, {+ position: [6.5, 0.125, 0],+ parent: root,+ });+ createPart('PipeRackTransverseSkid2', boxGeo(0.3, 0.25, 4.8), darkSteel, {+ position: [9.5, 0.125, 0],+ parent: root,+ });++ // Pipe Racks on both sides of Catwalk (storing horizontal drill pipe/casing)+ for (let side of [-1, 1]) {+ const rz = side * (cwW / 2 + 1.2);+ // Triangular steel rack supports resting directly on transverse skids+ createPart(`PipeRackFrame_${side}_1`, boxGeo(0.3, 0.4, 2.2), darkSteel, { position: [6.5, 0.2, rz], parent: root });+ createPart(`PipeRackFrame_${side}_2`, boxGeo(0.3, 0.4, 2.2), darkSteel, { position: [9.5, 0.2, rz], parent: root });++ // Casing pipes lying horizontally in racks+ for (let p = 0; p < 4; p++) {+ const pOffsetZ = rz - 0.65 + p * 0.42;+ createPart(`StoredPipe_${side}_${p}`, cylinderXGeo(0.1, 0.1, 4.2, 8), pipeSteel, {+ position: [8.0, 0.48, pOffsetZ],+ parent: root,+ });+ }+ }++ return root;+}diff --git a/examples/espresso-machine.kiln.js b/examples/espresso-machine.kiln.jsnew file mode 100644index 00000000..9beaa2fb--- /dev/null+++ b/examples/espresso-machine.kiln.js@@ -0,0 +1,694 @@+// Authored by: opencode-go/glm-5.3-flash, via opencode.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++// Commercial Three-Group Lever Espresso Machine+// A classic Italian commercial spring-lever espresso machine with 3 massive lever groups,+// twin steam wands, hot water dispenser, dual manometers, boiler level sight glass,+// perforated drip tray with staging stands, and heated cup storage on top.++const meta = {+ name: 'CommercialLeverEspressoMachine',+ category: 'prop',+ role: 'prop',+};++async function build() {+ const root = createRoot('CommercialLeverEspressoMachine');++ // ---------- Materials ----------+ // Polished mirror chrome / stainless steel (bodywork, group bodies, levers, wands, rails)+ const chromeMat = gameMaterial(0xf2f5f8, { metalness: 0.96, roughness: 0.14 });+ // Heavy cast chassis / dark trim / rubber feet & grip sleeves+ const darkChassisMat = gameMaterial(0x181a1d, { metalness: 0.35, roughness: 0.55 });+ // Rich turned walnut / rosewood (lever handles, portafilter handles, steam knobs)+ const richWoodMat = gameMaterial(0x3e1f10, { metalness: 0.05, roughness: 0.30 });+ // Polished golden brass (accents, sight glass cage, manometer bezels, ferrules, badges)+ const brassMat = gameMaterial(0xd8b046, { metalness: 0.92, roughness: 0.22 });+ // Gloss ceramic white (cups, saucers, manometer dials)+ const ceramicMat = gameMaterial(0xfbfbfa, { metalness: 0.05, roughness: 0.10 });+ // Ruby indicator lamp / power jewel+ const jewelRedMat = gameMaterial(0xff2211, {+ emissive: 0xee1100,+ emissiveIntensity: 2.5,+ roughness: 0.25,+ });++ // ---------- Reusable Geometries ----------+ // Feet+ const footRubberGeo = cylinderGeo(0.034, 0.038, 0.016, 14);+ const footChromeGeo = cylinderGeo(0.026, 0.034, 0.034, 14);++ // Group Head Geometries+ const groupNeckGeo = cylinderXGeo(0.032, 0.032, 0.065, 14);+ const groupCylinderGeo = cylinderGeo(0.043, 0.043, 0.130, 18);+ const groupRingGeo = torusGeo(0.044, 0.0035, 8, 18);+ const groupTopCapGeo = cylinderGeo(0.047, 0.047, 0.016, 18);+ const groupBellGeo = cylinderGeo(0.043, 0.050, 0.036, 18);+ const bayonetRingGeo = cylinderGeo(0.052, 0.052, 0.012, 18);+ const bayonetBrassGeo = torusGeo(0.053, 0.0035, 8, 18);+ const showerScreenGeo = cylinderGeo(0.036, 0.036, 0.004, 14);++ // Portafilter Geometries+ const filterBowlGeo = cylinderGeo(0.042, 0.038, 0.028, 18);+ const spoutManifoldGeo = cylinderXGeo(0.012, 0.012, 0.024, 12);+ const spoutTipGeo = cylinderGeo(0.0045, 0.0035, 0.032, 8);+ const portafilterFerruleGeo = cylinderXGeo(0.013, 0.010, 0.018, 12);+ const portafilterWoodGeo = lathe([+ [0.010, 0.000],+ [0.011, 0.015],+ [0.015, 0.045],+ [0.017, 0.075],+ [0.016, 0.095],+ [0.013, 0.115],+ [0.008, 0.125],+ [0.000, 0.125],+ ], 14);+ const portafilterCapGeo = cylinderXGeo(0.009, 0.009, 0.008, 12);++ // Lever Mechanism Geometries+ const pistonShaftGeo = cylinderGeo(0.012, 0.012, 0.038, 12);+ const forkArmGeo = boxGeo(0.038, 0.052, 0.008);+ const pivotPinGeo = cylinderZGeo(0.007, 0.007, 0.050, 10);+ const pinNutGeo = cylinderZGeo(0.010, 0.010, 0.005, 10);+ const leverRodGeo = cylinderGeo(0.0075, 0.0085, 0.360, 12);+ const leverGripGeo = lathe([+ [0.008, -0.055],+ [0.011, -0.042],+ [0.016, -0.015],+ [0.022, 0.010],+ [0.024, 0.030],+ [0.018, 0.048],+ [0.011, 0.055],+ [0.000, 0.055],+ ], 16);+ const leverFerruleGeo = cylinderGeo(0.012, 0.010, 0.016, 12);+ const leverCrownNutGeo = cylinderGeo(0.010, 0.012, 0.012, 12);+ const leverFinialGeo = sphereGeo(0.010, 10, 8);++ // Cups & Saucers Geometries+ const saucerGeo = lathe([+ [0.000, 0.000],+ [0.032, 0.001],+ [0.050, 0.005],+ [0.054, 0.009],+ [0.048, 0.008],+ [0.030, 0.003],+ [0.000, 0.002],+ ], 14);+ const cupGeo = lathe([+ [0.000, 0.000],+ [0.022, 0.000],+ [0.024, 0.008],+ [0.030, 0.025],+ [0.035, 0.042],+ [0.033, 0.042],+ [0.028, 0.025],+ [0.020, 0.006],+ [0.000, 0.006],+ ], 14);+ const cupHandleGeo = torusGeo(0.011, 0.0032, 8, 10);+ const coffeeFillGeo = cylinderGeo(0.028, 0.028, 0.003, 12);++ // ==========================================+ // 1. FEET & LOWER PLINTH (Grounding at Y=0)+ // ==========================================+ const footPositions = [+ [0.17, -0.40],+ [0.17, 0.40],+ [-0.17, -0.40],+ [-0.17, 0.40],+ ];+ for (let i = 0; i < footPositions.length; i++) {+ const [fx, fz] = footPositions[i];+ // Rubber foot touching Y = 0.000+ createPart(`FootRubber_${i}`, footRubberGeo, darkChassisMat, {+ position: [fx, 0.008, fz],+ parent: root,+ });+ // Polished chrome upper foot cone+ createPart(`FootChrome_${i}`, footChromeGeo, chromeMat, {+ position: [fx, 0.033, fz],+ parent: root,+ });+ }++ // Dark structural chassis plinth+ createPart('ChassisPlinth', boxGeo(0.38, 0.06, 0.88), darkChassisMat, {+ position: [-0.02, 0.08, 0],+ parent: root,+ });++ // ==========================================+ // 2. DRIP TRAY & GRATE+ // ==========================================+ createPart('DripTrayBasin', boxGeo(0.18, 0.08, 0.86), darkChassisMat, {+ position: [0.26, 0.09, 0],+ parent: root,+ });+ createPart('DripTrayRimFront', boxGeo(0.015, 0.082, 0.88), chromeMat, {+ position: [0.352, 0.091, 0],+ parent: root,+ });+ createPart('DripTrayRimLeft', boxGeo(0.185, 0.082, 0.015), chromeMat, {+ position: [0.262, 0.091, -0.435],+ parent: root,+ });+ createPart('DripTrayRimRight', boxGeo(0.185, 0.082, 0.015), chromeMat, {+ position: [0.262, 0.091, 0.435],+ parent: root,+ });++ // Stainless steel drip grate main plate+ createPart('DripGratePlate', boxGeo(0.165, 0.006, 0.84), chromeMat, {+ position: [0.26, 0.134, 0],+ parent: root,+ });++ // Laser-cut slotted drain bars+ const slotCount = 19;+ for (let s = 0; s < slotCount; s++) {+ const sz = -0.38 + s * (0.76 / (slotCount - 1));+ createPart(`DripSlot_${s}`, boxGeo(0.125, 0.008, 0.012), darkChassisMat, {+ position: [0.26, 0.136, sz],+ parent: root,+ });+ }++ // 3 Staging discs / cup support stands directly below each group head+ const groupZ = [-0.28, 0.0, 0.28];+ for (let g = 0; g < 3; g++) {+ const gz = groupZ[g];+ createPart(`CupStandRim_${g}`, torusGeo(0.062, 0.004, 8, 20), brassMat, {+ position: [0.245, 0.141, gz],+ rotation: [90, 0, 0],+ parent: root,+ });+ createPart(`CupStandMesh_${g}`, cylinderGeo(0.060, 0.060, 0.005, 16), chromeMat, {+ position: [0.245, 0.140, gz],+ parent: root,+ });+ }++ // ==========================================+ // 3. MAIN BODY & ENCLOSURE+ // ==========================================+ createPart('FrontSplashback', boxGeo(0.015, 0.21, 0.86), chromeMat, {+ position: [0.170, 0.245, 0],+ parent: root,+ });++ createPart('GroupMountDeck', boxGeo(0.16, 0.12, 0.88), chromeMat, {+ position: [0.10, 0.41, 0],+ parent: root,+ });+ createPart('GroupDeckBrassTrim', boxGeo(0.02, 0.010, 0.885), brassMat, {+ position: [0.181, 0.350, 0],+ parent: root,+ });++ createPart('MainCarcass', boxGeo(0.24, 0.36, 0.86), darkChassisMat, {+ position: [-0.09, 0.29, 0],+ parent: root,+ });++ for (const side of [-1, 1]) {+ const sz = side * 0.445;+ const sName = side < 0 ? 'L' : 'R';+ createPart(`SidePanelMain_${sName}`, boxGeo(0.42, 0.38, 0.016), chromeMat, {+ position: [0.00, 0.30, sz],+ parent: root,+ });+ for (let r = 0; r < 4; r++) {+ createPart(`SideStreak_${sName}_${r}`, boxGeo(0.28, 0.008, 0.022), brassMat, {+ position: [-0.02, 0.22 + r * 0.035, sz],+ parent: root,+ });+ }+ }++ createPart('BackMirrorPanel', boxGeo(0.015, 0.36, 0.88), chromeMat, {+ position: [-0.215, 0.29, 0],+ parent: root,+ });+ for (let v = 0; v < 8; v++) {+ createPart(`BackVent_${v}`, boxGeo(0.022, 0.010, 0.64), darkChassisMat, {+ position: [-0.218, 0.18 + v * 0.028, 0],+ parent: root,+ });+ }+ createPart('BackBrandPlate', boxGeo(0.012, 0.065, 0.28), brassMat, {+ position: [-0.224, 0.41, 0],+ parent: root,+ });+ createPart('BackBrandCrest', cylinderXGeo(0.022, 0.022, 0.018, 16), chromeMat, {+ position: [-0.225, 0.41, 0],+ parent: root,+ });++ createPart('FrontBrandBadge', boxGeo(0.010, 0.036, 0.20), brassMat, {+ position: [0.186, 0.445, 0],+ parent: root,+ });+ createPart('FrontBrandWings', boxGeo(0.014, 0.010, 0.26), chromeMat, {+ position: [0.187, 0.445, 0],+ parent: root,+ });++ // ==========================================+ // 4. TOP CUP WARMER TRAY & RAILING+ // ==========================================+ createPart('CupWarmerTray', boxGeo(0.32, 0.012, 0.86), chromeMat, {+ position: [-0.04, 0.476, 0],+ parent: root,+ });+ for (let k = 0; k < 12; k++) {+ createPart(`WarmerSlot_${k}`, boxGeo(0.24, 0.015, 0.012), darkChassisMat, {+ position: [-0.04, 0.480, -0.36 + k * 0.065],+ parent: root,+ });+ }++ createPart('GuardRailRear', cylinderZGeo(0.005, 0.005, 0.84, 10), chromeMat, {+ position: [-0.19, 0.525, 0],+ parent: root,+ });+ createPart('GuardRailLeft', cylinderXGeo(0.005, 0.005, 0.30, 10), chromeMat, {+ position: [-0.04, 0.525, -0.42],+ parent: root,+ });+ createPart('GuardRailRight', cylinderXGeo(0.005, 0.005, 0.30, 10), chromeMat, {+ position: [-0.04, 0.525, 0.42],+ parent: root,+ });++ const stanchionCoords = [+ [-0.19, -0.42],+ [-0.19, -0.14],+ [-0.19, 0.14],+ [-0.19, 0.42],+ [0.10, -0.42],+ [0.10, 0.42],+ ];+ for (let p = 0; p < stanchionCoords.length; p++) {+ const [sx, sz] = stanchionCoords[p];+ createPart(`RailPost_${p}`, cylinderGeo(0.0055, 0.0055, 0.048, 10), chromeMat, {+ position: [sx, 0.501, sz],+ parent: root,+ });+ createPart(`RailFinial_${p}`, sphereGeo(0.007, 8, 6), brassMat, {+ position: [sx, 0.528, sz],+ parent: root,+ });+ }++ const cupGrid = [+ [-0.12, -0.28],+ [-0.12, -0.10],+ [-0.12, 0.10],+ [-0.12, 0.28],+ [0.02, -0.28],+ [0.02, -0.10],+ [0.02, 0.10],+ [0.02, 0.28],+ ];+ for (let c = 0; c < cupGrid.length; c++) {+ const [cx, cz] = cupGrid[c];+ createPart(`Saucer_${c}`, saucerGeo, ceramicMat, {+ position: [cx, 0.482, cz],+ parent: root,+ });+ createPart(`Cup_${c}`, cupGeo, ceramicMat, {+ position: [cx, 0.485, cz],+ parent: root,+ });+ createPart(`CupHandle_${c}`, cupHandleGeo, ceramicMat, {+ position: [cx + 0.032, 0.505, cz],+ rotation: [0, 90, 0],+ parent: root,+ });+ if (c % 2 === 0) {+ createPart(`Coffee_${c}`, coffeeFillGeo, richWoodMat, {+ position: [cx, 0.510, cz],+ parent: root,+ });+ }+ }++ // ==========================================+ // 5. THE THREE SPRING-LEVER GROUPS+ // ==========================================+ for (let g = 0; g < 3; g++) {+ const gz = groupZ[g];+ const prefix = `Group_${g}`;++ createPart(`${prefix}_Neck`, groupNeckGeo, chromeMat, {+ position: [0.20, 0.42, gz],+ parent: root,+ });+ createPart(`${prefix}_NeckFlange`, boxGeo(0.045, 0.075, 0.075), brassMat, {+ position: [0.183, 0.42, gz],+ parent: root,+ });++ createPart(`${prefix}_Cylinder`, groupCylinderGeo, chromeMat, {+ position: [0.235, 0.435, gz],+ parent: root,+ });+ createPart(`${prefix}_RingLower`, groupRingGeo, brassMat, {+ position: [0.235, 0.395, gz],+ rotation: [90, 0, 0],+ parent: root,+ });+ createPart(`${prefix}_RingUpper`, groupRingGeo, brassMat, {+ position: [0.235, 0.470, gz],+ rotation: [90, 0, 0],+ parent: root,+ });+ createPart(`${prefix}_TopCap`, groupTopCapGeo, chromeMat, {+ position: [0.235, 0.508, gz],+ parent: root,+ });++ createPart(`${prefix}_Bell`, groupBellGeo, chromeMat, {+ position: [0.235, 0.355, gz],+ parent: root,+ });+ createPart(`${prefix}_Bayonet`, bayonetRingGeo, chromeMat, {+ position: [0.235, 0.332, gz],+ parent: root,+ });+ createPart(`${prefix}_BayonetBrass`, bayonetBrassGeo, brassMat, {+ position: [0.235, 0.332, gz],+ rotation: [90, 0, 0],+ parent: root,+ });+ createPart(`${prefix}_ShowerScreen`, showerScreenGeo, darkChassisMat, {+ position: [0.235, 0.324, gz],+ parent: root,+ });++ createPart(`${prefix}_PortaBowl`, filterBowlGeo, chromeMat, {+ position: [0.235, 0.312, gz],+ parent: root,+ });+ createPart(`${prefix}_SpoutManifold`, spoutManifoldGeo, chromeMat, {+ position: [0.235, 0.294, gz],+ parent: root,+ });+ createPart(`${prefix}_SpoutLeft`, spoutTipGeo, chromeMat, {+ position: [0.235, 0.272, gz - 0.013],+ rotation: [0, 0, 14],+ parent: root,+ });+ createPart(`${prefix}_SpoutRight`, spoutTipGeo, chromeMat, {+ position: [0.235, 0.272, gz + 0.013],+ rotation: [0, 0, -14],+ parent: root,+ });+ createPart(`${prefix}_PortaFerrule`, portafilterFerruleGeo, brassMat, {+ position: [0.282, 0.312, gz],+ parent: root,+ });+ createPart(`${prefix}_PortaWood`, portafilterWoodGeo, richWoodMat, {+ position: [0.292, 0.312, gz],+ rotation: [0, 0, -90],+ parent: root,+ });+ createPart(`${prefix}_PortaCap`, portafilterCapGeo, brassMat, {+ position: [0.420, 0.312, gz],+ parent: root,+ });++ createPart(`${prefix}_Shaft`, pistonShaftGeo, chromeMat, {+ position: [0.235, 0.530, gz],+ parent: root,+ });+ createPart(`${prefix}_ForkL`, forkArmGeo, chromeMat, {+ position: [0.235, 0.540, gz - 0.018],+ parent: root,+ });+ createPart(`${prefix}_ForkR`, forkArmGeo, chromeMat, {+ position: [0.235, 0.540, gz + 0.018],+ parent: root,+ });+ createPart(`${prefix}_PivotPin`, pivotPinGeo, chromeMat, {+ position: [0.235, 0.550, gz],+ parent: root,+ });+ createPart(`${prefix}_PinNutL`, pinNutGeo, brassMat, {+ position: [0.235, 0.550, gz - 0.026],+ parent: root,+ });+ createPart(`${prefix}_PinNutR`, pinNutGeo, brassMat, {+ position: [0.235, 0.550, gz + 0.026],+ parent: root,+ });++ const rad12 = (12 * Math.PI) / 180;+ const sin12 = Math.sin(rad12);+ const cos12 = Math.cos(rad12);++ const rodCenterX = 0.235 + 0.18 * sin12;+ const rodCenterY = 0.550 + 0.18 * cos12;+ createPart(`${prefix}_LeverRod`, leverRodGeo, chromeMat, {+ position: [rodCenterX, rodCenterY, gz],+ rotation: [0, 0, -12],+ parent: root,+ });++ const ferrX = 0.235 + 0.33 * sin12;+ const ferrY = 0.550 + 0.33 * cos12;+ createPart(`${prefix}_GripFerrule`, leverFerruleGeo, brassMat, {+ position: [ferrX, ferrY, gz],+ rotation: [0, 0, -12],+ parent: root,+ });++ const gripX = 0.235 + 0.39 * sin12;+ const gripY = 0.550 + 0.39 * cos12;+ createPart(`${prefix}_GripWood`, leverGripGeo, richWoodMat, {+ position: [gripX, gripY, gz],+ rotation: [0, 0, -12],+ parent: root,+ });++ const nutX = 0.235 + 0.45 * sin12;+ const nutY = 0.550 + 0.45 * cos12;+ createPart(`${prefix}_GripNut`, leverCrownNutGeo, chromeMat, {+ position: [nutX, nutY, gz],+ rotation: [0, 0, -12],+ parent: root,+ });+ const finX = 0.235 + 0.46 * sin12;+ const finY = 0.550 + 0.46 * cos12;+ createPart(`${prefix}_Finial`, leverFinialGeo, brassMat, {+ position: [finX, finY, gz],+ parent: root,+ });++ createPart(`${prefix}_FeedPipe`, pipeAlongPath([+ [0.180, 0.455, gz],+ [0.210, 0.455, gz + 0.024],+ [0.230, 0.420, gz + 0.038],+ ], 0.004, { bendRadius: 0.015, tubularSegments: 12, radialSegments: 8 }), brassMat, {+ parent: root,+ });+ }++ // ==========================================+ // 6. STEAM & HOT WATER DELIVERY SYSTEMS+ // ==========================================+ const wandLPath = [+ [0.175, 0.365, -0.380],+ [0.230, 0.340, -0.400],+ [0.285, 0.230, -0.410],+ [0.270, 0.165, -0.385],+ ];+ createPart('SteamWandBall_L', sphereGeo(0.014, 10, 8), brassMat, {+ position: [0.175, 0.365, -0.380],+ parent: root,+ });+ createPart('SteamWandPipe_L', pipeAlongPath(wandLPath, 0.0055, {+ bendRadius: 0.03,+ tubularSegments: 16,+ radialSegments: 8,+ }), chromeMat, {+ parent: root,+ });+ createPart('SteamGrip_L', cylinderGeo(0.008, 0.008, 0.045, 10), darkChassisMat, {+ position: [0.260, 0.280, -0.405],+ rotation: [20, 0, 15],+ parent: root,+ });+ createPart('SteamTip_L', cylinderGeo(0.006, 0.004, 0.018, 10), chromeMat, {+ position: [0.270, 0.165, -0.385],+ rotation: [15, 0, 0],+ parent: root,+ });++ const wandRPath = [+ [0.175, 0.365, 0.380],+ [0.230, 0.340, 0.400],+ [0.285, 0.230, 0.410],+ [0.270, 0.165, 0.385],+ ];+ createPart('SteamWandBall_R', sphereGeo(0.014, 10, 8), brassMat, {+ position: [0.175, 0.365, 0.380],+ parent: root,+ });+ createPart('SteamWandPipe_R', pipeAlongPath(wandRPath, 0.0055, {+ bendRadius: 0.03,+ tubularSegments: 16,+ radialSegments: 8,+ }), chromeMat, {+ parent: root,+ });+ createPart('SteamGrip_R', cylinderGeo(0.008, 0.008, 0.045, 10), darkChassisMat, {+ position: [0.260, 0.280, 0.405],+ rotation: [-20, 0, 15],+ parent: root,+ });+ createPart('SteamTip_R', cylinderGeo(0.006, 0.004, 0.018, 10), chromeMat, {+ position: [0.270, 0.165, 0.385],+ rotation: [-15, 0, 0],+ parent: root,+ });++ for (const side of [-1, 1]) {+ const vz = side * 0.380;+ const vName = side < 0 ? 'L' : 'R';+ createPart(`SteamValveEscutcheon_${vName}`, cylinderXGeo(0.024, 0.024, 0.010, 14), brassMat, {+ position: [0.185, 0.420, vz],+ parent: root,+ });+ createPart(`SteamValveKnob_${vName}`, cylinderXGeo(0.022, 0.026, 0.035, 14), richWoodMat, {+ position: [0.205, 0.420, vz],+ parent: root,+ });+ createPart(`SteamValveCap_${vName}`, cylinderXGeo(0.010, 0.010, 0.006, 12), brassMat, {+ position: [0.224, 0.420, vz],+ parent: root,+ });+ }++ const waterSpoutPath = [+ [0.175, 0.355, -0.140],+ [0.235, 0.330, -0.140],+ [0.265, 0.260, -0.140],+ [0.265, 0.200, -0.140],+ ];+ createPart('WaterSpoutPipe', pipeAlongPath(waterSpoutPath, 0.006, {+ bendRadius: 0.03,+ tubularSegments: 14,+ radialSegments: 8,+ }), chromeMat, {+ parent: root,+ });+ createPart('WaterDiffuserTip', cylinderGeo(0.009, 0.006, 0.018, 12), chromeMat, {+ position: [0.265, 0.192, -0.140],+ parent: root,+ });+ createPart('WaterValveEscutcheon', cylinderXGeo(0.020, 0.020, 0.010, 14), brassMat, {+ position: [0.185, 0.420, -0.140],+ parent: root,+ });+ createPart('WaterValveKnob', cylinderXGeo(0.018, 0.022, 0.032, 14), richWoodMat, {+ position: [0.203, 0.420, -0.140],+ parent: root,+ });++ // ==========================================+ // 7. GAUGES, SIGHT GLASS & INSTRUMENTATION+ // ==========================================+ const gaugeDefs = [+ { name: 'BoilerPressure', y: 0.280, label: '0-3 bar' },+ { name: 'PumpPressure', y: 0.205, label: '0-16 bar' },+ ];+ for (let i = 0; i < gaugeDefs.length; i++) {+ const g = gaugeDefs[i];+ createPart(`${g.name}_Bezel`, torusGeo(0.032, 0.004, 8, 20), brassMat, {+ position: [0.177, g.y, 0.380],+ rotation: [0, 90, 0],+ parent: root,+ });+ createPart(`${g.name}_Body`, cylinderXGeo(0.032, 0.032, 0.012, 18), chromeMat, {+ position: [0.175, g.y, 0.380],+ parent: root,+ });+ createPart(`${g.name}_Dial`, cylinderXGeo(0.028, 0.028, 0.002, 16), ceramicMat, {+ position: [0.180, g.y, 0.380],+ parent: root,+ });+ createPart(`${g.name}_Needle`, boxGeo(0.002, 0.018, 0.002), jewelRedMat, {+ position: [0.182, g.y + 0.005, 0.380],+ rotation: [0, 0, 35],+ parent: root,+ });+ createPart(`${g.name}_Rivet`, cylinderXGeo(0.0035, 0.0035, 0.004, 8), brassMat, {+ position: [0.183, g.y, 0.380],+ parent: root,+ });+ }++ createPart('SightGlassTube', cylinderGeo(0.008, 0.008, 0.105, 12), ceramicMat, {+ position: [0.185, 0.245, -0.380],+ parent: root,+ });+ createPart('SightGlassMountTop', boxGeo(0.028, 0.022, 0.028), brassMat, {+ position: [0.182, 0.303, -0.380],+ parent: root,+ });+ createPart('SightGlassMountBot', boxGeo(0.028, 0.022, 0.028), brassMat, {+ position: [0.182, 0.187, -0.380],+ parent: root,+ });+ for (let r = 0; r < 3; r++) {+ const ang = (r * 120 * Math.PI) / 180;+ const rx = 0.185 + 0.014 * Math.cos(ang);+ const rz = -0.380 + 0.014 * Math.sin(ang);+ createPart(`SightRod_${r}`, cylinderGeo(0.002, 0.002, 0.110, 6), brassMat, {+ position: [rx, 0.245, rz],+ parent: root,+ });+ }+ createPart('SightDrainCock', cylinderZGeo(0.003, 0.003, 0.024, 8), brassMat, {+ position: [0.198, 0.178, -0.380],+ parent: root,+ });++ createPart('PowerSwitchBezel', cylinderXGeo(0.016, 0.016, 0.006, 12), darkChassisMat, {+ position: [0.177, 0.155, 0.380],+ parent: root,+ });+ createPart('PowerSwitchKnob', boxGeo(0.016, 0.024, 0.008), brassMat, {+ position: [0.183, 0.155, 0.380],+ rotation: [0, 0, 45],+ parent: root,+ });++ createPart('LampHeatingBezel', cylinderXGeo(0.009, 0.009, 0.005, 12), chromeMat, {+ position: [0.177, 0.335, 0.380],+ parent: root,+ });+ createPart('LampHeatingJewel', sphereGeo(0.006, 10, 8), jewelRedMat, {+ position: [0.180, 0.335, 0.380],+ parent: root,+ });++ createPart('LampPowerBezel', cylinderXGeo(0.009, 0.009, 0.005, 12), chromeMat, {+ position: [0.177, 0.335, 0.355],+ parent: root,+ });+ createPart('LampPowerJewel', sphereGeo(0.006, 10, 8), brassMat, {+ position: [0.180, 0.335, 0.355],+ parent: root,+ });++ return root;+}\ No newline at end of filediff --git a/examples/excavator.kiln.js b/examples/excavator.kiln.jsnew file mode 100644index 00000000..08c9a2b4--- /dev/null+++ b/examples/excavator.kiln.js@@ -0,0 +1,312 @@+// Authored by: opencode-go/omen-alpha, via opencode.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'Excavator', category: 'prop' };+meta.role = 'vehicle';++const D2R = Math.PI / 180;+function minus(a, b) { return [a[0] - b[0], a[1] - b[1], a[2] - b[2]]; }+function midOf(a, b, f) { return [a[0] + (b[0] - a[0]) * f, a[1] + (b[1] - a[1]) * f, a[2] + (b[2] - a[2]) * f]; }+function angZ(v) { return Math.atan2(v[1], v[0]) / D2R; }++async function build() {+ const root = createRoot('Excavator');++ const yellow = gameMaterial(0xf0a80c, { roughness: 0.5, metalness: 0.12 });+ const charcoal = gameMaterial(0x24262b, { roughness: 0.92, metalness: 0.2 });+ const steel = gameMaterial(0x79818a, { roughness: 0.35, metalness: 0.85 });+ const steelDark = gameMaterial(0x474c52, { roughness: 0.55, metalness: 0.7 });+ const chrome = gameMaterial(0xc8ccd2, { roughness: 0.18, metalness: 1.0 });+ const glass = glassMaterial(0x1c2b36, { opacity: 0.55 });+ const black = gameMaterial(0x121316, { roughness: 0.9, metalness: 0.3 });+ const lamp = gameMaterial(0xfff1c4, { roughness: 0.4, emissive: 0xffdf9e, emissiveIntensity: 1.6 });++ // ---------------- key pins ----------------+ const BOOM_FOOT = [1.30, 1.78, 0];+ const BOOM_TIP = [2.95, 3.28, 0];+ const BUCKET_PIN = [4.90, 1.44, 0];+ const boomV = minus(BOOM_TIP, BOOM_FOOT);+ const dipV = minus(BUCKET_PIN, BOOM_TIP);+ const boomAng = angZ(boomV);+ const dipAng = angZ(dipV);++ const slew = createPivot('Slew', [0, 0, 0], root);+ const boomJ = createPivot('Boom', BOOM_FOOT, slew);+ const dipJ = createPivot('Dipper', boomV, boomJ);+ const bucketJ = createPivot('Bucket', dipV, dipJ);++ // ================= UNDERCARRIAGE =================+ const R = 0.42, CY = 0.494, FX = 1.52, RX = -1.52;+ const shoeGeo = boxGeo(0.235, 0.07, 0.62);+ const grouserGeo = boxGeo(0.24, 0.026, 0.24);+ const rollerGeo = cylinderZGeo(0.12, 0.12, 0.2, 14);+ const rollerFlangeGeo = cylinderZGeo(0.15, 0.15, 0.025, 14);+ const idlerGeo = cylinderZGeo(0.385, 0.385, 0.22, 18);+ const idlerFlangeGeo = cylinderZGeo(0.418, 0.418, 0.022, 18);+ const hubGeo = cylinderZGeo(0.12, 0.12, 0.34, 10);+ const sprocketDiscGeo = cylinderZGeo(0.28, 0.28, 0.16, 14);+ const sprocketToothGeo = boxGeo(0.13, 0.1, 0.12);++ for (const s of [-1, 1]) {+ const side = s > 0 ? 'Right' : 'Left';+ const g = new THREE.Group(); g.name = 'Track' + side; root.add(g);+ const zc = s * 0.95;+ let n = 0;+ const putShoe = (x, y, rz) => {+ const sh = createPart('Shoe' + side + (n++), shoeGeo, charcoal, { position: [x, y, zc], rotation: [0, 0, rz], parent: g });+ createPart('GrouserA' + side + n, grouserGeo, black, { position: [0, -0.047, 0.14], parent: sh });+ createPart('GrouserB' + side + n, grouserGeo, black, { position: [0, -0.047, -0.14], parent: sh });+ };+ for (let x = -1.44; x <= 1.45; x += 0.24) { putShoe(x, CY - R, 0); putShoe(x, CY + R, 0); }+ for (let a = -78.75; a <= 78.8; a += 22.5) { const r = a * D2R; putShoe(FX + R * Math.cos(r), CY + R * Math.sin(r), a + 90); }+ for (let a = -101.25; a >= -281.3; a -= 22.5) { const r = a * D2R; putShoe(RX + R * Math.cos(r), CY + R * Math.sin(r), a + 90); }++ for (let x = -1.15; x <= 1.21; x += 0.47) {+ const roller = createPart('Roller' + side + (n++), rollerGeo, steel, { position: [x, 0.229, zc - s * 0.16], parent: g });+ createPart('RollerFlangeF' + side + n, rollerFlangeGeo, steelDark, { position: [0, 0, 0.105], parent: roller });+ createPart('RollerFlangeB' + side + n, rollerFlangeGeo, steelDark, { position: [0, 0, -0.105], parent: roller });+ }+ const idler = createPart('Idler' + side, idlerGeo, steel, { position: [FX, CY, zc - s * 0.16], parent: g });+ createPart('IdlerFlangeF' + side, idlerFlangeGeo, steelDark, { position: [0, 0, 0.115], parent: idler });+ createPart('IdlerFlangeB' + side, idlerFlangeGeo, steelDark, { position: [0, 0, -0.115], parent: idler });+ createPart('IdlerHub' + side, hubGeo, steelDark, { position: [FX, CY, zc - s * 0.16], parent: g });+ const sprocketAsm = new THREE.Group(); sprocketAsm.name = 'SprocketAsm' + side;+ sprocketAsm.position.set(RX, CY, zc - s * 0.16); g.add(sprocketAsm);+ createPart('SprocketDisc' + side, sprocketDiscGeo, steelDark, { parent: sprocketAsm });+ const tooth0 = createPart('SprocketTooth0' + side, sprocketToothGeo, steelDark, { position: [0.33, 0, 0], parent: sprocketAsm });+ arrayRadial('SprocketTooth' + side, tooth0, 11, 'z', sprocketAsm);+ createPart('SprocketHub' + side, hubGeo, steelDark, { position: [RX, CY, zc - s * 0.16], parent: g });++ createPart('Frame' + side, boxGeo(3.5, 0.3, 0.34), yellow, { position: [0, 0.5, zc - s * 0.31], parent: g });+ createPart('RockGuardInner' + side, boxGeo(2.9, 0.5, 0.05), charcoal, { position: [0, 0.34, zc - s * 0.325], parent: g });+ createPart('RockGuardOuter' + side, boxGeo(2.9, 0.5, 0.05), charcoal, { position: [0, 0.34, zc + s * 0.325], parent: g });+ createPart('IdlerGuard' + side, boxGeo(0.5, 0.25, 0.68), yellow, { position: [1.55, 0.77, zc], parent: g });+ createPart('SprocketGuard' + side, boxGeo(0.5, 0.25, 0.68), yellow, { position: [-1.55, 0.77, zc], parent: g });+ }++ // car body + slew ring + slew gear+ createPart('CarBody', await roundedBoxGeo(2.0, 0.32, 1.24, 0.05), yellow, { position: [0, 0.76, 0], parent: root });+ createPart('SlewRing', cylinderGeo(1.0, 1.0, 0.12, 36), steelDark, { position: [0, 1.03, 0], parent: root });+ const slewTooth0 = createPart('SlewGearTooth0', boxGeo(0.09, 0.07, 0.05), steelDark, { position: [1.02, 1.0, 0], parent: root });+ arrayRadial('SlewGearTooth', slewTooth0, 24, 'y', root);+ createPart('GreaseRing', torusGeo(0.9, 0.03, 6, 36), black, { position: [0, 1.095, 0], rotation: [90, 0, 0], parent: root });++ // ================= HOUSE =================+ createPart('Deck', await roundedBoxGeo(3.6, 0.08, 2.12, 0.02), yellow, { position: [-0.12, 1.13, 0], parent: slew });+ createPart('DeckWalkway', boxGeo(0.85, 0.02, 1.9), black, { position: [1.28, 1.18, 0], parent: slew });+ for (const zz of [-0.93, 0.93]) createPart('WalkwayEdge' + zz, boxGeo(0.85, 0.03, 0.04), steelDark, { position: [1.28, 1.185, zz], parent: slew });+ createPart('Counterweight', await roundedBoxGeo(1.15, 1.3, 2.34, 0.14), yellow, { position: [-1.8, 1.79, 0], parent: slew });+ createPart('CwStrip', boxGeo(0.02, 0.42, 2.0), black, { position: [-2.38, 1.55, 0], parent: slew });+ for (const yy of [1.3, 2.2]) for (const zz of [-0.75, -0.25, 0.25, 0.75]) {+ createPart('CwBolt' + yy + zz, cylinderXGeo(0.035, 0.035, 0.04, 8), steelDark, { position: [-2.395, yy, zz], parent: slew });+ }+ // counterweight rear handrail+ for (const zz of [-0.8, 0, 0.8]) {+ createPart('CwRailPost' + zz, cylinderGeo(0.018, 0.018, 0.32, 6), black, { position: [-2.3, 2.6, zz], parent: slew });+ }+ beamBetween('Mesh_CwRailTop', [-2.3, 2.76, -0.85], [-2.3, 2.76, 0.85], 0.016, black, { parent: slew });++ createPart('Hood', await roundedBoxGeo(1.95, 1.06, 1.9, 0.09), yellow, { position: [-0.23, 1.7, 0], parent: slew });+ for (const yy of [1.5, 1.62, 1.74, 1.86, 1.98]) {+ createPart('LouverL' + yy, boxGeo(1.3, 0.05, 0.03), black, { position: [-0.25, yy, -0.94], parent: slew });+ createPart('LouverR' + yy, boxGeo(1.3, 0.05, 0.03), black, { position: [-0.25, yy, 0.94], parent: slew });+ }+ for (const zz of [-0.65, -0.35, -0.05, 0.25]) {+ createPart('HoodGrill' + zz, boxGeo(0.02, 0.55, 0.05), black, { position: [0.755, 1.7, zz], parent: slew });+ }+ createPart('AirCleaner', cylinderGeo(0.09, 0.09, 0.3, 10), steelDark, { position: [-0.15, 2.37, -0.72], parent: slew });+ createPart('AirCleanerCap', cylinderGeo(0.11, 0.11, 0.03, 10), black, { position: [-0.15, 2.53, -0.72], parent: slew });+ createPart('Exhaust', cylinderGeo(0.06, 0.06, 0.42, 12), steelDark, { position: [-0.7, 2.41, -0.5], parent: slew });+ createPart('ExhaustFlange', cylinderGeo(0.085, 0.085, 0.04, 12), black, { position: [-0.7, 2.22, -0.5], parent: slew });+ createPart('ExhaustCap', coneGeo(0.09, 0.1, 12), steelDark, { position: [-0.7, 2.67, -0.5], parent: slew });++ // tanks under the deck overhang+ createPart('FuelTank', boxGeo(0.85, 0.2, 0.5), steelDark, { position: [-1.05, 1.0, -0.52], parent: slew });+ for (const xx of [-1.25, -0.85]) createPart('FuelStrap' + xx, boxGeo(0.03, 0.22, 0.54), black, { position: [xx, 1.0, -0.52], parent: slew });+ createPart('BatteryBox', boxGeo(0.4, 0.24, 0.35), black, { position: [-1.6, 1.0, 0.72], parent: slew });++ // hoses from hood to boom bracket+ createPart('HoseA', pipeAlongPath([[-0.4, 2.2, 0.62], [0.25, 2.1, 0.72], [0.95, 1.9, 0.5], [1.28, 1.8, 0.3]], 0.028, { bendRadius: 0.09, radialSegments: 6 }), black, { parent: slew });+ createPart('HoseB', pipeAlongPath([[-0.4, 2.2, -0.62], [0.25, 2.05, -0.7], [0.9, 1.85, -0.55], [1.26, 1.78, -0.3]], 0.028, { bendRadius: 0.09, radialSegments: 6 }), black, { parent: slew });++ // ---------------- cab ----------------+ createPart('CabSill', await roundedBoxGeo(1.12, 0.32, 0.96, 0.05), yellow, { position: [1.33, 1.33, 0.65], parent: slew });+ createPart('CabRoof', await roundedBoxGeo(1.2, 0.09, 1.02, 0.03), yellow, { position: [1.34, 2.42, 0.65], parent: slew });+ createPart('CabRear', boxGeo(0.06, 0.95, 0.96), yellow, { position: [0.80, 1.9, 0.65], parent: slew });+ for (const zz of [0.2, 1.1]) createPart('CabPillar' + zz, boxGeo(0.07, 0.95, 0.07), yellow, { position: [1.84, 1.9, zz], parent: slew });+ createPart('CabGlassFront', boxGeo(0.025, 0.92, 0.88), glass, { position: [1.86, 1.9, 0.65], parent: slew });+ createPart('CabGlassRight', boxGeo(1.0, 0.92, 0.025), glass, { position: [1.33, 1.9, 1.12], parent: slew });+ createPart('CabGlassRear', boxGeo(0.025, 0.9, 0.9), glass, { position: [0.79, 1.89, 0.65], parent: slew });+ createPart('CabGlassLeft', boxGeo(0.45, 0.92, 0.025), glass, { position: [1.6, 1.9, 0.19], parent: slew });+ createPart('CabDoor', boxGeo(0.52, 0.9, 0.03), yellow, { position: [1.12, 1.91, 0.19], parent: slew });+ createPart('CabDoorWindow', boxGeo(0.3, 0.4, 0.025), glass, { position: [1.12, 2.1, 0.2], parent: slew });+ createPart('CabDoorHandle', boxGeo(0.05, 0.03, 0.02), black, { position: [1.34, 1.75, 0.21], parent: slew });+ createPart('CabGrabHandle', boxGeo(0.02, 0.45, 0.02), black, { position: [0.88, 1.9, 0.155], parent: slew });+ createPart('WiperA', boxGeo(0.012, 0.02, 0.3), black, { position: [1.89, 2.12, 0.5], rotation: [0, 0, 6], parent: slew });+ createPart('WiperB', boxGeo(0.012, 0.02, 0.3), black, { position: [1.89, 2.0, 0.84], rotation: [0, 0, 6], parent: slew });+ for (const zz of [0.4, 0.9]) {+ createPart('WorkLight' + zz, boxGeo(0.09, 0.07, 0.11), black, { position: [1.88, 2.44, zz], parent: slew });+ createPart('WorkLens' + zz, boxGeo(0.02, 0.05, 0.08), lamp, { position: [1.935, 2.44, zz], parent: slew });+ }+ beamBetween('Mesh_MirrorStalk', [0.82, 2.1, 0.17], [0.64, 2.12, 0.07], 0.015, black, { parent: slew });+ createPart('Mirror', boxGeo(0.02, 0.16, 0.2), black, { position: [0.62, 2.12, 0.05], parent: slew });++ // handrail along deck left edge+ for (let x = -1.05; x <= 1.1; x += 0.55) {+ createPart('RailPost' + x.toFixed(2), cylinderGeo(0.018, 0.018, 0.45, 6), black, { position: [x, 1.395, -1.03], parent: slew });+ }+ beamBetween('Mesh_RailTop', [-1.08, 1.62, -1.03], [1.12, 1.62, -1.03], 0.016, black, { parent: slew });+ beamBetween('Mesh_RailMid', [-1.08, 1.4, -1.03], [1.12, 1.4, -1.03], 0.014, black, { parent: slew });++ // access steps, left rear+ createPart('Step1', boxGeo(0.4, 0.04, 0.3), steelDark, { position: [-1.55, 0.55, -1.42], parent: slew });+ createPart('Step2', boxGeo(0.4, 0.04, 0.3), steelDark, { position: [-1.55, 0.88, -1.42], parent: slew });+ for (const xx of [-1.75, -1.35]) {+ createPart('StepBracket' + xx, boxGeo(0.06, 0.62, 0.3), yellow, { position: [xx, 0.95, -1.18], parent: slew });+ }++ // boom foot bracket (house side)+ for (const zz of [-0.35, 0.35]) {+ createPart('BoomBracket' + zz, boxGeo(0.5, 0.62, 0.05), yellow, { position: [1.3, 1.48, zz], parent: slew });+ }+ createPart('BoomBracketGusset', boxGeo(0.45, 0.4, 0.62), yellow, { position: [1.33, 1.35, 0], parent: slew });++ // ================= ARM =================+ // --- boom (parented to boomJ: coords are world - BOOM_FOOT) ---+ const bo = minus(midOf(BOOM_FOOT, BOOM_TIP, 0.5), BOOM_FOOT);+ createPart('BoomBeam', await roundedBoxGeo(2.42, 0.3, 0.7, 0.05), yellow, { position: bo, rotation: [0, 0, boomAng], parent: boomJ });+ for (const zz of [-0.32, 0.32]) {+ createPart('BoomPlate' + zz, boxGeo(2.3, 0.34, 0.05), yellow, { position: [bo[0], bo[1], zz], rotation: [0, 0, boomAng], parent: boomJ });+ }+ createPart('BoomCap', boxGeo(2.3, 0.05, 0.56), yellow, { position: [bo[0] - 0.11, bo[1] + 0.125, 0], rotation: [0, 0, boomAng], parent: boomJ });+ for (const t of [0.28, 0.52, 0.76]) {+ const p = [boomV[0] * t, boomV[1] * t, 0];+ createPart('BoomRib' + t, boxGeo(0.06, 0.38, 0.72), yellow, { position: p, rotation: [0, 0, boomAng], parent: boomJ });+ }+ // hydraulic hoses running along the boom top+ for (const hz of [0.2, 0.32]) {+ createPart('BoomHose' + hz, pipeAlongPath([[0.044, 0.283, hz], [0.704, 0.883, hz], [1.364, 1.483, hz]], 0.024, { bendRadius: 0.06, radialSegments: 6 }), black, { parent: boomJ });+ }+ createPart('BoomFootBoss', cylinderZGeo(0.1, 0.1, 0.8, 12), steelDark, { position: [0, 0, 0], parent: boomJ });+ createPart('BoomTipBoss', cylinderZGeo(0.09, 0.09, 0.7, 12), steelDark, { position: boomV, parent: boomJ });++ // --- dipper (parented to dipJ: coords are world - BOOM_TIP) ---+ const dp = minus(midOf(BOOM_TIP, BUCKET_PIN, 0.5), BOOM_TIP);+ createPart('DipperBeam', await roundedBoxGeo(2.86, 0.26, 0.5, 0.045), yellow, { position: dp, rotation: [0, 0, dipAng], parent: dipJ });+ for (const zz of [-0.22, 0.22]) {+ createPart('DipperPlate' + zz, boxGeo(2.7, 0.3, 0.045), yellow, { position: [dp[0], dp[1], zz], rotation: [0, 0, dipAng], parent: dipJ });+ }+ for (const t of [0.3, 0.7]) {+ const p = [dipV[0] * t, dipV[1] * t, 0];+ createPart('DipperRib' + t, boxGeo(0.05, 0.32, 0.54), yellow, { position: p, rotation: [0, 0, dipAng], parent: dipJ });+ }+ createPart('DipperFootBoss', cylinderZGeo(0.085, 0.085, 0.62, 12), steelDark, { position: [0, 0, 0], parent: dipJ });+ createPart('DipperEndBoss', cylinderZGeo(0.08, 0.08, 0.62, 12), steelDark, { position: dipV, parent: dipJ });++ // --- bucket (parented to bucketJ: coords are world - BUCKET_PIN) ---+ // faceted C-shell: outer curve from pin over the belly to the cutting edge,+ // inner face curving back up — leaves the mouth open toward the machine.+ const outerPts = [[-0.06, 0.12], [0.34, -0.04], [0.58, -0.32], [0.68, -0.64], [0.56, -0.94], [0.30, -1.12], [0.0, -1.18]];+ const innerPts = [[0.0, -1.18], [-0.28, -1.10], [-0.40, -0.82], [-0.30, -0.44], [-0.10, -0.18]];+ function shellPlate(name, a, b, th, mat) {+ const mx = (a[0] + b[0]) / 2, my = (a[1] + b[1]) / 2;+ const L = Math.hypot(b[0] - a[0], b[1] - a[1]) + 0.05;+ const ang = angZ([b[0] - a[0], b[1] - a[1], 0]);+ createPart(name, boxGeo(L, th, 1.4), mat, { position: [mx, my, 0], rotation: [0, 0, ang], parent: bucketJ });+ }+ for (let i = 0; i < outerPts.length - 1; i++) shellPlate('BucketShellOut' + i, outerPts[i], outerPts[i + 1], 0.07, steelDark);+ for (let i = 0; i < innerPts.length - 1; i++) shellPlate('BucketShellIn' + i, innerPts[i], innerPts[i + 1], 0.06, steelDark);+ // side-plate fill: horizontal chords spanning the C so the silhouette reads solid+ function xAtY(pts, y) {+ for (let i = 0; i < pts.length - 1; i++) {+ const a = pts[i], b = pts[i + 1];+ if ((y <= a[1] && y >= b[1]) || (y >= a[1] && y <= b[1])) {+ const t = (y - a[1]) / (b[1] - a[1]);+ return a[0] + (b[0] - a[0]) * t;+ }+ }+ return null;+ }+ for (const y of [0.06, -0.12, -0.34, -0.58, -0.82, -1.04, -1.16]) {+ const xo = xAtY(outerPts, y);+ const xi = y > -0.18 ? -0.09 : xAtY(innerPts, y);+ for (const zz of [-0.685, 0.685]) {+ createPart('BucketSideFill' + y + '_' + zz, boxGeo(Math.max(xo - xi, 0.02), 0.19, 0.03), steelDark, { position: [(xi + xo) / 2, y, zz], parent: bucketJ });+ }+ }+ createPart('BucketEdge', boxGeo(0.66, 0.07, 1.44), steel, { position: [0.0, -1.17, 0], rotation: [0, 0, -5], parent: bucketJ });+ createPart('BucketPinBoss', cylinderZGeo(0.09, 0.09, 1.5, 12), steelDark, { position: [0, 0, 0], parent: bucketJ });+ for (const zz of [-0.56, -0.28, 0, 0.28, 0.56]) {+ createPart('BucketTooth' + zz, coneXGeo(0.05, 0.26, 8), steel, { position: [0.02, -1.19, zz], rotation: [0, 0, -78], parent: bucketJ });+ }+ for (const zz of [-0.71, 0.71]) {+ createPart('BucketSideStrip' + zz, boxGeo(0.28, 0.1, 0.03), steel, { position: [0.28, -1.0, zz], rotation: [0, 0, -30], parent: bucketJ });+ }+ for (const zz of [-0.3, 0.3]) {+ createPart('BucketHorn' + zz, boxGeo(0.24, 0.3, 0.05), steelDark, { position: [0.05, 0.12, zz], parent: bucketJ });+ }++ // --- hydraulic rams ---+ function ram(name, base, tip, rB, rR, parent, off) {+ const b = minus(base, off), t = minus(tip, off);+ const L = Math.hypot(t[0] - b[0], t[1] - b[1]);+ const a = angZ(minus(t, b));+ createPart(name + 'Barrel', cylinderXGeo(rB, rB * 1.12, L * 0.52, 12), steel, { position: midOf(b, t, 0.26), rotation: [0, 0, a], parent });+ createPart(name + 'Rod', cylinderXGeo(rR, rR, L * 0.56, 10), chrome, { position: midOf(b, t, 0.74), rotation: [0, 0, a], parent });+ createPart(name + 'BaseLug', boxGeo(0.2, rB * 2.4, rB * 2.6), steelDark, { position: b, rotation: [0, 0, a], parent });+ createPart(name + 'TipLug', boxGeo(0.16, rR * 2.6, rR * 2.8), steelDark, { position: t, rotation: [0, 0, a], parent });+ }+ // boom lift rams (deck to boom underside)+ for (const zz of [-0.58, 0.58]) {+ const tipB = [BOOM_FOOT[0] + boomV[0] * 0.42 - 0.1, BOOM_FOOT[1] + boomV[1] * 0.42 - 0.12, zz];+ ram('BoomRam' + zz, [0.35, 1.27, zz], tipB, 0.085, 0.05, slew, [0, 0, 0]);+ }+ // dipper ram (boom top to mid-dipper)+ {+ const tipD = [BOOM_TIP[0] + dipV[0] * 0.62, BOOM_TIP[1] + dipV[1] * 0.62, 0];+ ram('DipperRam', [2.2, 2.78, 0], tipD, 0.08, 0.048, boomJ, BOOM_FOOT);+ }+ // bucket ram (dipper to bucket horns)+ {+ const tipK = [4.95, 1.69, 0];+ ram('BucketRam', [2.75, 3.0, 0], tipK, 0.07, 0.042, dipJ, BOOM_TIP);+ }++ return root;+}++function animate() {+ return [createClip('SlewSurvey', 6, [+ rotationTrack('Joint_Slew', [+ { time: 0, rotation: [0, 0, 0] },+ { time: 2.2, rotation: [0, 24, 0] },+ { time: 4, rotation: [0, 24, 0] },+ { time: 6, rotation: [0, 0, 0] },+ ]),+ rotationTrack('Joint_Boom', [+ { time: 0, rotation: [0, 0, 0] },+ { time: 1.6, rotation: [8, 0, 0] },+ { time: 3.4, rotation: [8, 0, 0] },+ { time: 6, rotation: [0, 0, 0] },+ ]),+ rotationTrack('Joint_Dipper', [+ { time: 0, rotation: [0, 0, 0] },+ { time: 1.6, rotation: [14, 0, 0] },+ { time: 3.4, rotation: [14, 0, 0] },+ { time: 6, rotation: [0, 0, 0] },+ ]),+ rotationTrack('Joint_Bucket', [+ { time: 0, rotation: [0, 0, 0] },+ { time: 1.0, rotation: [35, 0, 0] },+ { time: 3.4, rotation: [35, 0, 0] },+ { time: 5.0, rotation: [0, 0, 0] },+ { time: 6, rotation: [0, 0, 0] },+ ]),+ ])];+}diff --git a/examples/ferris-wheel.kiln.js b/examples/ferris-wheel.kiln.jsnew file mode 100644index 00000000..e24e5f8e--- /dev/null+++ b/examples/ferris-wheel.kiln.js@@ -0,0 +1,635 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.++const meta = { name: 'FerrisWheel', category: 'prop' };++function build() {+ const root = createRoot('FerrisWheel');++ // =========================================================================+ // Materials Palette+ // =========================================================================+ // Lattice structure: antique off-white painted industrial steel+ const steelLattice = gameMaterial(0xdfdbd2, { metalness: 0.25, roughness: 0.5 });+ // Base skid & ground frame: deep dark iron+ const steelDark = gameMaterial(0x282c30, { metalness: 0.6, roughness: 0.4 });+ // Wheel rim & structural rings: carnival crimson red+ const steelCrimson = gameMaterial(0xa71d2a, { metalness: 0.35, roughness: 0.4 });+ // Spoke tension rods: bright nickel / galvanized wire+ const spokeWire = gameMaterial(0xcccccc, { metalness: 0.85, roughness: 0.25 });+ // Mechanical drive & decorative accents: polished carnival brass / gold+ const goldBrass = gameMaterial(0xdfab2a, { metalness: 0.88, roughness: 0.2 });+ // Boarding platform planks: weathered boardwalk pine+ const woodDeck = gameMaterial(0x6b4c35, { metalness: 0.0, roughness: 0.8 });+ // Railings and operator console+ const ironRail = gameMaterial(0x1e2124, { metalness: 0.5, roughness: 0.5 });++ // Gondola carriage colors (festive carnival tri-color theme)+ const gondolaRed = gameMaterial(0xc1121f, { metalness: 0.2, roughness: 0.35 });+ const gondolaBlue = gameMaterial(0x1d3557, { metalness: 0.2, roughness: 0.35 });+ const gondolaGold = gameMaterial(0xf4a261, { metalness: 0.2, roughness: 0.35 });+ const gondolaMats = [gondolaRed, gondolaBlue, gondolaGold];++ // Illuminated bulbs & lantern glow+ const bulbGlowWarm = gameMaterial(0xfff5cc, {+ emissive: 0xffd166,+ emissiveIntensity: 3.0,+ roughness: 0.2,+ });+ const bulbGlowGold = gameMaterial(0xffe89e, {+ emissive: 0xff9f1c,+ emissiveIntensity: 3.2,+ roughness: 0.2,+ });++ // Shared geometry helpers (optimized for target triangle budget: 4,000 - 12,000)+ const geoGusset = boxGeo(0.15, 0.15, 0.035);+ const geoRivet = boxGeo(0.024, 0.024, 0.035);+ const geoBulb = sphereGeo(0.038, 4, 3); // 18 tris each++ // =========================================================================+ // 1. Foundation Skid Frame & Footings (Sitting on Y = 0)+ // =========================================================================+ const baseFrame = createPivot('BaseFrame', [0, 0, 0], root);++ // 4 Concrete / Cast-iron Footing Pedestals at the base corners+ const footingZ = 2.45;+ const footingX = 1.15;+ let boltIdx = 0;+ for (const sx of [-1, 1]) {+ for (const sz of [-1, 1]) {+ const cornerTag = `${sx > 0 ? 'F' : 'B'}_${sz > 0 ? 'R' : 'L'}`;+ createPart(`Footing_${cornerTag}`, boxGeo(0.42, 0.10, 0.42), steelDark, {+ position: [sx * footingX, 0.05, sz * footingZ],+ parent: baseFrame,+ });+ // Anchor bolts+ for (const bx of [-0.14, 0.14]) {+ for (const bz of [-0.14, 0.14]) {+ createPart(`AnchorBolt_${boltIdx++}`, boxGeo(0.03, 0.05, 0.03), goldBrass, {+ position: [sx * footingX + bx, 0.11, sz * footingZ + bz],+ parent: baseFrame,+ });+ }+ }+ }+ }++ // Longitudinal Skid Girders (along X at Z = +/- footingZ)+ for (const sz of [-1, 1]) {+ createPart(`SkidBeam_${sz > 0 ? 'R' : 'L'}`, boxGeo(footingX * 2 + 0.3, 0.12, 0.16), steelDark, {+ position: [0, 0.11, sz * footingZ],+ parent: baseFrame,+ });+ }+ // Transverse Ground Ties (along Z at X = +/- footingX)+ for (const sx of [-1, 1]) {+ createPart(`CrossTie_${sx > 0 ? 'F' : 'B'}`, boxGeo(0.16, 0.10, footingZ * 2), steelDark, {+ position: [sx * footingX, 0.11, 0],+ parent: baseFrame,+ });+ }++ // =========================================================================+ // 2. Riveted Lattice A-Frame Towers+ // =========================================================================+ const hubY = 5.20;+ const towerX = 0.88;++ // The wheel's swept envelope, declared up here because the towers may only be+ // braced where the ride is not. Section 4 builds the wheel from these same+ // numbers, so the clearance test below cannot drift away from the geometry it+ // is protecting.+ const rimRadius = 3.60;+ const innerRimRadius = 2.20;+ const gondolaDrop = 0.88; // pin to the underside of a car+ const gondolaHalfZ = 0.26;+ const swingRadius = rimRadius + Math.hypot(gondolaDrop, gondolaHalfZ);+ const legBottomZ = 2.40;+ const legTopZ = 0.16;+ const legBottomY = 0.12;++ // Build Front (X = +towerX) and Rear (X = -towerX) A-Frames+ for (const sx of [-1, 1]) {+ const sideName = sx > 0 ? 'Front' : 'Rear';+ const currentX = sx * towerX;+ const aFrame = createPivot(`AFrame_${sideName}`, [currentX, 0, 0], root);++ // Main Chords (Heavy tubular legs from base to hub bearing)+ beamBetween(`${sideName}Leg_L`, [0, legBottomY, -legBottomZ], [0, hubY, -legTopZ], 0.065, steelLattice, {+ segments: 5,+ parent: aFrame,+ });+ beamBetween(`${sideName}Leg_R`, [0, legBottomY, legBottomZ], [0, hubY, legTopZ], 0.065, steelLattice, {+ segments: 5,+ parent: aFrame,+ });++ // Horizontal Lattice Rungs and Diagonal X-Bracing+ const rungHeights = [0.95, 1.80, 2.65, 3.50, 4.35];+ const rungWidths = [];++ for (let k = 0; k < rungHeights.length; k++) {+ const y = rungHeights[k];+ const frac = (y - legBottomY) / (hubY - legBottomY);+ const halfW = legBottomZ * (1 - frac) + legTopZ * frac;+ rungWidths.push(halfW);++ // Horizontal strut connecting Left and Right legs+ beamBetween(`${sideName}Rung_${k}`, [0, y, -halfW], [0, y, halfW], 0.036, steelLattice, {+ segments: 4,+ parent: aFrame,+ });++ // Riveted Gusset plates at the joints+ for (const sz of [-1, 1]) {+ const gussetTag = sz > 0 ? 'R' : 'L';+ createPart(`${sideName}Gusset_${k}_${gussetTag}`, geoGusset, steelLattice, {+ position: [0, y, sz * halfW],+ parent: aFrame,+ });+ // Decorative rivet cluster on gusset+ let rivetSub = 0;+ for (const ry of [-0.04, 0.04]) {+ createPart(`${sideName}Rivet_${k}_${gussetTag}_${rivetSub++}`, geoRivet, steelDark, {+ position: [sx * 0.02, y + ry, sz * halfW],+ parent: aFrame,+ });+ }+ }++ // Diagonal X-Lacing between rung k and rung k-1+ if (k > 0) {+ const prevY = rungHeights[k - 1];+ const prevHalfW = rungWidths[k - 1];+ beamBetween(`${sideName}DiagA_${k}`, [0, prevY, -prevHalfW], [0, y, halfW], 0.020, steelLattice, {+ segments: 4,+ parent: aFrame,+ });+ beamBetween(`${sideName}DiagB_${k}`, [0, prevY, prevHalfW], [0, y, -halfW], 0.020, steelLattice, {+ segments: 4,+ parent: aFrame,+ });+ }+ }++ // Hub Bearing Block at apex of A-Frame+ createPart(`${sideName}BearingBlock`, boxGeo(0.24, 0.28, 0.36), steelDark, {+ position: [0, hubY, 0],+ parent: aFrame,+ });+ createPart(`${sideName}BearingCap`, cylinderXGeo(0.13, 0.13, 0.28, 8), goldBrass, {+ position: [0, hubY + 0.04, 0],+ parent: aFrame,+ });+ }++ // Cross-bracing between the front and rear A-frames.+ //+ // The towers can only be tied to each other where the wheel is not. A strut+ // spanning X at mid-height is cut in half by the rotating disc, and the cars+ // hang below the rim again, so the honest keep-out is `swingRadius` about the+ // hub. Real double-A-frame wheels answer this the same way: heavy portal+ // bracing down at the base, and above that the axle is the only thing joining+ // the two towers. Candidate heights are filtered rather than hand-picked, so+ // the clearance is checked instead of assumed.+ const halfWidthAt = (y) =>+ legBottomZ + (legTopZ - legBottomZ) * ((y - legBottomY) / (hubY - legBottomY));+ const clearsWheel = (y, z) => Math.hypot(hubY - y, z) > swingRadius + 0.12;++ const braceHeights = [0.45, 0.90, 1.45, 2.10, 2.90, 3.70].filter((y) =>+ clearsWheel(y, halfWidthAt(y)),+ );+ for (let k = 0; k < braceHeights.length; k++) {+ const y = braceHeights[k];+ const halfW = halfWidthAt(y);+ for (const sz of [-1, 1]) {+ const tag = `Y${Math.round(y * 100)}_${sz > 0 ? 'R' : 'L'}`;+ beamBetween(`SwayTie_${tag}`, [towerX, y, sz * halfW], [-towerX, y, sz * halfW], 0.034, steelLattice, {+ segments: 4,+ parent: root,+ });++ // X-brace up to the next tie, but only where that whole panel stays out+ // of the swept disc as well -- the crossing point is what matters.+ const nextY = braceHeights[k + 1];+ if (nextY === undefined) continue;+ const nextHalfW = halfWidthAt(nextY);+ if (!clearsWheel((y + nextY) / 2, (halfW + nextHalfW) / 2)) continue;+ beamBetween(`SwayDiagA_${tag}`, [towerX, y, sz * halfW], [-towerX, nextY, sz * nextHalfW], 0.018, steelLattice, {+ segments: 4,+ parent: root,+ });+ beamBetween(`SwayDiagB_${tag}`, [-towerX, y, sz * halfW], [towerX, nextY, sz * nextHalfW], 0.018, steelLattice, {+ segments: 4,+ parent: root,+ });+ }+ }++ // Maintenance Service Ladder on Rear Left A-Frame leg+ createLadder('MaintenanceLadder', {+ bottom: [-towerX - 0.08, 0.15, -legBottomZ * 0.95],+ top: [-towerX - 0.08, hubY - 0.35, -legTopZ - 0.10],+ material: ironRail,+ width: 0.34,+ rungCount: 14,+ railRadius: 0.016,+ rungRadius: 0.011,+ parent: root,+ });+ // Service platform attached securely to rear bearing block+ const catwalkY = hubY - 0.20;+ const catwalkZ = -legTopZ - 0.18;+ createPart('MaintenanceCatwalk', boxGeo(0.38, 0.04, 0.38), steelDark, {+ position: [-towerX - 0.05, catwalkY, catwalkZ],+ parent: root,+ });+ // Catwalk handrails firmly seated on the platform deck+ beamBetween('CatwalkPost1', [-towerX - 0.22, catwalkY + 0.02, catwalkZ - 0.16], [-towerX - 0.22, catwalkY + 0.40, catwalkZ - 0.16], 0.015, ironRail, {+ segments: 4,+ parent: root,+ });+ beamBetween('CatwalkPost2', [-towerX - 0.22, catwalkY + 0.02, catwalkZ + 0.16], [-towerX - 0.22, catwalkY + 0.40, catwalkZ + 0.16], 0.015, ironRail, {+ segments: 4,+ parent: root,+ });+ beamBetween('CatwalkTopRail', [-towerX - 0.22, catwalkY + 0.40, catwalkZ - 0.16], [-towerX - 0.22, catwalkY + 0.40, catwalkZ + 0.16], 0.015, ironRail, {+ segments: 4,+ parent: root,+ });++ // =========================================================================+ // 3. Central Axle, Drive Machinery & Ornate Carnival Starburst+ // =========================================================================+ createPart('MainAxle', cylinderXGeo(0.080, 0.080, towerX * 2 + 0.36, 8), steelDark, {+ position: [0, hubY, 0],+ parent: root,+ });++ // Mechanical Drive Motor & Bull Gear (on rear A-frame)+ createPart('DriveMotorHousing', boxGeo(0.34, 0.34, 0.30), steelDark, {+ position: [-towerX + 0.14, hubY - 0.70, -0.44],+ parent: root,+ });+ createPart('DriveMotorCylinder', cylinderXGeo(0.11, 0.11, 0.36, 8), steelCrimson, {+ position: [-towerX + 0.14, hubY - 0.70, -0.44],+ parent: root,+ });+ createPart('BullGearRear', cylinderXGeo(0.36, 0.36, 0.05, 12), goldBrass, {+ position: [-0.66, hubY, 0],+ parent: root,+ });++ // Front Hub Ornate Starburst Medallion (Facing +X)+ const hubStarburst = createPivot('HubStarburst', [towerX + 0.03, hubY, 0], root);+ // Concentric decorative rings and discs+ createPart('StarburstOuterRing', torusGeo(0.44, 0.018, 5, 20), goldBrass, {+ rotation: [0, 90, 0],+ parent: hubStarburst,+ });+ createPart('StarburstBackDisc', cylinderXGeo(0.42, 0.42, 0.03, 12), steelCrimson, {+ parent: hubStarburst,+ });+ createPart('StarburstFrontPlate', cylinderXGeo(0.24, 0.24, 0.045, 10), goldBrass, {+ position: [0.01, 0, 0],+ parent: hubStarburst,+ });+ createPart('StarburstCenterDome', geoBulb, bulbGlowGold, {+ position: [0.035, 0, 0],+ parent: hubStarburst,+ });+ // 12 Radiating Star Rays with illuminated cabochon bulbs+ for (let s = 0; s < 12; s++) {+ const starAngle = (s / 12) * Math.PI * 2;+ const sy = Math.cos(starAngle) * 0.34;+ const sz = Math.sin(starAngle) * 0.34;+ createPart(`StarBulb_${s}`, geoBulb, s % 2 === 0 ? bulbGlowWarm : bulbGlowGold, {+ position: [0.025, sy, sz],+ parent: hubStarburst,+ });+ beamBetween(`StarRay_${s}`, [0.015, 0.14 * Math.cos(starAngle), 0.14 * Math.sin(starAngle)], [0.015, 0.42 * Math.cos(starAngle), 0.42 * Math.sin(starAngle)], 0.013, goldBrass, {+ segments: 4,+ parent: hubStarburst,+ });+ }++ // =========================================================================+ // 4. Rotating Spoked Double-Rim Wheel (Joint_Wheel)+ // =========================================================================+ const wheelPivot = createPivot('Wheel', [0, hubY, 0], root);++ const rimSpacingX = 0.50; // +/- rimSpacingX+ const gondolaCount = 12;++ // Hub Spoke Flanges at +/- rimSpacingX+ for (const sx of [-1, 1]) {+ const side = sx > 0 ? 'F' : 'R';+ createPart(`HubFlange_${side}`, cylinderXGeo(0.40, 0.40, 0.07, 12), goldBrass, {+ position: [sx * rimSpacingX, 0, 0],+ parent: wheelPivot,+ });+ createPart(`HubCore_${side}`, cylinderXGeo(0.24, 0.24, 0.14, 8), steelCrimson, {+ position: [sx * (rimSpacingX + 0.05), 0, 0],+ parent: wheelPivot,+ });+ }++ // Concentric Rims (Outer & Inner) on Front and Rear planes+ for (const sx of [-1, 1]) {+ const side = sx > 0 ? 'Front' : 'Rear';+ createPart(`${side}OuterRim`, torusGeo(rimRadius, 0.033, 5, 32), steelCrimson, {+ position: [sx * rimSpacingX, 0, 0],+ rotation: [0, 90, 0],+ parent: wheelPivot,+ });+ createPart(`${side}InnerRim`, torusGeo(innerRimRadius, 0.023, 4, 24), steelLattice, {+ position: [sx * rimSpacingX, 0, 0],+ rotation: [0, 90, 0],+ parent: wheelPivot,+ });+ }++ // Radial Spokes, Web Trussing & Perimeter Lights+ for (let i = 0; i < gondolaCount; i++) {+ const angle = (i / gondolaCount) * Math.PI * 2;+ const midAngle = ((i + 0.5) / gondolaCount) * Math.PI * 2;++ const cosA = Math.cos(angle);+ const sinA = Math.sin(angle);+ const cosMid = Math.cos(midAngle);+ const sinMid = Math.sin(midAngle);++ // Rim coordinates+ const outY = rimRadius * cosA;+ const outZ = rimRadius * sinA;+ const inY = innerRimRadius * cosA;+ const inZ = innerRimRadius * sinA;+ const midOutY = rimRadius * cosMid;+ const midOutZ = rimRadius * sinMid;++ // Both Front and Rear Spoke sets+ for (const sx of [-1, 1]) {+ const side = sx > 0 ? 'F' : 'R';+ const curX = sx * rimSpacingX;++ // Radial spoke from hub flange (r = 0.40) to outer rim+ beamBetween(`Spoke_${side}_${i}`, [curX, 0.40 * cosA, 0.40 * sinA], [curX, outY, outZ], 0.019, spokeWire, {+ segments: 4,+ parent: wheelPivot,+ });++ // Diagonal web truss between inner rim and outer rim+ beamBetween(`TrussA_${side}_${i}`, [curX, inY, inZ], [curX, midOutY, midOutZ], 0.014, spokeWire, {+ segments: 4,+ parent: wheelPivot,+ });+ beamBetween(`TrussB_${side}_${i}`, [curX, midOutY, midOutZ], [curX, innerRimRadius * Math.cos((i + 1) * Math.PI * 2 / gondolaCount), innerRimRadius * Math.sin((i + 1) * Math.PI * 2 / gondolaCount)], 0.014, spokeWire, {+ segments: 4,+ parent: wheelPivot,+ });+ }++ // Heavy Spreader Crossbar between Front and Rear outer rims (Gondola Hanger Pin)+ beamBetween(`RimSpreader_${i}`, [rimSpacingX, outY, outZ], [-rimSpacingX, outY, outZ], 0.035, steelCrimson, {+ segments: 5,+ parent: wheelPivot,+ });++ // Outer Rim Fairground Lights+ createPart(`RimBulb_${i}`, geoBulb, i % 2 === 0 ? bulbGlowWarm : bulbGlowGold, {+ position: [rimSpacingX + 0.04, outY, outZ],+ parent: wheelPivot,+ });+ createPart(`RimBulbMid_${i}`, geoBulb, i % 2 === 0 ? bulbGlowGold : bulbGlowWarm, {+ position: [rimSpacingX + 0.04, midOutY, midOutZ],+ parent: wheelPivot,+ });++ // =======================================================================+ // 5. Lit Hanging Gondolas (Maintained Upright at each spoke pin)+ // =======================================================================+ const gondolaPivot = createPivot(`Gondola_${i}`, [0, outY, outZ], wheelPivot);+ const carMat = gondolaMats[i % 3];++ // Suspension Hanger: Inverted V-yoke dropping from pin to canopy+ // Top central pivot sleeve on the spreader pin+ createPart(`HangerSleeve_${i}`, cylinderXGeo(0.042, 0.042, 0.20, 6), steelDark, {+ position: [0, 0, 0],+ parent: gondolaPivot,+ });++ // Elegant Front & Rear A-frame suspension arms from pin to canopy+ const canopyTopY = -0.38;+ const canL = 0.68; // along X+ const canW = 0.52; // along Z+ for (const sx of [-canL / 2 + 0.08, canL / 2 - 0.08]) {+ beamBetween(`HangerArmA_${i}_${sx > 0 ? 'F' : 'B'}`, [sx, 0, 0], [sx, canopyTopY, -canW / 2 + 0.06], 0.015, ironRail, {+ segments: 4,+ parent: gondolaPivot,+ });+ beamBetween(`HangerArmB_${i}_${sx > 0 ? 'F' : 'B'}`, [sx, 0, 0], [sx, canopyTopY, canW / 2 - 0.06], 0.015, ironRail, {+ segments: 4,+ parent: gondolaPivot,+ });+ }++ // Canopy / Roof: Arched carnival awning with gold finial+ createPart(`CanopyTop_${i}`, boxGeo(canL, 0.035, canW), carMat, {+ position: [0, canopyTopY, 0],+ parent: gondolaPivot,+ });+ // Curved roof crown+ createPart(`CanopyArch_${i}`, cylinderXGeo(0.24, 0.24, canL - 0.04, 6), carMat, {+ position: [0, canopyTopY + 0.04, 0],+ scale: [1, 0.35, 1],+ parent: gondolaPivot,+ });+ // Gold decorative roof finial+ createPart(`CanopyFinial_${i}`, cylinderGeo(0.035, 0.035, 0.08, 5), goldBrass, {+ position: [0, canopyTopY + 0.12, 0],+ parent: gondolaPivot,+ });++ // Carriage Tub Body (Molded passenger basket)+ const tubBottomY = -gondolaDrop;+ const tubH = 0.26;+ const tubY = tubBottomY + tubH / 2;+ createPart(`CarriageTub_${i}`, boxGeo(canL - 0.02, tubH, canW - 0.02), carMat, {+ position: [0, tubY, 0],+ parent: gondolaPivot,+ });+ // Polished gold belt molding+ createPart(`TubBelt_${i}`, boxGeo(canL + 0.01, 0.035, canW + 0.01), goldBrass, {+ position: [0, tubY + tubH / 2 - 0.02, 0],+ parent: gondolaPivot,+ });++ // Contoured Passenger Benches (Facing each other along X)+ for (const sx of [-0.20, 0.20]) {+ createPart(`Bench_${i}_${sx > 0 ? 'F' : 'B'}`, boxGeo(0.18, 0.12, canW - 0.10), woodDeck, {+ position: [sx, tubBottomY + 0.18, 0],+ parent: gondolaPivot,+ });+ }++ // 4 Corner Stanchions connecting carriage tub to canopy+ let postIdx = 0;+ for (const sx of [-canL / 2 + 0.04, canL / 2 - 0.04]) {+ for (const sz of [-canW / 2 + 0.04, canW / 2 - 0.04]) {+ beamBetween(`CornerPost_${i}_${postIdx++}`, [sx, tubY + tubH / 2, sz], [sx, canopyTopY, sz], 0.012, goldBrass, {+ segments: 4,+ parent: gondolaPivot,+ });+ }+ }++ // Side Safety Railings (Spanning along X on Left and Right)+ for (const sz of [-canW / 2 + 0.04, canW / 2 - 0.04]) {+ beamBetween(`SideRail_${i}_${sz > 0 ? 'R' : 'L'}`, [-canL / 2 + 0.04, tubY + tubH / 2 + 0.10, sz], [canL / 2 - 0.04, tubY + tubH / 2 + 0.10, sz], 0.011, ironRail, {+ segments: 4,+ parent: gondolaPivot,+ });+ }++ // Lit Gondola Illumination: Warm Ceiling Lantern + Glowing Exterior Marker Bulbs+ createPart(`CeilingLantern_${i}`, cylinderGeo(0.032, 0.042, 0.065, 5), bulbGlowWarm, {+ position: [0, canopyTopY - 0.06, 0],+ parent: gondolaPivot,+ });+ // Front and Rear glowing marker lights on carriage exterior+ createPart(`GondolaMarkerF_${i}`, geoBulb, bulbGlowWarm, {+ position: [canL / 2 + 0.02, tubY + 0.04, 0],+ parent: gondolaPivot,+ });+ createPart(`GondolaMarkerB_${i}`, geoBulb, bulbGlowWarm, {+ position: [-canL / 2 - 0.02, tubY + 0.04, 0],+ parent: gondolaPivot,+ });+ }++ // =========================================================================+ // 6. Boarding Platform, Entrance Marquee & Operator Station+ // =========================================================================+ const platform = createPivot('BoardingPlatform', [0, 0, 0], root);+ const platH = 0.44;+ const platW = 1.60;+ const platL = 1.50;++ // Platform Decking & Timber Post Frame+ createPart('PlatformDeck', boxGeo(platL, 0.06, platW), woodDeck, {+ position: [0.15, platH - 0.03, 0],+ parent: platform,+ });+ createPart('PlatformFascia', boxGeo(platL, platH - 0.06, platW), steelDark, {+ position: [0.15, (platH - 0.06) / 2, 0],+ parent: platform,+ });++ // Access Stairs on the front (+X) side+ const stepCount = 3;+ const stepRise = platH / stepCount;+ const stepRun = 0.26;+ for (let s = 0; s < stepCount; s++) {+ const sy = (s + 0.5) * stepRise;+ const sx = 0.15 + platL / 2 + (s + 0.5) * stepRun;+ createPart(`Step_${s}`, boxGeo(stepRun, stepRise, platW * 0.75), woodDeck, {+ position: [sx, sy, 0],+ parent: platform,+ });+ }++ // Safety Handrails around platform perimeter+ const railH = 0.55;+ for (const sz of [-1, 1]) {+ const railSide = sz > 0 ? 'R' : 'L';+ beamBetween(`PlatRail_${railSide}`, [-platL / 2 + 0.15, platH + railH, sz * (platW / 2 - 0.05)], [platL / 2 + 0.15, platH + railH, sz * (platW / 2 - 0.05)], 0.016, ironRail, {+ segments: 4,+ parent: platform,+ });+ beamBetween(`PlatRailMid_${railSide}`, [-platL / 2 + 0.15, platH + railH * 0.5, sz * (platW / 2 - 0.05)], [platL / 2 + 0.15, platH + railH * 0.5, sz * (platW / 2 - 0.05)], 0.013, ironRail, {+ segments: 4,+ parent: platform,+ });+ let stanchionIdx = 0;+ for (const sx of [-platL / 2 + 0.15, 0.15, platL / 2 + 0.15]) {+ beamBetween(`PlatStanchion_${railSide}_${stanchionIdx++}`, [sx, platH, sz * (platW / 2 - 0.05)], [sx, platH + railH, sz * (platW / 2 - 0.05)], 0.016, ironRail, {+ segments: 4,+ parent: platform,+ });+ }+ }++ // Entrance Marquee Arch at the top of the stairs+ const archX = 0.15 + platL / 2;+ const archZ1 = -0.55;+ const archZ2 = 0.55;+ const archTopY = platH + 1.10;+ // Left and Right Arch Posts+ beamBetween('EntrancePost_L', [archX, platH, archZ1], [archX, archTopY, archZ1], 0.022, steelCrimson, {+ segments: 4,+ parent: platform,+ });+ beamBetween('EntrancePost_R', [archX, platH, archZ2], [archX, archTopY, archZ2], 0.022, steelCrimson, {+ segments: 4,+ parent: platform,+ });+ // Arch Header Beam+ beamBetween('EntranceHeader', [archX, archTopY, archZ1], [archX, archTopY, archZ2], 0.025, steelCrimson, {+ segments: 4,+ parent: platform,+ });+ // Entrance Signboard ("FERRIS WHEEL")+ createPart('EntranceSignboard', boxGeo(0.04, 0.16, 0.90), goldBrass, {+ position: [archX + 0.01, archTopY + 0.08, 0],+ parent: platform,+ });+ createPart('EntranceSignFascia', boxGeo(0.05, 0.10, 0.82), steelCrimson, {+ position: [archX + 0.015, archTopY + 0.08, 0],+ parent: platform,+ });+ // Glowing Entrance Lanterns on posts+ createPart('EntranceLantern_L', geoBulb, bulbGlowGold, {+ position: [archX + 0.03, archTopY + 0.02, archZ1],+ parent: platform,+ });+ createPart('EntranceLantern_R', geoBulb, bulbGlowGold, {+ position: [archX + 0.03, archTopY + 0.02, archZ2],+ parent: platform,+ });++ // Operator Console & Shelter on platform side+ const consolePivot = createPivot('OperatorConsole', [0.65, platH, 0.95], platform);+ createPart('ConsolePedestal', boxGeo(0.24, 0.65, 0.32), steelDark, {+ position: [0, 0.325, 0],+ parent: consolePivot,+ });+ createPart('ConsoleDesk', boxGeo(0.28, 0.04, 0.36), ironRail, {+ position: [0, 0.67, 0],+ rotation: [15, 0, 0],+ parent: consolePivot,+ });+ createPart('ControlLever', cylinderGeo(0.012, 0.012, 0.16, 4), goldBrass, {+ position: [-0.05, 0.76, 0],+ rotation: [0, 0, 20],+ parent: consolePivot,+ });+ createPart('EmergencyStop', cylinderGeo(0.022, 0.022, 0.03, 6), gondolaRed, {+ position: [0.06, 0.70, 0.05],+ parent: consolePivot,+ });+ // Operator stool+ createPart('OperatorStoolSeat', cylinderGeo(0.14, 0.14, 0.04, 8), woodDeck, {+ position: [0.32, 0.42, 0],+ parent: consolePivot,+ });+ beamBetween('StoolLeg', [0.32, 0, 0], [0.32, 0.40, 0], 0.02, ironRail, {+ segments: 4,+ parent: consolePivot,+ });++ return root;+}diff --git a/examples/fighter-jet.kiln.js b/examples/fighter-jet.kiln.jsnew file mode 100644index 00000000..051e5ad9--- /dev/null+++ b/examples/fighter-jet.kiln.js@@ -0,0 +1,696 @@+// Authored by: opus, via claude.+//+// Written by the model itself through the Kiln MCP tools, and cut off+// mid-run rather than finished -- by a provider limit, or by the+// dispatch deadline. The program below is what was on disk when the+// session ended; how many times it had looked at its own contact sheet+// by then is not recorded, so this one does not make the claim the+// others do.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.+//+// Refined later, in this repository, with `kiln_edit`: the wing was split at+// its own hinge lines. It had been lofted full chord underneath the flap, the+// flaperon and the aileron, which are lofted from the same stations over the+// same aerofoil, so both wings carried a hatched wedge from top where two+// identical surfaces sat at one depth. The skin was repainted later still;+// the comment at the material says why.++const meta = { name: 'FighterJet', category: 'prop', role: 'vehicle' };++// ---------------------------------------------------------------------------+// Frame: +X forward (nose), +Y up, +Z asset right. Gear down, tyres on Y = 0.+// Overall: 16.5 m nose to tail, 11.0 m span, 4.6 m to the fin tips.+// ---------------------------------------------------------------------------++const D2R = Math.PI / 180;++function lerp(a, b, t) { return a + (b - a) * t; }++// Generic skinned loft. `sections` is an array of equal-length rings of+// [x,y,z] points, ordered consistently around the loop. Both ends are capped+// with a centroid fan, then the winding is normalised by signed volume so the+// surface always faces outward (or inward when opts.invert is set).+function loftGeo(sections, opts) {+ opts = opts || {};+ const M = sections.length;+ const N = sections[0].length;+ const verts = [];+ for (let s = 0; s < M; s++) {+ const sec = sections[s];+ for (let i = 0; i < N; i++) verts.push(sec[i][0], sec[i][1], sec[i][2]);+ }+ const idx = [];+ for (let s = 0; s < M - 1; s++) {+ for (let i = 0; i < N; i++) {+ const j = (i + 1) % N;+ const a = s * N + i, b = s * N + j, c = (s + 1) * N + i, d = (s + 1) * N + j;+ idx.push(a, c, d);+ idx.push(a, d, b);+ }+ }+ if (opts.capStart !== false) {+ let cx = 0, cy = 0, cz = 0;+ for (let i = 0; i < N; i++) { cx += sections[0][i][0]; cy += sections[0][i][1]; cz += sections[0][i][2]; }+ const ci = verts.length / 3;+ verts.push(cx / N, cy / N, cz / N);+ for (let i = 0; i < N; i++) { const j = (i + 1) % N; idx.push(ci, j, i); }+ }+ if (opts.capEnd !== false) {+ const base = (M - 1) * N;+ let cx = 0, cy = 0, cz = 0;+ for (let i = 0; i < N; i++) { cx += sections[M - 1][i][0]; cy += sections[M - 1][i][1]; cz += sections[M - 1][i][2]; }+ const ci = verts.length / 3;+ verts.push(cx / N, cy / N, cz / N);+ for (let i = 0; i < N; i++) { const j = (i + 1) % N; idx.push(ci, base + i, base + j); }+ }+ let vol = 0;+ for (let t = 0; t < idx.length; t += 3) {+ const i0 = idx[t] * 3, i1 = idx[t + 1] * 3, i2 = idx[t + 2] * 3;+ const ax = verts[i0], ay = verts[i0 + 1], az = verts[i0 + 2];+ const bx = verts[i1], by = verts[i1 + 1], bz = verts[i1 + 2];+ const cx2 = verts[i2], cy2 = verts[i2 + 1], cz2 = verts[i2 + 2];+ vol += ax * (by * cz2 - bz * cy2) + ay * (bz * cx2 - bx * cz2) + az * (bx * cy2 - by * cx2);+ }+ const wantPositive = !opts.invert;+ if ((vol > 0) !== wantPositive) {+ for (let t = 0; t < idx.length; t += 3) { const tmp = idx[t + 1]; idx[t + 1] = idx[t + 2]; idx[t + 2] = tmp; }+ }+ const geo = new THREE.BufferGeometry();+ geo.setAttribute('position', new THREE.Float32BufferAttribute(verts, 3));+ geo.setIndex(idx);+ geo.computeVertexNormals();+ return geo;+}++// Surface of revolution about a cardinal axis from a CLOSED 2D outline of+// [axial, radial] pairs -> watertight tube/solid. Used for nozzles and tyres.+function revolveClosed(profile, segments, axis) {+ const sections = [];+ for (let s = 0; s < segments; s++) {+ const a = (s / segments) * Math.PI * 2;+ const ca = Math.cos(a), sa = Math.sin(a);+ const ring = [];+ for (let i = 0; i < profile.length; i++) {+ const p = profile[i][0], r = profile[i][1];+ if (axis === 'x') ring.push([p, r * ca, r * sa]);+ else if (axis === 'z') ring.push([r * ca, r * sa, p]);+ else ring.push([r * ca, p, r * sa]);+ }+ sections.push(ring);+ }+ // wrap around: treat as closed in the sweep direction too+ const M = sections.length, N = profile.length;+ const verts = [];+ for (let s = 0; s < M; s++) for (let i = 0; i < N; i++) verts.push(sections[s][i][0], sections[s][i][1], sections[s][i][2]);+ const idx = [];+ for (let s = 0; s < M; s++) {+ const s2 = (s + 1) % M;+ for (let i = 0; i < N; i++) {+ const j = (i + 1) % N;+ const a = s * N + i, b = s * N + j, c = s2 * N + i, d = s2 * N + j;+ idx.push(a, c, d);+ idx.push(a, d, b);+ }+ }+ let vol = 0;+ for (let t = 0; t < idx.length; t += 3) {+ const i0 = idx[t] * 3, i1 = idx[t + 1] * 3, i2 = idx[t + 2] * 3;+ const ax = verts[i0], ay = verts[i0 + 1], az = verts[i0 + 2];+ const bx = verts[i1], by = verts[i1 + 1], bz = verts[i1 + 2];+ const cx = verts[i2], cy = verts[i2 + 1], cz = verts[i2 + 2];+ vol += ax * (by * cz - bz * cy) + ay * (bz * cx - bx * cz) + az * (bx * cy - by * cx);+ }+ if (vol < 0) for (let t = 0; t < idx.length; t += 3) { const tmp = idx[t + 1]; idx[t + 1] = idx[t + 2]; idx[t + 2] = tmp; }+ const geo = new THREE.BufferGeometry();+ geo.setAttribute('position', new THREE.Float32BufferAttribute(verts, 3));+ geo.setIndex(idx);+ geo.computeVertexNormals();+ return geo;+}++// NACA symmetric half-thickness shape function, normalised so the peak is ~0.5.+function foilF(u) {+ const t = Math.max(0, Math.min(1, u));+ return 5 * (0.2969 * Math.sqrt(t) - 0.1260 * t - 0.3516 * t * t + 0.2843 * t * t * t - 0.1036 * t * t * t * t);+}++// Lofts a chordwise SLICE (u0..u1 of chord) of an aerofoil surface across a+// list of span stations. `mapper(x, station, offset)` puts a point in world space.+function foilLoft(stations, u0, u1, n, mapper) {+ const sections = [];+ const us = [];+ for (let i = 0; i <= n; i++) { const p = (1 - Math.cos(Math.PI * i / n)) / 2; us.push(u0 + (u1 - u0) * p); }+ for (let s = 0; s < stations.length; s++) {+ const st = stations[s];+ const chord = st.le - st.te;+ const loop = [];+ for (let i = 0; i <= n; i++) {+ const u = us[i];+ loop.push(mapper(st.le - u * chord, st, foilF(u) * st.t * chord));+ }+ for (let i = n; i >= 0; i--) {+ const u = us[i];+ loop.push(mapper(st.le - u * chord, st, -foilF(u) * st.t * chord));+ }+ sections.push(loop);+ }+ return loftGeo(sections, {});+}++// Chined fuselage cross-section: superellipse above and below a hard chine+// edge that carries a small vertical facet so it stays crisp when smoothed.+function fuseRing(st, nTop, nBot) {+ const pts = [];+ const eps = st.chine;+ for (let i = 0; i <= nTop; i++) {+ const t = (i / nTop) * Math.PI;+ const c = Math.cos(t), s = Math.sin(t);+ const z = st.w * Math.sign(c) * Math.pow(Math.abs(c), 2 / st.eTop);+ const y = st.cy + eps + st.hu * Math.pow(Math.abs(s), 2 / st.eTop);+ pts.push([st.x, y, z]);+ }+ for (let i = 0; i <= nBot; i++) {+ const t = Math.PI + (i / nBot) * Math.PI;+ const c = Math.cos(t), s = Math.sin(t);+ const z = st.w * Math.sign(c) * Math.pow(Math.abs(c), 2 / st.eBot);+ const y = st.cy - eps - st.hl * Math.pow(Math.abs(s), 2 / st.eBot);+ pts.push([st.x, y, z]);+ }+ return pts;+}++function roundRect(w, h, r, n) {+ // n points around a rounded rectangle in (z,y), centred on origin+ const pts = [];+ const cx = [w - r, w - r, -(w - r), -(w - r)];+ const cy = [h - r, -(h - r), -(h - r), h - r];+ const a0 = [0, -90, 180, 90];+ const per = Math.max(2, Math.round(n / 4));+ for (let q = 0; q < 4; q++) {+ for (let i = 0; i < per; i++) {+ const a = (a0[q] + (q === 0 ? 0 : 0) + (i / per) * 90 + (q === 0 ? 0 : 0)) * D2R;+ const ang = (a0[q] - (i / per) * 90) * D2R;+ pts.push([cx[q] + r * Math.cos(ang), cy[q] + r * Math.sin(ang)]);+ }+ }+ return pts;+}++async function build() {+ const root = createRoot('FighterJet');++ // ------------------------------------------------------------ materials+ // Low-visibility tactical paint, which is what an airframe is finished in --+ // it is not bare metal, and metalness 0.32 on a light grey was enough to make+ // it act like some. Under the studio dome the whole aircraft came back a+ // uniform near-white: not one panel line, not one shadow across the fuselage+ // spine, and no difference at all between the two tones the scheme is built+ // from. Paint is dielectric, so the metalness goes to almost nothing, and the+ // two greys move apart far enough that the upper surfaces read as a scheme.+ const skin = gameMaterial(0x5c646f, { metalness: 0.06, roughness: 0.62, flatShading: false });+ const skinDark = gameMaterial(0x424951, { metalness: 0.06, roughness: 0.66, flatShading: false });+ const radomeMat = gameMaterial(0x4e545b, { metalness: 0.10, roughness: 0.80, flatShading: false });+ const nozzleMat = gameMaterial(0xa89e90, { metalness: 0.92, roughness: 0.38, flatShading: false });+ const burnt = gameMaterial(0x4b433a, { metalness: 0.85, roughness: 0.62, flatShading: false });+ const black = gameMaterial(0x1b1e21, { roughness: 0.88, metalness: 0.15 });+ const rubber = gameMaterial(0x131416, { roughness: 0.98, metalness: 0.02 });+ const steel = gameMaterial(0xc9ced3, { metalness: 0.95, roughness: 0.18 });+ const duct = gameMaterial(0x8f949a, { metalness: 0.10, roughness: 0.55, flatShading: false });+ const glass = glassMaterial(0x8fb8cc, { opacity: 0.34, roughness: 0.06, metalness: 0.35 });+ const lightR = gameMaterial(0xd21f2a, { emissive: 0xd21f2a, emissiveIntensity: 0.9, roughness: 0.4 });+ const lightG = gameMaterial(0x21c04a, { emissive: 0x21c04a, emissiveIntensity: 0.9, roughness: 0.4 });+ const lightW = gameMaterial(0xf2f4f0, { emissive: 0xf2f4f0, emissiveIntensity: 0.8, roughness: 0.4 });++ // ------------------------------------------------------------- fuselage+ // x, half-width, chine height, upper height, lower depth, superellipse exps+ const fuseTable = [+ [8.62, 0.030, 2.000, 0.030, 0.030, 2.4, 2.4],+ [8.45, 0.140, 2.000, 0.125, 0.120, 2.5, 2.4],+ [8.10, 0.320, 2.000, 0.250, 0.240, 2.6, 2.4],+ [7.40, 0.500, 2.000, 0.380, 0.360, 2.7, 2.5],+ [6.60, 0.660, 2.000, 0.480, 0.460, 2.8, 2.5],+ [5.80, 0.780, 2.000, 0.540, 0.540, 2.9, 2.5],+ [5.00, 0.860, 2.000, 0.575, 0.600, 3.0, 2.6],+ [4.20, 0.920, 2.000, 0.600, 0.660, 3.0, 2.6],+ [3.40, 0.980, 2.000, 0.620, 0.720, 3.0, 2.7],+ [2.60, 1.040, 2.000, 0.640, 0.780, 3.0, 2.7],+ [1.80, 1.100, 1.990, 0.660, 0.820, 3.0, 2.8],+ [1.00, 1.160, 1.980, 0.680, 0.840, 3.0, 2.8],+ [0.10, 1.220, 1.970, 0.700, 0.860, 3.0, 2.8],+ [-0.80, 1.250, 1.960, 0.700, 0.860, 3.0, 2.8],+ [-1.70, 1.250, 1.955, 0.685, 0.845, 3.0, 2.8],+ [-2.60, 1.235, 1.950, 0.665, 0.825, 2.9, 2.8],+ [-3.50, 1.205, 1.950, 0.625, 0.785, 2.9, 2.7],+ [-4.40, 1.165, 1.950, 0.585, 0.745, 2.8, 2.7],+ [-5.30, 1.125, 1.950, 0.545, 0.690, 2.8, 2.6],+ [-6.20, 1.075, 1.950, 0.500, 0.625, 2.7, 2.6],+ [-6.70, 1.040, 1.950, 0.475, 0.585, 2.7, 2.5],+ [-7.05, 1.010, 1.950, 0.460, 0.560, 2.6, 2.5],+ ];+ const fuseSections = fuseTable.map(function (r) {+ return fuseRing({ x: r[0], w: r[1], cy: r[2], hu: r[3], hl: r[4], eTop: r[5], eBot: r[6], chine: 0.018 }, 11, 11);+ });+ createPart('Fuselage', loftGeo(fuseSections, {}), skin, { parent: root });++ // Radome: a darker dielectric cap over the forward 2 m of the nose.+ const radomeSections = fuseTable.filter(function (r) { return r[0] >= 6.55; }).map(function (r) {+ return fuseRing({ x: r[0], w: r[1] * 1.006, cy: r[2], hu: r[3] * 1.006, hl: r[4] * 1.006, eTop: r[5], eBot: r[6], chine: 0.019 }, 11, 11);+ });+ createPart('Radome', loftGeo(radomeSections, {}), radomeMat, { parent: root });++ // Pitot boom on the radome tip: nose datum is X = 9.00.+ createPart('PitotBoom', cylinderXGeo(0.016, 0.030, 0.40, 8), steel, { position: [8.80, 2.000, 0], parent: root });+ createPart('PitotTip', coneXGeo(0.016, 0.06, 8), black, { position: [8.97, 2.000, 0], parent: root });++ // Dorsal spine fairing behind the canopy.+ const spineSections = [];+ const spineTable = [[2.95, 0.30, 0.10], [2.20, 0.36, 0.16], [1.20, 0.40, 0.19], [0.00, 0.42, 0.20], [-1.40, 0.40, 0.18], [-2.60, 0.35, 0.14], [-3.40, 0.28, 0.08]];+ for (let i = 0; i < spineTable.length; i++) {+ const x = spineTable[i][0], w = spineTable[i][1], h = spineTable[i][2];+ // ride on the fuselage upper surface at that station+ let top = 2.60;+ for (let k = 0; k < fuseTable.length - 1; k++) {+ if (x <= fuseTable[k][0] && x >= fuseTable[k + 1][0]) {+ const t = (fuseTable[k][0] - x) / (fuseTable[k][0] - fuseTable[k + 1][0]);+ top = lerp(fuseTable[k][2] + fuseTable[k][3], fuseTable[k + 1][2] + fuseTable[k + 1][3], t);+ }+ }+ const ring = [];+ const n = 9;+ for (let j = 0; j <= n; j++) {+ const a = (j / n) * Math.PI;+ ring.push([x, top - 0.14 + h * Math.pow(Math.sin(a), 0.75), w * Math.cos(a)]);+ }+ for (let j = n - 1; j >= 1; j--) {+ const a = (j / n) * Math.PI;+ ring.push([x, top - 0.16, w * Math.cos(a) * 0.98]);+ }+ spineSections.push(ring);+ }+ createPart('DorsalSpine', loftGeo(spineSections, {}), skin, { parent: root });++ // ------------------------------------------------- leading-edge root ext+ const lerxTable = [+ [5.90, 0.86, 0.045], [5.40, 0.97, 0.070], [4.60, 1.06, 0.100],+ [3.80, 1.15, 0.125], [3.00, 1.25, 0.150], [2.40, 1.34, 0.165], [1.90, 1.40, 0.170],+ ];+ for (let s = -1; s <= 1; s += 2) {+ const secs = [];+ for (let i = 0; i < lerxTable.length; i++) {+ const x = lerxTable[i][0], zo = lerxTable[i][1], th = lerxTable[i][2];+ const zi = 0.45;+ const nv = 7;+ const ring = [];+ for (let j = 0; j <= nv; j++) {+ const v = j / nv;+ const z = lerp(zi, zo, v);+ ring.push([x, 2.000 + (th * Math.pow(1 - v, 0.55) + 0.006), s * z]);+ }+ for (let j = nv; j >= 0; j--) {+ const v = j / nv;+ const z = lerp(zi, zo, v);+ ring.push([x, 2.000 - (th * Math.pow(1 - v, 0.55) + 0.006), s * z]);+ }+ secs.push(ring);+ }+ createPart(s > 0 ? 'LerxRight' : 'LerxLeft', loftGeo(secs, {}), skin, { parent: root });+ }++ // ------------------------------------------------------------ main wing+ const wingStations = [+ { s: 0.95, le: 2.79, te: -4.15, t: 0.062, y: 1.920 },+ { s: 1.60, le: 2.38, te: -4.10, t: 0.060, y: 1.950 },+ { s: 2.40, le: 1.87, te: -4.03, t: 0.058, y: 1.985 },+ { s: 3.30, le: 1.30, te: -3.60, t: 0.056, y: 2.020 },+ { s: 4.20, le: 0.73, te: -3.10, t: 0.052, y: 2.060 },+ { s: 5.10, le: 0.16, te: -2.55, t: 0.048, y: 2.100 },+ { s: 5.50, le: -0.09, te: -2.30, t: 0.046, y: 2.115 },+ ];+ function wingStationsBetween(a, b) {+ const out = [];+ for (let i = 0; i < wingStations.length; i++) if (wingStations[i].s >= a - 1e-6 && wingStations[i].s <= b + 1e-6) out.push(wingStations[i]);+ return out;+ }+ for (let side = -1; side <= 1; side += 2) {+ const nm = side > 0 ? 'Right' : 'Left';+ const map = function (x, st, off) { return [x, st.y + off, side * st.s]; };+ // Split at the hinge lines instead of lofted full chord underneath them.+ // The flap, flaperon and aileron below come off the same stations and the+ // same aerofoil, so a wing that also spans their chord bands lays a second+ // identical surface at the same depth: the top view came back with a+ // hatched wedge across both wings where the rasterizer could not decide+ // which of the two it was looking at. Each band now belongs to one part,+ // and the seams fall exactly where a real hinge line does.+ createPart('WingInboard' + nm, foilLoft(wingStationsBetween(0.95, 1.60), 0.002, 0.985, 13, map), skin, { parent: root });+ createPart('WingBox' + nm, foilLoft(wingStationsBetween(1.60, 5.50), 0.150, 0.735, 13, map), skin, { parent: root });+ // leading-edge flap, outboard of the body side+ createPart('LEFlap' + nm, foilLoft(wingStationsBetween(1.60, 5.50), 0.004, 0.150, 8, map), skinDark, { parent: root });+ // inboard flaperon and outboard aileron+ createPart('Flaperon' + nm, foilLoft(wingStationsBetween(1.60, 3.30), 0.735, 0.985, 8, map), skinDark, { parent: root });+ createPart('Aileron' + nm, foilLoft(wingStationsBetween(3.30, 5.50), 0.735, 0.985, 8, map), skinDark, { parent: root });+ // wingtip nav light + static dischargers+ createPart('NavLight' + nm, capsuleXGeo(0.055, 0.20, 8), side > 0 ? lightG : lightR, { position: [-0.60, 2.118, side * 5.52], parent: root });+ for (let i = 0; i < 3; i++) {+ createPart('StaticWick' + nm + i, cylinderXGeo(0.008, 0.012, 0.28, 5), black, { position: [-2.55 - i * 0.02, 2.10 + i * 0.005, side * (4.55 + i * 0.42)], rotation: [0, -12 * side, 0], parent: root });+ }+ }++ // -------------------------------------------------------- vertical tails+ const finStations = [+ { s: 0.00, le: -3.05, te: -6.75, t: 0.055 },+ { s: 0.65, le: -3.48, te: -6.80, t: 0.050 },+ { s: 1.40, le: -3.98, te: -6.86, t: 0.045 },+ { s: 2.10, le: -4.45, te: -6.91, t: 0.040 },+ { s: 2.54, le: -4.68, te: -6.93, t: 0.038 },+ ];+ const cant = 25 * D2R, finRootY = 2.30, finRootZ = 1.02;+ for (let side = -1; side <= 1; side += 2) {+ const nm = side > 0 ? 'Right' : 'Left';+ const map = function (x, st, off) {+ return [x, finRootY + st.s * Math.cos(cant) - off * Math.sin(cant), side * (finRootZ + st.s * Math.sin(cant) + off * Math.cos(cant))];+ };+ createPart('VerticalTail' + nm, foilLoft(finStations, 0.002, 0.700, 10, map), skin, { parent: root });+ createPart('Rudder' + nm, foilLoft(finStations, 0.712, 0.985, 8, map), skinDark, { parent: root });+ // fin-tip antenna fairing+ const tipY = finRootY + 2.54 * Math.cos(cant), tipZ = side * (finRootZ + 2.54 * Math.sin(cant));+ createPart('FinTipPod' + nm, capsuleXGeo(0.048, 0.55, 8), skinDark, { position: [-5.75, tipY + 0.03, tipZ], rotation: [side * 25, 0, -6], parent: root });+ createPart('FinTipLight' + nm, capsuleXGeo(0.040, 0.10, 8), lightW, { position: [-6.16, tipY - 0.02, tipZ], rotation: [side * 25, 0, -6], parent: root });+ }++ // ----------------------------------------------------------- stabilators+ const stabStations = [+ { s: 0.00, le: -3.70, te: -6.40, t: 0.060 },+ { s: 0.90, le: -4.25, te: -6.42, t: 0.055 },+ { s: 1.70, le: -4.75, te: -6.45, t: 0.048 },+ { s: 2.35, le: -5.15, te: -6.48, t: 0.042 },+ ];+ const anh = 6 * D2R, stabRootY = 1.985, stabRootZ = 0.95;+ for (let side = -1; side <= 1; side += 2) {+ const nm = side > 0 ? 'Right' : 'Left';+ const map = function (x, st, off) {+ return [x, stabRootY - st.s * Math.sin(anh) + off * Math.cos(anh), side * (stabRootZ + st.s * Math.cos(anh) + off * Math.sin(anh))];+ };+ createPart('Stabilator' + nm, foilLoft(stabStations, 0.002, 0.985, 11, map), skin, { parent: root });+ // pivot fairing where the stabilator meets the boom+ createPart('StabPivot' + nm, capsuleXGeo(0.115, 0.70, 10), skinDark, { position: [-5.10, 1.965, side * 1.16], rotation: [0, 0, 0], parent: root });+ }++ // ------------------------------------------------------- caret intakes+ const intakeTable = [+ { x: 2.50, w: 0.455, h: 0.345, r: 0.075, zc: 1.245, yc: 1.505 },+ { x: 2.05, w: 0.460, h: 0.350, r: 0.085, zc: 1.250, yc: 1.510 },+ { x: 1.30, w: 0.470, h: 0.365, r: 0.110, zc: 1.255, yc: 1.530 },+ { x: 0.40, w: 0.470, h: 0.375, r: 0.140, zc: 1.245, yc: 1.560 },+ { x: -0.60, w: 0.450, h: 0.370, r: 0.170, zc: 1.215, yc: 1.590 },+ { x: -1.50, w: 0.410, h: 0.350, r: 0.190, zc: 1.180, yc: 1.620 },+ ];+ for (let side = -1; side <= 1; side += 2) {+ const nm = side > 0 ? 'Right' : 'Left';+ const secs = [];+ for (let i = 0; i < intakeTable.length; i++) {+ const st = intakeTable[i];+ const rr = roundRect(st.w, st.h, st.r, 16);+ const ring = [];+ for (let j = 0; j < rr.length; j++) {+ const zl = rr[j][0], yl = rr[j][1];+ let x = st.x;+ if (i === 0) {+ // caret rake: outboard-lower lip is furthest forward+ x = st.x + 0.24 * (zl / st.w) - 0.16 * (yl / st.h);+ }+ ring.push([x, st.yc + yl, side * (st.zc + zl)]);+ }+ secs.push(ring);+ }+ createPart('Intake' + nm, loftGeo(secs, {}), skin, { parent: root });++ // inner duct, normals inverted so the bore reads as a hole+ const inner = [];+ for (let i = 0; i < intakeTable.length; i++) {+ const st = intakeTable[i];+ const k = 0.86;+ const rr = roundRect(st.w * k, st.h * k, st.r * k, 14);+ const ring = [];+ for (let j = 0; j < rr.length; j++) {+ const zl = rr[j][0], yl = rr[j][1];+ let x = st.x;+ if (i === 0) x = st.x + 0.24 * (zl / (st.w * k)) * k - 0.16 * (yl / (st.h * k)) * k + 0.012;+ ring.push([x, st.yc + yl + (i > 2 ? (i - 2) * 0.05 : 0), side * (st.zc + zl)]);+ }+ inner.push(ring);+ }+ createPart('IntakeDuct' + nm, loftGeo(inner, { invert: true }), duct, { parent: root });+ createPart('IntakeFace' + nm, cylinderXGeo(0.33, 0.33, 0.05, 14), black, { position: [-1.40, 1.72, side * 1.19], parent: root });++ // boundary-layer diverter splitter plate between duct and fuselage side+ createPart('Diverter' + nm, boxGeo(2.9, 0.62, 0.05), skinDark, { position: [1.10, 1.52, side * 0.80], parent: root });+ // lower lip reinforcement+ createPart('IntakeLip' + nm, capsuleZGeo(0.045, 0.80, 8), skinDark, { position: [2.56, 1.175, side * 1.25], rotation: [0, 0, 0], parent: root });+ }++ // ---------------------------------------------------- exhaust / nozzles+ const nozProfile = [+ [-6.10, 0.545], [-6.45, 0.520], [-6.80, 0.480], [-7.10, 0.440], [-7.28, 0.428], [-7.42, 0.440], [-7.50, 0.458],+ [-7.50, 0.418], [-7.42, 0.402], [-7.28, 0.392], [-7.10, 0.404], [-6.80, 0.442], [-6.45, 0.482], [-6.10, 0.508],+ ];+ const petalGeo = await extrudeProfile(+ [[-0.24, -0.020], [0.24, -0.013], [0.24, 0.013], [-0.24, 0.020]],+ { depth: 0.140, axis: 'z', center: true }+ );+ const shingleGeo = await extrudeProfile(+ [[-0.19, -0.022], [0.19, -0.014], [0.19, 0.014], [-0.19, 0.022]],+ { depth: 0.152, axis: 'z', center: true }+ );+ for (let side = -1; side <= 1; side += 2) {+ const nm = side > 0 ? 'Right' : 'Left';+ const zc = side * 0.50, yc = 1.780;+ const noz = createPart('Nozzle' + nm, revolveClosed(nozProfile, 24, 'x'), nozzleMat, { parent: root });+ noz.position.set(0, yc, zc);+ // afterburner interior + flame holder+ createPart('BurnerCan' + nm, cylinderXGeo(0.375, 0.375, 1.30, 16), burnt, { position: [-6.85, yc, zc], parent: root });+ createPart('TurbineFace' + nm, cylinderXGeo(0.36, 0.36, 0.06, 16), black, { position: [-6.55, yc, zc], parent: root });+ createPart('FlameCone' + nm, coneXGeo(0.16, 0.55, 12), burnt, { position: [-6.90, yc, zc], parent: root });++ const count = 20;+ let petal0 = null, shing0 = null;+ for (let i = 0; i < count; i++) {+ const a = (i / count) * 360;+ const ar = a * D2R;+ const py = yc + 0.418 * Math.cos(ar), pz = zc + 0.418 * Math.sin(ar);+ if (i === 0) petal0 = createPart('NozzlePetal' + nm + i, petalGeo, nozzleMat, { position: [-7.30, py, pz], rotation: [a, 0, 0], parent: root });+ else createInstance('NozzlePetal' + nm + i, petal0, { position: [-7.30, py, pz], rotation: [a, 0, 0], parent: root });+ const b = ((i + 0.5) / count) * 360, br = b * D2R;+ const sy = yc + 0.478 * Math.cos(br), sz = zc + 0.478 * Math.sin(br);+ if (i === 0) shing0 = createPart('NozzleShingle' + nm + i, shingleGeo, nozzleMat, { position: [-7.00, sy, sz], rotation: [b, 0, 0], parent: root });+ else createInstance('NozzleShingle' + nm + i, shing0, { position: [-7.00, sy, sz], rotation: [b, 0, 0], parent: root });+ }+ // actuator rods around the nozzle throat+ for (let i = 0; i < 6; i++) {+ const a = (i / 6) * Math.PI * 2 + 0.4;+ beamBetween('NozzleActuator' + nm + i,+ [-6.55, yc + 0.55 * Math.cos(a), zc + 0.55 * Math.sin(a)],+ [-7.05, yc + 0.475 * Math.cos(a), zc + 0.475 * Math.sin(a)],+ 0.026, steel, { parent: root });+ }+ }+ // ventral fairing between the two engine bays+ createPart('EngineBayFairing', capsuleXGeo(0.22, 1.9, 10), skinDark, { position: [-6.10, 1.44, 0], parent: root });++ // ---------------------------------------------------------- cockpit tub+ const tub = boxGeo(2.55, 0.72, 1.14);+ createPart('CockpitTub', tub, black, { position: [4.45, 2.18, 0], parent: root });+ createPart('CockpitFloor', boxGeo(2.4, 0.06, 1.0), black, { position: [4.45, 1.86, 0], parent: root });+ // instrument panel + coaming+ createPart('InstrumentPanel', boxGeo(0.10, 0.46, 0.90), black, { position: [5.42, 2.24, 0], rotation: [0, 0, 18], parent: root });+ createPart('PanelGlare', await roundedBoxGeo(0.34, 0.10, 1.00, 0.035, { segments: 3 }), black, { position: [5.30, 2.47, 0], parent: root });+ createPart('MFD_Centre', decalBox(0.24, 0.24, 0.02), gameMaterial(0x123a2e, { emissive: 0x1d7a5a, emissiveIntensity: 0.5 }), { position: [5.37, 2.26, 0], rotation: [0, 0, 18], parent: root });+ createPart('MFD_Left', decalBox(0.18, 0.18, 0.02), gameMaterial(0x123a2e, { emissive: 0x1d7a5a, emissiveIntensity: 0.5 }), { position: [5.38, 2.24, -0.30], rotation: [0, 0, 18], parent: root });+ createPart('MFD_Right', decalBox(0.18, 0.18, 0.02), gameMaterial(0x123a2e, { emissive: 0x1d7a5a, emissiveIntensity: 0.5 }), { position: [5.38, 2.24, 0.30], rotation: [0, 0, 18], parent: root });+ // HUD+ createPart('HudBody', await roundedBoxGeo(0.26, 0.20, 0.34, 0.03, { segments: 3 }), black, { position: [5.30, 2.62, 0], parent: root });+ createPart('HudCombiner', decalBox(0.30, 0.30, 0.012), glass, { position: [5.22, 2.79, 0], rotation: [0, 0, 15], parent: root });+ createPart('HudCombiner2', decalBox(0.26, 0.26, 0.012), glass, { position: [5.36, 2.77, 0], rotation: [0, 0, 8], parent: root });+ // ejection seat+ createPart('SeatPan', await roundedBoxGeo(0.52, 0.10, 0.50, 0.03, { segments: 3 }), gameMaterial(0x2c3138, { roughness: 0.85 }), { position: [4.10, 2.10, 0], parent: root });+ createPart('SeatBack', await roundedBoxGeo(0.16, 0.66, 0.50, 0.04, { segments: 3 }), gameMaterial(0x2c3138, { roughness: 0.85 }), { position: [3.86, 2.36, 0], rotation: [0, 0, -12], parent: root });+ createPart('SeatHeadbox', await roundedBoxGeo(0.24, 0.30, 0.44, 0.05, { segments: 3 }), gameMaterial(0x33383f, { roughness: 0.85 }), { position: [3.79, 2.72, 0], parent: root });+ createPart('SeatHandle', cylinderZGeo(0.022, 0.022, 0.32, 8), gameMaterial(0xd8b400, { roughness: 0.5 }), { position: [3.86, 2.88, 0], parent: root });+ createPart('ControlStick', cylinderYGeo(0.022, 0.028, 0.30, 8), black, { position: [4.55, 2.10, 0], parent: root });+ createPart('StickGrip', capsuleYGeo(0.038, 0.12, 8), gameMaterial(0x24282d, { roughness: 0.9 }), { position: [4.55, 2.28, 0], parent: root });+ createPart('ThrottleQuadrant', boxGeo(0.34, 0.08, 0.10), black, { position: [4.75, 2.16, -0.44], parent: root });++ // --------------------------------------------------------- bubble canopy+ const canTable = [+ [5.95, 0.30, 0.18, 2.500], [5.70, 0.42, 0.36, 2.500], [5.40, 0.52, 0.55, 2.500],+ [5.00, 0.60, 0.70, 2.510], [4.50, 0.64, 0.78, 2.520], [4.00, 0.64, 0.78, 2.530],+ [3.50, 0.60, 0.70, 2.540], [3.10, 0.52, 0.52, 2.550], [2.85, 0.44, 0.30, 2.560],+ ];+ function canopyRing(x, w, h, sy) {+ const ring = [];+ const n = 12;+ for (let i = 0; i <= n; i++) {+ const a = (i / n) * Math.PI;+ ring.push([x, sy + h * Math.pow(Math.sin(a), 0.78), w * Math.cos(a)]);+ }+ for (let i = n - 1; i >= 1; i--) {+ const a = (i / n) * Math.PI;+ ring.push([x, sy - 0.05, w * Math.cos(a) * 0.985]);+ }+ return ring;+ }+ const canopySections = canTable.map(function (r) { return canopyRing(r[0], r[1], r[2], r[3]); });+ createPart('Canopy', loftGeo(canopySections, {}), glass, { parent: root });++ // canopy framing: windscreen bow, rear bow, and the two sill rails+ function archPath(x, w, h, sy, scale) {+ const pts = [];+ const n = 14;+ for (let i = 0; i <= n; i++) {+ const a = (i / n) * Math.PI;+ pts.push([x, sy + h * scale * Math.pow(Math.sin(a), 0.78), w * scale * Math.cos(a)]);+ }+ return pts;+ }+ createPart('WindscreenBow', curveToMesh(archPath(5.40, 0.52, 0.55, 2.500, 1.015), 0.030, 20, 6), skinDark, { parent: root });+ createPart('CanopyRearBow', curveToMesh(archPath(2.87, 0.44, 0.30, 2.560, 1.015), 0.030, 20, 6), skinDark, { parent: root });+ for (let side = -1; side <= 1; side += 2) {+ const rail = [];+ for (let i = 0; i < canTable.length; i++) rail.push([canTable[i][0], canTable[i][3] - 0.03, side * canTable[i][1] * 1.01]);+ createPart('CockpitSill' + (side > 0 ? 'Right' : 'Left'), curveToMesh(rail, 0.036, 26, 6), skinDark, { parent: root });+ }+ createPart('CanopyActuator', boxGeo(0.55, 0.09, 0.09), steel, { position: [3.05, 2.62, 0], parent: root });++ // -------------------------------------------------------- landing gear+ // shared wheel builder+ function makeWheel(name, cx, cy, cz, R, W, parent) {+ const rBead = R * 0.62;+ const tyre = [+ [-W / 2, rBead], [W / 2, rBead], [W / 2, rBead + (R - rBead) * 0.30], [W * 0.44, rBead + (R - rBead) * 0.72],+ [W * 0.34, R * 0.995], [W * 0.16, R], [-W * 0.16, R], [-W * 0.34, R * 0.995],+ [-W * 0.44, rBead + (R - rBead) * 0.72], [-W / 2, rBead + (R - rBead) * 0.30],+ ];+ const t = createPart(name + 'Tyre', revolveClosed(tyre, 22, 'z'), rubber, { parent: parent });+ t.position.set(cx, cy, cz);+ const rimProf = [+ [-W * 0.40, R * 0.28], [W * 0.40, R * 0.28], [W * 0.40, rBead * 1.02], [W * 0.18, rBead * 1.02],+ [W * 0.10, R * 0.50], [-W * 0.10, R * 0.50], [-W * 0.18, rBead * 1.02], [-W * 0.40, rBead * 1.02],+ ];+ const rim = createPart(name + 'Rim', revolveClosed(rimProf, 18, 'z'), gameMaterial(0x9aa0a6, { metalness: 0.85, roughness: 0.35 }), { parent: parent });+ rim.position.set(cx, cy, cz);+ createPart(name + 'Hub', cylinderZGeo(R * 0.24, R * 0.20, W * 0.95, 12), steel, { position: [cx, cy, cz], parent: parent });+ for (let i = 0; i < 6; i++) {+ const a = (i / 6) * Math.PI * 2;+ createPart(name + 'Bolt' + i, cylinderZGeo(0.022, 0.022, W * 0.86, 6), steel,+ { position: [cx + R * 0.36 * Math.cos(a), cy + R * 0.36 * Math.sin(a), cz], parent: parent });+ }+ createPart(name + 'Brake', cylinderZGeo(R * 0.52, R * 0.52, W * 0.30, 14), gameMaterial(0x585d63, { metalness: 0.8, roughness: 0.55 }),+ { position: [cx, cy, cz - Math.sign(cz || 1) * W * 0.42], parent: parent });+ }++ // --- nose gear ---+ const ng = createPivot('NoseGear', [0, 0, 0], root);+ createPart('NoseBayRoof', boxGeo(1.5, 0.10, 0.70), black, { position: [4.60, 1.36, 0], parent: ng });+ createPart('NoseTrunnion', await roundedBoxGeo(0.34, 0.24, 0.34, 0.04, { segments: 3 }), skinDark, { position: [4.78, 1.30, 0], parent: ng });+ createPart('NoseOleoBarrel', cylinderYGeo(0.088, 0.095, 0.60, 12), gameMaterial(0x767c83, { metalness: 0.8, roughness: 0.4 }), { position: [4.72, 1.02, 0], rotation: [0, 0, 5], parent: ng });+ createPart('NoseOleoPiston', cylinderYGeo(0.062, 0.062, 0.42, 12), steel, { position: [4.66, 0.70, 0], rotation: [0, 0, 5], parent: ng });+ createPart('NoseForkYokeL', boxGeo(0.12, 0.30, 0.05), gameMaterial(0x767c83, { metalness: 0.8, roughness: 0.4 }), { position: [4.63, 0.45, -0.145], parent: ng });+ createPart('NoseForkYokeR', boxGeo(0.12, 0.30, 0.05), gameMaterial(0x767c83, { metalness: 0.8, roughness: 0.4 }), { position: [4.63, 0.45, 0.145], parent: ng });+ createPart('NoseAxle', cylinderZGeo(0.040, 0.040, 0.34, 10), steel, { position: [4.62, 0.32, 0], parent: ng });+ makeWheel('NoseWheel', 4.62, 0.32, 0.0, 0.32, 0.20, ng);+ beamBetween('NoseDragBrace', [4.86, 1.24, 0], [5.44, 1.42, 0], 0.038, steel, { parent: ng });+ beamBetween('NoseTorqueUpper', [4.58, 1.00, 0.10], [4.55, 0.80, 0.06], 0.022, steel, { parent: ng });+ beamBetween('NoseTorqueLower', [4.55, 0.80, 0.06], [4.55, 0.58, 0.10], 0.022, steel, { parent: ng });+ createPart('TaxiLight', await roundedBoxGeo(0.10, 0.12, 0.18, 0.02, { segments: 3 }), lightW, { position: [4.86, 0.92, 0], parent: ng });+ createPart('NoseDoorL', boxGeo(1.20, 0.035, 0.42), skin, { position: [4.60, 1.24, -0.44], rotation: [-62, 0, 0], parent: ng });+ createPart('NoseDoorR', boxGeo(1.20, 0.035, 0.42), skin, { position: [4.60, 1.24, 0.44], rotation: [62, 0, 0], parent: ng });++ // --- main gear ---+ for (let side = -1; side <= 1; side += 2) {+ const nm = side > 0 ? 'Right' : 'Left';+ const mg = createPivot('MainGear' + nm, [0, 0, 0], root);+ createPart('MainBayRoof' + nm, boxGeo(1.7, 0.10, 0.78), black, { position: [-1.55, 1.16, side * 1.20], parent: mg });+ createPart('MainTrunnion' + nm, await roundedBoxGeo(0.40, 0.26, 0.30, 0.04, { segments: 3 }), skinDark, { position: [-1.40, 1.14, side * 1.10], parent: mg });+ beamBetween('MainOleoBarrel' + nm, [-1.44, 1.14, side * 1.12], [-1.58, 0.66, side * 1.36], 0.090, gameMaterial(0x767c83, { metalness: 0.8, roughness: 0.4 }), { parent: mg });+ beamBetween('MainOleoPiston' + nm, [-1.57, 0.72, side * 1.35], [-1.62, 0.46, side * 1.42], 0.062, steel, { parent: mg });+ beamBetween('MainDragBrace' + nm, [-1.46, 1.06, side * 1.16], [-2.46, 1.20, side * 0.98], 0.045, steel, { parent: mg });+ beamBetween('MainSideStay' + nm, [-1.52, 0.92, side * 1.26], [-1.50, 1.14, side * 0.72], 0.038, steel, { parent: mg });+ beamBetween('MainTorqueUpper' + nm, [-1.44, 0.96, side * 1.28], [-1.42, 0.78, side * 1.33], 0.022, steel, { parent: mg });+ beamBetween('MainTorqueLower' + nm, [-1.42, 0.78, side * 1.33], [-1.48, 0.56, side * 1.38], 0.022, steel, { parent: mg });+ createPart('MainAxle' + nm, cylinderZGeo(0.048, 0.048, 0.42, 10), steel, { position: [-1.62, 0.46, side * 1.42], parent: mg });+ makeWheel('MainWheel' + nm, -1.62, 0.46, side * 1.52, 0.46, 0.30, mg);+ createPart('MainDoor' + nm, boxGeo(1.45, 0.04, 0.50), skin, { position: [-1.55, 1.04, side * 1.02], rotation: [side * 68, 0, 0], parent: mg });+ createPart('MainDoorAft' + nm, boxGeo(0.62, 0.04, 0.36), skin, { position: [-2.40, 1.10, side * 1.24], rotation: [side * 48, 0, 0], parent: mg });+ }++ // -------------------------------------------------------------- pylons+ const pylonGeo = await roundedBoxGeo(1.85, 0.36, 0.22, 0.055, { segments: 3 });+ const pylonNose = await roundedBoxGeo(0.42, 0.24, 0.20, 0.075, { segments: 3 });+ const pylonSpec = [+ { z: 2.30, x: 0.20, yTop: 1.815 },+ { z: 3.55, x: -0.20, yTop: 1.905 },+ ];+ for (let side = -1; side <= 1; side += 2) {+ for (let i = 0; i < pylonSpec.length; i++) {+ const p = pylonSpec[i];+ const nm = (side > 0 ? 'R' : 'L') + (i === 0 ? 'Inner' : 'Outer');+ createPart('Pylon' + nm, pylonGeo, skinDark, { position: [p.x, p.yTop - 0.20, side * p.z], parent: root });+ createPart('PylonNose' + nm, pylonNose, skinDark, { position: [p.x + 1.05, p.yTop - 0.14, side * p.z], parent: root });+ createPart('PylonShoe' + nm, boxGeo(1.60, 0.05, 0.30), skinDark, { position: [p.x, p.yTop - 0.02, side * p.z], parent: root });+ // sway braces and the ejector-rack lugs+ for (let k = 0; k < 2; k++) {+ createPart('SwayBrace' + nm + k, cylinderYGeo(0.026, 0.026, 0.16, 6), steel, { position: [p.x - 0.30 + k * 0.60, p.yTop - 0.44, side * (p.z + 0.10)], parent: root });+ createPart('SwayBrace' + nm + 'b' + k, cylinderYGeo(0.026, 0.026, 0.16, 6), steel, { position: [p.x - 0.30 + k * 0.60, p.yTop - 0.44, side * (p.z - 0.10)], parent: root });+ }+ createPart('PylonLug' + nm, boxGeo(0.10, 0.10, 0.16), steel, { position: [p.x, p.yTop - 0.40, side * p.z], parent: root });+ }+ }++ // ------------------------------------------------------- surface detail+ // gun port and gas-purge vents on the left LERX shoulder+ createPart('GunPort', cylinderXGeo(0.055, 0.055, 0.22, 10), black, { position: [5.05, 2.16, -0.86], rotation: [0, 0, 0], parent: root });+ createPart('GunFairing', capsuleXGeo(0.10, 0.70, 10), skinDark, { position: [4.70, 2.14, -0.86], parent: root });+ for (let i = 0; i < 3; i++) createPart('GunVent' + i, decalBox(0.16, 0.05, 0.012), black, { position: [4.35 - i * 0.22, 2.20, -0.84], rotation: [0, 0, 0], parent: root });++ // in-flight refuelling receptacle door on the spine+ createPart('RefuelDoor', decalBox(0.42, 0.24, 0.02), skinDark, { position: [2.30, 2.72, 0.18], rotation: [-14, 0, 0], parent: root });++ // upper-surface airbrakes, cracked open either side of the spine+ for (let side = -1; side <= 1; side += 2) {+ createPart('Airbrake' + (side > 0 ? 'R' : 'L'), boxGeo(1.05, 0.05, 0.52), skinDark,+ { position: [-3.05, 2.60, side * 0.62], rotation: [0, 0, -9], parent: root });+ }++ // AoA vanes, angle-of-sideslip probe, and blade antennas+ for (let side = -1; side <= 1; side += 2) {+ createPart('AoaVane' + (side > 0 ? 'R' : 'L'), boxGeo(0.20, 0.05, 0.02), black, { position: [7.10, 2.02, side * 0.51], parent: root });+ createPart('AoaBoss' + (side > 0 ? 'R' : 'L'), cylinderZGeo(0.045, 0.045, 0.06, 8), skinDark, { position: [7.02, 2.02, side * 0.50], parent: root });+ }+ createPart('BladeAntennaTop', boxGeo(0.34, 0.20, 0.03), skinDark, { position: [0.60, 2.85, 0], rotation: [0, 0, -8], parent: root });+ createPart('BladeAntennaBelly', boxGeo(0.30, 0.18, 0.03), skinDark, { position: [3.00, 1.14, 0], rotation: [0, 0, 8], parent: root });++ // formation-light strips and anti-collision beacons+ for (let side = -1; side <= 1; side += 2) {+ createPart('FormLightFwd' + (side > 0 ? 'R' : 'L'), decalBox(0.70, 0.07, 0.012), lightW, { position: [3.60, 2.02, side * 1.01], rotation: [0, 0, 0], parent: root });+ createPart('FormLightAft' + (side > 0 ? 'R' : 'L'), decalBox(0.70, 0.07, 0.012), lightW, { position: [-2.60, 2.06, side * 1.24], rotation: [0, 0, 0], parent: root });+ }+ createPart('BeaconTop', capsuleYGeo(0.055, 0.06, 8), lightR, { position: [-1.20, 2.70, 0], parent: root });+ createPart('BeaconBelly', capsuleYGeo(0.055, 0.06, 8), lightR, { position: [-0.60, 1.10, 0], parent: root });+ createPart('TailLight', capsuleXGeo(0.05, 0.10, 8), lightW, { position: [-7.06, 2.30, 0], parent: root });++ // access panels along the spine and wing roots+ const panelSpec = [+ [1.60, 2.66, 0.55, 0.60, 0.44], [0.30, 2.66, 0.60, 0.60, 0.44], [-1.10, 2.62, 0.60, 0.60, 0.44],+ [-2.20, 2.55, 0.62, 0.50, 0.40], [-4.00, 2.48, 0.60, 0.60, 0.40],+ ];+ for (let i = 0; i < panelSpec.length; i++) {+ const p = panelSpec[i];+ for (let side = -1; side <= 1; side += 2) {+ createPart('Panel' + i + (side > 0 ? 'R' : 'L'), decalBox(p[3], p[4], 0.015), skinDark,+ { position: [p[0], p[1], side * p[2]], rotation: [90, 0, 0], parent: root });+ }+ }++ return root;+}diff --git a/examples/fire-lookout-tower.kiln.js b/examples/fire-lookout-tower.kiln.jsnew file mode 100644index 00000000..3203e0ec--- /dev/null+++ b/examples/fire-lookout-tower.kiln.js@@ -0,0 +1,234 @@+// Authored by: meituan/longcat-2.0:free, via hermes.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'FireLookoutTower', category: 'architecture', role: 'building' };++function build() {+ const root = createRoot('FireLookoutTower');++ const steel = gameMaterial(0x8B7355, { roughness: 0.6, metalness: 0.7 });+ const darkSteel = gameMaterial(0x404040, { roughness: 0.5, metalness: 0.8 });+ const glass = glassMaterial(0x88CCFF, { opacity: 0.35 });+ const brass = gameMaterial(0xB8860B, { roughness: 0.3, metalness: 0.9 });++ const H = 10;+ const baseHalf = 1.5;+ const topHalf = 0.75;++ function halfW(y) {+ return baseHalf * (1 - y / H) + topHalf * (y / H);+ }++ function corner(y, sx, sz) {+ return [sx * halfW(y), y, sz * halfW(y)];+ }++ const levels = [0, 2, 4, 6, 8, 10];++ // Four battered legs+ const signs = [[1, 1], [1, -1], [-1, 1], [-1, -1]];+ for (const [sx, sz] of signs) {+ beamBetween(`Leg_${sx}_${sz}`, corner(0, sx, sz), corner(H, sx, sz), 0.05, steel, { parent: root, segments: 12 });+ }++ // Horizontal rings at each level+ for (let i = 0; i < levels.length; i++) {+ const y = levels[i];+ const hw = halfW(y);+ const r = 0.03;+ beamBetween(`Ring_${i}_FR`, [hw, y, hw], [hw, y, -hw], r, steel, { parent: root });+ beamBetween(`Ring_${i}_FL`, [hw, y, -hw], [-hw, y, -hw], r, steel, { parent: root });+ beamBetween(`Ring_${i}_BL`, [-hw, y, -hw], [-hw, y, hw], r, steel, { parent: root });+ beamBetween(`Ring_${i}_BR`, [-hw, y, hw], [hw, y, hw], r, steel, { parent: root });+ }++ // X-bracing on each face between levels+ for (let i = 0; i < levels.length - 1; i++) {+ const yLow = levels[i];+ const yHigh = levels[i + 1];+ const r = 0.025;++ const faceDefs = [+ { name: 'F', c1: [1, 1], c2: [1, -1] },+ { name: 'L', c1: [1, -1], c2: [-1, -1] },+ { name: 'B', c1: [-1, -1], c2: [-1, 1] },+ { name: 'R', c1: [-1, 1], c2: [1, 1] },+ ];++ for (const face of faceDefs) {+ const pLow1 = corner(yLow, face.c1[0], face.c1[1]);+ const pLow2 = corner(yLow, face.c2[0], face.c2[1]);+ const pHigh1 = corner(yHigh, face.c1[0], face.c1[1]);+ const pHigh2 = corner(yHigh, face.c2[0], face.c2[1]);++ beamBetween(`Brace_${face.name}_${i}A`, pLow1, pHigh2, r, steel, { parent: root });+ beamBetween(`Brace_${face.name}_${i}B`, pLow2, pHigh1, r, steel, { parent: root });+ }+ }++ // Switchback stairs climbing the front face (+X)+ const stairLevels = [0, 2, 4, 6, 8];+ for (let i = 0; i < stairLevels.length; i++) {+ const yBase = stairLevels[i];+ const yTop = yBase + 2;+ const dir = i % 2 === 0 ? 1 : -1;+ const stepsPerFlight = 10;+ const stepDepth = 0.3;+ const stairWidth = 0.7;++ for (let s = 0; s < stepsPerFlight; s++) {+ const frac0 = s / stepsPerFlight;+ const frac1 = (s + 1) / stepsPerFlight;+ const y0 = yBase + frac0 * 2;+ const y1 = yBase + frac1 * 2;+ const hw0 = halfW(y0);+ const hw1 = halfW(y1);+ const z0 = dir * (stairWidth / 2) * (1 - 2 * frac0);+ const z1 = dir * (stairWidth / 2) * (1 - 2 * frac1);++ const midY = (y0 + y1) / 2;+ const midHW = halfW(midY);+ const midZ = (z0 + z1) / 2;++ // Step tread — sits right on the tower face+ createPart(`Stair_${i}_${s}`, boxGeo(stepDepth, 0.04, stairWidth / stepsPerFlight + 0.02), darkSteel, {+ position: [midHW + 0.05, midY + 0.05, midZ],+ parent: root,+ });+ }++ // Stringers (side beams) for this flight+ const zStart = dir * stairWidth / 2;+ const zEnd = -dir * stairWidth / 2;+ const hwLow = halfW(yBase);+ const hwHigh = halfW(yTop);+ beamBetween(`Stringer_${i}_L`, [hwLow + 0.05, yBase + 0.02, zStart], [hwHigh + 0.05, yTop + 0.02, zEnd], 0.02, steel, { parent: root });+ beamBetween(`Stringer_${i}_R`, [hwLow + 0.05 + stepDepth, yBase + 0.02, zStart], [hwHigh + 0.05 + stepDepth, yTop + 0.02, zEnd], 0.02, steel, { parent: root });++ // Landing at top of each flight+ const hwTop = halfW(yTop);+ createPart(`Landing_${i}`, boxGeo(stepDepth + 0.1, 0.05, stairWidth + 0.2), darkSteel, {+ position: [hwTop + 0.1, yTop + 0.025, 0],+ parent: root,+ });+ }++ // Cab on top - square glazed room+ const cabSize = 1.8;+ const cabY = H;+ const cabWallH = 2.2;+ const wallThk = 0.06;+ const cabHalf = cabSize / 2;++ createPart('CabFloor', boxGeo(cabSize, 0.1, cabSize), darkSteel, { position: [0, cabY, 0], parent: root });++ // Build each wall as a frame with glass infill+ // Front wall (+X) — door opening+ const frontFrameZ = cabHalf - 0.2;+ createPart('FrameFrontL', boxGeo(wallThk, cabWallH, 0.4), steel, { position: [cabHalf, cabY + 0.1 + cabWallH / 2, -frontFrameZ], parent: root });+ createPart('FrameFrontR', boxGeo(wallThk, cabWallH, 0.4), steel, { position: [cabHalf, cabY + 0.1 + cabWallH / 2, frontFrameZ], parent: root });+ createPart('FrameFrontTop', boxGeo(wallThk, 0.25, cabSize), steel, { position: [cabHalf, cabY + 0.1 + cabWallH - 0.125, 0], parent: root });+ createPart('FrameFrontBot', boxGeo(wallThk, 0.15, cabSize), steel, { position: [cabHalf, cabY + 0.1 + 0.075, 0], parent: root });+ createPart('GlassFront', boxGeo(0.02, cabWallH - 0.5, cabSize - 0.8), glass, { position: [cabHalf + 0.02, cabY + 0.1 + cabWallH / 2, 0], parent: root });+ createPart('MullionFrontV', boxGeo(wallThk + 0.01, cabWallH - 0.5, 0.04), steel, { position: [cabHalf, cabY + 0.1 + cabWallH / 2, 0], parent: root });++ // Back wall (-X) — full glass with mullions+ createPart('FrameBackL', boxGeo(wallThk, cabWallH, 0.4), steel, { position: [-cabHalf, cabY + 0.1 + cabWallH / 2, -frontFrameZ], parent: root });+ createPart('FrameBackR', boxGeo(wallThk, cabWallH, 0.4), steel, { position: [-cabHalf, cabY + 0.1 + cabWallH / 2, frontFrameZ], parent: root });+ createPart('FrameBackTop', boxGeo(wallThk, 0.25, cabSize), steel, { position: [-cabHalf, cabY + 0.1 + cabWallH - 0.125, 0], parent: root });+ createPart('FrameBackBot', boxGeo(wallThk, 0.15, cabSize), steel, { position: [-cabHalf, cabY + 0.1 + 0.075, 0], parent: root });+ createPart('GlassBack', boxGeo(0.02, cabWallH - 0.5, cabSize - 0.8), glass, { position: [-cabHalf - 0.02, cabY + 0.1 + cabWallH / 2, 0], parent: root });+ createPart('MullionBackV', boxGeo(wallThk + 0.01, cabWallH - 0.5, 0.04), steel, { position: [-cabHalf, cabY + 0.1 + cabWallH / 2, 0], parent: root });++ // Left wall (-Z) — full glass with mullions+ createPart('FrameLeftF', boxGeo(0.4, cabWallH, wallThk), steel, { position: [-frontFrameZ, cabY + 0.1 + cabWallH / 2, -cabHalf], parent: root });+ createPart('FrameLeftB', boxGeo(0.4, cabWallH, wallThk), steel, { position: [frontFrameZ, cabY + 0.1 + cabWallH / 2, -cabHalf], parent: root });+ createPart('FrameLeftTop', boxGeo(cabSize, 0.25, wallThk), steel, { position: [0, cabY + 0.1 + cabWallH - 0.125, -cabHalf], parent: root });+ createPart('FrameLeftBot', boxGeo(cabSize, 0.15, wallThk), steel, { position: [0, cabY + 0.1 + 0.075, -cabHalf], parent: root });+ createPart('GlassLeft', boxGeo(cabSize - 0.8, cabWallH - 0.5, 0.02), glass, { position: [0, cabY + 0.1 + cabWallH / 2, -cabHalf - 0.02], parent: root });+ createPart('MullionLeftV', boxGeo(0.04, cabWallH - 0.5, wallThk + 0.01), steel, { position: [0, cabY + 0.1 + cabWallH / 2, -cabHalf], parent: root });++ // Right wall (+Z) — full glass with mullions+ createPart('FrameRightF', boxGeo(0.4, cabWallH, wallThk), steel, { position: [-frontFrameZ, cabY + 0.1 + cabWallH / 2, cabHalf], parent: root });+ createPart('FrameRightB', boxGeo(0.4, cabWallH, wallThk), steel, { position: [frontFrameZ, cabY + 0.1 + cabWallH / 2, cabHalf], parent: root });+ createPart('FrameRightTop', boxGeo(cabSize, 0.25, wallThk), steel, { position: [0, cabY + 0.1 + cabWallH - 0.125, cabHalf], parent: root });+ createPart('FrameRightBot', boxGeo(cabSize, 0.15, wallThk), steel, { position: [0, cabY + 0.1 + 0.075, cabHalf], parent: root });+ createPart('GlassRight', boxGeo(cabSize - 0.8, cabWallH - 0.5, 0.02), glass, { position: [0, cabY + 0.1 + cabWallH / 2, cabHalf + 0.02], parent: root });+ createPart('MullionRightV', boxGeo(0.04, cabWallH - 0.5, wallThk + 0.01), steel, { position: [0, cabY + 0.1 + cabWallH / 2, cabHalf], parent: root });++ // Hipped roof (pyramid)+ const roofBaseY = cabY + 0.1 + cabWallH;+ const roofH = 0.9;+ const roofOverhang = 0.3;+ const roofHalf = cabSize / 2 + roofOverhang;++ createPart('Roof', coneGeo(roofHalf, roofH, 4), darkSteel, {+ position: [0, roofBaseY + roofH / 2, 0],+ parent: root,+ });++ // Roof fascia (trim at eave edge)+ const fasciaH = 0.08;+ beamBetween('FasciaFront', [roofHalf, roofBaseY + fasciaH / 2, roofHalf], [roofHalf, roofBaseY + fasciaH / 2, -roofHalf], 0.02, steel, { parent: root });+ beamBetween('FasciaBack', [-roofHalf, roofBaseY + fasciaH / 2, roofHalf], [-roofHalf, roofBaseY + fasciaH / 2, -roofHalf], 0.02, steel, { parent: root });+ beamBetween('FasciaLeft', [roofHalf, roofBaseY + fasciaH / 2, -roofHalf], [-roofHalf, roofBaseY + fasciaH / 2, -roofHalf], 0.02, steel, { parent: root });+ beamBetween('FasciaRight', [roofHalf, roofBaseY + fasciaH / 2, roofHalf], [-roofHalf, roofBaseY + fasciaH / 2, roofHalf], 0.02, steel, { parent: root });++ // Catwalk around cab+ const cwWidth = 0.9;+ const cwY = cabY + 0.1;+ const outerHalf = cabSize / 2 + cwWidth;++ // Catwalk floor+ createPart('CatwalkFront', boxGeo(cwWidth, 0.04, cabSize + cwWidth * 2), darkSteel, { position: [cabSize / 2 + cwWidth / 2, cwY, 0], parent: root });+ createPart('CatwalkBack', boxGeo(cwWidth, 0.04, cabSize + cwWidth * 2), darkSteel, { position: [-cabSize / 2 - cwWidth / 2, cwY, 0], parent: root });+ createPart('CatwalkLeft', boxGeo(cabSize + cwWidth * 2, 0.04, cwWidth), darkSteel, { position: [0, cwY, -cabSize / 2 - cwWidth / 2], parent: root });+ createPart('CatwalkRight', boxGeo(cabSize + cwWidth * 2, 0.04, cwWidth), darkSteel, { position: [0, cwY, cabSize / 2 + cwWidth / 2], parent: root });++ // Pipe railings around catwalk+ const railH = 1.0;+ const railR = 0.02;++ // Top rails+ beamBetween('RailFrontTop', [outerHalf, cwY + railH, -outerHalf], [outerHalf, cwY + railH, outerHalf], railR, steel, { parent: root });+ beamBetween('RailBackTop', [-outerHalf, cwY + railH, -outerHalf], [-outerHalf, cwY + railH, outerHalf], railR, steel, { parent: root });+ beamBetween('RailLeftTop', [-outerHalf, cwY + railH, -outerHalf], [outerHalf, cwY + railH, -outerHalf], railR, steel, { parent: root });+ beamBetween('RailRightTop', [-outerHalf, cwY + railH, outerHalf], [outerHalf, cwY + railH, outerHalf], railR, steel, { parent: root });++ // Mid rails+ beamBetween('RailFrontMid', [outerHalf, cwY + 0.5, -outerHalf], [outerHalf, cwY + 0.5, outerHalf], railR, steel, { parent: root });+ beamBetween('RailBackMid', [-outerHalf, cwY + 0.5, -outerHalf], [-outerHalf, cwY + 0.5, outerHalf], railR, steel, { parent: root });+ beamBetween('RailLeftMid', [-outerHalf, cwY + 0.5, -outerHalf], [outerHalf, cwY + 0.5, -outerHalf], railR, steel, { parent: root });+ beamBetween('RailRightMid', [-outerHalf, cwY + 0.5, outerHalf], [outerHalf, cwY + 0.5, outerHalf], railR, steel, { parent: root });++ // Corner posts+ const corners = [[outerHalf, -outerHalf], [outerHalf, outerHalf], [-outerHalf, -outerHalf], [-outerHalf, outerHalf]];+ for (const [x, z] of corners) {+ beamBetween(`Post_${x}_${z}`, [x, cwY, z], [x, cwY + railH, z], railR * 1.5, steel, { parent: root });+ }+ // Midpoint posts+ const mids = [[outerHalf, 0], [-outerHalf, 0], [0, -outerHalf], [0, outerHalf]];+ for (const [x, z] of mids) {+ beamBetween(`PostMid_${x}_${z}`, [x, cwY, z], [x, cwY + railH, z], railR, steel, { parent: root });+ }++ // Lightning rod and antenna on the roof peak+ const rodBaseY = roofBaseY + roofH;+ createPart('LightningRod', cylinderGeo(0.008, 0.015, 1.8, 8), steel, { position: [0, rodBaseY + 0.9, 0], parent: root });+ createPart('Antenna', cylinderGeo(0.006, 0.01, 2.5, 8), steel, { position: [0.5, rodBaseY + 1.25, 0.3], parent: root });++ // Toe board around catwalk (small lip at floor edge)+ const toeH = 0.1;+ beamBetween('ToeFront', [outerHalf, cwY + toeH / 2, -outerHalf], [outerHalf, cwY + toeH / 2, outerHalf], 0.015, steel, { parent: root });+ beamBetween('ToeBack', [-outerHalf, cwY + toeH / 2, -outerHalf], [-outerHalf, cwY + toeH / 2, outerHalf], 0.015, steel, { parent: root });+ beamBetween('ToeLeft', [-outerHalf, cwY + toeH / 2, -outerHalf], [outerHalf, cwY + toeH / 2, -outerHalf], 0.015, steel, { parent: root });+ beamBetween('ToeRight', [-outerHalf, cwY + toeH / 2, outerHalf], [outerHalf, cwY + toeH / 2, outerHalf], 0.015, steel, { parent: root });++ return root;+}diff --git a/examples/gothic-gatehouse.kiln.js b/examples/gothic-gatehouse.kiln.jsnew file mode 100644index 00000000..7664fcd8--- /dev/null+++ b/examples/gothic-gatehouse.kiln.js@@ -0,0 +1,864 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'GothicGatehouse', category: 'architecture', role: 'building' };++function build() {+ const root = createRoot('GothicGatehouse');++ // ==========================================+ // MATERIALS (High quality PBR palette, 5 materials)+ // ==========================================+ const stoneAshlar = gameMaterial(0x8e887d, { roughness: 0.88 }); // Main masonry+ const stoneDressing = gameMaterial(0x6e685f, { roughness: 0.84 }); // Trim, voussoirs, corbels, copings+ const stoneDark = gameMaterial(0x32302c, { roughness: 0.95 }); // Arrow slits, murder holes, reveals+ const oakWood = gameMaterial(0x56402a, { roughness: 0.78 }); // Drawbridge planks, cleats, gates+ const wroughtIron = gameMaterial(0x242426, { roughness: 0.52, metalness: 0.85 }); // Chains, portcullis, spikes, straps++ // ==========================================+ // DIMENSIONS & SPATIAL ANCHORS (+X forward, +Y up, +Z right)+ // ==========================================+ const towerRadius = 2.4;+ const towerHeight = 12.6;+ const towerX = 0.6; // Towers project forward for flanking fire+ const towerZ = 3.7; // +/- 3.7 along Z++ const wallDepth = 4.4; // Extends from X = -2.2 to X = +2.2+ const wallWidth = 4.6; // Spans between towers from Z = -2.3 to Z = +2.3+ const wallHeight = 8.8; // Central curtain wall height+ const passageFloorY = 0.7; // Raised ground/passage level above ditch++ // ==========================================+ // 1. FOUNDATIONS & SUBSTRUCTURE (Sitting on Y = 0)+ // ==========================================+ // Central gatehouse foundation block+ createPart('GatehouseFoundation', boxGeo(wallDepth + 0.3, passageFloorY, wallWidth + 0.2), stoneDressing, {+ position: [0, passageFloorY / 2, 0],+ parent: root+ });++ // Flagstone floor inside passage+ createPart('PassageFloor', boxGeo(wallDepth + 0.2, 0.1, 2.4), stoneAshlar, {+ position: [0, passageFloorY + 0.05, 0],+ parent: root+ });++ // ==========================================+ // 2. CENTRAL GATEHOUSE BLOCK & WALLS+ // ==========================================+ // Left and Right jamb walls+ const jambThickZ = 1.1;+ createPart('GateJambL', boxGeo(wallDepth, 3.2, jambThickZ), stoneAshlar, {+ position: [0, passageFloorY + 1.6, -1.75],+ parent: root+ });+ createPart('GateJambR', boxGeo(wallDepth, 3.2, jambThickZ), stoneAshlar, {+ position: [0, passageFloorY + 1.6, 1.75],+ parent: root+ });++ // Dressed stone jamb quoins (front entrance)+ for (let y = passageFloorY + 0.3; y <= passageFloorY + 3.2; y += 0.6) {+ createPart('JambQuoinL_' + y.toFixed(1), boxGeo(0.5, 0.26, 0.22), stoneDressing, {+ position: [wallDepth / 2 + 0.02, y, -1.2],+ parent: root+ });+ createPart('JambQuoinR_' + y.toFixed(1), boxGeo(0.5, 0.26, 0.22), stoneDressing, {+ position: [wallDepth / 2 + 0.02, y, 1.2],+ parent: root+ });+ }++ // Upper gatehouse wall (above arch springing)+ const upperWallH = wallHeight - (passageFloorY + 3.2);+ createPart('WallUpper', boxGeo(wallDepth, upperWallH, wallWidth), stoneAshlar, {+ position: [0, passageFloorY + 3.2 + upperWallH / 2, 0],+ parent: root+ });++ // Front spandrel infill above arch+ createPart('FrontSpandrel', boxGeo(0.4, 2.2, 2.5), stoneAshlar, {+ position: [wallDepth / 2 - 0.2, passageFloorY + 4.6, 0],+ parent: root+ });++ // Rear wall opening spandrel+ createPart('RearSpandrel', boxGeo(0.4, 2.2, 2.5), stoneAshlar, {+ position: [-wallDepth / 2 + 0.2, passageFloorY + 4.6, 0],+ parent: root+ });++ // Horizontal string-course mouldings on central block+ createPart('CentStringCourse1', boxGeo(wallDepth + 0.15, 0.18, wallWidth + 0.1), stoneDressing, {+ position: [0, passageFloorY + 3.3, 0],+ parent: root+ });+ createPart('CentStringCourse2', boxGeo(wallDepth + 0.15, 0.18, wallWidth + 0.1), stoneDressing, {+ position: [0, wallHeight - 0.1, 0],+ parent: root+ });++ // ==========================================+ // 3. POINTED GOTHIC ARCHWAY & PORTAL+ // ==========================================+ // Equilateral pointed arch:+ // Springing points at Z = +/-1.2, Y = passageFloorY + 3.2 = 3.9+ // Apex at Z = 0, Y = 3.9 + 2.08 = 5.98+ const archSpringY = passageFloorY + 3.2;+ const archSpan = 2.4;+ const archR = archSpan;+ const voussoirsPerSide = 7;++ // Outer arch voussoirs (Front portal & Rear portal)+ for (let side = -1; side <= 1; side += 2) {+ const centerZ = side * (archSpan / 2);+ for (let i = 0; i < voussoirsPerSide; i++) {+ const theta = ((i + 0.5) / voussoirsPerSide) * (Math.PI / 3);+ const zLocal = -side * archR * Math.cos(theta);+ const yLocal = archR * Math.sin(theta);+ const vz = centerZ + zLocal;+ const vy = archSpringY + yLocal;+ const rotX = side * (theta * (180 / Math.PI) - 90);++ createPart('VoussoirF_' + side + '_' + i, boxGeo(0.45, 0.32, 0.26), stoneDressing, {+ position: [wallDepth / 2 + 0.05, vy, vz],+ rotation: [rotX, 0, 0],+ parent: root+ });+ createPart('VoussoirB_' + side + '_' + i, boxGeo(0.45, 0.32, 0.26), stoneDressing, {+ position: [-wallDepth / 2 - 0.05, vy, vz],+ rotation: [rotX, 0, 0],+ parent: root+ });+ }+ }++ // Pointed arch hood moulding (dripstone) above front arch+ for (let side = -1; side <= 1; side += 2) {+ const centerZ = side * (archSpan / 2);+ for (let i = 0; i < 5; i++) {+ const theta = ((i + 0.5) / 5) * (Math.PI / 3);+ const vz = centerZ - side * (archR + 0.2) * Math.cos(theta);+ const vy = archSpringY + (archR + 0.2) * Math.sin(theta);+ const rotX = side * (theta * (180 / Math.PI) - 90);++ createPart('HoodMould_' + side + '_' + i, boxGeo(0.18, 0.15, 0.2), stoneDressing, {+ position: [wallDepth / 2 + 0.16, vy, vz],+ rotation: [rotX, 0, 0],+ parent: root+ });+ }+ }++ // Vault ribs inside the gate passage ceiling+ for (let side = -1; side <= 1; side += 2) {+ const centerZ = side * (archSpan / 2);+ for (let i = 0; i < 4; i++) {+ const theta = ((i + 0.5) / 4) * (Math.PI / 3);+ const vz = centerZ - side * (archR - 0.05) * Math.cos(theta);+ const vy = archSpringY + (archR - 0.05) * Math.sin(theta);+ const rotX = side * (theta * (180 / Math.PI) - 90);++ createPart('VaultRib_' + side + '_' + i, boxGeo(wallDepth - 0.6, 0.22, 0.35), stoneAshlar, {+ position: [0, vy, vz],+ rotation: [rotX, 0, 0],+ parent: root+ });+ }+ }++ // ==========================================+ // 4. PORTCULLIS IN RECESSED GROOVES (RAISED)+ // ==========================================+ const portX = 0.9;+ // Left and right vertical stone grooves in the arch jambs+ createPart('PortGrooveL', boxGeo(0.2, 3.8, 0.14), stoneDark, {+ position: [portX, passageFloorY + 2.0, -1.18],+ parent: root+ });+ createPart('PortGrooveR', boxGeo(0.2, 3.8, 0.14), stoneDark, {+ position: [portX, passageFloorY + 2.0, 1.18],+ parent: root+ });++ // Raised portcullis frame (bottom sits at Y = passageFloorY + 2.4 = 3.1)+ const portBaseY = passageFloorY + 2.4;+ const portHeight = 2.6;+ const portHalfW = 1.05;++ // Vertical wooden stiles with iron shoes and sharp spikes+ const numPortV = 7;+ for (let i = 0; i < numPortV; i++) {+ const pz = -portHalfW + (i / (numPortV - 1)) * (portHalfW * 2);++ createPart('PortBarV_' + i, boxGeo(0.08, portHeight, 0.08), oakWood, {+ position: [portX, portBaseY + portHeight / 2, pz],+ parent: root+ });++ createPart('PortSpike_' + i, coneYGeo(0.05, 0.35, 4), wroughtIron, {+ position: [portX, portBaseY - 0.16, pz],+ rotation: [180, 0, 0], // Pointing down+ parent: root+ });+ }++ // Horizontal oak bars & iron reinforcement straps+ const numPortH = 5;+ for (let j = 0; j < numPortH; j++) {+ const py = portBaseY + 0.3 + j * 0.52;+ createPart('PortBarH_' + j, boxGeo(0.1, 0.08, portHalfW * 2 + 0.1), oakWood, {+ position: [portX, py, 0],+ parent: root+ });+ createPart('PortBandH_' + j, boxGeo(0.11, 0.03, portHalfW * 2 + 0.1), wroughtIron, {+ position: [portX, py, 0],+ parent: root+ });+ }++ // Top suspension shackles+ createPart('PortShackleL', torusGeo(0.08, 0.02, 5, 8), wroughtIron, {+ position: [portX, portBaseY + portHeight + 0.05, -0.6],+ rotation: [0, 90, 0],+ parent: root+ });+ createPart('PortShackleR', torusGeo(0.08, 0.02, 5, 8), wroughtIron, {+ position: [portX, portBaseY + portHeight + 0.05, 0.6],+ rotation: [0, 90, 0],+ parent: root+ });++ // Inner heavy oak gate doors (swung OPEN against jamb walls, welcoming visitors across lowered drawbridge)+ createPart('InnerGatePostL', boxGeo(0.2, 3.2, 0.2), oakWood, {+ position: [-0.6, passageFloorY + 1.6, -1.1],+ parent: root+ });+ createPart('InnerGatePostR', boxGeo(0.2, 3.2, 0.2), oakWood, {+ position: [-0.6, passageFloorY + 1.6, 1.1],+ parent: root+ });+ // Gate leaves folded open flat against passage walls+ createPart('GateLeafL', boxGeo(0.95, 2.9, 0.1), oakWood, {+ position: [-0.15, passageFloorY + 1.5, -1.05],+ parent: root+ });+ createPart('GateLeafR', boxGeo(0.95, 2.9, 0.1), oakWood, {+ position: [-0.15, passageFloorY + 1.5, 1.05],+ parent: root+ });+ // Iron strap hinges on open gates+ for (let gy = passageFloorY + 0.6; gy <= passageFloorY + 2.5; gy += 1.4) {+ createPart('GateHingeL_' + gy.toFixed(1), boxGeo(0.8, 0.08, 0.12), wroughtIron, {+ position: [-0.15, gy, -1.03],+ parent: root+ });+ createPart('GateHingeR_' + gy.toFixed(1), boxGeo(0.8, 0.08, 0.12), wroughtIron, {+ position: [-0.15, gy, 1.03],+ parent: root+ });+ }++ // ==========================================+ // 5. UPPER GUARD ROOM WINDOWS (Gothic Tracery)+ // ==========================================+ const winY = passageFloorY + 5.6;+ createPart('WinRecessF', boxGeo(0.3, 1.7, 1.2), stoneDark, {+ position: [wallDepth / 2 - 0.05, winY, 0],+ parent: root+ });+ createPart('WinSillF', boxGeo(0.45, 0.16, 1.4), stoneDressing, {+ position: [wallDepth / 2 + 0.05, winY - 0.9, 0],+ parent: root+ });+ createPart('WinMullionF', boxGeo(0.35, 1.5, 0.12), stoneDressing, {+ position: [wallDepth / 2 + 0.02, winY - 0.05, 0],+ parent: root+ });+ createPart('WinArchL_F', boxGeo(0.32, 0.12, 0.45), stoneDressing, {+ position: [wallDepth / 2 + 0.02, winY + 0.72, -0.26],+ rotation: [-25, 0, 0],+ parent: root+ });+ createPart('WinArchR_F', boxGeo(0.32, 0.12, 0.45), stoneDressing, {+ position: [wallDepth / 2 + 0.02, winY + 0.72, 0.26],+ rotation: [25, 0, 0],+ parent: root+ });++ // Rear central window+ createPart('WinRecessB', boxGeo(0.3, 1.7, 1.2), stoneDark, {+ position: [-wallDepth / 2 + 0.05, winY, 0],+ parent: root+ });+ createPart('WinSillB', boxGeo(0.45, 0.16, 1.4), stoneDressing, {+ position: [-wallDepth / 2 - 0.05, winY - 0.9, 0],+ parent: root+ });+ createPart('WinMullionB', boxGeo(0.35, 1.5, 0.12), stoneDressing, {+ position: [-wallDepth / 2 - 0.02, winY - 0.05, 0],+ parent: root+ });++ // ==========================================+ // 6. TWIN DRUM TOWERS (Mass, Batters, Storeys)+ // ==========================================+ [-towerZ, towerZ].forEach((tz, tIdx) => {+ const side = tz < 0 ? 'L' : 'R';+ const sideSign = tz < 0 ? -1 : 1;++ // A. Battered plinth / talus foundation (Y = 0 to 2.2)+ createPart('TowerPlinth_' + side, taperConeGeo(towerRadius + 0.65, towerRadius + 0.1, 2.2, 'y', 20), stoneDressing, {+ position: [towerX, 1.1, tz],+ parent: root+ });+ // Plinth drip mould+ createPart('PlinthMould_' + side, cylinderGeo(towerRadius + 0.16, towerRadius + 0.16, 0.2, 20), stoneDressing, {+ position: [towerX, 2.2, tz],+ parent: root+ });++ // B. Lower Tower Drum (Stage 1: Y = 2.2 to 6.2)+ createPart('TowerDrumLower_' + side, cylinderGeo(towerRadius, towerRadius, 4.0, 20), stoneAshlar, {+ position: [towerX, 4.2, tz],+ parent: root+ });++ // Mid-height string course belt+ createPart('TowerBeltCourse_' + side, cylinderGeo(towerRadius + 0.14, towerRadius + 0.14, 0.28, 20), stoneDressing, {+ position: [towerX, 6.2, tz],+ parent: root+ });++ // C. Upper Tower Drum (Stage 2: Y = 6.2 to 11.2)+ createPart('TowerDrumUpper_' + side, cylinderGeo(towerRadius, towerRadius, 5.0, 20), stoneAshlar, {+ position: [towerX, 8.7, tz],+ parent: root+ });++ // D. Cornice belt below machicolation corbels+ createPart('TowerSubCorbelBelt_' + side, cylinderGeo(towerRadius + 0.08, towerRadius + 0.08, 0.25, 20), stoneDressing, {+ position: [towerX, 11.2, tz],+ parent: root+ });++ // E. Machicolations: Stepped corbel brackets around the drum tower+ const numTowerCorbels = 14;+ const corbelBaseY = 11.35;+ for (let c = 0; c < numTowerCorbels; c++) {+ const angle = (c / numTowerCorbels) * Math.PI * 2;+ const cosA = Math.cos(angle);+ const sinA = Math.sin(angle);+ const rotY = -(angle * 180) / Math.PI;++ // Triple-stepped stone corbel bracket+ const r1 = towerRadius + 0.12;+ createPart('Corbel1_' + side + '_' + c, boxGeo(0.24, 0.24, 0.22), stoneDressing, {+ position: [towerX + cosA * r1, corbelBaseY + 0.12, tz + sinA * r1],+ rotation: [0, rotY, 0],+ parent: root+ });+ const r2 = towerRadius + 0.26;+ createPart('Corbel2_' + side + '_' + c, boxGeo(0.28, 0.24, 0.24), stoneDressing, {+ position: [towerX + cosA * r2, corbelBaseY + 0.36, tz + sinA * r2],+ rotation: [0, rotY, 0],+ parent: root+ });+ const r3 = towerRadius + 0.42;+ createPart('Corbel3_' + side + '_' + c, boxGeo(0.34, 0.26, 0.26), stoneDressing, {+ position: [towerX + cosA * r3, corbelBaseY + 0.61, tz + sinA * r3],+ rotation: [0, rotY, 0],+ parent: root+ });++ // Recessed murder hole chute between corbels+ const midAngle = angle + (Math.PI / numTowerCorbels);+ const midCos = Math.cos(midAngle);+ const midSin = Math.sin(midAngle);+ createPart('ChuteHole_' + side + '_' + c, boxGeo(0.2, 0.08, 0.2), stoneDark, {+ position: [towerX + midCos * (towerRadius + 0.35), corbelBaseY + 0.72, tz + midSin * (towerRadius + 0.35)],+ rotation: [0, -(midAngle * 180) / Math.PI, 0],+ parent: root+ });+ }++ // Projecting parapet floor ring supported by corbels+ createPart('TowerGalleryRing_' + side, cylinderGeo(towerRadius + 0.58, towerRadius + 0.58, 0.32, 20), stoneDressing, {+ position: [towerX, 12.18, tz],+ parent: root+ });++ // Gallery wall walk floor+ createPart('TowerWalkFloor_' + side, cylinderGeo(towerRadius + 0.35, towerRadius + 0.35, 0.05, 20), stoneAshlar, {+ position: [towerX, 12.35, tz],+ parent: root+ });++ // F. Crenellated Parapet (Merlons and Coping Caps)+ const numMerlons = 10;+ const parapetY = 12.35;+ for (let m = 0; m < numMerlons; m++) {+ const angle = (m / numMerlons) * Math.PI * 2;+ const cosA = Math.cos(angle);+ const sinA = Math.sin(angle);+ const rotY = -(angle * 180) / Math.PI;+ const mRad = towerRadius + 0.48;++ createPart('Merlon_' + side + '_' + m, boxGeo(0.32, 1.05, 0.85), stoneAshlar, {+ position: [towerX + cosA * mRad, parapetY + 0.52, tz + sinA * mRad],+ rotation: [0, rotY, 0],+ parent: root+ });++ createPart('MerlonCap_' + side + '_' + m, boxGeo(0.38, 0.14, 0.9), stoneDressing, {+ position: [towerX + cosA * mRad, parapetY + 1.11, tz + sinA * mRad],+ rotation: [0, rotY, 0],+ parent: root+ });++ if (cosA > -0.2) {+ createPart('MerlonSlit_' + side + '_' + m, boxGeo(0.34, 0.55, 0.08), stoneDark, {+ position: [towerX + cosA * mRad, parapetY + 0.55, tz + sinA * mRad],+ rotation: [0, rotY, 0],+ parent: root+ });+ }+ }++ // Doorway from wall-walk into tower chamber+ createPart('TowerDoorway_' + side, boxGeo(0.3, 1.8, 0.75), stoneDark, {+ position: [towerX - 0.8, wallHeight + 1.0, tz - sideSign * (towerRadius - 0.4)],+ rotation: [0, sideSign * 45, 0],+ parent: root+ });++ // G. Arrow Loops in Tower Faces (3 Storeys of authentic cruciform balistraria)+ // Tier 1+ const loopAnglesTier1 = [10, 45, -25];+ loopAnglesTier1.forEach((deg, lIdx) => {+ const rad = (deg * Math.PI) / 180;+ const cosA = Math.cos(rad);+ const sinA = Math.sin(rad) * sideSign;+ const lx = towerX + cosA * (towerRadius + 0.02);+ const lz = tz + sinA * (towerRadius + 0.02);+ const rotY = -deg * sideSign;+ const ly = 3.6;++ createPart('LoopSurround1_' + side + '_' + lIdx, boxGeo(0.12, 1.5, 0.45), stoneDressing, {+ position: [lx, ly, lz],+ rotation: [0, rotY, 0],+ parent: root+ });+ createPart('LoopV1_' + side + '_' + lIdx, boxGeo(0.14, 1.25, 0.09), stoneDark, {+ position: [lx + 0.01 * cosA, ly, lz + 0.01 * sinA],+ rotation: [0, rotY, 0],+ parent: root+ });+ createPart('LoopH1_' + side + '_' + lIdx, boxGeo(0.14, 0.09, 0.32), stoneDark, {+ position: [lx + 0.01 * cosA, ly + 0.2, lz + 0.01 * sinA],+ rotation: [0, rotY, 0],+ parent: root+ });+ });++ // Tier 2+ const loopAnglesTier2 = [0, 35, 70, -35];+ loopAnglesTier2.forEach((deg, lIdx) => {+ const rad = (deg * Math.PI) / 180;+ const cosA = Math.cos(rad);+ const sinA = Math.sin(rad) * sideSign;+ const lx = towerX + cosA * (towerRadius + 0.02);+ const lz = tz + sinA * (towerRadius + 0.02);+ const rotY = -deg * sideSign;+ const ly = 8.0;++ createPart('LoopSurround2_' + side + '_' + lIdx, boxGeo(0.12, 1.5, 0.45), stoneDressing, {+ position: [lx, ly, lz],+ rotation: [0, rotY, 0],+ parent: root+ });+ createPart('LoopV2_' + side + '_' + lIdx, boxGeo(0.14, 1.25, 0.09), stoneDark, {+ position: [lx + 0.01 * cosA, ly, lz + 0.01 * sinA],+ rotation: [0, rotY, 0],+ parent: root+ });+ createPart('LoopH2_' + side + '_' + lIdx, boxGeo(0.14, 0.09, 0.32), stoneDark, {+ position: [lx + 0.01 * cosA, ly + 0.2, lz + 0.01 * sinA],+ rotation: [0, rotY, 0],+ parent: root+ });+ });++ // Tier 3+ const loopAnglesTier3 = [15, 55, -20];+ loopAnglesTier3.forEach((deg, lIdx) => {+ const rad = (deg * Math.PI) / 180;+ const cosA = Math.cos(rad);+ const sinA = Math.sin(rad) * sideSign;+ const lx = towerX + cosA * (towerRadius + 0.02);+ const lz = tz + sinA * (towerRadius + 0.02);+ const rotY = -deg * sideSign;+ const ly = 10.3;++ createPart('LoopV3_' + side + '_' + lIdx, boxGeo(0.12, 1.1, 0.08), stoneDark, {+ position: [lx, ly, lz],+ rotation: [0, rotY, 0],+ parent: root+ });+ });+ });++ // Watch turret / Cap-house on Right Tower+ createPart('TurretDrum', cylinderGeo(1.0, 1.0, 2.2, 16), stoneAshlar, {+ position: [towerX + 0.6, towerHeight + 0.7, towerZ + 0.6],+ parent: root+ });+ createPart('TurretConicalRoof', coneGeo(1.2, 1.4, 16), stoneDressing, {+ position: [towerX + 0.6, towerHeight + 2.4, towerZ + 0.6],+ parent: root+ });+ createPart('TurretFinial', cylinderGeo(0.04, 0.04, 0.6, 6), wroughtIron, {+ position: [towerX + 0.6, towerHeight + 3.3, towerZ + 0.6],+ parent: root+ });++ // ==========================================+ // 7. CENTRAL MACHICOLATIONS & PARAPET+ // ==========================================+ const centCorbelY = wallHeight;++ // Corbel table across front and rear central walls+ const corbelZPositions = [-1.8, -1.2, -0.6, 0.0, 0.6, 1.2, 1.8];+ corbelZPositions.forEach((cz, cIdx) => {+ // Front corbel brackets+ createPart('CentCorbel1_F_' + cIdx, boxGeo(0.24, 0.22, 0.22), stoneDressing, {+ position: [wallDepth / 2 + 0.12, centCorbelY + 0.11, cz],+ parent: root+ });+ createPart('CentCorbel2_F_' + cIdx, boxGeo(0.38, 0.22, 0.25), stoneDressing, {+ position: [wallDepth / 2 + 0.25, centCorbelY + 0.33, cz],+ parent: root+ });+ createPart('CentCorbel3_F_' + cIdx, boxGeo(0.52, 0.24, 0.28), stoneDressing, {+ position: [wallDepth / 2 + 0.38, centCorbelY + 0.56, cz],+ parent: root+ });++ // Rear corbel brackets+ createPart('CentCorbel1_B_' + cIdx, boxGeo(0.24, 0.22, 0.22), stoneDressing, {+ position: [-wallDepth / 2 - 0.12, centCorbelY + 0.11, cz],+ parent: root+ });+ createPart('CentCorbel2_B_' + cIdx, boxGeo(0.38, 0.22, 0.25), stoneDressing, {+ position: [-wallDepth / 2 - 0.25, centCorbelY + 0.33, cz],+ parent: root+ });+ createPart('CentCorbel3_B_' + cIdx, boxGeo(0.52, 0.24, 0.28), stoneDressing, {+ position: [-wallDepth / 2 - 0.38, centCorbelY + 0.56, cz],+ parent: root+ });++ // Murder hole slots between front and rear corbels+ if (cIdx < corbelZPositions.length - 1) {+ const midZ = (cz + corbelZPositions[cIdx + 1]) / 2;+ createPart('CentChute_F_' + cIdx, boxGeo(0.25, 0.08, 0.25), stoneDark, {+ position: [wallDepth / 2 + 0.38, centCorbelY + 0.64, midZ],+ parent: root+ });+ createPart('CentChute_B_' + cIdx, boxGeo(0.25, 0.08, 0.25), stoneDark, {+ position: [-wallDepth / 2 - 0.38, centCorbelY + 0.64, midZ],+ parent: root+ });+ }+ });++ // Projecting gallery floor slab+ createPart('CentGalleryFloor', boxGeo(wallDepth + 1.2, 0.28, wallWidth + 0.2), stoneDressing, {+ position: [0, centCorbelY + 0.76, 0],+ parent: root+ });++ // Central roof / wall-walk floor+ createPart('CentWalkFloor', boxGeo(wallDepth + 0.6, 0.06, wallWidth), stoneAshlar, {+ position: [0, centCorbelY + 0.92, 0],+ parent: root+ });++ // Central Merlons & Crenellations (Front and Rear)+ const centMerlonZ = [-1.8, -0.9, 0.0, 0.9, 1.8];+ centMerlonZ.forEach((mz, mIdx) => {+ // Front merlons+ createPart('CentMerlon_F_' + mIdx, boxGeo(0.3, 0.95, 0.54), stoneAshlar, {+ position: [wallDepth / 2 + 0.52, centCorbelY + 1.4, mz],+ parent: root+ });+ createPart('CentMerlonCap_F_' + mIdx, boxGeo(0.36, 0.12, 0.58), stoneDressing, {+ position: [wallDepth / 2 + 0.52, centCorbelY + 1.93, mz],+ parent: root+ });+ createPart('CentMerlonSlit_F_' + mIdx, boxGeo(0.32, 0.5, 0.07), stoneDark, {+ position: [wallDepth / 2 + 0.52, centCorbelY + 1.4, mz],+ parent: root+ });++ // Rear merlons+ createPart('CentMerlon_B_' + mIdx, boxGeo(0.3, 0.95, 0.54), stoneAshlar, {+ position: [-wallDepth / 2 - 0.52, centCorbelY + 1.4, mz],+ parent: root+ });+ createPart('CentMerlonCap_B_' + mIdx, boxGeo(0.36, 0.12, 0.58), stoneDressing, {+ position: [-wallDepth / 2 - 0.52, centCorbelY + 1.93, mz],+ parent: root+ });+ });++ // Low crenel sills (leaves deep, clear embrasure gaps for archers)+ for (let e = 0; e < centMerlonZ.length - 1; e++) {+ const ez = (centMerlonZ[e] + centMerlonZ[e + 1]) / 2;+ createPart('CentCrenelSill_F_' + e, boxGeo(0.3, 0.12, 0.36), stoneDressing, {+ position: [wallDepth / 2 + 0.52, centCorbelY + 0.98, ez],+ parent: root+ });+ createPart('CentCrenelSill_B_' + e, boxGeo(0.3, 0.12, 0.36), stoneDressing, {+ position: [-wallDepth / 2 - 0.52, centCorbelY + 0.98, ez],+ parent: root+ });+ }++ // ==========================================+ // 8. TIMBER DRAWBRIDGE & STONE ABUTMENT+ // ==========================================+ const bridgeStartX = wallDepth / 2 - 0.3; // X = 1.9 (gate threshold)+ const bridgeLength = 4.4;+ const bridgeEndX = bridgeStartX + bridgeLength; // X = 6.3+ const bridgeWidth = 2.4;+ const bridgeThick = 0.22;+ const deckY = passageFloorY + 0.12;++ // A. Stone Abutment (Pier across the moat)+ const abutmentLength = 3.6;+ const abutmentCenterX = bridgeEndX + abutmentLength / 2; // X = 8.1++ // Abutment battered foundation & body (sitting on Y = 0)+ createPart('AbutmentPlinth', taperConeGeo(bridgeWidth / 2 + 0.8, bridgeWidth / 2 + 0.5, deckY, 'y', 16), stoneDressing, {+ position: [abutmentCenterX, deckY / 2, 0],+ parent: root+ });+ createPart('AbutmentBody', boxGeo(abutmentLength, deckY, bridgeWidth + 0.8), stoneAshlar, {+ position: [abutmentCenterX, deckY / 2, 0],+ parent: root+ });+ // Abutment forward cutwater buttress+ createPart('AbutmentButtress', boxGeo(0.6, deckY, 1.4), stoneDressing, {+ position: [bridgeEndX + abutmentLength + 0.2, deckY / 2, 0],+ parent: root+ });+ // Abutment road surface+ createPart('AbutmentRoad', boxGeo(abutmentLength + 0.1, 0.08, bridgeWidth + 0.6), stoneDressing, {+ position: [abutmentCenterX, deckY + 0.04, 0],+ parent: root+ });+ // Timber landing curb/bumper where the lowered drawbridge rests+ createPart('AbutmentBumper', boxGeo(0.24, 0.16, bridgeWidth + 0.2), oakWood, {+ position: [bridgeEndX + 0.12, deckY + 0.08, 0],+ parent: root+ });+ // Abutment stone parapets with coping+ createPart('AbutmentParapetL', boxGeo(abutmentLength - 0.4, 0.65, 0.35), stoneAshlar, {+ position: [abutmentCenterX + 0.2, deckY + 0.38, -bridgeWidth / 2 - 0.3],+ parent: root+ });+ createPart('AbutmentParapetR', boxGeo(abutmentLength - 0.4, 0.65, 0.35), stoneAshlar, {+ position: [abutmentCenterX + 0.2, deckY + 0.38, bridgeWidth / 2 + 0.3],+ parent: root+ });+ createPart('AbutmentParapetCapL', boxGeo(abutmentLength - 0.3, 0.1, 0.42), stoneDressing, {+ position: [abutmentCenterX + 0.2, deckY + 0.74, -bridgeWidth / 2 - 0.3],+ parent: root+ });+ createPart('AbutmentParapetCapR', boxGeo(abutmentLength - 0.3, 0.1, 0.42), stoneDressing, {+ position: [abutmentCenterX + 0.2, deckY + 0.74, bridgeWidth / 2 + 0.3],+ parent: root+ });++ // B. Timber Drawbridge Structure (Lowered)+ const bridgeCenterX = (bridgeStartX + bridgeEndX) / 2;+ const numPlanks = 6;+ const plankW = (bridgeWidth - 0.1) / numPlanks;+ for (let p = 0; p < numPlanks; p++) {+ const pz = -bridgeWidth / 2 + plankW / 2 + 0.05 + p * plankW;+ createPart('BridgePlank_' + p, boxGeo(bridgeLength - 0.1, bridgeThick, plankW - 0.02), oakWood, {+ position: [bridgeCenterX, deckY, pz],+ parent: root+ });+ }++ // Transverse wood cleats (traction bars every 0.6m)+ const numCleats = 7;+ for (let c = 1; c < numCleats; c++) {+ const cx = bridgeStartX + (c / numCleats) * bridgeLength;+ createPart('DeckCleat_' + c, boxGeo(0.1, 0.06, bridgeWidth - 0.12), oakWood, {+ position: [cx, deckY + bridgeThick / 2 + 0.03, 0],+ parent: root+ });+ createPart('CleatSpikeL_' + c, boxGeo(0.04, 0.02, 0.04), wroughtIron, {+ position: [cx, deckY + bridgeThick / 2 + 0.065, -0.9],+ parent: root+ });+ createPart('CleatSpikeR_' + c, boxGeo(0.04, 0.02, 0.04), wroughtIron, {+ position: [cx, deckY + bridgeThick / 2 + 0.065, 0.9],+ parent: root+ });+ }++ // Heavy wrought-iron edge binding straps+ createPart('BridgeStrapL', boxGeo(bridgeLength, 0.04, 0.08), wroughtIron, {+ position: [bridgeCenterX, deckY + bridgeThick / 2 + 0.02, -bridgeWidth / 2 + 0.05],+ parent: root+ });+ createPart('BridgeStrapR', boxGeo(bridgeLength, 0.04, 0.08), wroughtIron, {+ position: [bridgeCenterX, deckY + bridgeThick / 2 + 0.02, bridgeWidth / 2 - 0.05],+ parent: root+ });++ // Heavy hinge pintles and barrels at gate threshold+ createPart('HingeBarrelL', cylinderZGeo(0.1, 0.1, 0.32, 10), wroughtIron, {+ position: [bridgeStartX + 0.08, deckY, -1.05],+ parent: root+ });+ createPart('HingeBarrelR', cylinderZGeo(0.1, 0.1, 0.32, 10), wroughtIron, {+ position: [bridgeStartX + 0.08, deckY, 1.05],+ parent: root+ });+ createPart('HingeBracketL', boxGeo(0.4, 0.12, 0.1), wroughtIron, {+ position: [bridgeStartX - 0.05, deckY, -1.05],+ parent: root+ });+ createPart('HingeBracketR', boxGeo(0.4, 0.12, 0.1), wroughtIron, {+ position: [bridgeStartX - 0.05, deckY, 1.05],+ parent: root+ });++ // Heavy lifting eyes / ring brackets at outer nose of drawbridge+ const eyeX = bridgeEndX - 0.15;+ const eyeZ = 1.05;+ createPart('LiftingEyePlateL', boxGeo(0.3, 0.06, 0.18), wroughtIron, {+ position: [eyeX, deckY + bridgeThick / 2 + 0.03, -eyeZ],+ parent: root+ });+ createPart('LiftingEyePlateR', boxGeo(0.3, 0.06, 0.18), wroughtIron, {+ position: [eyeX, deckY + bridgeThick / 2 + 0.03, eyeZ],+ parent: root+ });+ createPart('LiftingRingL', torusGeo(0.1, 0.026, 6, 10), wroughtIron, {+ position: [eyeX, deckY + bridgeThick / 2 + 0.14, -eyeZ],+ rotation: [0, 90, 45],+ parent: root+ });+ createPart('LiftingRingR', torusGeo(0.1, 0.026, 6, 10), wroughtIron, {+ position: [eyeX, deckY + bridgeThick / 2 + 0.14, eyeZ],+ rotation: [0, 90, -45],+ parent: root+ });++ // ==========================================+ // 9. WINCH HOUSINGS & BALANCED CHAINS+ // ==========================================+ const winchY = passageFloorY + 5.2; // Y = 5.9+ const winchX = wallDepth / 2 + 0.22; // X = 2.42+ const winchZ = 1.05;++ [-winchZ, winchZ].forEach((wz, wIdx) => {+ const wSide = wz < 0 ? 'L' : 'R';++ // Stone housing block+ createPart('WinchHousing_' + wSide, boxGeo(0.65, 0.85, 0.55), stoneAshlar, {+ position: [winchX, winchY, wz],+ parent: root+ });+ // Corbel support beneath housing+ createPart('WinchCorbel_' + wSide, boxGeo(0.5, 0.35, 0.45), stoneDressing, {+ position: [winchX - 0.05, winchY - 0.55, wz],+ parent: root+ });+ // Sloped weather coping on housing top+ createPart('WinchCoping_' + wSide, boxGeo(0.72, 0.16, 0.62), stoneDressing, {+ position: [winchX, winchY + 0.48, wz],+ parent: root+ });+ // Dark chain aperture slit into wall+ createPart('WinchAperture_' + wSide, boxGeo(0.2, 0.36, 0.16), stoneDark, {+ position: [winchX + 0.26, winchY - 0.05, wz],+ parent: root+ });+ // Iron guide roller+ createPart('WinchRoller_' + wSide, cylinderZGeo(0.08, 0.08, 0.2, 8), wroughtIron, {+ position: [winchX + 0.22, winchY - 0.05, wz],+ parent: root+ });+ });++ // Wrought Iron Chains running from winch housings down to drawbridge lifting rings+ // Budget-optimized interlocking torus links (5x8 = 80 tris per link, 14 links = 1120 tris per chain)+ [-winchZ, winchZ].forEach((wz, cIdx) => {+ const cSide = wz < 0 ? 'L' : 'R';+ const startPt = [winchX + 0.28, winchY - 0.05, wz];+ const endPt = [eyeX, deckY + bridgeThick / 2 + 0.16, wz];++ const dx = endPt[0] - startPt[0];+ const dy = endPt[1] - startPt[1];+ const dz = endPt[2] - startPt[2];++ const pitchDeg = Math.atan2(dy, Math.hypot(dx, dz)) * (180 / Math.PI);+ const yawDeg = -Math.atan2(dz, dx) * (180 / Math.PI);++ // A chain is interlocking links, not beads on a string, and the difference+ // is arithmetic. A torus link is 2 * (R + tube) long, so consecutive centres+ // have to sit closer together than that or the rings stop touching. This run+ // is 5.88 m from winch to lifting ring and it was being divided into a fixed+ // 13 steps, which put the centres 0.20 m apart and the links only 0.194 m+ // long: 24 separated rings, a floating-part warning on every one of them,+ // and a chain that read as a dotted line.+ //+ // So the pitch is chosen first, at a link size that suits a drawbridge, and+ // the count follows from the span. Keeping tube at 0.29 R makes each link+ // 1.29 pitches long, which is 0.29 of a pitch of overlap at every joint --+ // enough to read as engaged from any angle. The tessellation drops to 4 x 6+ // because there are now thirty links a side and none of them is ever more+ // than a few pixels across.+ const pitch = 0.193;+ const linkR = pitch / 2;+ const linkTube = linkR * 0.29;+ const span = Math.hypot(dx, dy, dz);+ const numLinks = Math.max(2, Math.round(span / pitch));+ for (let l = 0; l <= numLinks; l++) {+ const t = l / numLinks;+ const sag = Math.sin(t * Math.PI) * 0.08;+ const lx = startPt[0] + dx * t;+ const ly = startPt[1] + dy * t - sag;+ const lz = startPt[2] + dz * t;++ const rollDeg = (l % 2 === 0) ? 0 : 90;++ createPart('ChainLink_' + cSide + '_' + l, torusGeo(linkR, linkTube, 4, 6), wroughtIron, {+ position: [lx, ly, lz],+ rotation: [rollDeg, yawDeg, pitchDeg],+ parent: root+ });+ }++ // Terminal iron shackle / clevis at drawbridge ring+ createPart('ChainShackle_' + cSide, boxGeo(0.12, 0.08, 0.08), wroughtIron, {+ position: [endPt[0] - 0.08, endPt[1] + 0.04, wz],+ parent: root+ });+ });++ return root;+}diff --git a/examples/gramophone.kiln.js b/examples/gramophone.kiln.jsnew file mode 100644index 00000000..2a38e28f--- /dev/null+++ b/examples/gramophone.kiln.js@@ -0,0 +1,716 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'Gramophone', category: 'prop' };++function build() {+ const root = createRoot('Gramophone');++ // ==========================================+ // MATERIALS+ // ==========================================+ const woodMahogany = gameMaterial(0x3e1f10, { roughness: 0.55, metalness: 0.05 });+ const woodPanel = gameMaterial(0x542b16, { roughness: 0.60, metalness: 0.05 });+ const brassPolished = gameMaterial(0xebb438, { roughness: 0.25, metalness: 0.90 });+ const darkBrass = gameMaterial(0x917122, { roughness: 0.40, metalness: 0.85 });+ const steelPolished = gameMaterial(0xd8d8d8, { roughness: 0.20, metalness: 0.95 });+ const feltGreen = gameMaterial(0x1a4522, { roughness: 0.95, metalness: 0.0 });+ const recordVinyl = gameMaterial(0x111111, { roughness: 0.30, metalness: 0.15 });+ const recordGroove = gameMaterial(0x1c1c1c, { roughness: 0.45, metalness: 0.10 });+ const recordLabel = gameMaterial(0x961515, { roughness: 0.65, metalness: 0.0 });+ const mica = gameMaterial(0xe8e4db, { roughness: 0.20, metalness: 0.10 });++ // ==========================================+ // 1. TURNED WOODEN PLINTH CABINET+ // ==========================================++ // 1A. Four Turned Classical Feet (touching Y = 0)+ // Turned profile: pad foot -> scotia -> torus -> collar+ const footProfile = [+ [0.000, 0.000],+ [0.024, 0.000],+ [0.025, 0.006],+ [0.021, 0.012],+ [0.024, 0.020],+ [0.022, 0.027],+ [0.015, 0.031],+ [0.018, 0.035],+ [0.000, 0.035]+ ];+ const footGeo = lathe(footProfile, 14);+ const footPositions = [+ [0.145, 0.000, 0.145],+ [-0.145, 0.000, 0.145],+ [0.145, 0.000, -0.145],+ [-0.145, 0.000, -0.145]+ ];+ footPositions.forEach(([fx, fy, fz], idx) => {+ createPart(`Foot_${idx}`, footGeo, woodMahogany, {+ position: [fx, fy, fz],+ parent: root+ });+ });++ // 1B. Stepped Plinth Base Mouldings (Y = 0.035 to 0.065)+ createPart('PlinthBaseTier1', boxGeo(0.36, 0.016, 0.36), woodMahogany, {+ position: [0, 0.043, 0],+ parent: root+ });+ createPart('PlinthBaseMoulding', boxGeo(0.34, 0.014, 0.34), woodMahogany, {+ position: [0, 0.058, 0],+ parent: root+ });++ // 1C. Cabinet Main Body (Y = 0.065 to 0.165)+ createPart('CabinetCore', boxGeo(0.32, 0.100, 0.32), woodMahogany, {+ position: [0, 0.115, 0],+ parent: root+ });++ // Four Turned Corner Columns+ const columnProfile = [+ [0.000, 0.000],+ [0.016, 0.000],+ [0.016, 0.008],+ [0.013, 0.014],+ [0.011, 0.022],+ [0.011, 0.078],+ [0.013, 0.086],+ [0.016, 0.092],+ [0.016, 0.100],+ [0.000, 0.100]+ ];+ const columnGeo = lathe(columnProfile, 14);+ footPositions.forEach(([cx, _, cz], idx) => {+ createPart(`Column_${idx}`, columnGeo, woodMahogany, {+ position: [cx, 0.065, cz],+ parent: root+ });+ });++ // Recessed Side Panels with Moulding Trim+ // Front (+X) panel+ createPart('Panel_Front_Backing', boxGeo(0.004, 0.076, 0.22), woodPanel, {+ position: [0.161, 0.115, 0],+ parent: root+ });+ createPart('Trim_Front_Top', boxGeo(0.006, 0.006, 0.22), woodMahogany, {+ position: [0.162, 0.150, 0],+ parent: root+ });+ createPart('Trim_Front_Bottom', boxGeo(0.006, 0.006, 0.22), woodMahogany, {+ position: [0.162, 0.080, 0],+ parent: root+ });+ createPart('Trim_Front_Left', boxGeo(0.006, 0.076, 0.006), woodMahogany, {+ position: [0.162, 0.115, -0.107],+ parent: root+ });+ createPart('Trim_Front_Right', boxGeo(0.006, 0.076, 0.006), woodMahogany, {+ position: [0.162, 0.115, 0.107],+ parent: root+ });++ // Maker's Brass Plaque on Front+ createPart('MakerPlaque', boxGeo(0.002, 0.028, 0.065), brassPolished, {+ position: [0.164, 0.115, 0],+ parent: root+ });+ createPart('PlaqueBorder', boxGeo(0.003, 0.030, 0.067), darkBrass, {+ position: [0.163, 0.115, 0],+ parent: root+ });+ // Plaque corner rivets+ const plaqueRivets = [+ [0.165, 0.125, -0.028],+ [0.165, 0.125, 0.028],+ [0.165, 0.105, -0.028],+ [0.165, 0.105, 0.028]+ ];+ plaqueRivets.forEach(([rx, ry, rz], idx) => {+ createPart(`PlaqueRivet_${idx}`, cylinderXGeo(0.001, 0.001, 0.003, 6), steelPolished, {+ position: [rx, ry, rz],+ parent: root+ });+ });++ // Back (-X) panel+ createPart('Panel_Back_Backing', boxGeo(0.004, 0.076, 0.22), woodPanel, {+ position: [-0.161, 0.115, 0],+ parent: root+ });+ createPart('Trim_Back_Top', boxGeo(0.006, 0.006, 0.22), woodMahogany, {+ position: [-0.162, 0.150, 0],+ parent: root+ });+ createPart('Trim_Back_Bottom', boxGeo(0.006, 0.006, 0.22), woodMahogany, {+ position: [-0.162, 0.080, 0],+ parent: root+ });++ // Left (-Z) panel+ createPart('Panel_Left_Backing', boxGeo(0.22, 0.076, 0.004), woodPanel, {+ position: [0, 0.115, -0.161],+ parent: root+ });+ createPart('Trim_Left_Top', boxGeo(0.22, 0.006, 0.006), woodMahogany, {+ position: [0, 0.150, -0.162],+ parent: root+ });+ createPart('Trim_Left_Bottom', boxGeo(0.22, 0.006, 0.006), woodMahogany, {+ position: [0, 0.080, -0.162],+ parent: root+ });++ // Right (+Z) panel (around crank)+ createPart('Panel_Right_Backing', boxGeo(0.22, 0.076, 0.004), woodPanel, {+ position: [0, 0.115, 0.161],+ parent: root+ });+ createPart('Trim_Right_Top', boxGeo(0.22, 0.006, 0.006), woodMahogany, {+ position: [0, 0.150, 0.162],+ parent: root+ });+ createPart('Trim_Right_Bottom', boxGeo(0.22, 0.006, 0.006), woodMahogany, {+ position: [0, 0.080, 0.162],+ parent: root+ });++ // 1D. Top Cornice Moulding & Deck (Y = 0.165 to 0.190)+ createPart('Cornice_Tier1', boxGeo(0.335, 0.012, 0.335), woodMahogany, {+ position: [0, 0.171, 0],+ parent: root+ });+ createPart('Cornice_Tier2', boxGeo(0.355, 0.013, 0.355), woodMahogany, {+ position: [0, 0.183, 0],+ parent: root+ });++ // ==========================================+ // 2. CRANK HANDLE ON +Z SIDE+ // ==========================================+ // Escutcheon plate+ createPart('CrankEscutcheon', cylinderZGeo(0.022, 0.022, 0.004, 14), brassPolished, {+ position: [0.01, 0.115, 0.164],+ parent: root+ });+ createPart('CrankEscutcheonCenter', cylinderZGeo(0.012, 0.012, 0.008, 10), darkBrass, {+ position: [0.01, 0.115, 0.166],+ parent: root+ });++ // Escutcheon screws+ const screwOffsets = [+ [0.01, 0.129, 0.166],+ [-0.002, 0.108, 0.166],+ [0.022, 0.108, 0.166]+ ];+ screwOffsets.forEach(([sx, sy, sz], idx) => {+ createPart(`CrankScrew_${idx}`, cylinderZGeo(0.002, 0.002, 0.004, 6), steelPolished, {+ position: [sx, sy, sz],+ parent: root+ });+ });++ // Steel shaft extending from cabinet+ createPart('CrankShaft', cylinderZGeo(0.0055, 0.0055, 0.055, 8), steelPolished, {+ position: [0.01, 0.115, 0.194],+ parent: root+ });++ // Brass crank hub and arm+ createPart('CrankHub', cylinderZGeo(0.009, 0.009, 0.010, 10), brassPolished, {+ position: [0.01, 0.115, 0.222],+ parent: root+ });+ createPart('CrankArm', boxGeo(0.010, 0.065, 0.008), brassPolished, {+ position: [0.01, 0.082, 0.222],+ parent: root+ });+ createPart('CrankElbowPin', cylinderZGeo(0.0045, 0.0045, 0.055, 8), steelPolished, {+ position: [0.01, 0.052, 0.245],+ parent: root+ });++ // Turned wooden handle grip+ const gripProfile = [+ [0.000, 0.000],+ [0.008, 0.000],+ [0.012, 0.010],+ [0.014, 0.024],+ [0.011, 0.038],+ [0.007, 0.046],+ [0.009, 0.050],+ [0.000, 0.050]+ ];+ const gripGeo = lathe(gripProfile, 12);+ createPart('CrankHandleGrip', gripGeo, woodMahogany, {+ position: [0.01, 0.052, 0.226],+ rotation: [90, 0, 0],+ parent: root+ });+ createPart('CrankGripCap', cylinderZGeo(0.008, 0.008, 0.003, 8), brassPolished, {+ position: [0.01, 0.052, 0.276],+ parent: root+ });++ // ==========================================+ // 3. HINGED LID+ // ==========================================+ const lidHingePivot = createPivot('LidHinge', [-0.155, 0.190, 0], root);+ lidHingePivot.rotation.z = (112 * Math.PI) / 180;++ createPart('LidTopMoulding', boxGeo(0.355, 0.014, 0.355), woodMahogany, {+ position: [0.177, 0.015, 0],+ parent: lidHingePivot+ });+ createPart('LidBevelTier', boxGeo(0.335, 0.012, 0.335), woodMahogany, {+ position: [0.177, 0.028, 0],+ parent: lidHingePivot+ });+ createPart('LidBackPanel', boxGeo(0.28, 0.003, 0.28), woodPanel, {+ position: [0.177, 0.035, 0],+ parent: lidHingePivot+ });+ createPart('LidUnderPanel', boxGeo(0.28, 0.004, 0.28), woodPanel, {+ position: [0.177, 0.006, 0],+ parent: lidHingePivot+ });++ createPart('LidClasp', boxGeo(0.004, 0.014, 0.016), brassPolished, {+ position: [0.355, 0.015, 0],+ parent: lidHingePivot+ });++ [-0.09, 0.09].forEach((hz, idx) => {+ createPart(`HingeBarrel_${idx}`, cylinderZGeo(0.004, 0.004, 0.024, 10), brassPolished, {+ position: [-0.155, 0.190, hz],+ parent: root+ });+ createPart(`HingeCabinetLeaf_${idx}`, boxGeo(0.016, 0.002, 0.020), brassPolished, {+ position: [-0.147, 0.190, hz],+ parent: root+ });+ });++ // Slotted Brass Quadrant Stay Arm on left side (-Z)+ const stayBottom = [-0.13, 0.192, -0.15];+ const stayTop = [-0.215, 0.338, -0.15];+ beamBetween('LidStayArm', stayBottom, stayTop, 0.0035, brassPolished, { parent: root });+ createPart('LidStayKnob', cylinderZGeo(0.006, 0.006, 0.008, 10), darkBrass, {+ position: [-0.172, 0.265, -0.15],+ parent: root+ });+ createPart('LidStayFoot', boxGeo(0.014, 0.004, 0.012), brassPolished, {+ position: [-0.13, 0.192, -0.15],+ parent: root+ });+ createPart('LidStayLidBracket', boxGeo(0.012, 0.008, 0.012), brassPolished, {+ position: [-0.215, 0.338, -0.15],+ parent: root+ });++ // ==========================================+ // 4. TURNTABLE & RECORD+ // ==========================================+ const ttPos = [0.01, 0.190, -0.04];++ // Platter Body (Brass with bevelled edge)+ createPart('PlatterRim', cylinderGeo(0.125, 0.125, 0.012, 28), brassPolished, {+ position: [ttPos[0], ttPos[1] + 0.006, ttPos[2]],+ parent: root+ });+ createPart('PlatterCollar', cylinderGeo(0.122, 0.125, 0.004, 28), darkBrass, {+ position: [ttPos[0], ttPos[1] + 0.014, ttPos[2]],+ parent: root+ });++ // Velvet Felt Mat (Rich Emerald Green)+ createPart('TurntableFelt', cylinderGeo(0.122, 0.122, 0.003, 28), feltGreen, {+ position: [ttPos[0], ttPos[1] + 0.017, ttPos[2]],+ parent: root+ });++ // 78 RPM Shellac Record+ createPart('RecordBody', cylinderGeo(0.116, 0.116, 0.0025, 28), recordVinyl, {+ position: [ttPos[0], ttPos[1] + 0.0195, ttPos[2]],+ parent: root+ });++ // Concentric Grooves (Specular ring highlights)+ const grooveRadii = [0.070, 0.096];+ grooveRadii.forEach((gr, idx) => {+ createPart(`RecordGroove_${idx}`, torusGeo(gr, 0.001, 6, 24), recordGroove, {+ position: [ttPos[0], ttPos[1] + 0.021, ttPos[2]],+ rotation: [90, 0, 0],+ parent: root+ });+ });++ // Center Record Label (Crimson & Gold border)+ createPart('RecordLabel', cylinderGeo(0.040, 0.040, 0.003, 24), recordLabel, {+ position: [ttPos[0], ttPos[1] + 0.0205, ttPos[2]],+ parent: root+ });+ createPart('RecordLabelRing', torusGeo(0.036, 0.0008, 6, 24), brassPolished, {+ position: [ttPos[0], ttPos[1] + 0.0225, ttPos[2]],+ rotation: [90, 0, 0],+ parent: root+ });++ // Polished Steel Center Spindle Pin+ createPart('Spindle', cylinderGeo(0.0036, 0.0036, 0.022, 12), steelPolished, {+ position: [ttPos[0], ttPos[1] + 0.028, ttPos[2]],+ parent: root+ });++ // Deck Controls+ // Speed regulator plate & lever+ createPart('SpeedPlate', boxGeo(0.036, 0.002, 0.026), brassPolished, {+ position: [0.11, 0.191, -0.12],+ parent: root+ });+ beamBetween('SpeedLever', [0.11, 0.192, -0.12], [0.12, 0.205, -0.12], 0.002, steelPolished, { parent: root });+ createPart('SpeedKnob', sphereGeo(0.004, 8, 6), darkBrass, {+ position: [0.12, 0.206, -0.12],+ parent: root+ });++ // Platter Brake switch+ createPart('BrakeHousing', boxGeo(0.016, 0.008, 0.012), brassPolished, {+ position: [0.08, 0.194, 0.06],+ parent: root+ });+ beamBetween('BrakeLever', [0.08, 0.198, 0.06], [0.06, 0.208, 0.06], 0.002, steelPolished, { parent: root });+ createPart('BrakePad', boxGeo(0.006, 0.008, 0.008), feltGreen, {+ position: [0.07, 0.198, 0.05],+ parent: root+ });++ // Needle Cup on deck with spare needles+ createPart('NeedleCupRim', torusGeo(0.016, 0.003, 8, 16), brassPolished, {+ position: [0.12, 0.193, -0.03],+ rotation: [90, 0, 0],+ parent: root+ });+ createPart('NeedleCupWell', cylinderGeo(0.016, 0.016, 0.004, 16), darkBrass, {+ position: [0.12, 0.191, -0.03],+ parent: root+ });+ beamBetween('SpareNeedle1', [0.115, 0.193, -0.035], [0.125, 0.194, -0.025], 0.0008, steelPolished, { parent: root });+ beamBetween('SpareNeedle2', [0.125, 0.193, -0.035], [0.115, 0.194, -0.025], 0.0008, steelPolished, { parent: root });++ // ==========================================+ // 5. BACK BRACKET & SUPPORT+ // ==========================================+ const bracketPos = [-0.13, 0.190, 0.05];++ createPart('BracketBasePlate', boxGeo(0.055, 0.006, 0.065), darkBrass, {+ position: [bracketPos[0], bracketPos[1] + 0.003, bracketPos[2]],+ parent: root+ });+ const boltDeltas = [+ [0.02, 0.022],+ [-0.02, 0.022],+ [0.02, -0.022],+ [-0.02, -0.022]+ ];+ boltDeltas.forEach(([bx, bz], idx) => {+ createPart(`BracketBolt_${idx}`, cylinderYGeo(0.0025, 0.0025, 0.005, 6), steelPolished, {+ position: [bracketPos[0] + bx, bracketPos[1] + 0.008, bracketPos[2] + bz],+ parent: root+ });+ });++ const pillarProfile = [+ [0.000, 0.000],+ [0.022, 0.000],+ [0.022, 0.008],+ [0.015, 0.016],+ [0.013, 0.065],+ [0.017, 0.075],+ [0.020, 0.085],+ [0.000, 0.085]+ ];+ const pillarGeo = lathe(pillarProfile, 14);+ createPart('BracketPillar', pillarGeo, brassPolished, {+ position: [bracketPos[0], bracketPos[1] + 0.006, bracketPos[2]],+ parent: root+ });++ createPart('BracketArmBody', boxGeo(0.045, 0.022, 0.035), darkBrass, {+ position: [bracketPos[0] + 0.015, bracketPos[1] + 0.090, bracketPos[2]],+ parent: root+ });+ createPart('BracketSocketRing', torusGeo(0.019, 0.003, 8, 16), brassPolished, {+ position: [bracketPos[0], bracketPos[1] + 0.095, bracketPos[2]],+ rotation: [90, 0, 0],+ parent: root+ });++ // ==========================================+ // 6. PIVOTING TONE ARM & SOUND BOX+ // ==========================================+ const armPivotPos = [bracketPos[0] + 0.035, bracketPos[1] + 0.085, bracketPos[2] - 0.025];++ createPart('ToneArmSwivelBase', cylinderGeo(0.014, 0.014, 0.020, 14), brassPolished, {+ position: armPivotPos,+ parent: root+ });+ createPart('ToneArmGimbalRing', torusGeo(0.015, 0.003, 8, 16), darkBrass, {+ position: [armPivotPos[0], armPivotPos[1] + 0.012, armPivotPos[2]],+ parent: root+ });++ createPart('ToneArmCounterweight', cylinderXGeo(0.012, 0.012, 0.025, 12), brassPolished, {+ position: [armPivotPos[0] - 0.025, armPivotPos[1] + 0.012, armPivotPos[2]],+ parent: root+ });++ // Tone Arm curved tube reaching over to record+ const soundBoxPos = [armPivotPos[0] + 0.205, 0.236, armPivotPos[2] - 0.015];+ const toneArmPoints = [+ [armPivotPos[0], armPivotPos[1] + 0.012, armPivotPos[2]],+ [armPivotPos[0] + 0.045, armPivotPos[1] + 0.008, armPivotPos[2] - 0.018],+ [armPivotPos[0] + 0.110, armPivotPos[1] - 0.005, armPivotPos[2] - 0.025],+ [armPivotPos[0] + 0.165, armPivotPos[1] - 0.018, armPivotPos[2] - 0.025],+ [soundBoxPos[0] - 0.012, soundBoxPos[1] + 0.005, soundBoxPos[2] - 0.006]+ ];+ const toneArmGeo = pipeAlongPath(toneArmPoints, 0.0065, {+ bendRadius: 0.025,+ tubularSegments: 16,+ radialSegments: 10+ });+ createPart('ToneArmTube', toneArmGeo, brassPolished, { parent: root });++ // Tone arm elbow connecting into back of sound box+ createPart('ToneArmSoundBoxFerrule', cylinderGeo(0.009, 0.009, 0.012, 12), darkBrass, {+ position: [soundBoxPos[0] - 0.008, soundBoxPos[1] + 0.003, soundBoxPos[2] - 0.004],+ parent: root+ });++ // Sound Box (Reproducer / Exhibition soundbox)+ // Rotated so mica diaphragm faces forward-right (+X, +Z) and stylus chuck points DOWN (-Y)+ const soundBoxPivot = createPivot('SoundBoxPivot', soundBoxPos, root);+ soundBoxPivot.rotation.x = (20 * Math.PI) / 180;+ soundBoxPivot.rotation.y = (25 * Math.PI) / 180;+ soundBoxPivot.rotation.z = (-75 * Math.PI) / 180;++ // Sound box casing+ createPart('SoundBoxCase', cylinderGeo(0.025, 0.025, 0.010, 20), brassPolished, {+ position: [0, 0, 0],+ parent: soundBoxPivot+ });+ createPart('SoundBoxBackCap', cylinderGeo(0.021, 0.023, 0.004, 20), darkBrass, {+ position: [0, -0.006, 0],+ parent: soundBoxPivot+ });+ // Front bezel retaining ring+ createPart('SoundBoxBezel', torusGeo(0.024, 0.0025, 8, 20), brassPolished, {+ position: [0, 0.005, 0],+ rotation: [90, 0, 0],+ parent: soundBoxPivot+ });++ // 6 Perimeter bezel screws+ for (let si = 0; si < 6; si++) {+ const sAng = (si * Math.PI * 2) / 6;+ const sx = Math.cos(sAng) * 0.023;+ const sz = Math.sin(sAng) * 0.023;+ createPart(`BezelScrew_${si}`, cylinderYGeo(0.0012, 0.0012, 0.003, 6), steelPolished, {+ position: [sx, 0.007, sz],+ parent: soundBoxPivot+ });+ }++ // Mica Diaphragm (translucent / pearlescent disc)+ createPart('MicaDiaphragm', cylinderGeo(0.021, 0.021, 0.001, 20), mica, {+ position: [0, 0.004, 0],+ parent: soundBoxPivot+ });++ // Center spider / needle bar mounting dot+ createPart('DiaphragmSpider', sphereGeo(0.0025, 6, 6), darkBrass, {+ position: [0, 0.0055, 0],+ parent: soundBoxPivot+ });++ // Needle bar extending from lower trunnions to center+ beamBetween('NeedleBar', [0, 0.0055, 0], [0.022, 0.004, 0], 0.0012, steelPolished, {+ parent: soundBoxPivot+ });++ // Stylus chuck boss at bottom (local +X)+ createPart('StylusChuck', boxGeo(0.007, 0.008, 0.006), darkBrass, {+ position: [0.024, 0.002, 0],+ parent: soundBoxPivot+ });+ // Knurled thumbscrew on stylus chuck+ createPart('StylusThumbScrew', cylinderGeo(0.0025, 0.0025, 0.008, 8), brassPolished, {+ position: [0.024, 0.002, 0.006],+ rotation: [90, 0, 0],+ parent: soundBoxPivot+ });++ // Steel Needle pointing down to rest on the record groove+ beamBetween('StylusNeedle', [0.024, 0.002, 0], [0.033, 0.002, 0], 0.0012, steelPolished, {+ parent: soundBoxPivot+ });++ // ==========================================+ // 7. CURVED ELBOW & MORNING-GLORY HORN+ // ==========================================++ // 7A. Smooth Curved Brass Elbow+ const elbowPath = [+ [bracketPos[0], bracketPos[1] + 0.085, bracketPos[2]],+ [bracketPos[0], bracketPos[1] + 0.155, bracketPos[2]],+ [bracketPos[0] + 0.025, bracketPos[1] + 0.205, bracketPos[2]],+ [bracketPos[0] + 0.065, bracketPos[1] + 0.230, bracketPos[2]],+ [bracketPos[0] + 0.110, bracketPos[1] + 0.243, bracketPos[2]]+ ];+ const elbowGeo = pipeAlongPath(elbowPath, 0.016, {+ bendRadius: 0.035,+ tubularSegments: 20,+ radialSegments: 12+ });+ createPart('ElbowPipe', elbowGeo, brassPolished, { parent: root });++ // Elbow collar at base+ createPart('ElbowBaseCollar', cylinderGeo(0.021, 0.021, 0.014, 14), darkBrass, {+ position: [bracketPos[0], bracketPos[1] + 0.095, bracketPos[2]],+ parent: root+ });++ // Elbow connection ferrule at horn mouth+ const hornThroatPos = [bracketPos[0] + 0.110, bracketPos[1] + 0.243, bracketPos[2]];+ createPart('HornCouplingFerrule', cylinderGeo(0.022, 0.022, 0.016, 14), darkBrass, {+ position: hornThroatPos,+ rotation: [0, 0, -74],+ parent: root+ });++ // 7B. Large Brass Morning-Glory Horn (12 Fluted Tapering Petals)+ const hornLength = 0.40;+ const rThroat = 0.018;+ const rBell = 0.215;+ const wall = 0.0022;++ const hornSteps = 16;+ const outerCurve = [];+ const innerCurve = [];++ for (let i = 0; i <= hornSteps; i++) {+ const u = i / hornSteps;+ const y = u * hornLength;+ const r = rThroat + 0.014 * u + (rBell - rThroat - 0.014) * Math.pow(u, 3.4);+ outerCurve.push([r + wall * 0.5, y]);+ innerCurve.push([Math.max(0.003, r - wall * 0.5), y]);+ }++ const rOuterRim = outerCurve[outerCurve.length - 1][0];+ const rInnerRim = innerCurve[innerCurve.length - 1][0];+ const rMidRim = (rOuterRim + rInnerRim) * 0.5;+ const rimProfile = [+ [rOuterRim, hornLength],+ [rMidRim + 0.003, hornLength + 0.004],+ [rInnerRim, hornLength]+ ];++ const hornProfile = [+ ...outerCurve,+ ...rimProfile,+ ...innerCurve.slice().reverse(),+ outerCurve[0]+ ];++ const hornGeo = lathe(hornProfile, 12);++ const hornPivot = createPivot('HornPivot', hornThroatPos, root);+ hornPivot.rotation.z = (-74 * Math.PI) / 180;++ createPart('HornBellBody', hornGeo, brassPolished, {+ position: [0, 0, 0],+ parent: hornPivot+ });++ // 12 Seam Ribs running along the 12 petal folds+ for (let pi = 0; pi < 12; pi++) {+ const angle = (pi * Math.PI * 2) / 12;+ const cosA = Math.cos(angle);+ const sinA = Math.sin(angle);++ const ribPoints = [];+ const ribSteps = 8;+ for (let ri = 1; ri <= ribSteps; ri++) {+ const u = ri / ribSteps;+ const y = u * hornLength;+ const r = rThroat + 0.014 * u + (rBell - rThroat - 0.014) * Math.pow(u, 3.4) + wall * 0.6;+ ribPoints.push([r * cosA, y, r * sinA]);+ }++ const ribGeo = pipeAlongPath(ribPoints, 0.0016, {+ bendRadius: 0.02,+ tubularSegments: 8,+ radialSegments: 5+ });+ createPart(`HornPetalRib_${pi}`, ribGeo, darkBrass, {+ parent: hornPivot+ });++ const nextAngle = ((pi + 1) * Math.PI * 2) / 12;+ const midAngle = (angle + nextAngle) * 0.5;+ const rimR = rBell + 0.003;+ createPart(`PetalCrest_${pi}`, sphereGeo(0.004, 6, 6), brassPolished, {+ position: [rimR * Math.cos(midAngle), hornLength + 0.003, rimR * Math.sin(midAngle)],+ parent: hornPivot+ });+ }++ // 7C. Slender Support Brace for the Heavy Horn+ const braceCollarU = 0.35;+ const braceCollarY = braceCollarU * hornLength;+ const braceCollarR = rThroat + 0.014 * braceCollarU + (rBell - rThroat - 0.014) * Math.pow(braceCollarU, 3.4);++ createPart('HornSupportCollar', torusGeo(braceCollarR + 0.002, 0.0025, 8, 18), darkBrass, {+ position: [0, braceCollarY, 0],+ rotation: [90, 0, 0],+ parent: hornPivot+ });+ createPart('CollarLug', boxGeo(0.008, 0.010, 0.010), darkBrass, {+ position: [0, braceCollarY, -(braceCollarR + 0.003)],+ parent: hornPivot+ });++ const collarWorldPos = [+ hornThroatPos[0] + braceCollarY * Math.sin((74 * Math.PI) / 180),+ hornThroatPos[1] + braceCollarY * Math.cos((74 * Math.PI) / 180),+ hornThroatPos[2] - (braceCollarR + 0.003)+ ];++ // Slender Brace Rod from the back bracket post up to the horn collar+ const braceBasePos = [bracketPos[0] + 0.01, bracketPos[1] + 0.080, bracketPos[2] - 0.015];+ beamBetween('HornSupportBrace', braceBasePos, collarWorldPos, 0.0035, brassPolished, {+ parent: root+ });+ createPart('BraceTurnbuckle', cylinderGeo(0.005, 0.005, 0.022, 8), darkBrass, {+ position: [+ (braceBasePos[0] + collarWorldPos[0]) * 0.5,+ (braceBasePos[1] + collarWorldPos[1]) * 0.5,+ (braceBasePos[2] + collarWorldPos[2]) * 0.5+ ],+ parent: root+ });+ createPart('BraceAnchorFoot', boxGeo(0.012, 0.016, 0.014), darkBrass, {+ position: braceBasePos,+ parent: root+ });++ return root;+}diff --git a/examples/gun-gpu.png b/examples/gun-gpu.pngindex 14dcd7fe..b9fa70b1 100644Binary files a/examples/gun-gpu.png and b/examples/gun-gpu.png differdiff --git a/examples/harbour-crane.kiln.js b/examples/harbour-crane.kiln.jsnew file mode 100644index 00000000..14aabf45--- /dev/null+++ b/examples/harbour-crane.kiln.js@@ -0,0 +1,561 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'HarbourCrane', category: 'prop' };++function build() {+ const root = createRoot('HarbourCrane');++ // ==========================================+ // MATERIALS (Authentic Maritime Container Terminal PBR)+ // ==========================================+ const craneOrange = gameMaterial(0xd34218, { roughness: 0.45, metalness: 0.25 });+ const craneWhite = gameMaterial(0xf2f4f7, { roughness: 0.35, metalness: 0.15 });+ const darkSteel = gameMaterial(0x24272d, { roughness: 0.55, metalness: 0.75 });+ const hazardYellow = gameMaterial(0xf6b200, { roughness: 0.4, metalness: 0.2 });+ const railingYellow= gameMaterial(0xebb312, { roughness: 0.5, metalness: 0.2 });+ const cableSteel = gameMaterial(0x18191c, { roughness: 0.7, metalness: 0.85 });+ const concreteGrey = gameMaterial(0x5f636a, { roughness: 0.9, metalness: 0.05 });+ const glass = glassMaterial(0x7dc2e8, { opacity: 0.45, roughness: 0.1, metalness: 0.1 });+ const cabInterior = gameMaterial(0x1a1c20, { roughness: 0.8, metalness: 0.2 });+ const warningLight = gameMaterial(0xee1100, { roughness: 0.3, emissive: 0xee1100, emissiveIntensity: 0.9 });+ const statusGreen = gameMaterial(0x22cc44, { roughness: 0.4, emissive: 0x11aa22, emissiveIntensity: 0.8 });++ // ==========================================+ // KEY DIMENSIONS & COORDINATES+ // +X forward (waterside outreach over docked container ship)+ // +Y up (ground dock rail level at Y = 0.0)+ // +Z asset right (quay wall & crane travel rails run along Z)+ // ==========================================+ const legX_WS = 7.0; // Waterside legs at X = +7.0+ const legX_LS = -7.0; // Landside legs at X = -7.0+ const legSpanZ = 7.5; // Half-width along dock track: legs at Z = +/-7.5 (15m wheelbase along track)+ const portalH = 16.0; // Clearance height for container trucks/trains driving along Z+ const boomH = 25.5; // Main girder rail level+ const apexH = 37.0; // Pylon apex sheave height++ // ==========================================+ // 1. DOCK RAILS & BOGIES (Grounding on Y=0)+ // Two ground crane rails embedded in dock at Y=0.0+ // ==========================================+ const railLengthZ = 22.0;+ const railHeight = 0.35;+ const railWidth = 0.30;+ const railGeo = boxGeo(railWidth, railHeight, railLengthZ);++ // Waterside and Landside crane rails sitting exactly on Y=0+ createPart('Rail_Waterside', railGeo, darkSteel, { position: [legX_WS, railHeight * 0.5, 0], parent: root });+ createPart('Rail_Landside', railGeo, darkSteel, { position: [legX_LS, railHeight * 0.5, 0], parent: root });++ // Sill Beams along Z connecting the bogies on each rail+ const sillBeamLength = legSpanZ * 2 + 3.0; // 18m+ const sillBeamGeo = boxGeo(0.9, 0.9, sillBeamLength);+ createPart('SillBeam_Waterside', sillBeamGeo, craneOrange, { position: [legX_WS, 1.35, 0], parent: root });+ createPart('SillBeam_Landside', sillBeamGeo, craneOrange, { position: [legX_LS, 1.35, 0], parent: root });++ // Bogie Assemblies at 4 corners+ // Wheels roll along Z: wheel axis is along X (cylinderXGeo)+ const wheelRadius = 0.40;+ const wheelY = railHeight + wheelRadius * 0.85; // tread rests on rail+ const wheelGeo = cylinderXGeo(wheelRadius, wheelRadius, 0.28, 12);+ const flangeGeo = cylinderXGeo(wheelRadius + 0.06, wheelRadius + 0.06, 0.05, 12);+ const subTruckGeo = boxGeo(0.7, 0.5, 2.2);+ const rockerGeo = boxGeo(0.8, 0.65, 3.8);+ const bogiePivotGeo = cylinderYGeo(0.45, 0.45, 0.8, 12);+ const railScraperGeo = boxGeo(0.45, 0.3, 0.35);++ const bogieCorners = [+ { name: 'WS_R', x: legX_WS, z: legSpanZ },+ { name: 'WS_L', x: legX_WS, z: -legSpanZ },+ { name: 'LS_R', x: legX_LS, z: legSpanZ },+ { name: 'LS_L', x: legX_LS, z: -legSpanZ },+ ];++ bogieCorners.forEach((c) => {+ // Central equalizer rocker+ createPart(`Rocker_${c.name}`, rockerGeo, darkSteel, { position: [c.x, 0.95, c.z], parent: root });+ createPart(`Pivot_${c.name}`, bogiePivotGeo, darkSteel, { position: [c.x, 1.35, c.z], parent: root });++ // Two 2-wheel sub-trucks per corner = 4 wheels per corner = 16 wheels total+ [-1.15, 1.15].forEach((dz, tIdx) => {+ const tz = c.z + dz;+ createPart(`Truck_${c.name}_${tIdx}`, subTruckGeo, darkSteel, { position: [c.x, 0.6, tz], parent: root });++ // Wheels+ [-0.6, 0.6].forEach((wz, wIdx) => {+ const posZ = tz + wz;+ createPart(`Wheel_${c.name}_${tIdx}_${wIdx}`, wheelGeo, darkSteel, { position: [c.x, wheelY, posZ], parent: root });+ // Wheel flange inside rail+ createPart(`Flange_${c.name}_${tIdx}_${wIdx}`, flangeGeo, darkSteel, { position: [c.x + (c.x > 0 ? -0.15 : 0.15), wheelY, posZ], parent: root });+ });++ // Rail safety scrapers / storm clamps+ createPart(`Scraper_${c.name}_${tIdx}`, railScraperGeo, hazardYellow, {+ position: [c.x, railHeight + 0.1, tz + (dz > 0 ? 1.05 : -1.05)],+ parent: root,+ });+ });+ });++ // Cable reel drum on the Landside-Right sill beam (trailing high-voltage cable)+ const reelDrumGeo = cylinderXGeo(1.3, 1.3, 0.9, 16);+ const reelCoreGeo = cylinderXGeo(0.55, 0.55, 1.0, 16);+ createPart('CableReelDrum', reelDrumGeo, hazardYellow, { position: [legX_LS - 0.75, 2.2, legSpanZ - 2.5], parent: root });+ createPart('CableReelCore', reelCoreGeo, darkSteel, { position: [legX_LS - 0.75, 2.2, legSpanZ - 2.5], parent: root });+ beamBetween('ReelBracket_A', [legX_LS, 1.35, legSpanZ - 2.5], [legX_LS - 0.75, 2.2, legSpanZ - 2.5], 0.09, darkSteel, { parent: root });+ beamBetween('ReelBracket_B', [legX_LS, 1.35, legSpanZ - 1.7], [legX_LS - 0.75, 2.2, legSpanZ - 2.5], 0.08, darkSteel, { parent: root });++ // ==========================================+ // 2. PORTAL TOWER & MASSIVE LEGS+ // 4 Legs: 2 Waterside legs at +X, 2 Landside legs at -X+ // Spanning across dock at portal deck Y = portalH+ // ==========================================+ const deckX = 4.6;+ const deckZ = 5.2;++ // 4 Heavy boxed legs+ const legNodes = [+ { id: 'WS_R', b: [legX_WS, 1.4, legSpanZ], t: [deckX, portalH, deckZ] },+ { id: 'WS_L', b: [legX_WS, 1.4, -legSpanZ], t: [deckX, portalH, -deckZ] },+ { id: 'LS_R', b: [legX_LS, 1.4, legSpanZ], t: [-deckX, portalH, deckZ] },+ { id: 'LS_L', b: [legX_LS, 1.4, -legSpanZ], t: [-deckX, portalH, -deckZ] },+ ];++ legNodes.forEach((leg) => {+ beamBetween(`Leg_${leg.id}`, leg.b, leg.t, 0.48, craneOrange, { parent: root });+ });++ // Waterside Portal Opening (at +X) and Landside Portal Opening (at -X)+ // Cross beam at portalH spanning between Left (-Z) and Right (+Z) legs+ const portalGantryBeamGeo = boxGeo(1.1, 1.5, deckZ * 2 + 1.4);+ createPart('PortalBeam_WS', portalGantryBeamGeo, craneOrange, { position: [deckX, portalH, 0], parent: root });+ createPart('PortalBeam_LS', portalGantryBeamGeo, craneOrange, { position: [-deckX, portalH, 0], parent: root });++ // Longitudinal tie beams connecting Waterside and Landside at portalH+ const portalSideTieGeo = boxGeo(deckX * 2, 1.1, 1.1);+ createPart('PortalSideTie_R', portalSideTieGeo, craneOrange, { position: [0, portalH, deckZ], parent: root });+ createPart('PortalSideTie_L', portalSideTieGeo, craneOrange, { position: [0, portalH, -deckZ], parent: root });++ // Side A-Frame Truss Bracing (between Waterside & Landside legs at +Z and -Z)+ [-1, 1].forEach((sZ) => {+ const sideName = sZ > 0 ? 'R' : 'L';+ const zBase = sZ * legSpanZ;+ const zTop = sZ * deckZ;+ const zMid = (zBase + zTop) * 0.5;+ const midH = 8.8;++ // Horizontal mid-strut+ beamBetween(`SideStrut_${sideName}`, [legX_WS * 0.72, midH, zMid], [legX_LS * 0.72, midH, zMid], 0.28, craneOrange, { parent: root });++ // Lower X-brace+ beamBetween(`SideX_Low1_${sideName}`, [legX_WS, 1.8, zBase], [legX_LS * 0.72, midH, zMid], 0.22, craneOrange, { parent: root });+ beamBetween(`SideX_Low2_${sideName}`, [legX_LS, 1.8, zBase], [legX_WS * 0.72, midH, zMid], 0.22, craneOrange, { parent: root });++ // Upper X-brace+ beamBetween(`SideX_Up1_${sideName}`, [legX_WS * 0.72, midH, zMid], [-deckX, portalH, zTop], 0.22, craneOrange, { parent: root });+ beamBetween(`SideX_Up2_${sideName}`, [legX_LS * 0.72, midH, zMid], [deckX, portalH, zTop], 0.22, craneOrange, { parent: root });+ });++ // Diagonal Knee Braces under Portal Cross Girders (arch clearance for container trucks)+ [-1, 1].forEach((sX) => {+ const pX = sX > 0 ? deckX : -deckX;+ [-1, 1].forEach((sZ) => {+ beamBetween(`KneeBrace_${sX > 0 ? 'WS' : 'LS'}_${sZ > 0 ? 'R' : 'L'}`,+ [pX, portalH - 0.7, sZ * (deckZ - 1.2)],+ [sX * (Math.abs(pX) + 0.8), portalH - 3.8, sZ * (deckZ + 0.4)],+ 0.22, craneOrange, { parent: root });+ });+ });++ // Portal Deck Walkway Platform & Safety Handrails+ const portalDeckPlank = boxGeo(deckX * 2 + 0.8, 0.16, deckZ * 2 - 0.8);+ createPart('PortalDeck', portalDeckPlank, darkSteel, { position: [0, portalH + 0.65, 0], parent: root });++ // Portal Deck Handrails+ [-1, 1].forEach((sZ) => {+ const zR = sZ * (deckZ - 0.25);+ beamBetween(`PortalRailTop_${sZ > 0 ? 'R' : 'L'}`, [-deckX, portalH + 1.65, zR], [deckX, portalH + 1.65, zR], 0.035, railingYellow, { parent: root });+ beamBetween(`PortalRailMid_${sZ > 0 ? 'R' : 'L'}`, [-deckX, portalH + 1.15, zR], [deckX, portalH + 1.15, zR], 0.025, railingYellow, { parent: root });+ for (let x = -deckX + 0.6; x <= deckX - 0.4; x += 1.8) {+ beamBetween(`PortalRailPost_${sZ > 0 ? 'R' : 'L'}_${Math.round(x)}`, [x, portalH + 0.65, zR], [x, portalH + 1.65, zR], 0.035, railingYellow, { parent: root });+ }+ });++ // ==========================================+ // 3. UPPER TOWER & A-FRAME PYLON (APEX)+ // Columns rising from portal deck (Y=16) to boom level (Y=25.5)+ // and A-frame pylon up to apex (Y=37)+ // ==========================================+ const boomDeckX = 3.4;+ const boomDeckZ = 3.6;++ const towerCols = [+ { id: 'WS_R', b: [deckX, portalH, deckZ], t: [boomDeckX, boomH, boomDeckZ] },+ { id: 'WS_L', b: [deckX, portalH, -deckZ], t: [boomDeckX, boomH, -boomDeckZ] },+ { id: 'LS_R', b: [-deckX, portalH, deckZ], t: [-boomDeckX, boomH, boomDeckZ] },+ { id: 'LS_L', b: [-deckX, portalH, -deckZ], t: [-boomDeckX, boomH, -boomDeckZ] },+ ];++ towerCols.forEach((col) => {+ beamBetween(`TowerCol_${col.id}`, col.b, col.t, 0.40, craneOrange, { parent: root });+ });++ // Upper Tower side diagonal bracing+ [-1, 1].forEach((sZ) => {+ const side = sZ > 0 ? 'R' : 'L';+ beamBetween(`TowerX1_${side}`, [deckX, portalH + 1.0, sZ * deckZ], [-boomDeckX, boomH - 0.2, sZ * boomDeckZ], 0.2, craneOrange, { parent: root });+ beamBetween(`TowerX2_${side}`, [-deckX, portalH + 1.0, sZ * deckZ], [boomDeckX, boomH - 0.2, sZ * boomDeckZ], 0.2, craneOrange, { parent: root });+ });++ // Upper boom support collar beams+ beamBetween('BoomCollar_WS', [boomDeckX, boomH, boomDeckZ], [boomDeckX, boomH, -boomDeckZ], 0.32, craneOrange, { parent: root });+ beamBetween('BoomCollar_LS', [-boomDeckX, boomH, boomDeckZ], [-boomDeckX, boomH, -boomDeckZ], 0.32, craneOrange, { parent: root });++ // A-Frame Pylon (Mast) rising above the boom to apexH (Y = 37.0)+ const apexX = 0.6;+ const apexZ = 1.4;++ beamBetween('Pylon_WS_R', [boomDeckX, boomH, boomDeckZ], [apexX, apexH, apexZ], 0.32, craneOrange, { parent: root });+ beamBetween('Pylon_WS_L', [boomDeckX, boomH, -boomDeckZ], [apexX, apexH, -apexZ], 0.32, craneOrange, { parent: root });+ beamBetween('Pylon_LS_R', [-boomDeckX, boomH, boomDeckZ], [apexX, apexH, apexZ], 0.32, craneOrange, { parent: root });+ beamBetween('Pylon_LS_L', [-boomDeckX, boomH, -boomDeckZ], [apexX, apexH, -apexZ], 0.32, craneOrange, { parent: root });++ // Apex Crosshead & Sheave Nest+ const apexCapGeo = boxGeo(1.8, 0.9, apexZ * 2 + 1.1);+ createPart('ApexCap', apexCapGeo, darkSteel, { position: [apexX, apexH + 0.35, 0], parent: root });++ const apexSheaveGeo = torusGeo(0.55, 0.08, 8, 16);+ createPart('ApexSheave_R', apexSheaveGeo, darkSteel, { position: [apexX, apexH + 0.6, apexZ], rotation: [0, 90, 0], parent: root });+ createPart('ApexSheave_L', apexSheaveGeo, darkSteel, { position: [apexX, apexH + 0.6, -apexZ], rotation: [0, 90, 0], parent: root });++ // Aircraft Warning Beacon at Apex (properly overlapping ApexCap)+ const beaconGeo = cylinderYGeo(0.14, 0.14, 0.45, 8);+ createPart('PylonBeacon', beaconGeo, warningLight, { position: [apexX, apexH + 0.85, 0], parent: root });++ // Pylon internal lacings+ const pylonMidH = (boomH + apexH) * 0.5;+ beamBetween('PylonMidStrut_R', [(boomDeckX + apexX) * 0.5, pylonMidH, (boomDeckZ + apexZ) * 0.5], [(-boomDeckX + apexX) * 0.5, pylonMidH, (boomDeckZ + apexZ) * 0.5], 0.18, craneOrange, { parent: root });+ beamBetween('PylonMidStrut_L', [(boomDeckX + apexX) * 0.5, pylonMidH, (-boomDeckZ - apexZ) * 0.5], [(-boomDeckX + apexX) * 0.5, pylonMidH, (-boomDeckZ - apexZ) * 0.5], 0.18, craneOrange, { parent: root });+ beamBetween('PylonMidTie', [(boomDeckX + apexX) * 0.5, pylonMidH, (boomDeckZ + apexZ) * 0.5], [(boomDeckX + apexX) * 0.5, pylonMidH, (-boomDeckZ - apexZ) * 0.5], 0.18, craneOrange, { parent: root });++ // ==========================================+ // 4. MAIN CANTILEVER BOOM & COUNTERWEIGHT BOOM+ // Reaching out along +X over the water (outreach tip at X = +33.0)+ // Counterweight boom reaching behind along -X (tip at X = -15.5)+ // Twin box girders at Z = +/-1.85+ // ==========================================+ const boomTipX = 33.0;+ const boomRearX = -15.5;+ const boomLength = boomTipX - boomRearX; // 48.5m+ const boomCenterX = (boomTipX + boomRearX) * 0.5; // 8.75m+ const girderZ = 1.85;+ const girderWidth = 0.65;+ const girderHeight = 2.3;++ // Twin main girders+ const girderGeo = boxGeo(boomLength, girderHeight, girderWidth);+ createPart('Girder_R', girderGeo, craneOrange, { position: [boomCenterX, boomH + 1.15, girderZ], parent: root });+ createPart('Girder_L', girderGeo, craneOrange, { position: [boomCenterX, boomH + 1.15, -girderZ], parent: root });++ // Trolley running rails underneath girders (Y = boomH - 0.05)+ const trolleyRailGeo = boxGeo(boomLength - 3.5, 0.14, 0.18);+ createPart('TrolleyRail_R', trolleyRailGeo, darkSteel, { position: [boomCenterX + 1.6, boomH - 0.05, girderZ], parent: root });+ createPart('TrolleyRail_L', trolleyRailGeo, darkSteel, { position: [boomCenterX + 1.6, boomH - 0.05, -girderZ], parent: root });++ // Transverse diaphragms connecting the twin girders+ const diaphragmGeo = boxGeo(0.4, 1.9, girderZ * 2 - girderWidth);+ for (let x = -13.5; x <= 31.0; x += 3.5) {+ createPart(`Diaphragm_${Math.round(x)}`, diaphragmGeo, craneOrange, { position: [x, boomH + 1.15, 0], parent: root });+ }++ // Boom maintenance catwalk & decking+ const walkwayGeo = boxGeo(boomLength - 0.8, 0.12, girderZ * 2 - girderWidth);+ createPart('BoomWalkway', walkwayGeo, darkSteel, { position: [boomCenterX, boomH + 2.32, 0], parent: root });++ // Boom yellow safety handrails along both outer girder edges+ [-1, 1].forEach((sZ) => {+ const zRail = sZ * (girderZ + 0.38);+ beamBetween(`BoomRailTop_${sZ > 0 ? 'R' : 'L'}`, [boomRearX + 0.6, boomH + 3.35, zRail], [boomTipX - 0.6, boomH + 3.35, zRail], 0.035, railingYellow, { parent: root });+ beamBetween(`BoomRailMid_${sZ > 0 ? 'R' : 'L'}`, [boomRearX + 0.6, boomH + 2.85, zRail], [boomTipX - 0.6, boomH + 2.85, zRail], 0.025, railingYellow, { parent: root });+ for (let x = boomRearX + 1.0; x <= boomTipX - 1.0; x += 3.2) {+ beamBetween(`BoomRailPost_${sZ > 0 ? 'R' : 'L'}_${Math.round(x)}`, [x, boomH + 2.32, zRail], [x, boomH + 3.35, zRail], 0.03, railingYellow, { parent: root });+ }+ });++ // Boom Tip Headblock & Buffers at X = boomTipX+ const boomTipHeadGeo = boxGeo(0.9, 1.8, girderZ * 2 + 1.3);+ createPart('BoomTipHead', boomTipHeadGeo, darkSteel, { position: [boomTipX - 0.3, boomH + 1.15, 0], parent: root });++ // Warning light at boom tip (overlapping BoomTipHead top at boomH + 2.05)+ createPart('TipBeacon', beaconGeo, warningLight, { position: [boomTipX - 0.3, boomH + 2.15, 0], parent: root });++ // Floodlight array at boom tip pointing down toward cargo ships+ const floodlightBarGeo = boxGeo(0.25, 0.35, 3.4);+ createPart('FloodlightBar', floodlightBarGeo, darkSteel, { position: [boomTipX - 0.7, boomH - 0.25, 0], parent: root });+ // Rigid floodlight mounting brackets connecting to BoomTipHead+ beamBetween('LightMount_R', [boomTipX - 0.3, boomH + 0.3, 1.2], [boomTipX - 0.7, boomH - 0.25, 1.2], 0.06, darkSteel, { parent: root });+ beamBetween('LightMount_L', [boomTipX - 0.3, boomH + 0.3, -1.2], [boomTipX - 0.7, boomH - 0.25, -1.2], 0.06, darkSteel, { parent: root });++ [-1.2, 0, 1.2].forEach((zL, i) => {+ const lightHousingGeo = boxGeo(0.5, 0.45, 0.55);+ createPart(`FloodHousing_${i}`, lightHousingGeo, craneWhite, { position: [boomTipX - 0.7, boomH - 0.6, zL], parent: root });+ const lensGeo = cylinderXGeo(0.2, 0.2, 0.05, 12);+ createPart(`FloodLens_${i}`, lensGeo, glass, { position: [boomTipX - 0.44, boomH - 0.6, zL], parent: root });+ });++ // ==========================================+ // 5. TENSION STAYS (FORESTAYS & BACKSTAYS)+ // Structural pin-ended tension tie bars+ // ==========================================+ // Outer forestays to outreach tip (X = 27.0)+ beamBetween('Stay_Outer_R', [apexX, apexH + 0.5, apexZ], [27.0, boomH + 2.3, girderZ], 0.09, cableSteel, { parent: root });+ beamBetween('Stay_Outer_L', [apexX, apexH + 0.5, -apexZ], [27.0, boomH + 2.3, -girderZ], 0.09, cableSteel, { parent: root });++ // Inner forestays to mid boom (X = 14.5)+ beamBetween('Stay_Inner_R', [apexX, apexH + 0.4, apexZ], [14.5, boomH + 2.3, girderZ], 0.08, cableSteel, { parent: root });+ beamBetween('Stay_Inner_L', [apexX, apexH + 0.4, -apexZ], [14.5, boomH + 2.3, -girderZ], 0.08, cableSteel, { parent: root });++ // Rear backstays to counterweight boom (X = -14.0)+ beamBetween('Backstay_Main_R', [apexX, apexH + 0.5, apexZ], [-14.0, boomH + 2.3, girderZ], 0.09, cableSteel, { parent: root });+ beamBetween('Backstay_Main_L', [apexX, apexH + 0.5, -apexZ], [-14.0, boomH + 2.3, -girderZ], 0.09, cableSteel, { parent: root });++ // ==========================================+ // 6. MACHINE HOUSE & COUNTERWEIGHT+ // ==========================================+ // Machine House sits on rear boom deck (X = -4.8 to -11.4)+ const mhLength = 6.6;+ const mhWidth = 4.5;+ const mhHeight = 3.5;+ const mhGeo = boxGeo(mhLength, mhHeight, mhWidth);+ createPart('MachineHouse', mhGeo, craneWhite, { position: [-8.1, boomH + 2.32 + mhHeight * 0.5, 0], parent: root });++ // Machine house roof louvers & HVAC+ const hvacGeo = boxGeo(1.6, 0.8, 1.8);+ createPart('HVAC_Pod', hvacGeo, darkSteel, { position: [-6.8, boomH + 2.32 + mhHeight + 0.4, 0.9], parent: root });+ const ventCowlGeo = cylinderYGeo(0.38, 0.42, 0.6, 12);+ createPart('VentCowl', ventCowlGeo, darkSteel, { position: [-9.5, boomH + 2.32 + mhHeight + 0.3, -1.1], parent: root });++ // Service access doors+ const mhDoorGeo = boxGeo(0.1, 2.2, 1.1);+ createPart('MH_Door', mhDoorGeo, darkSteel, { position: [-4.75, boomH + 3.42, 0], parent: root });++ // Machine house roof maintenance jib crane+ const jibMastGeo = cylinderYGeo(0.12, 0.12, 1.9, 8);+ createPart('JibMast', jibMastGeo, hazardYellow, { position: [-10.8, boomH + 2.32 + mhHeight + 0.95, 1.3], parent: root });+ beamBetween('JibArm', [-10.8, boomH + 2.32 + mhHeight + 1.8, 1.3], [-7.8, boomH + 2.32 + mhHeight + 1.8, 1.3], 0.08, hazardYellow, { parent: root });+ beamBetween('JibStay', [-10.8, boomH + 2.32 + mhHeight + 1.8, 1.3], [-9.0, boomH + 2.32 + mhHeight + 1.2, 1.3], 0.05, cableSteel, { parent: root });++ // Machine house roof safety handrails (with vertical posts fully anchoring to roof)+ const mhTopY = boomH + 2.32 + mhHeight;+ [-1, 1].forEach((sZ) => {+ const zE = sZ * (mhWidth * 0.5 - 0.12);+ beamBetween(`MHRailTop_${sZ > 0 ? 'R' : 'L'}`, [-8.1 - mhLength * 0.5 + 0.2, mhTopY + 1.0, zE], [-8.1 + mhLength * 0.5 - 0.2, mhTopY + 1.0, zE], 0.03, railingYellow, { parent: root });+ beamBetween(`MHRailMid_${sZ > 0 ? 'R' : 'L'}`, [-8.1 - mhLength * 0.5 + 0.2, mhTopY + 0.5, zE], [-8.1 + mhLength * 0.5 - 0.2, mhTopY + 0.5, zE], 0.02, railingYellow, { parent: root });+ for (let x = -8.1 - mhLength * 0.5 + 0.3; x <= -8.1 + mhLength * 0.5 - 0.1; x += 1.6) {+ beamBetween(`MHRailPost_${sZ > 0 ? 'R' : 'L'}_${Math.round(x)}`, [x, mhTopY - 0.05, zE], [x, mhTopY + 1.0, zE], 0.03, railingYellow, { parent: root });+ }+ });++ // End rail at back of machine house roof+ const mhRearX = -8.1 - mhLength * 0.5 + 0.2;+ beamBetween('MHRailEndTop', [mhRearX, mhTopY + 1.0, -mhWidth * 0.5 + 0.12], [mhRearX, mhTopY + 1.0, mhWidth * 0.5 - 0.12], 0.03, railingYellow, { parent: root });+ beamBetween('MHRailEndMid', [mhRearX, mhTopY + 0.5, -mhWidth * 0.5 + 0.12], [mhRearX, mhTopY + 0.5, mhWidth * 0.5 - 0.12], 0.02, railingYellow, { parent: root });++ // Counterweight Blocks at rear boom tip (X = -13.2 to -15.5)+ const cwFrameGeo = boxGeo(2.6, 2.5, 4.4);+ createPart('CounterweightCradle', cwFrameGeo, darkSteel, { position: [-14.2, boomH + 1.25, 0], parent: root });+ const ballastBlockGeo = boxGeo(2.2, 2.1, 4.0);+ createPart('BallastBlock', ballastBlockGeo, concreteGrey, { position: [-14.2, boomH + 1.25, 0], parent: root });++ // ==========================================+ // 7. TROLLEY & OPERATOR CAB+ // Positioned out over the water at X = 18.0+ // ==========================================+ const trolleyX = 18.0;+ const trolleyY = boomH - 0.35; // overlaps bottom of rails++ // Trolley chassis+ const trolleyChassisGeo = boxGeo(4.4, 0.7, 4.3);+ createPart('TrolleyChassis', trolleyChassisGeo, craneOrange, { position: [trolleyX, trolleyY, 0], parent: root });++ // 4 Trolley wheel bogies engaging the boom rails+ [-1.6, 1.6].forEach((dx, idx) => {+ [-girderZ, girderZ].forEach((gz, sideIdx) => {+ const tWheel = cylinderZGeo(0.26, 0.26, 0.22, 12);+ createPart(`TrolleyWheel_${idx}_${sideIdx}`, tWheel, darkSteel, { position: [trolleyX + dx, boomH + 0.05, gz], parent: root });+ const tBracket = boxGeo(0.65, 0.45, 0.28);+ createPart(`TrolleyBracket_${idx}_${sideIdx}`, tBracket, darkSteel, { position: [trolleyX + dx, boomH - 0.15, gz], parent: root });+ });+ });++ // Hoist winch drums & drive motor housings on trolley+ const winchDrumGeo = cylinderXGeo(0.48, 0.48, 1.8, 16);+ createPart('WinchDrum_R', winchDrumGeo, darkSteel, { position: [trolleyX, trolleyY + 0.65, 1.0], parent: root });+ createPart('WinchDrum_L', winchDrumGeo, darkSteel, { position: [trolleyX, trolleyY + 0.65, -1.0], parent: root });++ const motorBoxGeo = boxGeo(1.3, 0.75, 1.1);+ createPart('HoistMotor_F', motorBoxGeo, darkSteel, { position: [trolleyX + 1.4, trolleyY + 0.6, 0], parent: root });+ createPart('HoistMotor_R', motorBoxGeo, darkSteel, { position: [trolleyX - 1.4, trolleyY + 0.6, 0], parent: root });++ // Operator Cab suspended underneath front-left of trolley+ const cabX = trolleyX + 1.2;+ const cabY = trolleyY - 1.85;+ const cabZ = 1.1; // offset so operator looks directly down at container spread++ // Cab rigid steel suspension arms+ beamBetween('CabHanger_1', [cabX - 0.85, trolleyY - 0.35, cabZ - 0.75], [cabX - 0.85, cabY + 1.15, cabZ - 0.75], 0.06, darkSteel, { parent: root });+ beamBetween('CabHanger_2', [cabX + 0.85, trolleyY - 0.35, cabZ - 0.75], [cabX + 0.85, cabY + 1.15, cabZ - 0.75], 0.06, darkSteel, { parent: root });+ beamBetween('CabHanger_3', [cabX - 0.85, trolleyY - 0.35, cabZ + 0.75], [cabX - 0.85, cabY + 1.15, cabZ + 0.75], 0.06, darkSteel, { parent: root });+ beamBetween('CabHanger_4', [cabX + 0.85, trolleyY - 0.35, cabZ + 0.75], [cabX + 0.85, cabY + 1.15, cabZ + 0.75], 0.06, darkSteel, { parent: root });++ // Cab body+ const cabBodyGeo = boxGeo(2.5, 2.1, 2.0);+ createPart('CabBody', cabBodyGeo, craneWhite, { position: [cabX, cabY, cabZ], parent: root });++ // Panoramic Glazing: forward window, downward observation bay, side windows+ const cabFrontWin = boxGeo(0.1, 1.15, 1.7);+ createPart('CabWin_Front', cabFrontWin, glass, { position: [cabX + 1.26, cabY + 0.35, cabZ], parent: root });++ // Downward floor observation window+ const cabDownWin = boxGeo(0.1, 0.75, 1.5);+ createPart('CabWin_Down', cabDownWin, glass, { position: [cabX + 1.2, cabY - 0.65, cabZ], rotation: [0, 0, 30], parent: root });++ // Side windows+ const cabSideWin = boxGeo(1.5, 1.05, 0.1);+ createPart('CabWin_SideR', cabSideWin, glass, { position: [cabX + 0.3, cabY + 0.35, cabZ + 1.01], parent: root });+ createPart('CabWin_SideL', cabSideWin, glass, { position: [cabX + 0.3, cabY + 0.35, cabZ - 1.01], parent: root });++ // Interior operator seat and dual console joysticks+ const seatGeo = boxGeo(0.65, 0.75, 0.65);+ createPart('OperatorSeat', seatGeo, cabInterior, { position: [cabX + 0.2, cabY - 0.2, cabZ], parent: root });+ const consoleGeo = boxGeo(0.45, 0.65, 0.85);+ createPart('OperatorConsole', consoleGeo, darkSteel, { position: [cabX + 0.85, cabY - 0.3, cabZ], parent: root });++ // ==========================================+ // 8. SPREADER & WIRE HOIST RIGGING+ // Spreader length (40ft = ~9.2m) is ALONG Z (parallel to dock & ship holds)!+ // Spreader width is ALONG X (~2.44m standard container width)+ // ==========================================+ const spreaderY = 9.2;+ const headblockY = spreaderY + 1.45;++ // Headblock (sheave carrier between cables and spreader)+ const headblockGeo = boxGeo(2.2, 0.7, 3.2);+ createPart('Headblock', headblockGeo, hazardYellow, { position: [trolleyX, headblockY, 0], parent: root });++ // 4 Hoist sheaves in headblock+ const hbSheaveGeo = torusGeo(0.38, 0.06, 8, 16);+ createPart('HbSheave_FR', hbSheaveGeo, darkSteel, { position: [trolleyX + 0.8, headblockY + 0.35, 1.1], rotation: [90, 0, 0], parent: root });+ createPart('HbSheave_FL', hbSheaveGeo, darkSteel, { position: [trolleyX + 0.8, headblockY + 0.35, -1.1], rotation: [90, 0, 0], parent: root });+ createPart('HbSheave_RR', hbSheaveGeo, darkSteel, { position: [trolleyX - 0.8, headblockY + 0.35, 1.1], rotation: [90, 0, 0], parent: root });+ createPart('HbSheave_RL', hbSheaveGeo, darkSteel, { position: [trolleyX - 0.8, headblockY + 0.35, -1.1], rotation: [90, 0, 0], parent: root });++ // 4 Main hoist steel cables (deeply overlapping trolley chassis and headblock)+ beamBetween('Cable_FR', [trolleyX + 0.8, trolleyY + 0.2, 1.1], [trolleyX + 0.8, headblockY - 0.1, 1.1], 0.038, cableSteel, { parent: root });+ beamBetween('Cable_FL', [trolleyX + 0.8, trolleyY + 0.2, -1.1], [trolleyX + 0.8, headblockY - 0.1, -1.1], 0.038, cableSteel, { parent: root });+ beamBetween('Cable_RR', [trolleyX - 0.8, trolleyY + 0.2, 1.1], [trolleyX - 0.8, headblockY - 0.1, 1.1], 0.038, cableSteel, { parent: root });+ beamBetween('Cable_RL', [trolleyX - 0.8, trolleyY + 0.2, -1.1], [trolleyX - 0.8, headblockY - 0.1, -1.1], 0.038, cableSteel, { parent: root });++ // Twistlock adapter pins connecting headblock to spreader frame+ [-0.7, 0.7].forEach((hx, hIdx) => {+ [-1.0, 1.0].forEach((hz, zIdx) => {+ beamBetween(`HbPin_${hIdx}_${zIdx}`, [trolleyX + hx, headblockY + 0.1, hz], [trolleyX + hx, spreaderY + 0.4, hz], 0.08, darkSteel, { parent: root });+ });+ });++ // 40ft Telescopic Container Spreader Body+ // Length along Z = 9.2m, width along X = 2.44m, height = 0.65m+ const spreaderMainGeo = boxGeo(2.44, 0.65, 9.2);+ createPart('SpreaderMain', spreaderMainGeo, hazardYellow, { position: [trolleyX, spreaderY, 0], parent: root });++ // Spreader central hydraulic pack & tower+ const hydrPackGeo = boxGeo(1.6, 0.85, 2.4);+ createPart('SpreaderHydraulics', hydrPackGeo, darkSteel, { position: [trolleyX, spreaderY + 0.55, 0], parent: root });++ // Telescoping end beams at Z = +/-4.6+ [-1, 1].forEach((sEnd) => {+ const endZ = sEnd * 4.6;+ const endBeamGeo = boxGeo(2.5, 0.8, 0.6);+ createPart(`SpreaderEnd_${sEnd > 0 ? 'R' : 'L'}`, endBeamGeo, hazardYellow, { position: [trolleyX, spreaderY, endZ], parent: root });++ // 4 Corner flippers (angled guide flippers for centering onto containers)+ [-1, 1].forEach((sX) => {+ const flipX = trolleyX + sX * 1.25;+ const flipperGeo = boxGeo(0.35, 0.95, 0.12);+ createPart(`Flipper_${sEnd > 0 ? 'R' : 'L'}_${sX > 0 ? 'F' : 'R'}`, flipperGeo, hazardYellow, {+ position: [flipX, spreaderY - 0.35, endZ + sEnd * 0.2],+ rotation: [sEnd * 25, 0, 0],+ parent: root,+ });++ // Twistlock pins at corner+ const twistlockGeo = cylinderYGeo(0.14, 0.14, 0.42, 8);+ createPart(`Twistlock_${sEnd > 0 ? 'R' : 'L'}_${sX > 0 ? 'F' : 'R'}`, twistlockGeo, darkSteel, {+ position: [flipX - sX * 0.15, spreaderY - 0.45, endZ],+ parent: root,+ });++ // Twistlock status indicator light+ const statusLightGeo = cylinderYGeo(0.06, 0.06, 0.12, 6);+ createPart(`StatusLight_${sEnd > 0 ? 'R' : 'L'}_${sX > 0 ? 'F' : 'R'}`, statusLightGeo, statusGreen, {+ position: [flipX - sX * 0.15, spreaderY + 0.45, endZ],+ parent: root,+ });+ });+ });++ // ==========================================+ // 9. ACCESS LADDERS & CATWALKS+ // ==========================================+ // Lower caged ladder on Landside-Right leg from dock rail level (Y=1.4) to mid landing (Y=8.8)+ createLadder('LegLadder_Lower', {+ bottom: [legX_LS * 0.95, 1.4, legSpanZ + 0.45],+ top: [legX_LS * 0.72, 8.8, (legSpanZ + deckZ) * 0.5 + 0.45],+ width: 0.5,+ rungCount: 16,+ material: railingYellow,+ parent: root,+ });++ // Mid landing platform at Y = 8.8+ const midLandingGeo = boxGeo(1.4, 0.12, 1.4);+ createPart('MidLanding_LS_R', midLandingGeo, darkSteel, { position: [legX_LS * 0.72, 8.8, (legSpanZ + deckZ) * 0.5 + 0.55], parent: root });++ // Upper ladder from mid landing (Y=8.8) to portal deck (Y=portalH)+ createLadder('LegLadder_Upper', {+ bottom: [legX_LS * 0.72, 8.8, (legSpanZ + deckZ) * 0.5 + 0.45],+ top: [-deckX - 0.1, portalH, deckZ + 0.45],+ width: 0.5,+ rungCount: 16,+ material: railingYellow,+ parent: root,+ });++ // Tower ladder from portal deck (Y=portalH) to boom level (Y=boomH)+ createLadder('TowerLadder', {+ bottom: [-deckX + 0.2, portalH + 0.65, deckZ - 0.2],+ top: [-boomDeckX + 0.2, boomH + 1.0, boomDeckZ - 0.2],+ width: 0.5,+ rungCount: 18,+ material: railingYellow,+ parent: root,+ });++ // Access stairs leading from rear boom deck into Machine House+ createLadder('MHLadder', {+ bottom: [-boomDeckX, boomH + 1.15, 0],+ top: [-4.75, boomH + 2.32, 0],+ width: 0.8,+ rungCount: 4,+ material: railingYellow,+ parent: root,+ });++ return root;+}diff --git a/examples/hero-sheet.png b/examples/hero-sheet.pngindex 14dcd7fe..b9fa70b1 100644Binary files a/examples/hero-sheet.png and b/examples/hero-sheet.png differdiff --git a/examples/hot-air-balloon.kiln.js b/examples/hot-air-balloon.kiln.jsnew file mode 100644index 00000000..08ffe8c9--- /dev/null+++ b/examples/hot-air-balloon.kiln.js@@ -0,0 +1,377 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.++const meta = { name: 'HotAirBalloon', category: 'prop' };++async function build() {+ const root = createRoot('HotAirBalloon');++ // ==========================================+ // MATERIALS PALETTE (11 Functional Materials)+ // ==========================================+ // Striped envelope colors (vibrant carnival / festival balloon)+ const matRed = gameMaterial(0xc62828, { roughness: 0.75 });+ const matCream = gameMaterial(0xf5f3ea, { roughness: 0.75 });+ const matBlue = gameMaterial(0x1565c0, { roughness: 0.75 });+ const matGold = gameMaterial(0xfbc02d, { roughness: 0.75 });+ const envColors = [matRed, matCream, matBlue, matGold];++ // Structural dark trim (skirt, load rings, cables, tank straps)+ const matDarkTrim = gameMaterial(0x242424, { roughness: 0.65 });++ // Metals+ const matSteel = gameMaterial(0xb2bec3, { metalness: 0.88, roughness: 0.28 });+ const matBrass = gameMaterial(0xd4af37, { metalness: 0.90, roughness: 0.25 });++ // Wicker & Wood+ const matWicker = gameMaterial(0x9a6e3e, { roughness: 0.92 });+ const matWickerDark = gameMaterial(0x684722, { roughness: 0.92 });+ const matWood = gameMaterial(0x422610, { roughness: 0.85 });+ const matLeather = gameMaterial(0x381b0c, { roughness: 0.65 });++ // Ballast Canvas & Rigging Ropes+ const matSandbag = gameMaterial(0xcbb082, { roughness: 0.95 });+ const matRope = gameMaterial(0x735038, { roughness: 0.90 });++ // ==========================================+ // 1. BASKET BASE & RUNNERS (Sitting on Y=0)+ // ==========================================+ // Heavy hardwood skids resting on ground Y = 0.00 to 0.06+ const runnerGeo = boxGeo(1.36, 0.06, 0.09);+ createPart('Runner_L', runnerGeo, matWood, { position: [0, 0.03, -0.38], parent: root });+ createPart('Runner_R', runnerGeo, matWood, { position: [0, 0.03, 0.38], parent: root });++ // Transverse floor cross slats+ const crossSlatGeo = boxGeo(0.08, 0.04, 0.86);+ createPart('Slat_F', crossSlatGeo, matWood, { position: [0.50, 0.04, 0], parent: root });+ createPart('Slat_M', crossSlatGeo, matWood, { position: [0, 0.04, 0], parent: root });+ createPart('Slat_B', crossSlatGeo, matWood, { position: [-0.50, 0.04, 0], parent: root });++ // Marine plywood floor board+ const floorGeo = boxGeo(1.28, 0.03, 1.08);+ createPart('Floor', floorGeo, matWood, { position: [0, 0.075, 0], parent: root });++ // ==========================================+ // 2. WICKER BASKET BODY+ // ==========================================+ const basketGroup = createPivot('BasketGroup', [0, 0, 0], root);++ // Four hollow woven wicker walls (height from Y = 0.08 to Y = 1.04)+ const wallLongGeo = boxGeo(0.08, 0.96, 1.08);+ const wallShortGeo = boxGeo(1.20, 0.96, 0.08);++ createPart('Wall_Front', wallLongGeo, matWicker, { position: [0.60, 0.56, 0], parent: basketGroup });+ createPart('Wall_Back', wallLongGeo, matWicker, { position: [-0.60, 0.56, 0], parent: basketGroup });+ createPart('Wall_Left', wallShortGeo, matWicker, { position: [0, 0.56, -0.50], parent: basketGroup });+ createPart('Wall_Right', wallShortGeo, matWicker, { position: [0, 0.56, 0.50], parent: basketGroup });++ // Horizontal woven wicker accent ribs wrapping around exterior+ const bandXGeo = boxGeo(1.30, 0.035, 0.03);+ const bandZGeo = boxGeo(0.03, 0.035, 1.10);+ const bandHeights = [0.20, 0.38, 0.56, 0.74, 0.92];++ for (let b = 0; b < bandHeights.length; b++) {+ const yH = bandHeights[b];+ createPart('BandX_L_' + b, bandXGeo, matWickerDark, { position: [0, yH, -0.53], parent: basketGroup });+ createPart('BandX_R_' + b, bandXGeo, matWickerDark, { position: [0, yH, 0.53], parent: basketGroup });+ createPart('BandZ_F_' + b, bandZGeo, matWickerDark, { position: [0.63, yH, 0], parent: basketGroup });+ createPart('BandZ_B_' + b, bandZGeo, matWickerDark, { position: [-0.63, yH, 0], parent: basketGroup });+ }++ // Heavy stitched leather corner boots at bottom corners+ const cornerBootGeo = boxGeo(0.14, 0.20, 0.14);+ createPart('Boot_FL', cornerBootGeo, matLeather, { position: [0.60, 0.16, -0.50], parent: basketGroup });+ createPart('Boot_FR', cornerBootGeo, matLeather, { position: [0.60, 0.16, 0.50], parent: basketGroup });+ createPart('Boot_BL', cornerBootGeo, matLeather, { position: [-0.60, 0.16, -0.50], parent: basketGroup });+ createPart('Boot_BR', cornerBootGeo, matLeather, { position: [-0.60, 0.16, 0.50], parent: basketGroup });++ // Padded leather bolster rim around top edge of basket (Y = 1.04 to 1.14)+ const bolsterLongGeo = cylinderZGeo(0.055, 0.055, 1.10, 10);+ const bolsterShortGeo = cylinderXGeo(0.055, 0.055, 1.28, 10);+ createPart('Bolster_Front', bolsterLongGeo, matLeather, { position: [0.61, 1.08, 0], parent: basketGroup });+ createPart('Bolster_Back', bolsterLongGeo, matLeather, { position: [-0.61, 1.08, 0], parent: basketGroup });+ createPart('Bolster_Left', bolsterShortGeo, matLeather, { position: [0, 1.08, -0.51], parent: basketGroup });+ createPart('Bolster_Right', bolsterShortGeo, matLeather, { position: [0, 1.08, 0.51], parent: basketGroup });++ // Tapered corner cuffs connecting the bolsters cleanly+ const cornerCapGeo = taperConeGeo(0.065, 0.050, 0.08, 'y', 10);+ createPart('CornerCap_FL', cornerCapGeo, matLeather, { position: [0.61, 1.08, -0.51], parent: basketGroup });+ createPart('CornerCap_FR', cornerCapGeo, matLeather, { position: [0.61, 1.08, 0.51], parent: basketGroup });+ createPart('CornerCap_BL', cornerCapGeo, matLeather, { position: [-0.61, 1.08, -0.51], parent: basketGroup });+ createPart('CornerCap_BR', cornerCapGeo, matLeather, { position: [-0.61, 1.08, 0.51], parent: basketGroup });++ // Braided rope grab handles on front and back+ const handleGeo = torusGeo(0.07, 0.015, 6, 10);+ createPart('Handle_Front', handleGeo, matRope, { position: [0.66, 0.52, 0], rotation: [0, 90, 0], parent: basketGroup });+ createPart('Handle_Back', handleGeo, matRope, { position: [-0.66, 0.52, 0], rotation: [0, 90, 0], parent: basketGroup });++ // ==========================================+ // 3. PROPANE FUEL TANKS (In 4 Corners)+ // ==========================================+ const tankPositions = [+ [0.42, -0.32],+ [0.42, 0.32],+ [-0.42, -0.32],+ [-0.42, 0.32]+ ];++ const tankBodyGeo = cylinderGeo(0.125, 0.125, 0.72, 12);+ const tankBaseGeo = cylinderGeo(0.12, 0.13, 0.06, 12);+ const tankDomeGeo = taperConeGeo(0.125, 0.07, 0.10, 'y', 12);+ const tankCollarGeo = cylinderGeo(0.12, 0.12, 0.10, 12);+ const tankValveGeo = cylinderGeo(0.022, 0.022, 0.05, 8);+ const tankKnobGeo = cylinderGeo(0.032, 0.032, 0.02, 8);+ const tankGaugeGeo = cylinderXGeo(0.028, 0.028, 0.025, 8);+ const strapGeo = boxGeo(0.26, 0.035, 0.035);++ for (let t = 0; t < tankPositions.length; t++) {+ const [tx, tz] = tankPositions[t];+ const tankPivot = createPivot('TankPivot_' + t, [tx, 0.09, tz], basketGroup);++ // Foot base ring+ createPart('TankBase_' + t, tankBaseGeo, matDarkTrim, { position: [0, 0.03, 0], parent: tankPivot });+ // Main vessel body (Y = 0.12 to 0.84)+ createPart('TankBody_' + t, tankBodyGeo, matSteel, { position: [0, 0.42, 0], parent: tankPivot });+ // Upper dome shoulder (Y = 0.84 to 0.94)+ createPart('TankDome_' + t, tankDomeGeo, matSteel, { position: [0, 0.83, 0], parent: tankPivot });+ // Protective collar shroud with cutout handles (Y = 0.94 to 1.04)+ createPart('TankCollar_' + t, tankCollarGeo, matDarkTrim, { position: [0, 0.93, 0], parent: tankPivot });+ // Brass shutoff valve cluster+ createPart('TankValve_' + t, tankValveGeo, matBrass, { position: [0, 0.95, 0], parent: tankPivot });+ createPart('TankKnob_' + t, tankKnobGeo, matRed, { position: [0, 1.00, 0], parent: tankPivot });+ // Pressure gauge dial facing inward toward pilot+ const gaugeX = tx > 0 ? -0.06 : 0.06;+ createPart('TankGauge_' + t, tankGaugeGeo, matBrass, { position: [gaugeX, 0.93, 0], parent: tankPivot });+ // Securing tie-down strap+ createPart('TankStrap_' + t, strapGeo, matDarkTrim, { position: [0, 0.55, 0.11 * Math.sign(tz)], parent: tankPivot });+ }++ // ==========================================+ // 4. SANDBAGS ON BASKET RIM (Ballast Sacks)+ // ==========================================+ // Pear-shaped ballast sack profile+ const sackProfile = [+ [0.01, -0.18],+ [0.075, -0.15],+ [0.098, -0.05],+ [0.088, 0.07],+ [0.045, 0.14],+ [0.028, 0.17]+ ];+ const sackBodyGeo = lathe(sackProfile, 10);+ const cinchGeo = torusGeo(0.036, 0.012, 6, 8);+ const sackMouthGeo = taperConeGeo(0.028, 0.065, 0.07, 'y', 10);++ // 8 sandbags hanging on the basket rim (centered on walls)+ const sandbagPlacements = [+ { name: 'Front_L', pos: [0.68, 0.74, -0.20] },+ { name: 'Front_R', pos: [0.68, 0.74, 0.20] },+ { name: 'Back_L', pos: [-0.68, 0.74, -0.20] },+ { name: 'Back_R', pos: [-0.68, 0.74, 0.20] },+ { name: 'Left_F', pos: [0.22, 0.74, -0.58] },+ { name: 'Left_B', pos: [-0.22, 0.74, -0.58] },+ { name: 'Right_F', pos: [0.22, 0.74, 0.58] },+ { name: 'Right_B', pos: [-0.22, 0.74, 0.58] }+ ];++ for (let s = 0; s < sandbagPlacements.length; s++) {+ const sb = sandbagPlacements[s];+ const sbPivot = createPivot('Sandbag_' + sb.name, sb.pos, basketGroup);++ // Bulging canvas sack body+ createPart('Sack_' + s, sackBodyGeo, matSandbag, { position: [0, 0, 0], parent: sbPivot });+ // Cinched neck rope+ createPart('Cinch_' + s, cinchGeo, matRope, { position: [0, 0.17, 0], parent: sbPivot });+ // Ruffled sack mouth opening+ createPart('Mouth_' + s, sackMouthGeo, matSandbag, { position: [0, 0.21, 0], parent: sbPivot });++ // Hanging rope lanyard securing sack to the bolster rim+ beamBetween(+ 'Rope_' + s,+ [sb.pos[0], sb.pos[1] + 0.17, sb.pos[2]],+ [sb.pos[0] * 0.90, 1.08, sb.pos[2] * 0.90],+ 0.010,+ matRope,+ { segments: 6, parent: basketGroup }+ );+ }++ // ==========================================+ // 5. BURNER FRAME & BURNERS+ // ==========================================+ const burnerGroup = createPivot('BurnerGroup', [0, 0, 0], root);++ // 4 Corner support upright poles rising from basket corners to burner frame+ const poleBasePositions = [+ [0.54, 1.08, -0.44],+ [0.54, 1.08, 0.44],+ [-0.54, 1.08, -0.44],+ [-0.54, 1.08, 0.44]+ ];+ const poleTopPositions = [+ [0.34, 2.12, -0.28],+ [0.34, 2.12, 0.28],+ [-0.34, 2.12, -0.28],+ [-0.34, 2.12, 0.28]+ ];++ for (let p = 0; p < 4; p++) {+ const pBase = poleBasePositions[p];+ const pTop = poleTopPositions[p];+ // Main stainless upright strut+ beamBetween('BurnerPole_' + p, pBase, pTop, 0.018, matSteel, { segments: 8, parent: burnerGroup });+ // Lower leather protective sleeve padding+ const pMid = [pBase[0] * 0.72 + pTop[0] * 0.28, 1.38, pBase[2] * 0.72 + pTop[2] * 0.28];+ beamBetween('PolePadding_' + p, pBase, pMid, 0.028, matLeather, { segments: 8, parent: burnerGroup });+ }++ // Burner gimbal outer frame at Y = 2.15+ const frameXGeo = boxGeo(0.68, 0.035, 0.035);+ const frameZGeo = boxGeo(0.035, 0.035, 0.56);+ createPart('FrameX_L', frameXGeo, matSteel, { position: [0, 2.15, -0.28], parent: burnerGroup });+ createPart('FrameX_R', frameXGeo, matSteel, { position: [0, 2.15, 0.28], parent: burnerGroup });+ createPart('FrameZ_F', frameZGeo, matSteel, { position: [0.34, 2.15, 0], parent: burnerGroup });+ createPart('FrameZ_B', frameZGeo, matSteel, { position: [-0.34, 2.15, 0], parent: burnerGroup });++ // Center crossbar & gimbal pivot+ const crossXGeo = boxGeo(0.68, 0.025, 0.025);+ createPart('CrossBar_Mid', crossXGeo, matDarkTrim, { position: [0, 2.15, 0], parent: burnerGroup });++ // Dual Burner Cans (side-by-side along Z axis)+ const burnerZOffsets = [-0.14, 0.14];+ const burnerCanGeo = cylinderGeo(0.105, 0.095, 0.20, 14);+ const burnerNozzleGeo = taperConeGeo(0.095, 0.125, 0.06, 'y', 14);+ const coilGeo = torusGeo(0.088, 0.014, 8, 14);++ for (let b = 0; b < 2; b++) {+ const bZ = burnerZOffsets[b];+ const bPivot = createPivot('BurnerCan_' + b, [0, 2.22, bZ], burnerGroup);++ // Perforated burner can cylinder+ createPart('CanBody_' + b, burnerCanGeo, matSteel, { position: [0, 0, 0], parent: bPivot });+ // Upper flared nozzle bell+ createPart('Nozzle_' + b, burnerNozzleGeo, matDarkTrim, { position: [0, 0.13, 0], parent: bPivot });+ // Copper vaporizing pre-heat coils lying horizontally across top of nozzle+ createPart('Coil_1_' + b, coilGeo, matBrass, { position: [0, 0.16, 0], rotation: [90, 0, 0], parent: bPivot });+ createPart('Coil_2_' + b, coilGeo, matBrass, { position: [0, 0.20, 0], rotation: [90, 0, 0], parent: bPivot });++ // Pilot light pipe+ const pilotGeo = cylinderGeo(0.012, 0.012, 0.12, 8);+ createPart('Pilot_' + b, pilotGeo, matBrass, { position: [0.08, 0.10, 0], parent: bPivot });+ }++ // Central manifold block+ const manifoldGeo = boxGeo(0.12, 0.07, 0.36);+ createPart('Manifold', manifoldGeo, matDarkTrim, { position: [0, 2.06, 0], parent: burnerGroup });++ // Physical structural mounting brackets connecting Manifold to CrossBar_Mid+ const mountBracketGeo = boxGeo(0.035, 0.08, 0.035);+ createPart('ManifoldMount_L', mountBracketGeo, matDarkTrim, { position: [0, 2.11, -0.14], parent: burnerGroup });+ createPart('ManifoldMount_R', mountBracketGeo, matDarkTrim, { position: [0, 2.11, 0.14], parent: burnerGroup });++ // Squeeze blast valve handles hanging down below manifold+ const valveLeverGeo = cylinderGeo(0.010, 0.010, 0.14, 8);+ const valveKnobGeo = cylinderGeo(0.022, 0.022, 0.04, 8);+ for (let b = 0; b < 2; b++) {+ const bZ = burnerZOffsets[b];+ createPart('ValveLever_' + b, valveLeverGeo, matBrass, { position: [-0.04, 1.98, bZ], rotation: [15, 0, 0], parent: burnerGroup });+ createPart('ValveKnob_' + b, valveKnobGeo, matRed, { position: [-0.04, 1.91, bZ], parent: burnerGroup });+ }++ // Dual pressure gauges on pilot-facing side of manifold+ const gaugeGeo = cylinderXGeo(0.028, 0.028, 0.02, 8);+ createPart('BurnerGauge_L', gaugeGeo, matBrass, { position: [-0.07, 2.06, -0.09], parent: burnerGroup });+ createPart('BurnerGauge_R', gaugeGeo, matBrass, { position: [-0.07, 2.06, 0.09], parent: burnerGroup });++ // 4 Flexible fuel hoses running to all 4 propane tanks+ const hoseRoutes = [+ [[-0.04, 2.03, -0.14], [-0.20, 1.75, -0.22], [-0.34, 1.35, -0.28], [-0.42, 1.04, -0.32]],+ [[-0.04, 2.03, 0.14], [-0.20, 1.75, 0.22], [-0.34, 1.35, 0.28], [-0.42, 1.04, 0.32]],+ [[0.04, 2.03, -0.14], [0.20, 1.75, -0.22], [0.34, 1.35, -0.28], [0.42, 1.04, -0.32]],+ [[0.04, 2.03, 0.14], [0.20, 1.75, 0.22], [0.34, 1.35, 0.28], [0.42, 1.04, 0.32]],+ ];+ for (let h = 0; h < hoseRoutes.length; h++) {+ pipeAlongPath(hoseRoutes[h], 0.011, { bendRadius: 0.06, parent: burnerGroup });+ }++ // ==========================================+ // 6. SUSPENSION FLYING WIRES (Rigging)+ // ==========================================+ const throatRadius = 0.78;+ const throatY = 3.50;++ for (let w = 0; w < 8; w++) {+ const angle = (w * Math.PI * 2) / 8;+ const wx = throatRadius * Math.cos(angle);+ const wz = throatRadius * Math.sin(angle);++ const fromCorner = (w % 2 === 0);+ const origin = fromCorner+ ? [Math.sign(wx) * 0.54, 1.10, Math.sign(wz) * 0.44]+ : [Math.sign(wx) * 0.34, 2.15, Math.sign(wz) * 0.28];++ beamBetween('FlyingWire_' + w, origin, [wx, throatY, wz], 0.007, matDarkTrim, { segments: 6, parent: root });+ const carabinerGeo = torusGeo(0.024, 0.006, 6, 8);+ createPart('Carabiner_' + w, carabinerGeo, matSteel, { position: [wx, throatY, wz], parent: root });+ }++ // ==========================================+ // 7. BALLOON ENVELOPE (Striped Teardrop)+ // ==========================================+ const envelopeGroup = createPivot('EnvelopeGroup', [0, 0, 0], root);++ // Throat load hoop ring+ const throatHoopGeo = torusGeo(throatRadius, 0.035, 8, 20);+ createPart('ThroatHoop', throatHoopGeo, matDarkTrim, { position: [0, throatY, 0], parent: envelopeGroup });++ // Nomex flame-resistant bottom skirt+ const skirtGeo = taperConeGeo(throatRadius, 0.90, 0.35, 'y', 20);+ createPart('NomexSkirt', skirtGeo, matDarkTrim, { position: [0, throatY + 0.17, 0], parent: envelopeGroup });++ // Aerodynamic teardrop envelope profile with smooth hemispherical crown+ const envelopeProfile = [+ [0.90, 3.85], // skirt junction+ [1.25, 4.40],+ [1.80, 5.10],+ [2.45, 5.90],+ [3.20, 6.80],+ [3.85, 7.80],+ [4.30, 8.80], // lower equator+ [4.42, 9.70], // maximum equator diameter (8.84m)+ [4.25, 10.55],+ [3.80, 11.35],+ [3.10, 12.05],+ [2.20, 12.60],+ [1.30, 12.88],+ [0.55, 13.01],+ [0.01, 13.05] // smooth rounded apex+ ];++ // 24 vertical gores (stripes) revolving 15° each+ const goreCount = 24;+ const dAngle = (Math.PI * 2) / goreCount;+ const goreGeo = revolveGeo(envelopeProfile, { angle: dAngle, segments: 3 });++ for (let g = 0; g < goreCount; g++) {+ const mat = envColors[g % 4];+ createPart('Gore_' + g, goreGeo, mat, {+ rotation: [0, (g * 360) / goreCount, 0],+ parent: envelopeGroup+ });+ }++ // Crown apex cap & parachute valve vent disc+ const crownRingGeo = torusGeo(0.50, 0.035, 8, 16);+ createPart('CrownRing', crownRingGeo, matDarkTrim, { position: [0, 13.03, 0], parent: envelopeGroup });++ const crownDiscGeo = cylinderGeo(0.48, 0.48, 0.04, 16);+ createPart('CrownDisc', crownDiscGeo, matDarkTrim, { position: [0, 13.04, 0], parent: envelopeGroup });++ const apexFinialGeo = torusGeo(0.12, 0.02, 6, 12);+ createPart('ApexFinial', apexFinialGeo, matDarkTrim, { position: [0, 13.10, 0], parent: envelopeGroup });++ return root;+}diff --git a/examples/lighthouse.kiln.js b/examples/lighthouse.kiln.jsnew file mode 100644index 00000000..b266df58--- /dev/null+++ b/examples/lighthouse.kiln.js@@ -0,0 +1,238 @@+// Authored by: opencode-go/muse-spark-1.3-contributor, via opencode.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'Lighthouse', category: 'prop' };++async function build() {+ const root = createRoot('Lighthouse');++ const stone = gameMaterial(0xb8ad98, { roughness: 0.93 });+ const stoneDark = gameMaterial(0x8d8471, { roughness: 0.95 });+ const trimWhite = gameMaterial(0xe8e2d4, { roughness: 0.85 });+ const plinthGray = gameMaterial(0x7d7a74, { roughness: 0.95 });+ const iron = gameMaterial(0x1e2126, { roughness: 0.55, metalness: 0.75 });+ const copper = gameMaterial(0x8a5a33, { roughness: 0.45, metalness: 0.85 });+ const copperDark = gameMaterial(0x5e3d24, { roughness: 0.6, metalness: 0.7 });+ const glassMat = glassMaterial(0xbfe3ef, { opacity: 0.35, roughness: 0.1 });+ const lensMat = gameMaterial(0xffe9a8, { emissive: 0xffc63a, emissiveIntensity: 2.2, roughness: 0.3 });+ const lampMat = gameMaterial(0xfff6d8, { emissive: 0xfff2b0, emissiveIntensity: 3.5, roughness: 0.4 });+ const woodDoor = gameMaterial(0x4a3220, { roughness: 0.85 });+ const slate = gameMaterial(0x46505a, { roughness: 0.85 });+ const rockMat = gameMaterial(0x6f6e68, { roughness: 0.98 });+ const rockDark = gameMaterial(0x55544f, { roughness: 0.98 });+ const grassMat = gameMaterial(0x5a6b46, { roughness: 0.95 });++ // rock island+ createPart('BasePlatform', cylinderGeo(5.6, 6.1, 0.5, 28), rockDark, { position: [0, 0.25, 0], parent: root });+ createPart('GrassTop', cylinderGeo(5.35, 5.5, 0.12, 28), grassMat, { position: [0, 0.55, 0], parent: root });++ function makeRock(name, px, pz, s, sy, rotY, mat, seed) {+ let g = boxGeo(s, sy, s * 0.8);+ g = mergeVertices(g);+ const pos = g.getAttribute('position');+ for (let i = 0; i < pos.count; i++) {+ const vx = pos.getX(i), vy = pos.getY(i), vz = pos.getZ(i);+ const j = Math.sin(vx * 12.9898 + seed * 78.233 + vz * 37.719) * 0.16 + Math.cos(vy * 9.5 + seed * 13.7) * 0.1;+ pos.setXYZ(i, vx * (1 + j * 0.5), vy * (1 + j * 0.35), vz * (1 + j * 0.5));+ }+ g.computeVertexNormals();+ g = subdivide(g, 2);+ createPart(name, g, mat, { position: [px, 0.35 + sy * 0.25, pz], rotation: [0, rotY, 0], parent: root });+ }+ makeRock('Rock1', 4.4, 1.2, 1.5, 1.1, 20, rockMat, 1);+ makeRock('Rock2', -4.2, 2.2, 1.8, 1.3, 65, rockMat, 2);+ makeRock('Rock3', 3.4, -3.6, 1.6, 1.0, 110, rockDark, 3);+ makeRock('Rock4', -3.6, -3.4, 2.0, 1.4, 40, rockMat, 4);+ makeRock('Rock5', 0.8, 4.7, 1.3, 0.9, 80, rockDark, 5);+ makeRock('Rock6', -1.2, -4.9, 1.4, 1.0, 15, rockMat, 6);+ makeRock('Rock7', 5.3, -1.1, 1.1, 0.8, 130, rockMat, 7);+ makeRock('Rock8', -5.3, -0.4, 1.2, 0.9, 95, rockDark, 8);++ // tower plinth+ createPart('PlinthStep1', cylinderGeo(2.15, 2.3, 0.35, 28), plinthGray, { position: [0, 0.78, 0], parent: root });+ createPart('PlinthStep2', cylinderGeo(1.9, 2.05, 0.35, 28), stoneDark, { position: [0, 1.1, 0], parent: root });++ // tapered tower+ const towerH = 7.2;+ const towerY = 1.275 + towerH / 2;+ createPart('Tower', cylinderGeo(1.15, 1.68, towerH, 40), stone, { position: [0, towerY, 0], parent: root });++ for (let i = 0; i < 12; i++) {+ const t = i / 11;+ const r = 1.68 + (1.15 - 1.68) * t;+ const y = 1.275 + 0.35 + t * (towerH - 0.5);+ createPart('Course' + i, torusGeo(r + 0.015, 0.028, 6, 36), stoneDark, { position: [0, y, 0], rotation: [90, 0, 0], parent: root });+ }+ for (let c = 0; c < 10; c++) {+ const t = (c + 0.5) / 10;+ const r = 1.68 + (1.15 - 1.68) * t;+ const y = 1.275 + 0.35 + t * (towerH - 0.5);+ const n = 18;+ for (let k = 0; k < n; k++) {+ if ((k + c) % 2 === 0) continue;+ const a = (k / n) * Math.PI * 2 + c * 0.17;+ createPart('Joint_c' + c + '_' + k, boxGeo(0.03, 0.5, 0.035), stoneDark, { position: [Math.cos(a) * (r + 0.008), y + 0.3, Math.sin(a) * (r + 0.008)], rotation: [0, -a * 180 / Math.PI, 0], parent: root });+ }+ }++ createPart('TowerBaseTrim', torusGeo(1.78, 0.07, 8, 36), trimWhite, { position: [0, 1.65, 0], rotation: [90, 0, 0], parent: root });+ createPart('TowerMidTrim', torusGeo(1.42, 0.055, 8, 36), trimWhite, { position: [0, 5.2, 0], rotation: [90, 0, 0], parent: root });++ // door (+X)+ const doorX = 1.62;+ createPart('DoorFrame', boxGeo(0.18, 2.1, 1.2), trimWhite, { position: [doorX, 2.2, 0], parent: root });+ createPart('Door', boxGeo(0.16, 1.85, 0.9), woodDoor, { position: [doorX + 0.04, 2.1, 0], parent: root });+ createPart('DoorLintel', boxGeo(0.3, 0.18, 1.35), stoneDark, { position: [doorX, 3.32, 0], parent: root });+ createPart('DoorHood', boxGeo(0.5, 0.08, 1.4), iron, { position: [doorX + 0.15, 3.48, 0], parent: root });+ createPart('DoorStep', boxGeo(0.7, 0.18, 1.3), plinthGray, { position: [doorX + 0.35, 1.2, 0], parent: root });+ createPart('DoorKnob', sphereGeo(0.05, 8, 6), iron, { position: [doorX + 0.14, 2.05, 0.3], parent: root });++ // windows spiral+ const winAngles = [0.9, 2.6, 4.4];+ const winHeights = [3.6, 5.1, 6.6];+ for (let i = 0; i < 3; i++) {+ const a = winAngles[i], y = winHeights[i];+ const r = 1.68 + (1.15 - 1.68) * ((y - 1.275) / towerH);+ const px = Math.cos(a) * (r - 0.02), pz = Math.sin(a) * (r - 0.02);+ const deg = -a * 180 / Math.PI;+ createPart('WinFrame' + i, boxGeo(0.12, 0.9, 0.64), trimWhite, { position: [px, y, pz], rotation: [0, deg, 0], parent: root });+ createPart('WinGlass' + i, boxGeo(0.14, 0.68, 0.44), iron, { position: [px, y, pz], rotation: [0, deg, 0], parent: root });+ createPart('WinMullV' + i, boxGeo(0.15, 0.68, 0.05), trimWhite, { position: [px, y, pz], rotation: [0, deg, 0], parent: root });+ createPart('WinSill' + i, boxGeo(0.26, 0.09, 0.74), trimWhite, { position: [Math.cos(a) * (r + 0.02), y - 0.5, Math.sin(a) * (r + 0.02)], rotation: [0, deg, 0], parent: root });+ }++ // corbelled gallery+ const galBase = 1.275 + towerH;+ createPart('Corbel1', cylinderGeo(1.3, 1.12, 0.28, 28), stoneDark, { position: [0, galBase + 0.14, 0], parent: root });+ createPart('Corbel2', cylinderGeo(1.55, 1.28, 0.28, 28), stone, { position: [0, galBase + 0.42, 0], parent: root });+ createPart('Corbel3', cylinderGeo(1.8, 1.53, 0.3, 28), stoneDark, { position: [0, galBase + 0.7, 0], parent: root });+ createPart('GalleryDeck', cylinderGeo(1.92, 1.92, 0.16, 28), plinthGray, { position: [0, galBase + 0.9, 0], parent: root });+ for (let i = 0; i < 16; i++) {+ const a = (i / 16) * Math.PI * 2;+ createPart('CorbelBlock' + i, boxGeo(0.22, 0.3, 0.22), stoneDark, { position: [Math.cos(a) * 1.35, galBase + 0.3, Math.sin(a) * 1.35], rotation: [0, -a * 180 / Math.PI, 0], parent: root });+ }+ // deck anchor bolts+ for (let i = 0; i < 12; i++) {+ const a = (i / 12) * Math.PI * 2;+ createPart('DeckBolt' + i, cylinderGeo(0.035, 0.035, 0.07, 6), iron, { position: [Math.cos(a) * 1.65, galBase + 1.0, Math.sin(a) * 1.65], parent: root });+ }++ // railing+ const railY = galBase + 0.98;+ const railR = 1.8;+ for (let i = 0; i < 20; i++) {+ const a = (i / 20) * Math.PI * 2;+ createPart('RailPost' + i, cylinderGeo(0.03, 0.03, 1.0, 8), iron, { position: [Math.cos(a) * railR, railY + 0.5, Math.sin(a) * railR], parent: root });+ }+ createPart('RailTop', torusGeo(railR, 0.045, 8, 36), iron, { position: [0, railY + 1.0, 0], rotation: [90, 0, 0], parent: root });+ createPart('RailMid', torusGeo(railR, 0.03, 6, 36), iron, { position: [0, railY + 0.55, 0], rotation: [90, 0, 0], parent: root });+ // gallery access hatch (iron trap on deck)+ createPart('DeckHatch', boxGeo(0.6, 0.06, 0.6), iron, { position: [0.9, galBase + 1.0, 0.9], parent: root });++ // lantern room+ const lantBase = galBase + 0.98;+ createPart('LanternFloor', cylinderGeo(1.32, 1.32, 0.14, 24), iron, { position: [0, lantBase + 0.05, 0], parent: root });+ createPart('LanternSillRing', torusGeo(1.3, 0.06, 8, 24), iron, { position: [0, lantBase + 0.14, 0], rotation: [90, 0, 0], parent: root });+ for (let i = 0; i < 8; i++) {+ const a = (i / 8) * Math.PI * 2;+ createPart('Mullion' + i, boxGeo(0.09, 1.6, 0.09), iron, { position: [Math.cos(a) * 1.28, lantBase + 0.93, Math.sin(a) * 1.28], rotation: [0, -a * 180 / Math.PI, 0], parent: root });+ }+ createPart('LanternGlass', cylinderGeo(1.28, 1.28, 1.55, 8), glassMat, { position: [0, lantBase + 0.93, 0], parent: root });+ createPart('LanternTopRing', torusGeo(1.3, 0.06, 8, 24), iron, { position: [0, lantBase + 1.72, 0], rotation: [90, 0, 0], parent: root });++ createPart('FresnelLens', cylinderGeo(0.55, 0.62, 1.15, 8), lensMat, { position: [0, lantBase + 0.93, 0], parent: root });+ createPart('FresnelRing1', torusGeo(0.6, 0.035, 6, 8), iron, { position: [0, lantBase + 0.65, 0], rotation: [90, 22.5, 0], parent: root });+ createPart('FresnelRing2', torusGeo(0.585, 0.035, 6, 8), iron, { position: [0, lantBase + 0.93, 0], rotation: [90, 22.5, 0], parent: root });+ createPart('FresnelRing3', torusGeo(0.565, 0.035, 6, 8), iron, { position: [0, lantBase + 1.2, 0], rotation: [90, 22.5, 0], parent: root });+ createPart('LensCapTop', cylinderGeo(0.58, 0.58, 0.08, 8), iron, { position: [0, lantBase + 1.53, 0], parent: root });+ createPart('LensCapBot', cylinderGeo(0.65, 0.65, 0.08, 8), iron, { position: [0, lantBase + 0.33, 0], parent: root });+ createPart('LampBulb', sphereGeo(0.22, 12, 8), lampMat, { position: [0, lantBase + 0.93, 0], parent: root });+ createPart('LampPedestal', cylinderGeo(0.12, 0.2, 0.35, 12), iron, { position: [0, lantBase + 0.28, 0], parent: root });++ // copper dome + weathervane+ const roofY = lantBase + 1.78;+ const dome = createPart('CopperDome', sphereGeo(1.5, 20, 12), copper, { position: [0, roofY + 0.1, 0], parent: root });+ dome.scale.set(1, 0.62, 1);+ createPart('DomeRim', torusGeo(1.48, 0.07, 8, 28), copperDark, { position: [0, roofY + 0.12, 0], rotation: [90, 0, 0], parent: root });+ for (let i = 0; i < 8; i++) {+ const a = (i / 8) * Math.PI * 2;+ beamBetween('DomeRib' + i, [0, roofY + 1.0, 0], [Math.cos(a) * 1.42, roofY + 0.12, Math.sin(a) * 1.42], 0.028, copperDark, { parent: root });+ }+ createPart('FinialBall', sphereGeo(0.14, 12, 8), copperDark, { position: [0, roofY + 1.12, 0], parent: root });+ createPart('VaneRod', cylinderGeo(0.025, 0.025, 1.0, 8), iron, { position: [0, roofY + 1.6, 0], parent: root });+ createPart('VaneArrow', boxGeo(0.7, 0.04, 0.04), iron, { position: [0.05, roofY + 1.85, 0], parent: root });+ createPart('VaneHead', coneXGeo(0.09, 0.22, 8), iron, { position: [0.5, roofY + 1.85, 0], parent: root });+ createPart('VaneTail', boxGeo(0.04, 0.22, 0.16), iron, { position: [-0.3, roofY + 1.85, 0], parent: root });+ createPart('VaneCrossX', boxGeo(0.04, 0.04, 0.5), iron, { position: [0, roofY + 1.65, 0], parent: root });+ createPart('VaneCrossZ', boxGeo(0.5, 0.04, 0.04), iron, { position: [0, roofY + 1.55, 0], parent: root });++ // keeper's cottage+ //+ // The gable ends are pentagons cut to the roof, not rectangles. The first+ // version stood a plain 1.1 m slab on each end wall and let the roof pass+ // across it, which left most of a metre of tan stone standing above the+ // slate at both eaves -- the cottage read as a roofless shell with a roof+ // dropped inside it. A gable is the wall that FILLS the triangle under the+ // pitch, so it is derived from the pitch rather than guessed: same ridge+ // line, same slope, tucked 20 mm under the roof underside so the two can+ // never fight for the same pixel.+ const cx = -0.6, cz = 3.6;+ const roofPitch = 30;+ const roofSlope = Math.tan((roofPitch * Math.PI) / 180);+ const roofT = 0.1; // slate slab thickness+ const ridgeMidY = 3.38 + 0.975 * Math.sin((roofPitch * Math.PI) / 180);+ const roofUnderY = (dz) =>+ ridgeMidY - roofT / 2 / Math.cos((roofPitch * Math.PI) / 180) - roofSlope * Math.abs(dz);+ const gableHalfZ = 1.6; // outer face of the end walls+ const gableGeo = await extrudeProfile(+ [+ [-gableHalfZ, 2.70], // buried 0.2 m into the wall below+ [gableHalfZ, 2.70],+ [gableHalfZ, roofUnderY(gableHalfZ) - 0.02],+ [0, roofUnderY(0) - 0.02],+ [-gableHalfZ, roofUnderY(gableHalfZ) - 0.02],+ ],+ { depth: 0.18, axis: 'x' },+ );+ createPart('CottageWallN', boxGeo(3.6, 2.3, 0.18), stone, { position: [cx, 1.75, cz + 1.5], parent: root });+ createPart('CottageWallS', boxGeo(3.6, 2.3, 0.18), stone, { position: [cx, 1.75, cz - 1.5], parent: root });+ createPart('CottageWallW', boxGeo(0.18, 2.3, 3.2), stone, { position: [cx - 1.8, 1.75, cz], parent: root });+ createPart('CottageWallE', boxGeo(0.18, 2.3, 3.2), stone, { position: [cx + 1.8, 1.75, cz], parent: root });+ createPart('CottageFloor', boxGeo(3.8, 0.15, 3.4), plinthGray, { position: [cx, 0.68, cz], parent: root });+ createPart('CottageGableW', gableGeo, stoneDark, { position: [cx - 1.8, 0, cz], parent: root });+ createPart('CottageGableE', gableGeo, stoneDark, { position: [cx + 1.8, 0, cz], parent: root });+ createPart('CottageRoofL', boxGeo(4.2, 0.1, 1.95), slate, { position: [cx, 3.38, cz + 0.82], rotation: [30, 0, 0], parent: root });+ createPart('CottageRoofR', boxGeo(4.2, 0.1, 1.95), slate, { position: [cx, 3.38, cz - 0.82], rotation: [-30, 0, 0], parent: root });+ createPart('CottageRidge', boxGeo(4.20, 0.09, 0.2), stoneDark, { position: [cx, 3.86, cz], parent: root });+ // roof battens (slate courses)+ for (let i = 0; i < 3; i++) {+ createPart('BattenL' + i, boxGeo(4.20, 0.05, 0.08), stoneDark, { position: [cx, 3.18 + i * 0.24, cz + 1.18 - i * 0.4], rotation: [30, 0, 0], parent: root });+ createPart('BattenR' + i, boxGeo(4.20, 0.05, 0.08), stoneDark, { position: [cx, 3.18 + i * 0.24, cz - 1.18 + i * 0.4], rotation: [-30, 0, 0], parent: root });+ }+ createPart('Chimney', boxGeo(0.5, 1.7, 0.5), stoneDark, { position: [cx - 1.0, 3.9, cz + 0.3], parent: root });+ createPart('ChimneyCap', boxGeo(0.66, 0.12, 0.66), plinthGray, { position: [cx - 1.0, 4.78, cz + 0.3], parent: root });+ createPart('ChimneyPot', cylinderGeo(0.12, 0.16, 0.35, 10), stoneDark, { position: [cx - 1.0, 5.0, cz + 0.3], parent: root });+ createPart('CottageDoor', boxGeo(0.1, 1.7, 0.85), woodDoor, { position: [cx + 1.92, 1.55, cz], parent: root });+ createPart('CottageDoorTrim', boxGeo(0.08, 1.9, 1.05), trimWhite, { position: [cx + 1.88, 1.6, cz], parent: root });+ createPart('CottageDoorStep', boxGeo(0.5, 0.14, 1.1), plinthGray, { position: [cx + 2.2, 0.72, cz], parent: root });+ createPart('CottageWinN', boxGeo(1.0, 0.7, 0.1), iron, { position: [cx + 0.3, 2.0, cz + 1.55], parent: root });+ createPart('CottageWinTrimN', boxGeo(1.15, 0.85, 0.06), trimWhite, { position: [cx + 0.3, 2.0, cz + 1.52], parent: root });+ createPart('CottageMullVN', boxGeo(0.06, 0.7, 0.12), trimWhite, { position: [cx + 0.3, 2.0, cz + 1.56], parent: root });+ createPart('CottageWinS', boxGeo(1.0, 0.7, 0.1), iron, { position: [cx + 0.3, 2.0, cz - 1.55], parent: root });+ createPart('CottageWinTrimS', boxGeo(1.15, 0.85, 0.06), trimWhite, { position: [cx + 0.3, 2.0, cz - 1.52], parent: root });+ createPart('CottageMullVS', boxGeo(0.06, 0.7, 0.12), trimWhite, { position: [cx + 0.3, 2.0, cz - 1.56], parent: root });+ createPart('Passage', boxGeo(1.6, 1.9, 1.4), stone, { position: [-0.3, 1.6, 2.2], rotation: [0, 25, 0], parent: root });+ // stone path: tower door to cottage + edge+ createPart('Path1', boxGeo(1.0, 0.08, 1.1), plinthGray, { position: [2.6, 0.65, 0.4], parent: root });+ createPart('Path2', boxGeo(0.9, 0.08, 1.0), plinthGray, { position: [2.7, 0.65, 1.6], parent: root });+ createPart('Path3', boxGeo(0.9, 0.08, 1.0), plinthGray, { position: [2.2, 0.65, 2.7], parent: root });+ createPart('Path4', boxGeo(0.8, 0.08, 0.9), plinthGray, { position: [1.6, 0.65, 3.4], parent: root });++ return root;+}diff --git a/examples/longcase-clock.kiln.js b/examples/longcase-clock.kiln.jsnew file mode 100644index 00000000..e31ceb16--- /dev/null+++ b/examples/longcase-clock.kiln.js@@ -0,0 +1,785 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Refined later, in this repository, with `kiln_edit`: the hood's break-arch+// was rebuilt from segments, replacing a full torus that read as a circle+// floating over the dial.+// The attribution above is for the authoring run, which had none of this in+// scope. Both passes went through the same tools; only the second one could+// see the gallery it was going into.++const meta = { name: 'LongcaseClock', category: 'prop' };++function build() {+ const root = createRoot('LongcaseClock');++ // =========================================================================+ // Materials Palette (Cohesive, low draw-calls, high instanceability grade)+ // =========================================================================+ const walnutDark = gameMaterial(0x361d10, { roughness: 0.72, metalness: 0.04 }); // Solid English walnut case & moldings+ const walnutBurl = gameMaterial(0x542d16, { roughness: 0.60, metalness: 0.04 }); // Bookmatched burl veneer panels+ const brass = gameMaterial(0xd8ad36, { roughness: 0.22, metalness: 0.90 }); // Polished brass finials, pendulum, weights+ const dialFace = gameMaterial(0xfbf6e8, { roughness: 0.88, metalness: 0.0 }); // Antique cream painted enamel dial face+ const dialBlack = gameMaterial(0x141414, { roughness: 0.85, metalness: 0.1 }); // Enamel black numerals, tracks, hands+ const dialMoon = gameMaterial(0x122244, { roughness: 0.68, metalness: 0.12 }); // Prussian midnight blue lunar arch+ const dialGold = gameMaterial(0xdfb43a, { roughness: 0.25, metalness: 0.85 }); // Painted gold stars and moon face++ // =========================================================================+ // 1. Plinth Base & Bracket Feet (Sitting on Y = 0)+ // =========================================================================+ // 4 Carved Ogee Bracket Feet resting on the floor (Y: 0.00 to 0.09)+ const footPositions = [+ [0.12, 0.045, -0.22], // Front-Left+ [0.12, 0.045, 0.22], // Front-Right+ [-0.12, 0.045, -0.22], // Back-Left+ [-0.12, 0.045, 0.22], // Back-Right+ ];+ for (let i = 0; i < footPositions.length; i++) {+ const [fx, fy, fz] = footPositions[i];+ createPart('Foot_' + i, boxGeo(0.09, 0.09, 0.09), walnutDark, {+ position: [fx, fy, fz],+ parent: root,+ });+ createPart('FootWing_' + i, cylinderGeo(0.04, 0.02, 0.09, 10), walnutDark, {+ position: [fx, fy, fz],+ rotation: [0, 45, 0],+ parent: root,+ });+ }++ // Base Plinth Lower Step (Y: 0.09 to 0.15, size: 0.34 x 0.06 x 0.54)+ createPart('PlinthLowerStep', boxGeo(0.34, 0.06, 0.54), walnutDark, {+ position: [0, 0.12, 0],+ parent: root,+ });++ // Plinth Stepped Cyma Molding (Y: 0.15 to 0.18)+ createPart('PlinthMolding1', boxGeo(0.32, 0.03, 0.52), walnutDark, {+ position: [0, 0.165, 0],+ parent: root,+ });++ // Base Pedestal Carcass (Y: 0.18 to 0.52, size: 0.30 x 0.34 x 0.48)+ createPart('BasePedestal', boxGeo(0.30, 0.34, 0.48), walnutDark, {+ position: [0, 0.35, 0],+ parent: root,+ });++ // Front Inset Burl Walnut Panel on Base (X = +0.152)+ createPart('BasePanelBurlField', boxGeo(0.008, 0.26, 0.40), walnutBurl, {+ position: [0.152, 0.35, 0],+ parent: root,+ });+ // Stepped molding framing the front panel+ createPart('BasePanelBorderTop', boxGeo(0.014, 0.016, 0.41), walnutDark, {+ position: [0.154, 0.48, 0],+ parent: root,+ });+ createPart('BasePanelBorderBottom', boxGeo(0.014, 0.016, 0.41), walnutDark, {+ position: [0.154, 0.22, 0],+ parent: root,+ });+ createPart('BasePanelBorderLeft', boxGeo(0.014, 0.276, 0.016), walnutDark, {+ position: [0.154, 0.35, -0.20],+ parent: root,+ });+ createPart('BasePanelBorderRight', boxGeo(0.014, 0.276, 0.016), walnutDark, {+ position: [0.154, 0.35, 0.20],+ parent: root,+ });+ // Brass corner inlays on base panel+ const baseCornerOffsets = [[0.12, -0.19], [0.12, 0.19], [-0.12, -0.19], [-0.12, 0.19]];+ for (let bc = 0; bc < 4; bc++) {+ const [bcy, bcz] = baseCornerOffsets[bc];+ createPart('BaseCornerInlay_' + bc, sphereGeo(0.006, 8, 6), brass, {+ position: [0.156, 0.35 + bcy, bcz],+ parent: root,+ });+ }++ // Base-to-Waist Transition Moldings (Throat/Waist Rail, Y: 0.52 to 0.58)+ createPart('WaistTransition1', boxGeo(0.28, 0.03, 0.44), walnutDark, {+ position: [0, 0.535, 0],+ parent: root,+ });+ createPart('WaistTransition2', boxGeo(0.25, 0.03, 0.40), walnutDark, {+ position: [0, 0.565, 0],+ parent: root,+ });++ // =========================================================================+ // 2. Trunk / Waist Section (Y: 0.58 to 1.48)+ // =========================================================================+ // Waist Back Panel (X = -0.10)+ createPart('WaistBack', boxGeo(0.02, 0.90, 0.36), walnutDark, {+ position: [-0.10, 1.03, 0],+ parent: root,+ });+ // Waist Left Wall (Z = -0.17)+ createPart('WaistWallLeft', boxGeo(0.20, 0.90, 0.02), walnutDark, {+ position: [0.0, 1.03, -0.17],+ parent: root,+ });+ // Waist Right Wall (Z = +0.17)+ createPart('WaistWallRight', boxGeo(0.20, 0.90, 0.02), walnutDark, {+ position: [0.0, 1.03, 0.17],+ parent: root,+ });+ // Waist Floor Board+ createPart('WaistFloor', boxGeo(0.20, 0.02, 0.34), walnutDark, {+ position: [0.0, 0.59, 0],+ parent: root,+ });+ // Waist Ceiling Board+ createPart('WaistCeiling', boxGeo(0.20, 0.02, 0.34), walnutDark, {+ position: [0.0, 1.47, 0],+ parent: root,+ });++ // Fluted Quarter-Columns on the front corners of the waist (Z = ±0.165, X = +0.095)+ const colZOffsets = [-0.165, 0.165];+ for (let c = 0; c < 2; c++) {+ const cz = colZOffsets[c];+ const prefix = c === 0 ? 'ColL_' : 'ColR_';++ // Turned brass base+ createPart(prefix + 'BrassBase', cylinderGeo(0.022, 0.026, 0.035, 14), brass, {+ position: [0.095, 0.605, cz],+ parent: root,+ });+ createPart(prefix + 'BaseTorus', torusGeo(0.023, 0.005, 6, 14), brass, {+ position: [0.095, 0.622, cz],+ rotation: [90, 0, 0],+ parent: root,+ });++ // Column wooden shaft+ createPart(prefix + 'WoodShaft', cylinderGeo(0.017, 0.018, 0.80, 14), walnutDark, {+ position: [0.095, 1.035, cz],+ parent: root,+ });++ // Reeded fluting ribs (6 vertical ribs)+ for (let r = 0; r < 6; r++) {+ const angle = (r * Math.PI) / 3;+ const rx = 0.095 + 0.0175 * Math.cos(angle);+ const rz = cz + 0.0175 * Math.sin(angle);+ createPart(prefix + 'Reed_' + r, cylinderGeo(0.0035, 0.0035, 0.76, 6), walnutBurl, {+ position: [rx, 1.035, rz],+ parent: root,+ });+ }++ // Turned brass capital+ createPart(prefix + 'BrassCapNeck', cylinderGeo(0.018, 0.017, 0.025, 14), brass, {+ position: [0.095, 1.445, cz],+ parent: root,+ });+ createPart(prefix + 'BrassCapCrown', cylinderGeo(0.026, 0.019, 0.025, 14), brass, {+ position: [0.095, 1.465, cz],+ parent: root,+ });+ }++ // Long Waist Door Frame (Front X = +0.10, clear glazed aperture)+ // Left Stile+ createPart('DoorStileLeft', boxGeo(0.02, 0.86, 0.035), walnutDark, {+ position: [0.10, 1.03, -0.13],+ parent: root,+ });+ // Right Stile+ createPart('DoorStileRight', boxGeo(0.02, 0.86, 0.035), walnutDark, {+ position: [0.10, 1.03, 0.13],+ parent: root,+ });+ // Bottom Rail+ createPart('DoorRailBottom', boxGeo(0.02, 0.045, 0.225), walnutDark, {+ position: [0.10, 0.62, 0],+ parent: root,+ });+ // Top Arched Rail+ createPart('DoorRailTop', boxGeo(0.02, 0.045, 0.225), walnutDark, {+ position: [0.10, 1.44, 0],+ parent: root,+ });+ // Inner beaded molding around door aperture+ createPart('DoorBeadBottom', cylinderGeo(0.004, 0.004, 0.22, 8), brass, {+ position: [0.105, 0.645, 0],+ rotation: [90, 0, 0],+ parent: root,+ });+ createPart('DoorBeadLeft', cylinderGeo(0.004, 0.004, 0.77, 8), brass, {+ position: [0.105, 1.03, -0.11],+ parent: root,+ });+ createPart('DoorBeadRight', cylinderGeo(0.004, 0.004, 0.77, 8), brass, {+ position: [0.105, 1.03, 0.11],+ parent: root,+ });++ // Brass Hinges and Keyhole Escutcheon+ createPart('HingeTop', cylinderGeo(0.005, 0.005, 0.04, 10), brass, {+ position: [0.11, 1.32, -0.148],+ parent: root,+ });+ createPart('HingeBottom', cylinderGeo(0.005, 0.005, 0.04, 10), brass, {+ position: [0.11, 0.74, -0.148],+ parent: root,+ });+ createPart('EscutcheonPlate', boxGeo(0.004, 0.04, 0.022), brass, {+ position: [0.112, 1.03, 0.12],+ parent: root,+ });+ createPart('KeyholeHole', cylinderGeo(0.003, 0.003, 0.008, 6), dialBlack, {+ position: [0.113, 1.03, 0.12],+ rotation: [0, 0, 90],+ parent: root,+ });++ // =========================================================================+ // 3. Interior Clockwork (Drive Weights + Swinging Pendulum)+ // =========================================================================+ // Two Brass Cylindrical Weights (Suspended from movement)+ const weightConfigs = [+ { name: 'WeightTime', x: 0.02, y: 1.15, z: -0.07 }, // Left weight+ { name: 'WeightStrike', x: 0.02, y: 1.05, z: 0.07 }, // Right weight+ ];+ for (const wc of weightConfigs) {+ createPart(wc.name + '_Body', cylinderGeo(0.023, 0.023, 0.16, 16), brass, {+ position: [wc.x, wc.y, wc.z],+ parent: root,+ });+ createPart(wc.name + '_TopCap', sphereGeo(0.023, 12, 8), brass, {+ position: [wc.x, wc.y + 0.08, wc.z],+ scale: [1, 0.5, 1],+ parent: root,+ });+ createPart(wc.name + '_BottomTip', coneGeo(0.023, 0.035, 12), brass, {+ position: [wc.x, wc.y - 0.095, wc.z],+ rotation: [180, 0, 0],+ parent: root,+ });+ createPart(wc.name + '_Pulley', torusGeo(0.011, 0.004, 6, 12), brass, {+ position: [wc.x, wc.y + 0.10, wc.z],+ rotation: [0, 90, 0],+ parent: root,+ });+ const chainLen = 1.47 - (wc.y + 0.11);+ createPart(wc.name + '_Chain', cylinderGeo(0.002, 0.002, chainLen, 6), brass, {+ position: [wc.x, wc.y + 0.11 + chainLen / 2, wc.z],+ parent: root,+ });+ }++ // =========================================================================+ // 4. Swinging Pendulum Assembly (Joint_Pendulum)+ // =========================================================================+ const pendulumPivotY = 1.44;+ const pendulumJoint = createPivot('Pendulum', [0.0, pendulumPivotY, 0.0], root);++ // Top suspension block (local coords)+ createPart('PendulumTopBlock', boxGeo(0.016, 0.025, 0.012), brass, {+ position: [0, -0.0125, 0],+ parent: pendulumJoint,+ });++ // Polished brass pendulum rod (length 0.65m)+ const rodLength = 0.65;+ createPart('PendulumRod', cylinderGeo(0.005, 0.005, rodLength, 10), brass, {+ position: [0, -rodLength / 2, 0],+ parent: pendulumJoint,+ });++ // Heavy Lenticular Brass Bob (Centered at local Y = -0.58)+ const bobY = -0.58;+ createPart('PendulumBobDisc', sphereGeo(0.075, 18, 12), brass, {+ position: [0, bobY, 0],+ scale: [0.28, 1.0, 1.0],+ parent: pendulumJoint,+ });+ createPart('PendulumBobBezel', torusGeo(0.075, 0.008, 8, 20), brass, {+ position: [0, bobY, 0],+ rotation: [0, 90, 0],+ parent: pendulumJoint,+ });+ createPart('PendulumBobRosette', cylinderGeo(0.020, 0.026, 0.010, 12), brass, {+ position: [0.021, bobY, 0],+ rotation: [0, 0, 90],+ parent: pendulumJoint,+ });+ createPart('PendulumBobStar', sphereGeo(0.012, 8, 6), brass, {+ position: [0.026, bobY, 0],+ parent: pendulumJoint,+ });++ // Rating Nut and Bottom Spire+ createPart('PendulumRatingNut', cylinderGeo(0.009, 0.011, 0.020, 8), brass, {+ position: [0, -0.665, 0],+ parent: pendulumJoint,+ });+ createPart('PendulumBottomFinial', coneGeo(0.009, 0.028, 10), brass, {+ position: [0, -0.685, 0],+ rotation: [180, 0, 0],+ parent: pendulumJoint,+ });++ // =========================================================================+ // 5. Throat / Hood Support Moldings (Y: 1.48 to 1.55)+ // =========================================================================+ createPart('ThroatStep1', boxGeo(0.26, 0.02, 0.40), walnutDark, {+ position: [0, 1.49, 0],+ parent: root,+ });+ createPart('ThroatStep2', boxGeo(0.29, 0.02, 0.46), walnutDark, {+ position: [0, 1.51, 0],+ parent: root,+ });+ createPart('ThroatStep3', boxGeo(0.31, 0.02, 0.50), walnutDark, {+ position: [0, 1.53, 0],+ parent: root,+ });++ // =========================================================================+ // 6. Hood / Bonnet Carcass (Y: 1.55 to 2.12)+ // =========================================================================+ // Hood Back Wall+ createPart('HoodBack', boxGeo(0.02, 0.57, 0.48), walnutDark, {+ position: [-0.14, 1.835, 0],+ parent: root,+ });+ // Hood Side Walls with Arched Openings+ const sideZ = [-0.24, 0.24];+ for (let s = 0; s < 2; s++) {+ const sz = sideZ[s];+ const prefix = s === 0 ? 'HoodSideL_' : 'HoodSideR_';++ createPart(prefix + 'Lower', boxGeo(0.28, 0.12, 0.02), walnutDark, {+ position: [0, 1.61, sz],+ parent: root,+ });+ createPart(prefix + 'Upper', boxGeo(0.28, 0.15, 0.02), walnutDark, {+ position: [0, 2.045, sz],+ parent: root,+ });+ createPart(prefix + 'PillarF', boxGeo(0.03, 0.30, 0.02), walnutDark, {+ position: [0.12, 1.82, sz],+ parent: root,+ });+ createPart(prefix + 'PillarB', boxGeo(0.03, 0.30, 0.02), walnutDark, {+ position: [-0.12, 1.82, sz],+ parent: root,+ });+ }++ // Freestanding Turned Hood Columns at front corners (X = +0.14, Z = ±0.235)+ for (let hc = 0; hc < 2; hc++) {+ const hcz = hc === 0 ? -0.235 : 0.235;+ const prefix = hc === 0 ? 'HoodColL_' : 'HoodColR_';++ createPart(prefix + 'BaseBlock', boxGeo(0.045, 0.025, 0.045), walnutDark, {+ position: [0.14, 1.5625, hcz],+ parent: root,+ });+ createPart(prefix + 'BaseBrass', cylinderGeo(0.017, 0.020, 0.025, 14), brass, {+ position: [0.14, 1.585, hcz],+ parent: root,+ });+ createPart(prefix + 'BaseTorus', torusGeo(0.019, 0.0045, 6, 14), brass, {+ position: [0.14, 1.60, hcz],+ rotation: [90, 0, 0],+ parent: root,+ });++ createPart(prefix + 'Shaft', cylinderGeo(0.014, 0.016, 0.44, 14), walnutDark, {+ position: [0.14, 1.83, hcz],+ parent: root,+ });++ createPart(prefix + 'CapBrassNeck', cylinderGeo(0.015, 0.014, 0.02, 14), brass, {+ position: [0.14, 2.06, hcz],+ parent: root,+ });+ createPart(prefix + 'CapBrassCrown', cylinderGeo(0.024, 0.016, 0.025, 14), brass, {+ position: [0.14, 2.0825, hcz],+ parent: root,+ });+ createPart(prefix + 'CapAbacus', boxGeo(0.045, 0.015, 0.045), walnutDark, {+ position: [0.14, 2.1025, hcz],+ parent: root,+ });+ }++ // Hood Arched Door Surround (Front X = +0.145, open aperture framing the dial)+ createPart('HoodDoorStileL', boxGeo(0.02, 0.52, 0.035), walnutDark, {+ position: [0.145, 1.81, -0.20],+ parent: root,+ });+ createPart('HoodDoorStileR', boxGeo(0.02, 0.52, 0.035), walnutDark, {+ position: [0.145, 1.81, 0.20],+ parent: root,+ });+ createPart('HoodDoorRailBottom', boxGeo(0.02, 0.035, 0.38), walnutDark, {+ position: [0.145, 1.5675, 0],+ parent: root,+ });+ // Arched Hood Door Top Arch.+ //+ // This was one full torus, which is a ring and not an arch: its lower half ran+ // straight across the moon lunette and clipped the top of the chapter ring.+ // `torusGeo` takes no arc angle, so the half that is actually wanted is built+ // from segments swept over the top of an ellipse. Each block is turned to the+ // tangent there -- phi = atan2(b cos t, a sin t) -- which is 0 at the crown and+ // a quarter turn at each springing point, so the moulding meets the stiles+ // upright instead of cutting into them.+ const archA = 0.195;+ const archB = 0.145;+ const archY = 1.95;+ const archSegments = 15;+ const geoArchBlock = boxGeo(0.02, 0.036, 0.048);+ for (let i = 0; i < archSegments; i++) {+ const t = (i / (archSegments - 1)) * Math.PI;+ createPart('HoodDoorArch' + i, geoArchBlock, walnutDark, {+ position: [0.145, archY + archB * Math.sin(t), archA * Math.cos(t)],+ rotation: [(Math.atan2(archB * Math.cos(t), archA * Math.sin(t)) * 180) / Math.PI, 0, 0],+ parent: root,+ });+ }+ // Brass door knob+ createPart('HoodDoorKnob', sphereGeo(0.008, 10, 6), brass, {+ position: [0.155, 1.76, 0.19],+ parent: root,+ });++ // =========================================================================+ // 7. The Painted Dial & Movement Assembly (Facing +X)+ // =========================================================================+ const dialCenterX = 0.130;+ const dialCenterY = 1.76;+ const dialCenterZ = 0.0;++ // Solid brass dial backplate (0.36m x 0.36m square)+ createPart('DialPlateSquare', boxGeo(0.008, 0.36, 0.38), brass, {+ position: [dialCenterX - 0.005, dialCenterY, dialCenterZ],+ parent: root,+ });++ // Cast Brass Corner Spandrels in all 4 corners (Rococo scrollwork)+ const spandrelOffsets = [+ [-0.13, -0.13], // Bottom-Left+ [-0.13, 0.13], // Bottom-Right+ [0.13, -0.13], // Top-Left+ [0.13, 0.13], // Top-Right+ ];+ for (let sp = 0; sp < 4; sp++) {+ const [sy, sz] = spandrelOffsets[sp];+ createPart('SpandrelPlate_' + sp, boxGeo(0.005, 0.055, 0.055), brass, {+ position: [dialCenterX + 0.001, dialCenterY + sy, dialCenterZ + sz],+ parent: root,+ });+ createPart('SpandrelScrollA_' + sp, torusGeo(0.024, 0.0045, 6, 10), brass, {+ position: [dialCenterX + 0.003, dialCenterY + sy, dialCenterZ + sz],+ rotation: [0, 90, 0],+ parent: root,+ });+ createPart('SpandrelScrollB_' + sp, torusGeo(0.014, 0.0035, 6, 8), brass, {+ position: [dialCenterX + 0.004, dialCenterY + sy + 0.012, dialCenterZ + sz + 0.012],+ rotation: [0, 90, 45],+ parent: root,+ });+ }++ // Large Painted Cream Dial Face (Radius 0.136m, crisp and prominent)+ createPart('DialPaintedFace', cylinderGeo(0.136, 0.136, 0.008, 24), dialFace, {+ position: [dialCenterX, dialCenterY, dialCenterZ],+ rotation: [0, 0, 90],+ parent: root,+ });++ // Polished Brass Bezel Ring wrapping Chapter Ring+ createPart('DialBrassBezel', torusGeo(0.136, 0.007, 8, 24), brass, {+ position: [dialCenterX + 0.004, dialCenterY, dialCenterZ],+ rotation: [0, 90, 0],+ parent: root,+ });++ // Outer & Inner Minute Tracks (Concentric black enamel rings)+ createPart('DialOuterMinuteTrack', torusGeo(0.128, 0.0018, 4, 24), dialBlack, {+ position: [dialCenterX + 0.005, dialCenterY, dialCenterZ],+ rotation: [0, 90, 0],+ parent: root,+ });+ createPart('DialInnerMinuteTrack', torusGeo(0.122, 0.0018, 4, 24), dialBlack, {+ position: [dialCenterX + 0.005, dialCenterY, dialCenterZ],+ rotation: [0, 90, 0],+ parent: root,+ });+ createPart('DialInnerHourTrack', torusGeo(0.082, 0.0018, 4, 24), dialBlack, {+ position: [dialCenterX + 0.005, dialCenterY, dialCenterZ],+ rotation: [0, 90, 0],+ parent: root,+ });++ // 12 Five-Minute Diamond Markers+ for (let m = 0; m < 12; m++) {+ const angle = (m * 30 * Math.PI) / 180;+ const my = dialCenterY + 0.125 * Math.cos(angle);+ const mz = dialCenterZ + 0.125 * Math.sin(angle);+ createPart('MinutePip_' + m, boxGeo(0.002, 0.0045, 0.0045), dialBlack, {+ position: [dialCenterX + 0.005, my, mz],+ rotation: [45, 0, 0],+ parent: root,+ });+ }++ // 12 Roman Numerals (I through XII)+ const romanHourConfigs = [+ { hour: 12, bars: [{ z: -0.013, rot: 25 }, { z: -0.005, rot: -25 }, { z: 0.004, rot: 0 }, { z: 0.013, rot: 0 }] }, // XII+ { hour: 1, bars: [{ z: 0.0, rot: 0 }] }, // I+ { hour: 2, bars: [{ z: -0.006, rot: 0 }, { z: 0.006, rot: 0 }] }, // II+ { hour: 3, bars: [{ z: -0.009, rot: 0 }, { z: 0.0, rot: 0 }, { z: 0.009, rot: 0 }] }, // III+ { hour: 4, bars: [{ z: -0.010, rot: 0 }, { z: 0.001, rot: -22 }, { z: 0.010, rot: 22 }] }, // IV+ { hour: 5, bars: [{ z: -0.006, rot: -22 }, { z: 0.006, rot: 22 }] }, // V+ { hour: 6, bars: [{ z: -0.009, rot: -22 }, { z: 0.0, rot: 22 }, { z: 0.009, rot: 0 }] }, // VI+ { hour: 7, bars: [{ z: -0.013, rot: -22 }, { z: -0.005, rot: 22 }, { z: 0.004, rot: 0 }, { z: 0.013, rot: 0 }] }, // VII+ { hour: 8, bars: [{ z: -0.017, rot: -22 }, { z: -0.009, rot: 22 }, { z: 0.0, rot: 0 }, { z: 0.008, rot: 0 }, { z: 0.016, rot: 0 }] }, // VIII+ { hour: 9, bars: [{ z: -0.010, rot: 0 }, { z: 0.001, rot: 25 }, { z: 0.010, rot: -25 }] }, // IX+ { hour: 10, bars: [{ z: -0.005, rot: 25 }, { z: 0.005, rot: -25 }] }, // X+ { hour: 11, bars: [{ z: -0.011, rot: 25 }, { z: -0.003, rot: -25 }, { z: 0.008, rot: 0 }] }, // XI+ ];+ const numeralRadius = 0.102;+ for (const nc of romanHourConfigs) {+ const hourRad = ((nc.hour % 12) * 30 * Math.PI) / 180;+ const cy = dialCenterY + numeralRadius * Math.cos(hourRad);+ const cz = dialCenterZ + numeralRadius * Math.sin(hourRad);+ const numeralRotX = -(nc.hour % 12) * 30;++ for (let b = 0; b < nc.bars.length; b++) {+ const bar = nc.bars[b];+ createPart('Num_' + nc.hour + '_' + b, boxGeo(0.002, 0.020, 0.004), dialBlack, {+ position: [dialCenterX + 0.005, cy, cz + bar.z],+ rotation: [numeralRotX + bar.rot, 0, 0],+ parent: root,+ });+ }+ }++ // Painted Moon Phase Lunette (Rolling Moon Arch)+ const moonArchY = 1.99;+ createPart('MoonArchBackdrop', cylinderGeo(0.12, 0.12, 0.006, 20), dialMoon, {+ position: [dialCenterX + 0.001, moonArchY, 0],+ rotation: [0, 0, 90],+ scale: [1, 0.70, 1],+ parent: root,+ });+ // Golden Moon Face (smiling disc)+ createPart('MoonFaceGold', sphereGeo(0.042, 14, 10), dialGold, {+ position: [dialCenterX + 0.004, moonArchY + 0.01, 0],+ scale: [0.15, 1, 1],+ parent: root,+ });+ // Painted Golden Stars in the night sky+ const starCoords = [+ [0.05, -0.06], [0.04, 0.065], [0.06, 0.02],+ [-0.015, -0.075], [-0.025, 0.08], [0.025, -0.025],+ [0.01, 0.04], [0.03, -0.07],+ ];+ for (let st = 0; st < starCoords.length; st++) {+ const [sy, sz] = starCoords[st];+ createPart('StarA_' + st, boxGeo(0.002, 0.009, 0.0025), dialGold, {+ position: [dialCenterX + 0.004, moonArchY + sy, sz],+ parent: root,+ });+ createPart('StarB_' + st, boxGeo(0.002, 0.0025, 0.009), dialGold, {+ position: [dialCenterX + 0.004, moonArchY + sy, sz],+ parent: root,+ });+ }+ // Arched brass surround rim framing the moon dial+ createPart('MoonArchBrassRim', torusGeo(0.12, 0.006, 8, 20), brass, {+ position: [dialCenterX + 0.004, moonArchY, 0],+ rotation: [0, 90, 0],+ parent: root,+ });++ // Center Brass Arbor Collet & Cap Nut+ createPart('CenterArborCollet', cylinderGeo(0.014, 0.014, 0.014, 14), brass, {+ position: [dialCenterX + 0.006, dialCenterY, dialCenterZ],+ rotation: [0, 0, 90],+ parent: root,+ });+ createPart('CenterArborNut', sphereGeo(0.007, 10, 6), brass, {+ position: [dialCenterX + 0.016, dialCenterY, dialCenterZ],+ parent: root,+ });++ // Pierced Ornate Clock Hands (Display time: 10:10)+ // Hour Hand (Pointing towards 10 o'clock: ~120° from +Y)+ createPart('HourHandHeart', torusGeo(0.016, 0.0035, 6, 12), dialBlack, {+ position: [dialCenterX + 0.010, dialCenterY + 0.034, dialCenterZ - 0.028],+ rotation: [0, 90, 30],+ parent: root,+ });+ createPart('HourHandSpadeTip', coneGeo(0.009, 0.024, 8), dialBlack, {+ position: [dialCenterX + 0.010, dialCenterY + 0.052, dialCenterZ - 0.043],+ rotation: [0, 0, -50],+ parent: root,+ });+ createPart('HourHandShaft', cylinderGeo(0.003, 0.0045, 0.038, 6), dialBlack, {+ position: [dialCenterX + 0.010, dialCenterY + 0.017, dialCenterZ - 0.014],+ rotation: [50, 0, 0],+ parent: root,+ });++ // Minute Hand (Pointing towards 2 o'clock: ~60° from +Y)+ createPart('MinuteHandLoop1', torusGeo(0.014, 0.003, 6, 12), dialBlack, {+ position: [dialCenterX + 0.012, dialCenterY + 0.036, dialCenterZ + 0.032],+ rotation: [0, 90, -40],+ parent: root,+ });+ createPart('MinuteHandLoop2', torusGeo(0.010, 0.003, 6, 12), dialBlack, {+ position: [dialCenterX + 0.012, dialCenterY + 0.060, dialCenterZ + 0.052],+ rotation: [0, 90, -40],+ parent: root,+ });+ createPart('MinuteHandNeedle', coneGeo(0.006, 0.044, 8), dialBlack, {+ position: [dialCenterX + 0.012, dialCenterY + 0.088, dialCenterZ + 0.076],+ rotation: [0, 0, 40],+ parent: root,+ });+ createPart('MinuteHandShaft', cylinderGeo(0.003, 0.005, 0.052, 6), dialBlack, {+ position: [dialCenterX + 0.012, dialCenterY + 0.022, dialCenterZ + 0.018],+ rotation: [-40, 0, 0],+ parent: root,+ });++ // =========================================================================+ // 8. Hood Cornice, Swan-Neck Pediment & Brass Finials (Y: 2.12 to 2.36)+ // =========================================================================+ // Stepped Classical Cornice at the top of the hood (Y: 2.12 to 2.16)+ createPart('HoodCorniceLower', boxGeo(0.33, 0.025, 0.52), walnutDark, {+ position: [0, 2.1325, 0],+ parent: root,+ });+ createPart('HoodCorniceUpper', boxGeo(0.35, 0.025, 0.55), walnutDark, {+ position: [0, 2.1575, 0],+ parent: root,+ });++ // Swan-Neck Pediment: Twin Carved Arched Scrolls+ const scrollZOffsets = [-0.15, 0.15];+ for (let sc = 0; sc < 2; sc++) {+ const scz = scrollZOffsets[sc];+ const prefix = sc === 0 ? 'ScrollL_' : 'ScrollR_';+ const sign = sc === 0 ? -1 : 1;++ // Outer primary scroll molding+ createPart(prefix + 'ArchOuter', torusGeo(0.11, 0.018, 8, 16), walnutDark, {+ position: [0.08, 2.19, scz],+ rotation: [0, 90, sign * 25],+ parent: root,+ });+ // Inner fillet molding+ createPart(prefix + 'ArchInner', torusGeo(0.09, 0.008, 6, 14), walnutDark, {+ position: [0.082, 2.19, scz],+ rotation: [0, 90, sign * 25],+ parent: root,+ });+ // Center terminal rosettes in carved brass+ createPart(prefix + 'RosetteBrass', cylinderGeo(0.018, 0.018, 0.018, 14), brass, {+ position: [0.095, 2.245, sign * 0.055],+ rotation: [0, 0, 90],+ parent: root,+ });+ createPart(prefix + 'RosetteOrb', sphereGeo(0.013, 10, 6), brass, {+ position: [0.106, 2.245, sign * 0.055],+ parent: root,+ });+ }++ // Pediment Tympanum Backboard (Bookmatched walnut panel)+ createPart('PedimentTympanum', boxGeo(0.02, 0.14, 0.46), walnutBurl, {+ position: [-0.02, 2.21, 0],+ parent: root,+ });++ // Three Turned Brass Finials on Pedestals (Prompt rule: "brass finials")+ const finialConfigs = [+ { name: 'FinialLeft', px: 0.08, py: 2.17, pz: -0.22, scale: 0.90 },+ { name: 'FinialCenter', px: 0.08, py: 2.22, pz: 0.0, scale: 1.18 }, // Grand master center finial+ { name: 'FinialRight', px: 0.08, py: 2.17, pz: 0.22, scale: 0.90 },+ ];++ for (const fc of finialConfigs) {+ const s = fc.scale;+ createPart(fc.name + '_Plinth', boxGeo(0.050 * s, 0.028 * s, 0.050 * s), walnutDark, {+ position: [fc.px, fc.py + 0.014 * s, fc.pz],+ parent: root,+ });++ const baseY = fc.py + 0.028 * s;++ createPart(fc.name + '_Collar', boxGeo(0.035 * s, 0.012 * s, 0.035 * s), brass, {+ position: [fc.px, baseY + 0.006 * s, fc.pz],+ parent: root,+ });+ createPart(fc.name + '_Pedestal', cylinderGeo(0.013 * s, 0.020 * s, 0.020 * s, 14), brass, {+ position: [fc.px, baseY + 0.021 * s, fc.pz],+ parent: root,+ });+ createPart(fc.name + '_UrnBody', sphereGeo(0.026 * s, 14, 10), brass, {+ position: [fc.px, baseY + 0.046 * s, fc.pz],+ scale: [1, 1.25, 1],+ parent: root,+ });+ createPart(fc.name + '_UrnRim', torusGeo(0.018 * s, 0.0045 * s, 6, 14), brass, {+ position: [fc.px, baseY + 0.072 * s, fc.pz],+ rotation: [90, 0, 0],+ parent: root,+ });+ createPart(fc.name + '_SpireNeck', cylinderGeo(0.008 * s, 0.013 * s, 0.016 * s, 12), brass, {+ position: [fc.px, baseY + 0.083 * s, fc.pz],+ parent: root,+ });+ createPart(fc.name + '_Orb', sphereGeo(0.015 * s, 12, 8), brass, {+ position: [fc.px, baseY + 0.101 * s, fc.pz],+ parent: root,+ });+ createPart(fc.name + '_SpireNeedle', coneGeo(0.008 * s, 0.046 * s, 12), brass, {+ position: [fc.px, baseY + 0.132 * s, fc.pz],+ parent: root,+ });+ }++ return root;+}++// ===========================================================================+// Animation: Grandfather Clock Swinging Pendulum (Smooth Harmonic Motion)+// ===========================================================================+function animate() {+ const duration = 2.0; // Standard 2-second cycle for a 1-second grandfather clock seconds pendulum+ const maxSwingDeg = 5.5; // Natural pendular swing angle with clean cabinet clearance++ // Sinusoidal harmonic oscillation around X axis (Y-Z plane, left-to-right swing)+ // Perfectly loops: pose at t = duration equals pose at t = 0+ const samples = 16;+ const swingKeys = [];+ for (let s = 0; s <= samples; s++) {+ const t = (s * duration) / samples;+ // Harmonic cosine swing: maximum tilt at t = 0 and t = duration, passes 0 at t = 0.5s & 1.5s+ const angleX = maxSwingDeg * Math.cos((2 * Math.PI * t) / duration);+ swingKeys.push({+ time: parseFloat(t.toFixed(4)),+ rotation: [parseFloat(angleX.toFixed(3)), 0, 0],+ });+ }++ return [+ createClip('swing', duration, [+ rotationTrack('Joint_Pendulum', swingKeys),+ ]),+ ];+}\ No newline at end of filediff --git a/examples/lunar-lander.kiln.js b/examples/lunar-lander.kiln.jsdeleted file mode 100644index 6370cf14..00000000--- a/examples/lunar-lander.kiln.js+++ /dev/null@@ -1,379 +0,0 @@-// A lunar module.-//-// Authored by: Claude Opus 5, via Claude Code. Every part below was written by-// the model itself, looking at its own renders through the Kiln tools and-// revising. Not a line of it is hand-authored.-//-// Every other hero in this set is a thing that was MADE TO LOOK LIKE SOMETHING:-// a gun carriage, a lamp column, a motorcycle tank. All of them have designed-// surfaces. A lunar module has none. Nothing about it was styled, because it-// never flew through air and never had to survive being seen. It is a machine-// wrapped in crumpled foil and held together by struts that go exactly where-// the loads are, and its silhouette is the direct output of that.-//-// That makes it the one asset here where SYMMETRY IS THE ENEMY. The real-// vehicle is four-fold symmetric in its structure and violently asymmetric in-// everything bolted to it: one ladder, one dish on one side, one hatch, docking-// target on one face, RCS quads that are the same four times but antennas that-// are not. Build the fittings symmetrically and it stops reading as a-// spacecraft and starts reading as a lamp. So the structure below is generated-// in a four-fold loop and then everything hung on it is placed once, by hand,-// on the face it actually belongs to.-//-// The material lesson is foil. Kapton and aluminised mylar are metallic, but-// they are CRUMPLED, and crumple is a normal-map property, not an albedo one.-// A flat gold albedo at high metalness gives you a brass barrel. The same-// albedo with a strong normal derived from high-frequency noise gives you-// something that reads as thin sheet stretched over a frame, which is the whole-// visual identity of the descent stage.-const meta = { name: 'LunarLander', category: 'vehicle', role: 'hero' };--async function build() {- const root = createRoot('LunarLander');- const uv = (g) => autoUnwrap(g, { resolution: 1024 });- const D = Math.PI / 180;-- // ---------- Dimensions ----------- const DESC_R = 2.05; // octagon circumradius of the descent stage- const DESC_Y0 = 1.32; // descent stage underside- const DESC_Y1 = 2.92; // descent stage deck- const ASC_Y1 = 4.62; // top of the ascent stage- const PAD_R = 3.15; // footpad ring radius-- // ---------- Materials ----------- // Gold Kapton. See the header: the crumple lives in the normal map. Strength- // 4.0 is far past what any other asset here uses, and it is the difference- // between foil and sheet brass.- const foilAlbedo = proceduralTexture({- schemaVersion: 2, size: 1024, usage: 'albedo', name: 'KaptonGold',- layers: [- { op: 'solid', color: 0xa3853f },- { op: 'noise', colorA: 0x8d7134, colorB: 0xc0a25a, scale: 150, octaves: 5, seed: 3, blend: 'overlay', opacity: 0.34 },- { op: 'noise', colorA: 0x7a6229, colorB: 0xa3853f, scale: 34, octaves: 3, seed: 41, blend: 'multiply', opacity: 0.10 },- ],- });- const foil = pbrMaterial({- albedo: foilAlbedo, normal: normalMapFromHeight(foilAlbedo, { strength: 3.0 }),- roughness: 0.56, metalness: 0.34,- });-- // Black Kapton, the same crumple at a different value. The descent stage is- // banded gold and black, and that banding is most of what identifies it.- const blackFoilAlbedo = proceduralTexture({- schemaVersion: 2, size: 512, usage: 'albedo', name: 'KaptonBlack',- layers: [- { op: 'solid', color: 0x35322e },- { op: 'noise', colorA: 0x24221f, colorB: 0x4a463f, scale: 120, octaves: 5, seed: 11, blend: 'overlay', opacity: 0.55 },- ],- });- const blackFoil = pbrMaterial({- albedo: blackFoilAlbedo, normal: normalMapFromHeight(blackFoilAlbedo, { strength: 3.0 }),- roughness: 0.58, metalness: 0.38,- });-- // Thermal white. A DIELECTRIC -- white paint over aluminium, not bare metal.- const whiteAlbedo = proceduralTexture({- schemaVersion: 2, size: 512, usage: 'albedo', name: 'ThermalWhite',- layers: [- { op: 'solid', color: 0xd6d4cf },- { op: 'noise', colorA: 0xbcbab5, colorB: 0xe8e6e1, scale: 40, octaves: 3, seed: 7, blend: 'overlay', opacity: 0.40 },- ],- });- const white = pbrMaterial({- albedo: whiteAlbedo, normal: normalMapFromHeight(whiteAlbedo, { strength: 1.2 }),- roughness: 0.72, metalness: 0.04,- });-- // Bare structure: struts, ladder, engine mount.- const alloyAlbedo = proceduralTexture({- schemaVersion: 2, size: 512, usage: 'albedo', name: 'Alloy',- layers: [- { op: 'solid', color: 0x9a9ea3 },- { op: 'noise', colorA: 0x83878c, colorB: 0xb4b8bd, scale: 46, octaves: 3, seed: 19, blend: 'overlay', opacity: 0.45 },- ],- });- const alloy = pbrMaterial({- albedo: alloyAlbedo, normal: normalMapFromHeight(alloyAlbedo, { strength: 1.0 }),- roughness: 0.42, metalness: 0.88,- });-- // The descent engine bell: ablative, scorched, and rough enough that it does- // not compete with the foil for attention.- const nozzle = gameMaterial(0x3a3330, { roughness: 0.86, metalness: 0.35 });- const glassPane = glassMaterial(0x0d1a1f, { opacity: 0.72, roughness: 0.05, metalness: 0 });- const trim = gameMaterial(0x2b2e31, { roughness: 0.52, metalness: 0.45 });-- const box = async (name, w, h, d, r, position, mat, rotation, parent) =>- createPart(name, await uv(await roundedBoxGeo(w, h, d, r)), mat, {- position, rotation, parent: parent ?? root,- });-- // ---------- Descent stage ----------- // An octagonal prism. Extruded as a profile rather than assembled from boxes,- // because eight faces built as four crossed slabs leaves visible seams at- // every corner and the corners are exactly where the legs attach.- const octagon = (r, rot = 22.5) =>- Array.from({ length: 8 }, (_, i) => {- const a = (i * 45 + rot) * D;- return [Math.cos(a) * r, Math.sin(a) * r];- });-- createPart('DescentBody', await uv(await extrudeProfile(octagon(DESC_R), {- depth: DESC_Y1 - DESC_Y0, axis: 'y', bevel: 0.04,- })), foil, { position: [0, (DESC_Y0 + DESC_Y1) / 2, 0], parent: root });- // Black band around the lower third, and the deck cap on top.- createPart('DescentBand', await uv(await extrudeProfile(octagon(DESC_R + 0.015), {- depth: 0.46, axis: 'y', bevel: 0.02,- })), blackFoil, { position: [0, DESC_Y0 + 0.30, 0], parent: root });- createPart('DescentDeck', await uv(await extrudeProfile(octagon(DESC_R + 0.03), {- depth: 0.10, axis: 'y', bevel: 0.02,- })), alloy, { position: [0, DESC_Y1 + 0.03, 0], parent: root });- createPart('DescentFloor', await uv(await extrudeProfile(octagon(DESC_R - 0.02), {- depth: 0.08, axis: 'y', bevel: 0.02,- })), blackFoil, { position: [0, DESC_Y0 + 0.02, 0], parent: root });- // Panel seams: a batten up each of the eight corners, so the foil reads as- // panels stretched between frames instead of one shrink-wrapped solid.- for (let i = 0; i < 8; i++) {- const a = (i * 45 + 22.5) * D;- createPart(`DescentBatten_${i}`, await uv(await roundedBoxGeo(0.07, DESC_Y1 - DESC_Y0, 0.07, 0.018)), alloy, {- position: [Math.cos(a) * (DESC_R - 0.02), (DESC_Y0 + DESC_Y1) / 2, Math.sin(a) * (DESC_R - 0.02)],- rotation: [0, -i * 45 - 22.5, 0], parent: root,- });- }-- // Quadrant bays, each on a named face and each different. This is the part of- // the descent stage that stops it reading as an octagonal drum.- const faceAt = (deg, out) => {- const a = deg * D;- const rr = DESC_R * Math.cos(22.5 * D) + out;- return [Math.cos(a) * rr, Math.sin(a) * rr];- };- {- // MESA: the stowage pallet, hinged down on the face the ladder faces.- const [mx, mz] = faceAt(270, 0.17);- await box('MesaBay', 1.34, 0.92, 0.34, 0.05, [mx, 2.18, mz], blackFoil);- await box('MesaLid', 1.30, 0.06, 0.44, 0.02, [mx, 2.68, mz - 0.10], alloy, [-14, 0, 0]);- for (const t of [-0.44, 0, 0.44]) {- await box(`MesaStrap_${t.toFixed(2)}`, 0.05, 0.94, 0.04, 0.012, [mx + t, 2.18, mz - 0.17], alloy);- }- }- {- // Science package: a smaller pallet with the RTG cask strapped beside it.- const [sx, sz2] = faceAt(90, 0.14);- await box('SeqBay', 0.96, 0.70, 0.28, 0.05, [sx, 2.30, sz2], blackFoil);- createPart('RtgCask', cylinderZGeo(0.15, 0.15, 0.86, 16), alloy,- { position: [sx - 0.74, 2.12, sz2 + 0.02], rotation: [0, 90, 0], parent: root });- for (const t of [-0.30, 0.30]) {- await box(`SeqStrap_${t.toFixed(2)}`, 0.05, 0.72, 0.04, 0.012, [sx + t, 2.30, sz2 + 0.15], alloy);- }- }- {- // Aft bay: three tanks behind a part-height cover, on the face opposite the- // ladder. Different again, so no two quadrants share a read.- const [ax, az] = faceAt(180, 0.10);- await box('AftDescentCover', 1.10, 0.44, 0.22, 0.04, [ax, 1.76, az], alloy, [0, 90, 0]);- for (const t of [-0.38, 0, 0.38]) {- createPart(`DescentTank_${t.toFixed(2)}`, cylinderGeo(0.16, 0.16, 0.78, 14), white,- { position: [ax - 0.04, 2.42, az + t], parent: root });- }- }-- // ---------- Descent engine ----------- createPart('EngineSkirt', await uv(await revolveProfile([- [0.000, 0.00], [0.300, 0.00], [0.330, 0.12], [0.320, 0.26], [0.000, 0.26],- ], { segments: 24, axis: 'y', smooth: true })), alloy, {- position: [0, DESC_Y0 - 0.26, 0], parent: root,- });- // The bell. A revolve, so the flare is a real curve and it survives being- // looked at from directly underneath. The profile already runs mouth-first- // from y=0, so it needs NO flip -- the first pass turned it 180 degrees and- // drove the whole nozzle through the ground plane.- const bellProfile = [- [0.620, 0.00], [0.600, 0.06], [0.420, 0.36],- [0.300, 0.62], [0.250, 0.86], [0.245, 0.98],- ];- const BELL_Y = 0.08;- createPart('EngineBell', await uv(await revolveProfile(- [[0.000, 0.00], ...bellProfile, [0.000, 0.98]],- { segments: 32, axis: 'y', smooth: true },- )), nozzle, { position: [0, BELL_Y, 0], parent: root });- // Stiffening rings. Their radius is READ OFF the bell profile rather than- // guessed, so every ring sits on the surface at whatever height it lands.- const bellRadiusAt = (y) => {- for (let k = 1; k < bellProfile.length; k++) {- const [r0, y0] = bellProfile[k - 1];- const [r1, y1] = bellProfile[k];- if (y >= y0 && y <= y1) return r0 + (r1 - r0) * ((y - y0) / (y1 - y0));- }- return bellProfile[bellProfile.length - 1][0];- };- for (let i = 0; i < 6; i++) {- const ly = 0.10 + i * 0.165;- createPart(`BellRib_${i}`, torusGeo(bellRadiusAt(ly) + 0.010, 0.018, 6, 28), nozzle, {- position: [0, BELL_Y + ly, 0], rotation: [90, 0, 0], parent: root,- });- }-- // ---------- Landing gear ----------- // Four legs on the diagonals, each a primary strut with two secondary struts- // bracing it back to the stage. This is the part where the structure is- // genuinely four-fold symmetric, so it is the part that gets a loop.- for (let i = 0; i < 4; i++) {- const a = (i * 90 + 45) * D;- const c = Math.cos(a);- const s = Math.sin(a);- const top = [c * (DESC_R - 0.30), DESC_Y1 - 0.14, s * (DESC_R - 0.30)];- const knee = [c * PAD_R, 0.42, s * PAD_R];- const padTop = [c * PAD_R, 0.30, s * PAD_R];-- beamBetween(`LegPrimary_${i}`, top, knee, 0.088, alloy, { parent: root });- // Secondary struts, splayed to either side of the primary.- for (const sd of [-1, 1]) {- const anchor = [- Math.cos(a + sd * 30 * D) * (DESC_R - 0.10), DESC_Y0 + 0.10, Math.sin(a + sd * 30 * D) * (DESC_R - 0.10),- ];- beamBetween(`LegSecondary_${i}${sd > 0 ? 'A' : 'B'}`, anchor, knee, 0.048, alloy, { parent: root });- }- // Deployment truss back up to the deck.- beamBetween(`LegTruss_${i}`, [c * (PAD_R - 0.95), 0.92, s * (PAD_R - 0.95)],- [c * (DESC_R - 0.18), DESC_Y1 - 0.20, s * (DESC_R - 0.18)], 0.036, alloy, { parent: root });-- // Footpad: a shallow dish, not a disc. It has to look like it would sink.- createPart(`Footpad_${i}`, await uv(await revolveProfile([- [0.000, 0.00], [0.400, 0.02], [0.455, 0.10], [0.450, 0.17],- [0.300, 0.19], [0.000, 0.19],- ], { segments: 22, axis: 'y', smooth: true })), alloy, {- position: [padTop[0], 0.0, padTop[2]], parent: root,- });- createPart(`FootpadCollar_${i}`, cylinderGeo(0.085, 0.085, 0.24, 12), alloy, {- position: [padTop[0], 0.30, padTop[2]], parent: root,- });- // Contact probe: the wire that told the crew to cut the engine. One of the- // four was deleted on the real vehicle so it could not spear the ladder.- if (i !== 0) {- beamBetween(`ContactProbe_${i}`, [c * (PAD_R + 0.10), 0.16, s * (PAD_R + 0.10)],- [c * (PAD_R + 0.34), -0.0, s * (PAD_R + 0.34)], 0.014, alloy, { parent: root });- }- }-- // ---------- Ascent stage ----------- // Deliberately not a box and not a cylinder: a wide low body with a canted- // forward face carrying the windows, which is the shape everyone recognises.- await box('AscentBody', 2.10, 1.24, 2.32, 0.14, [0, 3.60, 0], white);- await box('AscentShoulderL', 0.90, 0.52, 2.36, 0.16, [-0.94, 3.36, 0], white);- // Forward face, canted back at the top the way the real crew compartment is.- await box('AscentFace', 0.30, 1.10, 1.84, 0.10, [1.04, 3.66, 0], white, [0, 0, -14]);- // Cabin roof and the black thermal blanket over the aft equipment bay.- await box('AscentRoof', 1.70, 0.22, 2.00, 0.10, [0, 4.30, 0], white);- await box('AftBlanket', 0.70, 1.00, 2.10, 0.12, [-1.10, 3.88, 0], blackFoil);- // Battens and fittings over the blanket. Without these it is a black hole in- // the silhouette; with them it reads as a covered equipment rack.- for (const bz of [-0.72, -0.24, 0.24, 0.72]) {- await box(`AftBatten_${bz.toFixed(2)}`, 0.06, 1.02, 0.05, 0.014, [-1.46, 3.88, bz], alloy);- }- await box('AftGirth', 0.06, 0.05, 2.02, 0.014, [-1.46, 4.26, 0], alloy);- createPart('AftTankA', cylinderZGeo(0.20, 0.20, 0.66, 16), white,- { position: [-1.52, 3.50, 0.48], parent: root });- createPart('AftTankB', cylinderZGeo(0.15, 0.15, 0.52, 14), alloy,- { position: [-1.50, 3.52, -0.62], parent: root });-- // Two triangular windows, canted down so the crew could see the ground. Built- // as thin plates on the canted face rather than cut into it -- a boolean here- // would need the face to be manifold with the shoulder, and the win is zero.- for (const sz of [-1, 1]) {- const mir = (pts) => pts.map(([u, v]) => [u * sz, v]);- createPart(`Window_${sz > 0 ? 'R' : 'L'}`, await uv(await extrudeProfile(mir([- [0.00, 0.39], [0.44, 0.13], [0.39, -0.34], [-0.13, -0.26],- ]), { depth: 0.05, axis: 'x', bevel: 0.012 })), glassPane, {- position: [1.23, 3.80, sz * 0.40], rotation: [0, 0, -14], parent: root,- });- createPart(`WindowFrame_${sz > 0 ? 'R' : 'L'}`, await uv(await extrudeProfile(mir([- [0.00, 0.47], [0.52, 0.17], [0.47, -0.42], [-0.20, -0.33],- ]), { depth: 0.03, axis: 'x', bevel: 0.010 })), trim, {- position: [1.20, 3.80, sz * 0.40], rotation: [0, 0, -14], parent: root,- });- }-- // Forward hatch, square with rounded corners, below and between the windows.- await box('Hatch', 0.12, 0.82, 0.82, 0.05, [1.16, 3.06, 0], white, [0, 0, -4]);- await box('HatchHandle', 0.09, 0.09, 0.30, 0.03, [1.23, 3.06, 0.20], alloy);- // Egress porch and the ladder down the forward leg -- placed ONCE, on +X.- await box('Porch', 0.56, 0.09, 1.00, 0.03, [1.42, 2.98, 0], alloy);- {- const a = 45 * D; // the ladder rides the leg at +45 degrees- const lx = Math.cos(a);- const lz = Math.sin(a);- for (const sd of [-1, 1]) {- beamBetween(`LadderRail_${sd > 0 ? 'A' : 'B'}`,- [1.46 + sd * 0.02 * lz, 2.94, sd * 0.20], [PAD_R * lx * 0.86, 0.50, sd * 0.20], 0.022, alloy, { parent: root });- }- for (let r = 0; r < 9; r++) {- const f = r / 8;- createPart(`LadderRung_${r}`, cylinderZGeo(0.017, 0.017, 0.40, 8), alloy, {- position: [1.46 + (PAD_R * lx * 0.86 - 1.46) * f, 2.94 + (0.50 - 2.94) * f, 0], parent: root,- });- }- }-- // ---------- Fittings, each placed once ----------- // RCS thruster quads at the four corners of the ascent stage. These ARE- // four-fold, so they loop; everything after this does not.- for (let i = 0; i < 4; i++) {- const a = (i * 90 + 45) * D;- const c = Math.cos(a) * 1.34;- const s = Math.sin(a) * 1.42;- await box(`RcsBody_${i}`, 0.26, 0.26, 0.26, 0.05, [c, 3.86, s], alloy);- for (const [dx, dy, dz, nm] of [[0.20, 0, 0, 'F'], [-0.20, 0, 0, 'B'], [0, 0.20, 0, 'U'], [0, -0.20, 0, 'D']]) {- createPart(`RcsNozzle_${i}${nm}`, coneGeo(0.052, 0.11, 10), nozzle, {- position: [c + dx, 3.86 + dy, s + dz],- rotation: [dz ? 90 : 0, 0, dx ? (dx > 0 ? -90 : 90) : (dy > 0 ? 0 : 180)], parent: root,- });- }- }-- // Plume deflectors: a canted plate under each downward thruster, so the down- // jet has something to bounce off instead of the descent stage deck.- for (let i = 0; i < 4; i++) {- const a = (i * 90 + 45) * D;- await box(`PlumeDeflector_${i}`, 0.36, 0.04, 0.30, 0.012,- [Math.cos(a) * 1.34, 3.53, Math.sin(a) * 1.42], alloy, [0, -(i * 90 + 45), 24]);- }-- // Docking tunnel and drogue, on top.- createPart('DockTunnel', cylinderGeo(0.40, 0.44, 0.36, 24), alloy,- { position: [0, ASC_Y1 + 0.12, 0], parent: root });- createPart('DockRing', torusGeo(0.42, 0.045, 8, 28), alloy,- { position: [0, ASC_Y1 + 0.30, 0], rotation: [90, 0, 0], parent: root });- // Rendezvous radar: a dish, offset forward and to one side. Centring it would- // hand the whole vehicle a symmetry it does not have.- createPart('RadarMast', cylinderGeo(0.045, 0.045, 0.44, 10), alloy,- { position: [0.52, 4.72, -0.30], rotation: [0, 0, -16], parent: root });- createPart('RadarDish', await uv(await revolveProfile([- [0.000, 0.00], [0.150, 0.05], [0.290, 0.17], [0.300, 0.20],- [0.150, 0.09], [0.000, 0.03],- ], { segments: 22, axis: 'y', smooth: true })), alloy, {- position: [0.60, 4.94, -0.30], rotation: [0, 0, -52], parent: root,- });- // S-band steerable antenna, on the OTHER side and at a different angle.- createPart('SbandBoom', cylinderGeo(0.035, 0.035, 0.60, 10), alloy,- { position: [-0.30, 4.82, 0.72], rotation: [26, 0, 18], parent: root });- createPart('SbandDish', await uv(await revolveProfile([- [0.000, 0.00], [0.140, 0.06], [0.255, 0.19], [0.262, 0.22],- [0.140, 0.10], [0.000, 0.04],- ], { segments: 20, axis: 'y', smooth: true })), white, {- position: [-0.44, 5.10, 0.86], rotation: [40, 0, 30], parent: root,- });- // VHF whip and the tracking-light strobe.- beamBetween('VhfWhip', [-0.66, 4.34, -0.86], [-0.94, 5.28, -1.06], 0.012, alloy, { parent: root });- createPart('TrackLight', sphereGeo(0.070, 12, 8), white, { position: [0.82, 4.36, 0.62], parent: root });-- // Plume deflectors under the RCS quads, and a couple of hand rails. Small,- // asymmetric, and most of what makes the ascent stage look inhabited.- for (const [hx, hy, hz, rot] of [[1.20, 3.44, 0.62, 0], [1.20, 3.44, -0.62, 0], [-0.10, 4.36, 0.96, 90]]) {- createPart(`HandRail_${hz.toFixed(2)}_${hy.toFixed(2)}`, cylinderZGeo(0.016, 0.016, 0.34, 8), alloy, {- position: [hx, hy, hz], rotation: [0, rot, 0], parent: root,- });- }-- return root;-}diff --git a/examples/orbital-station.kiln.js b/examples/orbital-station.kiln.jsnew file mode 100644index 00000000..ef6e0994--- /dev/null+++ b/examples/orbital-station.kiln.js@@ -0,0 +1,93 @@+// Authored by: gpt-6-astra, via codex.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'OrbitalStation', category: 'prop' };+function build() {+ const root=createRoot('OrbitalStation');+ const white=gameMaterial(0xdce3e4,{roughness:0.6}), dark=gameMaterial(0x293a47,{metalness:0.6}), blue=gameMaterial(0x193f79,{metalness:0.5,roughness:0.3}), glass=gameMaterial(0x63b7c9,{emissive:0x286778,emissiveIntensity:0.35}), gold=gameMaterial(0xc58b43,{metalness:0.5});+ const frame=createPivot('Station',[0,10.25,0],root);+ const rotor=createPivot('HabitatRotor',[0,0,0],frame);+ const part=(n,g,m,p,parent=frame,r=[0,0,0])=>createPart(n,g,m,{position:p,parent,rotation:r});+ const beam=(n,a,b,r,m,parent=frame)=>beamBetween(n,a,b,r,m,{segments:6,parent});+ const ringPoint=(x,r,a)=>[x,r*Math.cos(a),r*Math.sin(a)];+ function wedge(r0,r1,x0,x1,a0,a1) {+ const v=[];for(const x of [x0,x1])for(const r of [r0,r1])for(const a of [a0,a1])v.push(...ringPoint(x,r,a));+ const g=new THREE.BufferGeometry();g.setAttribute('position',new THREE.Float32BufferAttribute(v,3));+ g.setIndex([0,1,3,0,3,2,4,6,7,4,7,5,0,4,5,0,5,1,2,3,7,2,7,6,0,2,6,0,6,4,1,5,7,1,7,3]);g.computeVertexNormals();return g;+ }+ for(let i=0;i<24;i++){+ const a=i*Math.PI/12, b=(i+1)*Math.PI/12, mid=(a+b)/2;+ part('HabitatWedge_'+i,wedge(8.1,9.9,-0.9,0.9,a,b),i%6===0?gold:white,[0,0,0],rotor);+ for(const side of [-1,1]){+ part('WindowBand_'+i+'_'+side,wedge(8.65,9.2,side>0?0.899:-0.93,side>0?0.93:-0.899,a+0.035,b-0.035),glass,[0,0,0],rotor);+ part('WindowMullion_'+i+'_'+side,boxGeo(0.06,0.57,0.055),white,ringPoint(side*0.942,8.925,mid),rotor,[mid*180/Math.PI,0,0]);+ beam('Handrail_'+i+'_'+side,ringPoint(side*1.22,9.65,a),ringPoint(side*1.22,9.65,b),0.045,dark,rotor);+ beam('RailStanchion_'+i+'_'+side,ringPoint(side*0.86,9.65,a),ringPoint(side*1.22,9.65,a),0.045,dark,rotor);+ }+ beam('OuterCoolant_'+i,ringPoint(0,10.15,a),ringPoint(0,10.15,b),0.1,gold,rotor);+ part('CableTray_'+i,boxGeo(0.34,0.12,2.56),dark,ringPoint(-0.5,9.96,mid),rotor,[mid*180/Math.PI,0,0]);+ if(i%2===0){+ part('ServiceJunction_'+i,boxGeo(0.65,0.22,0.5),white,ringPoint(0.25,9.9,mid),rotor,[mid*180/Math.PI,0,0]);+ part('ServiceLatch_'+i,boxGeo(0.18,0.04,0.3),gold,ringPoint(0.25,10.02,mid),rotor,[mid*180/Math.PI,0,0]);+ }+ beam('PipeClamp_'+i,ringPoint(0,9.8,mid),ringPoint(0,10.15,mid),0.12,dark,rotor);+ }+ for(let i=0;i<4;i++){+ const a=i*Math.PI/2, p=createPivot('SpokeFrame'+i,[0,0,0],rotor);p.rotation.x=a;+ part('TaperedSpoke'+i,cylinderGeo(0.65,0.32,6.9,8),white,[0,4.95,0],p);+ beam('SpokeService'+i,[0.4,1.4,0],[0.4,8.2,0],0.08,gold,p);+ for(let j=0;j<3;j++)part('SpokeFlange'+i+'_'+j,boxGeo(1.12,0.15,1.12),dark,[0,3+j*2,0],p);+ }+ part('FixedHub',cylinderXGeo(1.35,1.35,6.4,16),white,[0,0,0]);+ part('RotorBearing',cylinderXGeo(1.58,1.58,1.2,24),dark,[0,0,0]);+ for(const x of [-2.9,2.9])part('HubEndBand'+x,cylinderXGeo(1.43,1.43,0.22,16),gold,[x,0,0]);+ const dock=createPivot('DockingNode',[3.7,0,0],frame);+ part('DockingManifold',cylinderXGeo(0.95,1.15,1.4,12),dark,[0,0,0],dock);+ for(let i=0;i<4;i++){+ const a=i*Math.PI/2;+ beam('RadialDockNeck'+i,ringPoint(0,0.7,a),ringPoint(0,1.65,a),0.42,white,dock);+ const p=createPivot('DockCollarFrame'+i,ringPoint(0,1.7,a),dock);p.rotation.x=a-Math.PI/2;+ part('RadialDockCollar'+i,torusGeo(0.48,0.12,6,12),gold,[0,0,0],p);+ }+ part('AxialDockCollar',cylinderXGeo(0.58,0.58,0.55,12),gold,[4.6,0,0]);+ const craft=createPivot('SupplyCraft',[6.3,0,0],frame);+ part('CargoHull',cylinderXGeo(0.86,0.86,2.9,12),white,[0,0,0],craft);+ part('CargoForwardCap',coneXGeo(0.86,0.75,12),white,[1.8,0,0],craft);+ for(const x of [-1,0.8])part('CargoStrap'+x,cylinderXGeo(0.9,0.9,0.18,12),dark,[x,0,0],craft);+ part('Cockpit',boxGeo(0.7,0.14,0.85),glass,[1,0.82,0],craft);+ for(const s of [-1,1]){+ part('ThrusterPod'+s,cylinderXGeo(0.24,0.3,0.9,8),dark,[-0.8,0,s*0.92],craft);+ beam('ArrayBoom'+s,[-2.5,0,0],[-2.5,0,s*11.4],0.18,white);+ part('GimbalBearing'+s,cylinderZGeo(0.5,0.5,0.8,12),gold,[-2.5,0,s*11.2]);+ const wing=createPivot('SolarWing'+s,[-2.5,0,s*15.2],frame);wing.rotation.z=-0.85;+ part('ArrayBacking_'+s,boxGeo(4.6,0.16,8.2),dark,[0,0,0],wing);+ for(let row=0;row<12;row++)for(let col=0;col<4;col++)+ part('SolarCell_'+s+'_'+row+'_'+col,boxGeo(1.06,0.035,0.6),blue,[-1.68+col*1.12,0.097,-3.63+row*0.66],wing);+ for(const x of [-2.27,0,2.27])beam('ArraySpar_'+s+'_'+x,[x,-0.36,-4.1],[x,-0.36,4.1],0.055,white,wing);+ for(const x of [-2.27,0,2.27])for(const z of [-4,4])beam('TrussTie_'+s+'_'+x+'_'+z,[x,-0.36,z],[x,0,z],0.055,white,wing);+ for(let j=0;j<8;j++){+ beam('ArrayCrossbar_'+s+'_'+j,[-2.3,-0.12,-4+j*1.14],[2.3,-0.12,-4+j*1.14],0.045,white,wing);+ beam('ArrayTruss_'+s+'_'+j,[-2.25,-0.36,-4+j],[2.25,-0.12,-3+j],0.045,white,wing);+ }+ const rad=createPivot('Radiator'+s,[-2.4,s*2.6,0],frame);rad.rotation.x=s*0.45;+ beam('RadiatorMount'+s,[-2.4,s*1,0],[-2.4,s*2.6,0],0.18,dark);+ part('WhiteThermalPanel_'+s,boxGeo(3.4,0.12,4.8),white,[0,0,0],rad);+ for(let j=0;j<7;j++)part('RadiatorChannel_'+s+'_'+j,boxGeo(0.035,0.025,4.65),dark,[-1.4+j*0.46,0.075,0],rad);+ }+ beam('DishMast',[-1.9,1.1,0],[-1.9,3.6,0],0.1,dark);+ part('CommunicationsDish',lathe([[0,0],[0.3,0.04],[0.65,0.2],[1,0.48],[1,0.54],[0.64,0.26],[0.28,0.1],[0,0.07]],16),white,[-1.9,3.6,0]);+ beam('DishFeed',[-1.9,3.6,0],[-1.9,4.5,0],0.05,gold);+ beam('HornMast',[1.8,0.9,0],[1.8,2.8,0.2],0.09,dark);+ part('HornAntenna',cylinderXGeo(0.48,0.12,0.7,4),gold,[2.12,2.8,0.2]);+ root.updateMatrixWorld(true);+ const bounds=new THREE.Box3().setFromObject(root);frame.position.y-=bounds.min.y;+ return root;+}+function animate(){ return [createClip('HabitatRotation',60,[rotationTrack('Joint_HabitatRotor',[0,15,30,45,60].map((time,i)=>({time,rotation:[i*90,0,0]})))])]; }+diff --git a/examples/orrery.kiln.js b/examples/orrery.kiln.jsnew file mode 100644index 00000000..a5f1d278--- /dev/null+++ b/examples/orrery.kiln.js@@ -0,0 +1,551 @@+// Authored by: gemini-3.8-flash-medium, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Refined later, in this repository, with `kiln_edit`: the sun was lowered+// into the plane of the planets, which is the one relationship an orrery+// exists to show.+// The attribution above is for the authoring run, which had none of this in+// scope. Both passes went through the same tools; only the second one could+// see the gallery it was going into.++const meta = { name: 'Orrery', category: 'prop' };++function build() {+ const root = createRoot('Orrery');++ // Materials (PBR brass, mahogany, and planet pigments)+ const mahogany = gameMaterial(0x3a170d, { roughness: 0.45, metalness: 0.05 });+ const darkWood = gameMaterial(0x220c06, { roughness: 0.50, metalness: 0.02 });+ const polishedBrass = gameMaterial(0xd8b04a, { roughness: 0.28, metalness: 0.88 });+ const agedBrass = gameMaterial(0x8a6b2e, { roughness: 0.45, metalness: 0.82 });+ const sunGold = gameMaterial(0xffc520, { roughness: 0.20, metalness: 0.50, emissive: 0xff9a00, emissiveIntensity: 0.35 });+ const mercuryMat = gameMaterial(0x887b73, { roughness: 0.75, metalness: 0.25 });+ const venusMat = gameMaterial(0xe2caa0, { roughness: 0.45, metalness: 0.15 });+ const earthMat = gameMaterial(0x1a4674, { roughness: 0.35, metalness: 0.10 });+ const moonMat = gameMaterial(0xdedede, { roughness: 0.85, metalness: 0.05 });+ const ivory = gameMaterial(0xf7f0df, { roughness: 0.30, metalness: 0.05 });++ // Gear helper: builds disc + radially arrayed spur teeth+ function buildGear(name, teeth, radius, height, mat, parent, opts = {}) {+ const toothWidth = (Math.PI * 2 * radius / teeth) * 0.45;+ const toothDepth = radius * 0.14;+ const rimRadius = radius - toothDepth * 0.4;++ const disc = createPart(`${name}_Disc`, cylinderGeo(rimRadius, rimRadius, height, Math.max(14, teeth)), mat, {+ position: opts.position || [0, 0, 0],+ rotation: opts.rotation,+ parent+ });++ if (opts.rim) {+ createPart(`${name}_RimBezel`, torusGeo(rimRadius * 0.82, height * 0.22, 8, 16), mat, {+ position: [0, 0, 0],+ rotation: [90, 0, 0],+ parent: disc+ });+ }++ const toothGeo = boxGeo(toothDepth, height, toothWidth);+ const tooth0 = createPart(`${name}_Tooth0`, toothGeo, mat, {+ position: [rimRadius + toothDepth * 0.4, 0, 0],+ parent: disc+ });+ arrayRadial(`${name}_Tooth`, tooth0, teeth, 'y', disc);+ return disc;+ }++ // ---------------------------------------------------------------------------+ // Base: Mahogany Stand & Brass Accents (Ground sits on Y=0)+ // ---------------------------------------------------------------------------+ const baseGroup = new THREE.Object3D();+ baseGroup.name = 'BaseStructure';+ root.add(baseGroup);++ // 4 Brass feet touching ground at Y=0 (ball radius 0.03, centered at Y=0.03)+ const footPositions = [+ [0.46, 0.03, 0.46],+ [-0.46, 0.03, 0.46],+ [-0.46, 0.03, -0.46],+ [0.46, 0.03, -0.46]+ ];+ for (let i = 0; i < footPositions.length; i++) {+ const [fx, fy, fz] = footPositions[i];+ createPart(`FootBall_${i}`, sphereGeo(0.03, 14, 10), polishedBrass, {+ position: [fx, fy, fz],+ parent: baseGroup+ });+ createPart(`FootPad_${i}`, cylinderGeo(0.035, 0.04, 0.02, 14), agedBrass, {+ position: [fx, fy + 0.025, fz],+ parent: baseGroup+ });+ createPart(`FootScroll_${i}`, torusGeo(0.026, 0.007, 8, 14), polishedBrass, {+ position: [fx * 0.92, fy + 0.04, fz * 0.92],+ rotation: [45, 0, 45],+ parent: baseGroup+ });+ }++ // Stepped mahogany plinth+ createPart('BasePlinthLow', cylinderGeo(0.68, 0.72, 0.05, 26), darkWood, {+ position: [0, 0.055, 0],+ parent: baseGroup+ });+ createPart('BaseTorus', torusGeo(0.68, 0.018, 8, 24), polishedBrass, {+ position: [0, 0.08, 0],+ rotation: [90, 0, 0],+ parent: baseGroup+ });+ createPart('BasePlinthMid', cylinderGeo(0.64, 0.66, 0.05, 26), mahogany, {+ position: [0, 0.105, 0],+ parent: baseGroup+ });+ createPart('BasePlinthUpper', cylinderGeo(0.58, 0.62, 0.04, 26), mahogany, {+ position: [0, 0.15, 0],+ parent: baseGroup+ });+ createPart('BaseDeck', cylinderGeo(0.54, 0.56, 0.03, 26), darkWood, {+ position: [0, 0.185, 0],+ parent: baseGroup+ });++ // Brass Calendar / Zodiac Ring on deck+ createPart('CalendarDialPlate', cylinderGeo(0.52, 0.52, 0.008, 26), agedBrass, {+ position: [0, 0.204, 0],+ parent: baseGroup+ });+ createPart('CalendarDialRim', torusGeo(0.51, 0.010, 8, 24), polishedBrass, {+ position: [0, 0.21, 0],+ rotation: [90, 0, 0],+ parent: baseGroup+ });+ createPart('CalendarInnerRim', torusGeo(0.42, 0.008, 8, 24), polishedBrass, {+ position: [0, 0.21, 0],+ rotation: [90, 0, 0],+ parent: baseGroup+ });++ // 12 Zodiac hour studs around dial+ for (let i = 0; i < 12; i++) {+ const angle = (i * Math.PI * 2) / 12;+ const mx = Math.cos(angle) * 0.465;+ const mz = Math.sin(angle) * 0.465;+ createPart(`ZodiacStud_${i}`, cylinderGeo(0.008, 0.008, 0.015, 10), ivory, {+ position: [mx, 0.215, mz],+ parent: baseGroup+ });+ }++ // 4 Cardinal pointer markings on dial+ const cardinals = [[0.44, 0], [-0.44, 0], [0, 0.44], [0, -0.44]];+ for (let i = 0; i < cardinals.length; i++) {+ const [cx, cz] = cardinals[i];+ createPart(`CardinalPointer_${i}`, boxGeo(0.03, 0.006, 0.015), polishedBrass, {+ position: [cx, 0.212, cz],+ parent: baseGroup+ });+ }++ // ---------------------------------------------------------------------------+ // Central Mechanism Frame (Clockwork Cage)+ // ---------------------------------------------------------------------------+ const mechGroup = new THREE.Object3D();+ mechGroup.name = 'MechanismFrame';+ root.add(mechGroup);++ createPart('PillarBoss', cylinderGeo(0.18, 0.22, 0.04, 22), polishedBrass, {+ position: [0, 0.22, 0],+ parent: mechGroup+ });+ createPart('PillarBaseCollar', cylinderGeo(0.12, 0.16, 0.03, 22), agedBrass, {+ position: [0, 0.255, 0],+ parent: mechGroup+ });++ const pillarCoords = [+ [0.10, 0.10],+ [-0.10, 0.10],+ [-0.10, -0.10],+ [0.10, -0.10]+ ];+ for (let i = 0; i < pillarCoords.length; i++) {+ const [px, pz] = pillarCoords[i];+ createPart(`PillarBase_${i}`, cylinderGeo(0.025, 0.03, 0.02, 12), polishedBrass, {+ position: [px, 0.28, pz],+ parent: mechGroup+ });+ createPart(`PillarShaft_${i}`, cylinderGeo(0.016, 0.016, 0.14, 12), agedBrass, {+ position: [px, 0.36, pz],+ parent: mechGroup+ });+ createPart(`PillarTop_${i}`, cylinderGeo(0.03, 0.025, 0.02, 12), polishedBrass, {+ position: [px, 0.44, pz],+ parent: mechGroup+ });+ }++ createPart('MechPlateUpper', cylinderGeo(0.19, 0.19, 0.015, 22), polishedBrass, {+ position: [0, 0.46, 0],+ parent: mechGroup+ });++ // Central Spindle and turned decorative sleeves+ // Shortened with the sun. At 0.90 the spindle topped out at Y=1.37 to meet a+ // sun cradled at 1.34; with the sun brought down into the planet plane the+ // same rod would run straight up through the sphere and out of the top.+ createPart('CentralSpindle', cylinderGeo(0.022, 0.022, 0.72, 18), polishedBrass, {+ position: [0, 0.83, 0],+ parent: mechGroup+ });+ createPart('SpindleMidCollar', cylinderGeo(0.036, 0.036, 0.025, 18), agedBrass, {+ position: [0, 0.98, 0],+ parent: mechGroup+ });+ createPart('SpindleMidBezel', torusGeo(0.038, 0.007, 8, 18), polishedBrass, {+ position: [0, 1.15, 0],+ rotation: [90, 0, 0],+ parent: mechGroup+ });++ // Fixed central base gear+ buildGear('FixedBaseGear', 26, 0.155, 0.022, agedBrass, mechGroup, {+ position: [0, 0.48, 0],+ rim: true+ });++ // Secondary idler shaft & gears+ createPart('IdlerShaft', cylinderGeo(0.010, 0.010, 0.38, 10), polishedBrass, {+ position: [0.12, 0.65, 0.08],+ parent: mechGroup+ });+ buildGear('IdlerGear1', 16, 0.075, 0.018, agedBrass, mechGroup, {+ position: [0.12, 0.54, 0.08]+ });+ buildGear('IdlerGear2', 14, 0.065, 0.018, agedBrass, mechGroup, {+ position: [0.12, 0.66, 0.08]+ });+ buildGear('IdlerGear3', 12, 0.055, 0.018, agedBrass, mechGroup, {+ position: [0.12, 0.78, 0.08]+ });++ // ---------------------------------------------------------------------------+ // Winding Crank Mechanism (Moving joint Joint_Crank)+ // ---------------------------------------------------------------------------+ createPart('CrankBracket', boxGeo(0.09, 0.035, 0.04), agedBrass, {+ position: [0.14, 0.36, 0],+ parent: mechGroup+ });+ createPart('CrankBearing', boxGeo(0.05, 0.05, 0.06), agedBrass, {+ position: [0.18, 0.36, 0],+ parent: mechGroup+ });++ const crankJoint = createPivot('Crank', [0.22, 0.36, 0], root);+ createPart('CrankAxle', cylinderXGeo(0.01, 0.01, 0.10, 10), polishedBrass, {+ position: [0.05, 0, 0],+ parent: crankJoint+ });++ buildGear('CrankPinion', 12, 0.048, 0.016, agedBrass, crankJoint, {+ position: [-0.02, 0, 0],+ rotation: [0, 0, 90]+ });++ createPart('CrankArm', boxGeo(0.015, 0.11, 0.02), polishedBrass, {+ position: [0.10, 0.045, 0],+ parent: crankJoint+ });+ createPart('CrankHubCollar', cylinderXGeo(0.018, 0.018, 0.02, 12), agedBrass, {+ position: [0.10, 0, 0],+ parent: crankJoint+ });+ createPart('CrankPin', cylinderXGeo(0.008, 0.008, 0.06, 10), polishedBrass, {+ position: [0.13, 0.09, 0],+ parent: crankJoint+ });+ createPart('CrankIvoryKnob', cylinderXGeo(0.016, 0.012, 0.05, 14), ivory, {+ position: [0.145, 0.09, 0],+ parent: crankJoint+ });++ // ---------------------------------------------------------------------------+ // Arm 3: Earth & Moon (Outermost planet, lowest arm tier at Y=0.54, R3 = 0.94m)+ // By placing the outermost arm at the lowest tier, its long arm sweeps below+ // Venus and Mercury, completely preventing mechanical binding!+ // ---------------------------------------------------------------------------+ const earthJoint = createPivot('EarthArm', [0, 0.54, 0], root);++ createPart('EarthCollar', cylinderGeo(0.046, 0.046, 0.035, 14), polishedBrass, {+ position: [0, 0, 0],+ parent: earthJoint+ });+ buildGear('EarthGear', 28, 0.165, 0.02, agedBrass, earthJoint, {+ position: [0, -0.01, 0],+ rim: true+ });++ beamBetween('EarthRailLower', [0, 0, 0], [0.94, 0, 0], 0.008, polishedBrass, { parent: earthJoint });+ beamBetween('EarthRailUpper', [0.05, 0.045, 0], [0.94, 0.045, 0], 0.007, polishedBrass, { parent: earthJoint });++ const strutXs = [0.24, 0.44, 0.64, 0.84];+ for (let i = 0; i < strutXs.length; i++) {+ const sx = strutXs[i];+ beamBetween(`EarthStrut_${i}`, [sx, 0, 0], [sx, 0.045, 0], 0.005, agedBrass, { parent: earthJoint });+ beamBetween(`EarthDiag_${i}`, [sx - 0.08, 0, 0], [sx, 0.045, 0], 0.004, agedBrass, { parent: earthJoint });+ }++ beamBetween('EarthCounterArm', [0, 0.02, 0], [-0.30, 0.02, 0], 0.009, polishedBrass, { parent: earthJoint });+ createPart('EarthWeightBase', cylinderGeo(0.048, 0.052, 0.05, 16), agedBrass, {+ position: [-0.30, 0.02, 0],+ parent: earthJoint+ });+ createPart('EarthWeightFinial', sphereGeo(0.032, 14, 10), polishedBrass, {+ position: [-0.35, 0.02, 0],+ parent: earthJoint+ });++ // Earth riser column at R3 = 0.94m rising up to Y = 0.96 (world Y = 1.50)+ beamBetween('EarthRiserPillar', [0.94, 0, 0], [0.94, 0.96, 0], 0.010, polishedBrass, { parent: earthJoint });+ createPart('EarthGearboxHousing', cylinderGeo(0.038, 0.042, 0.045, 14), agedBrass, {+ position: [0.94, 0.97, 0],+ parent: earthJoint+ });+ buildGear('EarthMiniGear', 14, 0.038, 0.014, polishedBrass, earthJoint, {+ position: [0.94, 1.00, 0]+ });++ // Miniature Armillary Gimbal around Earth (23.5 degrees axial tilt)+ const meridianTilt = 23.5;+ createPart('EarthMeridianRing', torusGeo(0.12, 0.007, 8, 20), polishedBrass, {+ position: [0.94, 1.08, 0],+ rotation: [0, 0, meridianTilt],+ parent: earthJoint+ });+ createPart('EarthEquatorRing', torusGeo(0.11, 0.005, 8, 18), polishedBrass, {+ position: [0.94, 1.08, 0],+ rotation: [90, 0, meridianTilt],+ parent: earthJoint+ });+ createPart('EarthAxisPin', cylinderGeo(0.005, 0.005, 0.26, 10), agedBrass, {+ position: [0.94, 1.08, 0],+ rotation: [0, 0, meridianTilt],+ parent: earthJoint+ });+ createPart('EarthSphere', sphereGeo(0.076, 22, 16), earthMat, {+ position: [0.94, 1.08, 0],+ parent: earthJoint+ });++ // Moon Sub-assembly (pivots around Earth, parented to Joint_EarthArm)+ const moonJoint = createPivot('Moon', [0.94, 1.02, 0], earthJoint);++ beamBetween('MoonArmBeam', [0, 0, 0], [0.18, 0.04, 0], 0.004, polishedBrass, { parent: moonJoint });+ beamBetween('MoonRiser', [0.18, 0.04, 0], [0.18, 0.06, 0], 0.003, polishedBrass, { parent: moonJoint });+ beamBetween('MoonCounterArm', [0, 0, 0], [-0.05, 0, 0], 0.003, agedBrass, { parent: moonJoint });+ createPart('MoonWeightBall', sphereGeo(0.012, 12, 8), agedBrass, {+ position: [-0.05, 0, 0],+ parent: moonJoint+ });+ createPart('MoonSphere', sphereGeo(0.024, 14, 10), moonMat, {+ position: [0.18, 0.06, 0],+ parent: moonJoint+ });++ // ---------------------------------------------------------------------------+ // Arm 2: Venus (Middle planet, middle arm tier at Y=0.66, R2 = 0.64m)+ // Reaches to R=0.64, well inside Earth's riser at R=0.94+ // ---------------------------------------------------------------------------+ const venusJoint = createPivot('Venus', [0, 0.66, 0], root);+ venusJoint.rotation.y = THREE.MathUtils.degToRad(210);++ createPart('VenusCollar', cylinderGeo(0.040, 0.040, 0.035, 14), polishedBrass, {+ position: [0, 0, 0],+ parent: venusJoint+ });+ buildGear('VenusGear', 22, 0.135, 0.02, agedBrass, venusJoint, {+ position: [0, -0.01, 0],+ rim: true+ });++ beamBetween('VenusArmBeam', [0, 0, 0], [0.64, 0, 0], 0.008, polishedBrass, { parent: venusJoint });++ createPart('VenusScroll', torusGeo(0.06, 0.005, 8, 16), polishedBrass, {+ position: [0.32, -0.052, 0],+ rotation: [0, 0, 0],+ parent: venusJoint+ });++ beamBetween('VenusCounterArm', [0, 0, 0], [-0.22, 0, 0], 0.007, polishedBrass, { parent: venusJoint });+ createPart('VenusWeightCylinder', cylinderGeo(0.035, 0.035, 0.04, 14), agedBrass, {+ position: [-0.22, 0, 0],+ parent: venusJoint+ });+ createPart('VenusWeightFinial', sphereGeo(0.022, 14, 10), polishedBrass, {+ position: [-0.25, 0, 0],+ parent: venusJoint+ });++ beamBetween('VenusRiser', [0.64, 0, 0], [0.64, 0.74, 0], 0.007, polishedBrass, { parent: venusJoint });+ createPart('VenusCup', coneGeo(0.022, 0.03, 12), agedBrass, {+ position: [0.64, 0.755, 0],+ parent: venusJoint+ });+ createPart('VenusSphere', sphereGeo(0.066, 20, 14), venusMat, {+ position: [0.64, 0.82, 0],+ parent: venusJoint+ });++ // ---------------------------------------------------------------------------+ // Arm 1: Mercury (Innermost planet, top arm tier at Y=0.78, R1 = 0.36m)+ // Sits highest in the gear stack, perfectly clear of Venus (R=0.64) and Earth (R=0.94)+ // ---------------------------------------------------------------------------+ const mercuryJoint = createPivot('Mercury', [0, 0.78, 0], root);+ mercuryJoint.rotation.y = THREE.MathUtils.degToRad(75);++ createPart('MercCollar', cylinderGeo(0.036, 0.036, 0.035, 14), polishedBrass, {+ position: [0, 0, 0],+ parent: mercuryJoint+ });+ buildGear('MercGear', 18, 0.105, 0.02, agedBrass, mercuryJoint, {+ position: [0, -0.01, 0],+ rim: true+ });++ beamBetween('MercArmBeam', [0, 0, 0], [0.36, 0, 0], 0.007, polishedBrass, { parent: mercuryJoint });++ createPart('MercScroll', torusGeo(0.055, 0.004, 8, 16), polishedBrass, {+ position: [0.18, -0.048, 0],+ rotation: [0, 0, 0],+ parent: mercuryJoint+ });++ beamBetween('MercCounterArm', [0, 0, 0], [-0.14, 0, 0], 0.006, polishedBrass, { parent: mercuryJoint });+ createPart('MercWeightBall', sphereGeo(0.028, 14, 10), agedBrass, {+ position: [-0.14, 0, 0],+ parent: mercuryJoint+ });++ beamBetween('MercRiser', [0.36, 0, 0], [0.36, 0.50, 0], 0.006, polishedBrass, { parent: mercuryJoint });+ createPart('MercCup', coneGeo(0.016, 0.025, 12), agedBrass, {+ position: [0.36, 0.51, 0],+ parent: mercuryJoint+ });+ createPart('MercurySphere', sphereGeo(0.042, 16, 12), mercuryMat, {+ position: [0.36, 0.56, 0],+ parent: mercuryJoint+ });++ // ---------------------------------------------------------------------------+ // The Sun.+ //+ // It used to sit at Y=1.66, on top of a 0.90 m spindle, with the three planets+ // banded between 1.34 and 1.62 below and around it. Every part was individually+ // fine and the whole thing read as a table lamp: the one relationship an orrery+ // exists to show is that the planets go ROUND the sun, and a sun mounted above+ // them shows the opposite. Dropped to 1.48, which is the mean of Mercury (1.34),+ // Venus (1.48) and Earth (1.62), so the orbits now pass through it.+ // ---------------------------------------------------------------------------+ const sunGroup = new THREE.Object3D();+ sunGroup.name = 'SunAssembly';+ root.add(sunGroup);++ createPart('SunFinialBase', cylinderGeo(0.048, 0.065, 0.08, 18), polishedBrass, {+ position: [0, 1.16, 0],+ parent: sunGroup+ });+ createPart('SunNeck', cylinderGeo(0.030, 0.045, 0.08, 18), agedBrass, {+ position: [0, 1.24, 0],+ parent: sunGroup+ });+ createPart('SunCup', cylinderGeo(0.085, 0.04, 0.05, 20), polishedBrass, {+ position: [0, 1.305, 0],+ parent: sunGroup+ });++ // 16 Radiant Sunburst Rays+ for (let i = 0; i < 16; i++) {+ const angle = (i * Math.PI * 2) / 16;+ const rx = Math.cos(angle) * 0.085;+ const rz = Math.sin(angle) * 0.085;+ createPart(`SunRay_${i}`, coneGeo(0.009, 0.055, 8), sunGold, {+ position: [rx, 1.32, rz],+ rotation: [Math.sin(angle) * 35, 0, -Math.cos(angle) * 35],+ parent: sunGroup+ });+ }++ createPart('SunSphere', sphereGeo(0.165, 24, 18), sunGold, {+ position: [0, 1.48, 0],+ parent: sunGroup+ });++ return root;+}++function animate() {+ const duration = 12;++ // Track 1: Hand Crank (turns on X axis, 12 revolutions in 12s)+ const crankKeys = [];+ const crankSteps = 48;+ for (let i = 0; i <= crankSteps; i++) {+ crankKeys.push({+ time: (i * duration) / crankSteps,+ rotation: [(i * 90) % 360, 0, 0]+ });+ }++ // Track 2: Mercury (starts at 75°, completes 4 revolutions in 12s)+ const mercKeys = [];+ const mercSteps = 16;+ const mercBase = 75;+ for (let i = 0; i <= mercSteps; i++) {+ mercKeys.push({+ time: (i * duration) / mercSteps,+ rotation: [0, (mercBase + i * 90) % 360, 0]+ });+ }++ // Track 3: Venus (starts at 210°, completes 2 revolutions in 12s)+ const venusKeys = [];+ const venusSteps = 8;+ const venusBase = 210;+ for (let i = 0; i <= venusSteps; i++) {+ venusKeys.push({+ time: (i * duration) / venusSteps,+ rotation: [0, (venusBase + i * 90) % 360, 0]+ });+ }++ // Track 4: Earth (starts at 0°, completes 1 revolution in 12s)+ const earthKeys = [];+ const earthSteps = 4;+ for (let i = 0; i <= earthSteps; i++) {+ earthKeys.push({+ time: (i * duration) / earthSteps,+ rotation: [0, (i * 90) % 360, 0]+ });+ }++ // Track 5: Moon (orbits Earth, completes 6 revolutions in 12s)+ const moonKeys = [];+ const moonSteps = 24;+ for (let i = 0; i <= moonSteps; i++) {+ moonKeys.push({+ time: (i * duration) / moonSteps,+ rotation: [0, (i * 90) % 360, 0]+ });+ }++ return [+ createClip('OrreryMotion', duration, [+ rotationTrack('Joint_Crank', crankKeys),+ rotationTrack('Joint_Mercury', mercKeys),+ rotationTrack('Joint_Venus', venusKeys),+ rotationTrack('Joint_EarthArm', earthKeys),+ rotationTrack('Joint_Moon', moonKeys)+ ])+ ];+}diff --git a/examples/pinball-machine.kiln.js b/examples/pinball-machine.kiln.jsnew file mode 100644index 00000000..75b99d90--- /dev/null+++ b/examples/pinball-machine.kiln.js@@ -0,0 +1,225 @@+// Authored by: opencode-go/glm-5.3-flash, via opencode.+//+// Repaired by hand afterwards: the backbox was built entirely behind the+// cabinet's rear face and cantilevered on nothing. Sliding it forward onto the+// cabinet only traded one fault for another, because the playfield runs the+// cabinet's full length -- anything the head gains in support it takes out of+// the glass. So the cabinet grew the bay a real machine has: it is 1.34 m long+// rather than 1.14, its rear face is at x = -0.82, its back legs moved with it,+// and the head now sits on that bay entirely behind the playfield glass. The+// backbox itself is unchanged apart from being 0.20 m deep instead of 0.38.+// Nothing else in the program was touched.+//+// Written by the model itself through the Kiln MCP tools, and cut off+// mid-run rather than finished -- by a provider limit, or by the+// dispatch deadline. The program below is what was on disk when the+// session ended; how many times it had looked at its own contact sheet+// by then is not recorded, so this one does not make the claim the+// others do.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'PinballMachine', category: 'prop', role: 'prop' };++const glow = (hex, i) => gameMaterial(hex, { emissive: hex, emissiveIntensity: i });++async function build() {+ const root = createRoot('PinballMachine');++ const woodDark = gameMaterial(0x3b2a1d, { roughness: 0.65 });+ const woodInner = gameMaterial(0x241a12, { roughness: 0.85 });+ const chrome = gameMaterial(0xd9dee2, { metalness: 0.9, roughness: 0.22 });+ const steelDark = gameMaterial(0x5a5f64, { metalness: 0.85, roughness: 0.4 });+ const blackTrim = gameMaterial(0x141414, { roughness: 0.6 });+ const navyArt = gameMaterial(0x16306b, { roughness: 0.7 });+ const pfBlue = gameMaterial(0x1b4f8a, { roughness: 0.6 });+ const artOrange = gameMaterial(0xe07b1f, { roughness: 0.6 });+ const artRed = gameMaterial(0xc23327, { roughness: 0.55 });+ const artYellow = gameMaterial(0xe9c630, { roughness: 0.55 });+ const artCream = gameMaterial(0xf2e8cf, { roughness: 0.6 });+ const rubberYellow = gameMaterial(0xf0c419, { roughness: 0.9 });+ const bumperRed = gameMaterial(0xd23b2e, { roughness: 0.5 });+ const bumperBlue = gameMaterial(0x2e6fd2, { roughness: 0.5 });+ const glassMat = glassMaterial(0xcfe4f2, { opacity: 0.16 });+ const reelWhite = gameMaterial(0xf5f1e4, { roughness: 0.5 });+ const bgIndigo = glow(0x1a2452, 0.3);+ const bgOrange = glow(0xe07b1f, 0.55);+ const bgRed = glow(0xc23327, 0.5);+ const bgYellow = glow(0xe9c630, 0.55);+ const bgCream = glow(0xf2e8cf, 0.5);++ const add = (name, geo, mat, pos, rot, parent) => {+ const opts = { position: pos, parent: parent || root };+ if (rot) opts.rotation = rot;+ return createPart(name, geo, mat, opts);+ };++ const SLOPE = -4 * Math.PI / 180;++ // Legs+ for (const [lx, lz] of [[0.42, 0.225], [0.42, -0.225], [-0.72, 0.225], [-0.72, -0.225]]) {+ add('LegWood', cylinderGeo(0.030, 0.021, 0.52, 10), woodDark, [lx, 0.315, lz]);+ add('LegLeveler', cylinderGeo(0.016, 0.016, 0.04, 8), chrome, [lx, 0.035, lz]);+ add('LegFoot', cylinderGeo(0.020, 0.022, 0.012, 10), blackTrim, [lx, 0.006, lz]);+ add('LegPlate', boxGeo(0.06, 0.008, 0.06), chrome, [lx, 0.579, lz]);+ }++ // Cabinet+ add('CabinetBottom', boxGeo(1.34, 0.03, 0.476), woodInner, [-0.15, 0.59, 0]);+ add('CabinetFrontWall', boxGeo(0.03, 0.19, 0.52), woodDark, [0.505, 0.67, 0]);+ add('CabinetBackWall', boxGeo(0.03, 0.27, 0.52), woodDark, [-0.805, 0.71, 0]);+ const wallProfile = [[-0.82, 0], [0.52, 0], [0.52, 0.19], [-0.82, 0.27]];+ add('SideWallRight', await extrudeProfile(wallProfile, { depth: 0.022, axis: 'z', center: true }), woodDark, [0, 0.575, 0.249]);+ add('SideWallLeft', await extrudeProfile(wallProfile, { depth: 0.022, axis: 'z', center: true }), woodDark, [0, 0.575, -0.249]);++ // Playfield group (sloped)+ const pf = createPivot('PlayfieldGroup', [-0.05, 0.755, 0], root);+ pf.rotation.z = SLOPE;++ add('PlayfieldBoard', boxGeo(1.13, 0.02, 0.46), pfBlue, [0, -0.011, 0], null, pf);+ add('Glass', boxGeo(1.14, 0.005, 0.475), glassMat, [0, 0.0565, 0], null, pf);+ add('SideRailRight', boxGeo(1.14, 0.05, 0.024), chrome, [0.005, 0.025, 0.248], null, pf);+ add('SideRailLeft', boxGeo(1.14, 0.05, 0.024), chrome, [0.005, 0.025, -0.248], null, pf);+ add('LockdownBar', await roundedBoxGeo(0.055, 0.026, 0.50, 0.01), chrome, [0.575, 0.068, 0], null, pf);++ // Shooter lane+ add('LaneWall', boxGeo(0.90, 0.018, 0.010), artCream, [0.10, 0.009, -0.195], null, pf);+ add('Ball', sphereGeo(0.0135, 10, 8), chrome, [0.30, 0.0145, -0.218], null, pf);++ // Playfield art+ const ring = (name, r, tube, mat, x, z, parent) =>+ add(name, torusGeo(r, tube, 6, 20), mat, [x, 0.004, z], [90, 0, 0], parent);+ ring('ArtRingA', 0.085, 0.008, artOrange, -0.38, 0.015, pf);+ add('ArtDiscA', cylinderYGeo(0.03, 0.03, 0.004, 16), artYellow, [-0.38, 0.002, 0.015], null, pf);+ ring('ArtRingB', 0.07, 0.008, artRed, -0.18, 0.16, pf);+ add('ArtDiscB', cylinderYGeo(0.025, 0.025, 0.004, 16), artCream, [-0.18, 0.002, 0.16], null, pf);+ ring('ArtRingC', 0.07, 0.008, artOrange, -0.18, -0.13, pf);+ for (const [i, lz] of [0.075, 0.015, -0.045].entries())+ add('LaneStrip' + i, boxGeo(0.02, 0.002, 0.05), artCream, [-0.50, 0.001, lz], null, pf);+ for (const [i, lz] of [0.045, -0.015].entries())+ add('RolloverStar' + i, cylinderYGeo(0.009, 0.009, 0.003, 10), artYellow, [-0.50, 0.0015, lz], null, pf);++ // Pop bumpers+ const bumpers = [[-0.40, -0.055, bumperRed], [-0.40, 0.085, bumperBlue], [-0.27, 0.015, artYellow]];+ for (const [i, [bx, bz, mat]] of bumpers.entries()) {+ add('BumperBase' + i, cylinderYGeo(0.042, 0.042, 0.010, 14), artCream, [bx, 0.005, bz], null, pf);+ add('BumperBody' + i, cylinderYGeo(0.028, 0.028, 0.032, 14), mat, [bx, 0.026, bz], null, pf);+ add('BumperCap' + i, cylinderYGeo(0.018, 0.018, 0.008, 12), chrome, [bx, 0.046, bz], null, pf);+ add('BumperSkirt' + i, torusGeo(0.036, 0.004, 6, 16), blackTrim, [bx, 0.012, bz], [90, 0, 0], pf);+ }++ // Targets+ for (const [i, tz] of [0.05, 0.082, 0.114].entries())+ add('DropTarget' + i, boxGeo(0.005, 0.02, 0.016), artCream, [-0.14, 0.012, tz], null, pf);+ for (const [i, tz] of [-0.17, 0.17].entries())+ add('StandupTarget' + i, boxGeo(0.006, 0.022, 0.03), bumperRed, [-0.50, 0.013, tz], null, pf);++ // Spinner+ add('SpinnerPostL', cylinderYGeo(0.004, 0.004, 0.026, 8), chrome, [-0.44, 0.013, 0.030], null, pf);+ add('SpinnerPostR', cylinderYGeo(0.004, 0.004, 0.026, 8), chrome, [-0.44, 0.013, 0.0], null, pf);+ add('SpinnerFlap', boxGeo(0.0015, 0.026, 0.024), steelDark, [-0.44, 0.016, 0.015], null, pf);++ // Posts and rubbers+ const posts = [[0.28, 0.135], [0.28, -0.105], [0.40, 0.135], [0.40, -0.105], [-0.33, 0.185], [-0.33, -0.155]];+ for (const [i, [px, pz]] of posts.entries()) {+ add('Post' + i, cylinderYGeo(0.0045, 0.0055, 0.02, 8), artCream, [px, 0.010, pz], null, pf);+ if (i < 4) add('PostRubber' + i, torusGeo(0.011, 0.0025, 6, 12), rubberYellow, [px, 0.012, pz], [90, 0, 0], pf);+ }++ // Slingshots+ const slingL = [[0.12, 0.14], [0.27, 0.14], [0.12, 0.205]];+ const slingR = [[0.27, -0.11], [0.12, -0.11], [0.12, -0.175]];+ add('SlingBodyL', await extrudeProfile(slingL, { depth: 0.012, axis: 'y', center: true, bevel: 0.004 }), rubberYellow, [0, 0.006, 0], null, pf);+ add('SlingBodyR', await extrudeProfile(slingR, { depth: 0.012, axis: 'y', center: true, bevel: 0.004 }), rubberYellow, [0, 0.006, 0], null, pf);+ beamBetween('SlingBandL', [0.12, 0.014, 0.205], [0.27, 0.014, 0.14], 0.004, artRed, { parent: pf });+ beamBetween('SlingBandR', [0.12, 0.014, -0.175], [0.27, 0.014, -0.11], 0.004, artRed, { parent: pf });++ // Flippers+ const flipOutline = [[-0.052, 0.026], [-0.028, 0.032], [0.018, 0.021], [0.058, 0.0], [0.018, -0.021], [-0.028, -0.032], [-0.052, -0.026]];+ const flipGeo = await extrudeProfile(flipOutline, { depth: 0.013, axis: 'y', center: true, bevel: 0.005 });+ add('FlipperLeft', flipGeo, rubberYellow, [0.33, 0.0065, 0.085], [0, 25, 0], pf);+ add('FlipperRight', flipGeo, rubberYellow, [0.33, 0.0065, -0.055], [0, -25, 0], pf);++ // Apron+ const apronOutline = [[0.40, -0.175], [0.545, -0.045], [0.545, 0.075], [0.40, 0.195]];+ add('Apron', await extrudeProfile(apronOutline, { depth: 0.008, axis: 'y', center: true }), navyArt, [0, 0.004, 0], null, pf);+ beamBetween('ApronTrim', [0.545, 0.010, 0.075], [0.545, 0.010, -0.045], 0.004, chrome, { parent: pf });++ // Wire ramps+ const rampCtrl = [+ [[-0.30, 0.030, 0.16], [-0.05, 0.046, 0.20], [0.15, 0.030, 0.185], [0.30, 0.008, 0.13]],+ [[-0.30, 0.030, -0.16], [-0.05, 0.046, -0.20], [0.15, 0.030, -0.185], [0.30, 0.008, -0.13]]+ ];+ for (const [ri, ctrl] of rampCtrl.entries()) {+ const path = bezierCurve(ctrl, 24);+ for (const [si, dz] of [-0.016, 0.016].entries()) {+ const pts = path.map(p => [p[0], p[1], p[2] + dz]);+ add('RampRail' + ri + si, pipeAlongPath(pts, 0.0035, { bendRadius: 0.02, radialSegments: 6 }), steelDark, [0, 0, 0], null, pf);+ }+ beamBetween('RampLeg' + ri + 'a', [-0.05, 0.042, ctrl[1][2]], [-0.05, 0.001, ctrl[1][2]], 0.003, steelDark, { parent: pf });+ beamBetween('RampLeg' + ri + 'b', [0.15, 0.026, ctrl[2][2]], [0.15, 0.001, ctrl[2][2]], 0.003, steelDark, { parent: pf });+ }++ // Backbox+ add('BackboxBottom', boxGeo(0.20, 0.025, 0.47), woodDark, [-0.72, 0.8575, 0]);+ add('BackboxSideRight', boxGeo(0.20, 0.935, 0.02), woodDark, [-0.72, 1.3125, 0.225]);+ add('BackboxSideLeft', boxGeo(0.20, 0.935, 0.02), woodDark, [-0.72, 1.3125, -0.225]);+ add('BackboxBack', boxGeo(0.025, 0.935, 0.47), woodDark, [-0.8075, 1.3125, 0]);+ add('BackboxTop', boxGeo(0.24, 0.03, 0.49), woodDark, [-0.705, 1.77, 0]);+ add('BackboxFrameBottom', boxGeo(0.02, 0.05, 0.45), woodDark, [-0.62, 0.895, 0]);+ add('BackboxFrameTop', boxGeo(0.02, 0.05, 0.45), woodDark, [-0.62, 1.725, 0]);+ add('BackboxStileRight', boxGeo(0.02, 0.83, 0.025), woodDark, [-0.62, 1.31, 0.2125]);+ add('BackboxStileLeft', boxGeo(0.02, 0.83, 0.025), woodDark, [-0.62, 1.31, -0.2125]);++ // Backglass+ add('BackglassPanel', boxGeo(0.012, 0.78, 0.42), bgIndigo, [-0.625, 1.31, 0]);+ add('BackglassRingOuter', torusGeo(0.19, 0.014, 8, 28), bgRed, [-0.612, 1.44, 0], [0, 90, 0]);+ add('BackglassRingInner', torusGeo(0.13, 0.013, 8, 24), bgOrange, [-0.614, 1.44, 0], [0, 90, 0]);+ add('BackglassSun', cylinderXGeo(0.075, 0.075, 0.006, 20), bgYellow, [-0.615, 1.44, 0]);+ add('RocketBody', cylinderXGeo(0.016, 0.016, 0.09, 12), chrome, [-0.612, 1.14, -0.10]);+ add('RocketNose', coneXGeo(0.016, 0.045, 12), bgRed, [-0.557, 1.14, -0.10]);+ add('RocketFinTop', boxGeo(0.004, 0.03, 0.014), bgRed, [-0.645, 1.16, -0.10]);+ add('RocketFinBottom', boxGeo(0.004, 0.03, 0.014), bgRed, [-0.645, 1.12, -0.10]);+ add('RocketFlame', coneXGeo(0.010, 0.035, 8), bgOrange, [-0.665, 1.14, -0.10], [0, 0, 180]);+ for (const [i, [sy, sz]] of [[1.60, 0.14], [1.55, -0.16], [1.30, 0.17], [1.25, -0.17], [1.05, 0.10]].entries())+ add('BackglassStar' + i, cylinderXGeo(0.006, 0.006, 0.004, 8), bgCream, [-0.617, sy, sz]);+ add('BackglassBanner', boxGeo(0.008, 0.065, 0.40), bgYellow, [-0.616, 1.655, 0]);+ for (const [i, lz] of [-0.135, -0.09, -0.045, 0, 0.045, 0.09, 0.135].entries())+ add('BannerLetter' + i, decalBox(0.018, 0.03, 0.003), blackTrim, [-0.611, 1.655, lz], [0, 90, 0]);++ // Score window and reels+ add('ScoreWindowGlass', boxGeo(0.01, 0.07, 0.40), glassMat, [-0.626, 0.955, 0]);+ for (const [i, lz] of [-0.135, -0.045, 0.045, 0.135].entries()) {+ add('ScoreReel' + i, cylinderXGeo(0.03, 0.03, 0.05, 14), reelWhite, [-0.68, 0.955, lz]);+ add('ScoreDigits' + i, decalBox(0.022, 0.026, 0.002), blackTrim, [-0.6545, 0.955, lz], [0, 90, 0]);+ }+ add('ScoreBackdrop', boxGeo(0.006, 0.10, 0.42), blackTrim, [-0.715, 0.955, 0]);+ add('ScoreFrameTop', boxGeo(0.012, 0.012, 0.42), artRed, [-0.621, 0.995, 0]);+ add('ScoreFrameBottom', boxGeo(0.012, 0.012, 0.42), artRed, [-0.621, 0.915, 0]);++ // Coin door+ add('CoinDoorPlate', await roundedBoxGeo(0.20, 0.15, 0.016, 0.006), chrome, [0.524, 0.66, 0.02]);+ add('CoinSlotL', decalBox(0.026, 0.007, 0.004), blackTrim, [0.534, 0.695, -0.03], [0, 90, 0]);+ add('CoinSlotR', decalBox(0.026, 0.007, 0.004), blackTrim, [0.534, 0.695, 0.07], [0, 90, 0]);+ add('RejectButtonL', cylinderXGeo(0.008, 0.008, 0.006, 10), bumperRed, [0.534, 0.66, -0.03]);+ add('RejectButtonR', cylinderXGeo(0.008, 0.008, 0.006, 10), bumperRed, [0.534, 0.66, 0.07]);+ add('CoinDoorLock', cylinderXGeo(0.011, 0.011, 0.01, 10), steelDark, [0.535, 0.715, -0.055]);+ add('CoinDoorLip', boxGeo(0.014, 0.012, 0.21), chrome, [0.527, 0.583, 0.02]);++ // Plunger+ add('PlungerRod', cylinderXGeo(0.008, 0.008, 0.11, 10), chrome, [0.545, 0.723, -0.208]);+ add('PlungerKnob', cylinderXGeo(0.023, 0.026, 0.024, 12), bumperRed, [0.607, 0.723, -0.208]);+ add('PlungerEscutcheon', cylinderXGeo(0.017, 0.017, 0.008, 10), chrome, [0.523, 0.723, -0.208]);++ // Side art+ for (const s of [1, -1]) {+ add('SideStripeOrange' + s, boxGeo(0.85, 0.04, 0.005), artOrange, [-0.10, 0.665, s * 0.2625]);+ add('SideStripeCream' + s, boxGeo(0.85, 0.015, 0.005), artCream, [-0.10, 0.635, s * 0.263]);+ add('SideDiscOuter' + s, cylinderZGeo(0.045, 0.045, 0.005, 18), artOrange, [-0.42, 0.655, s * 0.263]);+ add('SideDiscInner' + s, cylinderZGeo(0.028, 0.028, 0.006, 18), artCream, [-0.42, 0.655, s * 0.264]);+ add('BackboxSideDisc' + s, cylinderZGeo(0.06, 0.06, 0.004, 18), bgOrange, [-0.72, 1.35, s * 0.236]);+ }++ return root;+}diff --git a/examples/pipe-organ.kiln.js b/examples/pipe-organ.kiln.jsnew file mode 100644index 00000000..fb56bf2d--- /dev/null+++ b/examples/pipe-organ.kiln.js@@ -0,0 +1,843 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'PipeOrgan', category: 'prop' };++function build() {+ const root = createRoot('PipeOrgan');++ // =========================================================================+ // MATERIALS+ // =========================================================================+ const woodDark = gameMaterial(0x381f10, { roughness: 0.68, metalness: 0.05 });+ const woodMedium = gameMaterial(0x543118, { roughness: 0.62, metalness: 0.05 });+ const woodLight = gameMaterial(0x754724, { roughness: 0.58, metalness: 0.05 });+ const pipeTin = gameMaterial(0xd8dce4, { roughness: 0.18, metalness: 0.92 });+ const pipeMouth = gameMaterial(0x18181c, { roughness: 0.7, metalness: 0.3 });+ const goldLeaf = gameMaterial(0xcaa034, { roughness: 0.32, metalness: 0.78 });+ const keyWhite = gameMaterial(0xf5f1e8, { roughness: 0.28, metalness: 0.05 });+ const keyBlack = gameMaterial(0x1a1a1c, { roughness: 0.38, metalness: 0.1 });+ const stopKnobWhite = gameMaterial(0xede7db, { roughness: 0.32, metalness: 0.05 });+ const feltRed = gameMaterial(0x82151b, { roughness: 0.9, metalness: 0.0 });+ const brassMat = gameMaterial(0xd4af37, { roughness: 0.25, metalness: 0.85 });+ const scorePaper = gameMaterial(0xfaf6ed, { roughness: 0.85, metalness: 0.0 });++ // =========================================================================+ // 0. GALLERY / DAIS PLATFORM+ // Connects the case, console, and bench into one grounded church organ loft.+ // Sits strictly on Y = 0.+ // =========================================================================+ const platform = createPivot('GalleryPlatform', [0, 0, 0], root);++ // Main case platform base+ createPart('PlatformPlinth', boxGeo(1.4, 0.05, 4.4), woodDark, {+ position: [-0.15, 0.025, 0],+ parent: platform+ });+ // Console dais running forward to carry console and bench+ createPart('ConsoleDais', boxGeo(2.1, 0.04, 2.1), woodMedium, {+ position: [1.6, 0.02, 0],+ parent: platform+ });+ // Stepped bevel trim along dais edges+ createPart('DaisTrimFront', boxGeo(0.06, 0.04, 2.14), woodDark, {+ position: [2.65, 0.02, 0],+ parent: platform+ });+ createPart('DaisTrimLeft', boxGeo(2.1, 0.04, 0.06), woodDark, {+ position: [1.6, 0.02, -1.07],+ parent: platform+ });+ createPart('DaisTrimRight', boxGeo(2.1, 0.04, 0.06), woodDark, {+ position: [1.6, 0.02, 1.07],+ parent: platform+ });++ // =========================================================================+ // 1. ORGAN CASE FAÇADE (Centred at X = 0, spanning Z = -2.1m to +2.1m)+ // Deep architectural case: back at X = -0.58m, front up to X = +0.40m+ // =========================================================================+ const caseGroup = createPivot('OrganCase', [0, 0, 0], root);++ // --- LOWER CASE (Dado / Pedestal) ---+ // Sub-base plinth+ createPart('CaseBasePlinth', boxGeo(0.95, 0.12, 4.14), woodDark, {+ position: [-0.11, 0.11, 0],+ parent: caseGroup+ });+ // Lower cabinet body+ createPart('CaseDadoBody', boxGeo(0.88, 1.38, 4.0), woodMedium, {+ position: [-0.11, 0.86, 0],+ parent: caseGroup+ });++ // Fielded panels across the lower case (7 panels with raised bolection moulding)+ const panelZs = [-1.65, -1.1, -0.55, 0, 0.55, 1.1, 1.65];+ panelZs.forEach((pz, idx) => {+ // Outer panel frame+ createPart(`DadoPanelFrame_${idx}`, boxGeo(0.03, 1.05, 0.46), woodDark, {+ position: [0.34, 0.88, pz],+ parent: caseGroup+ });+ // Raised inner field+ createPart(`DadoPanelField_${idx}`, boxGeo(0.04, 0.95, 0.38), woodLight, {+ position: [0.35, 0.88, pz],+ parent: caseGroup+ });+ });++ // Dado base rail and mid rail+ createPart('DadoBaseRail', boxGeo(0.92, 0.08, 4.06), woodDark, {+ position: [-0.09, 0.21, 0],+ parent: caseGroup+ });+ createPart('DadoMidRail', boxGeo(0.92, 0.06, 4.06), woodDark, {+ position: [-0.09, 1.44, 0],+ parent: caseGroup+ });++ // --- IMPOST (Classical shelf carrying the pipe flats) ---+ createPart('ImpostArchitrave', boxGeo(0.96, 0.1, 4.2), woodDark, {+ position: [-0.07, 1.6, 0],+ parent: caseGroup+ });+ createPart('ImpostFrieze', boxGeo(0.98, 0.08, 4.24), woodLight, {+ position: [-0.06, 1.69, 0],+ parent: caseGroup+ });+ createPart('ImpostCornice', boxGeo(1.02, 0.12, 4.3), woodDark, {+ position: [-0.04, 1.79, 0],+ parent: caseGroup+ });++ // Dentils along the Impost+ const dentilProto = createPart('ImpostDentil_0', boxGeo(0.04, 0.05, 0.04), woodLight, {+ position: [0.48, 1.76, -2.05],+ parent: caseGroup+ });+ for (let i = 1; i <= 24; i++) {+ const dZ = -2.05 + (i / 24) * 4.1;+ createInstance(`ImpostDentil_${i}`, dentilProto, {+ position: [0.48, 1.76, dZ],+ parent: caseGroup+ });+ }++ // --- CARVED SUPPORT CORBELS UNDER PIPE TOWERS ---+ // Large acanthus corbels supporting the projecting towers+ [-1.6, 0, 1.6].forEach((corbelZ, cIdx) => {+ const name = `TowerCorbel_${cIdx}`;+ // Upper scroll bracket+ createPart(`${name}_Upper`, boxGeo(0.18, 0.24, 0.16), woodDark, {+ position: [0.38, 1.56, corbelZ],+ parent: caseGroup+ });+ // Gilt acanthus carving+ createPart(`${name}_Acanthus`, coneGeo(0.08, 0.22, 6), goldLeaf, {+ position: [0.42, 1.54, corbelZ],+ rotation: [180, 0, 0],+ parent: caseGroup+ });+ });++ // --- FAÇADE PILASTERS (Dividing towers and flats) ---+ const pilasterZs = [-1.94, -1.28, -0.54, 0.54, 1.28, 1.94];+ let capitalProto = null;+ pilasterZs.forEach((pz, idx) => {+ // Pilaster shaft+ createPart(`PilasterShaft_${idx}`, boxGeo(0.1, 3.2, 0.1), woodMedium, {+ position: [0.08, 3.45, pz],+ parent: caseGroup+ });+ // Fluting detail (recessed stripe)+ createPart(`PilasterFlute_${idx}`, boxGeo(0.02, 3.0, 0.04), woodDark, {+ position: [0.135, 3.45, pz],+ parent: caseGroup+ });+ // Base plinth+ createPart(`PilasterBase_${idx}`, boxGeo(0.14, 0.14, 0.14), woodDark, {+ position: [0.09, 1.92, pz],+ parent: caseGroup+ });+ // Corinthian / Composite gilded capital+ if (!capitalProto) {+ capitalProto = createPart('CapitalProto', boxGeo(0.16, 0.14, 0.16), goldLeaf, {+ position: [0.09, 5.08, pz],+ parent: caseGroup+ });+ createPart('CapitalVolute', cylinderZGeo(0.035, 0.035, 0.18, 8), goldLeaf, {+ position: [0.12, 5.12, pz],+ parent: caseGroup+ });+ } else {+ createInstance(`Capital_${idx}`, capitalProto, {+ position: [0.09, 5.08, pz],+ parent: caseGroup+ });+ }+ });++ // --- REAR ENCLOSURE & SIDES (Deep enough to fully enclose all tower domes) ---+ // Back wall sits cleanly at X = -0.58m+ createPart('CaseBackWall', boxGeo(0.08, 5.2, 4.08), woodDark, {+ position: [-0.58, 2.7, 0],+ parent: caseGroup+ });+ createPart('CaseSideWallL', boxGeo(0.96, 5.2, 0.08), woodDark, {+ position: [-0.1, 2.7, -2.02],+ parent: caseGroup+ });+ createPart('CaseSideWallR', boxGeo(0.96, 5.2, 0.08), woodDark, {+ position: [-0.1, 2.7, 2.02],+ parent: caseGroup+ });++ // =========================================================================+ // DISPLAY PIPES WITH MITRED MOUTHS+ // =========================================================================+ function addDisplayPipe(name, posX, baseY, posZ, radius, totalHeight, parent) {+ const footLen = Math.min(0.72, totalHeight * 0.26);+ const bodyLen = totalHeight - footLen;+ const mouthY = baseY + footLen;++ // Conical Foot: tapers from toe at rackboard to mouth+ createPart(`${name}_Foot`, taperConeGeo(radius * 0.2, radius, footLen, 'y', 12), pipeTin, {+ position: [posX, baseY + footLen * 0.5, posZ],+ parent+ });++ // Resonator Body: polished tin cylinder+ createPart(`${name}_Body`, cylinderGeo(radius, radius, bodyLen, 12), pipeTin, {+ position: [posX, mouthY + bodyLen * 0.5, posZ],+ parent+ });++ // Dark Voice Slot (Languid flue opening)+ createPart(`${name}_VoiceSlot`, boxGeo(radius * 0.35, radius * 0.28, radius * 1.5), pipeMouth, {+ position: [posX + radius * 0.5, mouthY, posZ],+ parent+ });++ // Upper Mitred Lip: pointed French / bayleaf triangular leaf pointing up+ createPart(`${name}_UpperLip`, coneGeo(radius * 0.55, radius * 0.75, 4), goldLeaf, {+ position: [posX + radius * 0.62, mouthY + radius * 0.48, posZ],+ rotation: [0, 45, 0],+ parent+ });++ // Lower Mitred Lip: inverted triangular leaf pointing down into foot+ createPart(`${name}_LowerLip`, coneGeo(radius * 0.45, radius * 0.58, 4), goldLeaf, {+ position: [posX + radius * 0.58, mouthY - radius * 0.38, posZ],+ rotation: [180, 45, 0],+ parent+ });+ }++ // --- CENTRAL TOWER (Semi-circular forward bay at Z = 0) ---+ createPart('CenterTowerShelf', cylinderGeo(0.58, 0.58, 0.12, 16), woodDark, {+ position: [0.08, 1.86, 0],+ parent: caseGroup+ });+ createPart('CenterTowerShelfTrim', cylinderGeo(0.62, 0.58, 0.08, 16), woodLight, {+ position: [0.08, 1.80, 0],+ parent: caseGroup+ });++ // Central Tower: 7 graduated pipes forming a semi-circular arc+ const centerPipes = [+ { z: -0.42, x: 0.14, r: 0.075, h: 2.7 },+ { z: -0.30, x: 0.25, r: 0.088, h: 3.0 },+ { z: -0.16, x: 0.33, r: 0.098, h: 3.3 },+ { z: 0.0, x: 0.36, r: 0.108, h: 3.65 }, // King pipe (tallest)+ { z: 0.16, x: 0.33, r: 0.098, h: 3.3 },+ { z: 0.30, x: 0.25, r: 0.088, h: 3.0 },+ { z: 0.42, x: 0.14, r: 0.075, h: 2.7 },+ ];+ centerPipes.forEach((p, idx) => {+ addDisplayPipe(`CenterPipe_${idx}`, p.x, 1.92, p.z, p.r, p.h, caseGroup);+ });++ // Central Tower Entablature & Cornice (centered at X = 0.06, radius 0.62; rear is at 0.06 - 0.62 = -0.56, safely in front of back wall -0.58)+ createPart('CenterTowerFrieze', cylinderGeo(0.58, 0.58, 0.24, 16), woodDark, {+ position: [0.06, 5.58, 0],+ parent: caseGroup+ });+ createPart('CenterTowerCorniceLower', cylinderGeo(0.62, 0.58, 0.1, 16), woodLight, {+ position: [0.06, 5.72, 0],+ parent: caseGroup+ });+ createPart('CenterTowerCorniceUpper', cylinderGeo(0.66, 0.62, 0.12, 16), woodDark, {+ position: [0.06, 5.82, 0],+ parent: caseGroup+ });+ // Central Tower Pediment Dome & Golden Finial+ createPart('CenterTowerDome', coneGeo(0.64, 0.36, 16), woodDark, {+ position: [0.06, 6.02, 0],+ parent: caseGroup+ });+ createPart('CenterTowerFinialBall', sphereGeo(0.12, 10, 8), goldLeaf, {+ position: [0.06, 6.28, 0],+ parent: caseGroup+ });+ createPart('CenterTowerFinialSpire', coneGeo(0.09, 0.4, 10), goldLeaf, {+ position: [0.06, 6.52, 0],+ parent: caseGroup+ });++ // --- CARVED PIPE SHADES (Center Tower) ---+ // Arched valence drape in gold leaf+ createPart('CenterPipeShadeArch', cylinderGeo(0.54, 0.54, 0.32, 16), goldLeaf, {+ position: [0.08, 5.34, 0],+ parent: caseGroup+ });+ // Carved drop-pendants hanging between pipes+ const shadePendantProto = createPart('ShadePendantProto', coneGeo(0.035, 0.22, 6), goldLeaf, {+ position: [0.35, 5.15, -0.36],+ rotation: [180, 0, 0],+ parent: caseGroup+ });+ const pendantZs = [-0.23, -0.08, 0.08, 0.23, 0.36];+ pendantZs.forEach((pz, idx) => {+ const px = Math.sqrt(Math.max(0, 0.35 * 0.35 - pz * pz * 0.6)) + 0.06;+ createInstance(`CenterPendant_${idx}`, shadePendantProto, {+ position: [px, 5.15, pz],+ rotation: [180, 0, 0],+ parent: caseGroup+ });+ });++ // Lower Toe Shades (carved scrollwork along the rackboard)+ createPart('CenterToeShade', boxGeo(0.1, 0.16, 0.86), goldLeaf, {+ position: [0.24, 2.02, 0],+ parent: caseGroup+ });++ // --- SIDE TOWERS (Pointed V-towers at Z = -1.6m and Z = +1.6m) ---+ const sideTowerConfigs = [+ { name: 'Left', zCenter: -1.6 },+ { name: 'Right', zCenter: 1.6 },+ ];++ sideTowerConfigs.forEach((st) => {+ const side = st.name;+ const tz = st.zCenter;++ // V-shaped base pedestal bracket+ createPart(`${side}TowerShelf`, boxGeo(0.56, 0.12, 0.72), woodDark, {+ position: [0.12, 1.86, tz],+ parent: caseGroup+ });+ createPart(`${side}TowerShelfBevel`, boxGeo(0.6, 0.08, 0.76), woodLight, {+ position: [0.12, 1.80, tz],+ parent: caseGroup+ });++ // 7 pipes in pointed V-profile+ const sidePipes = [+ { zOff: -0.30, x: 0.12, r: 0.07, h: 2.4 },+ { zOff: -0.20, x: 0.22, r: 0.08, h: 2.75 },+ { zOff: -0.10, x: 0.31, r: 0.09, h: 3.1 },+ { zOff: 0.0, x: 0.36, r: 0.10, h: 3.4 }, // Side tower king pipe+ { zOff: 0.10, x: 0.31, r: 0.09, h: 3.1 },+ { zOff: 0.20, x: 0.22, r: 0.08, h: 2.75 },+ { zOff: 0.30, x: 0.12, r: 0.07, h: 2.4 },+ ];+ sidePipes.forEach((sp, idx) => {+ addDisplayPipe(`${side}Pipe_${idx}`, sp.x, 1.92, tz + sp.zOff, sp.r, sp.h, caseGroup);+ });++ // Tower Entablature & Cornice+ createPart(`${side}TowerEntablature`, boxGeo(0.58, 0.22, 0.76), woodDark, {+ position: [0.12, 5.3, tz],+ parent: caseGroup+ });+ createPart(`${side}TowerCornice`, boxGeo(0.66, 0.14, 0.84), woodLight, {+ position: [0.14, 5.46, tz],+ parent: caseGroup+ });+ // Pointed pediment / cap & finial urn+ createPart(`${side}TowerPediment`, coneGeo(0.42, 0.44, 4), woodDark, {+ position: [0.14, 5.72, tz],+ rotation: [0, 45, 0],+ parent: caseGroup+ });+ createPart(`${side}TowerFinialUrn`, cylinderGeo(0.08, 0.05, 0.26, 10), goldLeaf, {+ position: [0.14, 6.04, tz],+ parent: caseGroup+ });+ createPart(`${side}TowerFinialFlame`, coneGeo(0.09, 0.28, 10), goldLeaf, {+ position: [0.14, 6.26, tz],+ parent: caseGroup+ });++ // Pipe shades (upper tracery & pendants)+ createPart(`${side}PipeShadeValence`, boxGeo(0.16, 0.28, 0.7), goldLeaf, {+ position: [0.22, 5.08, tz],+ parent: caseGroup+ });+ [-0.22, -0.07, 0.07, 0.22].forEach((pz, pIdx) => {+ createInstance(`${side}Pendant_${pIdx}`, shadePendantProto, {+ position: [0.28, 4.9, tz + pz],+ rotation: [180, 0, 0],+ parent: caseGroup+ });+ });+ // Lower toe shade+ createPart(`${side}ToeShade`, boxGeo(0.08, 0.15, 0.68), goldLeaf, {+ position: [0.22, 2.02, tz],+ parent: caseGroup+ });+ });++ // --- INTERMEDIATE FLATS (Between center tower and side towers) ---+ const flatConfigs = [+ { name: 'LeftFlat', zCenter: -0.91 },+ { name: 'RightFlat', zCenter: 0.91 },+ ];++ flatConfigs.forEach((fl, fIdx) => {+ const fName = fl.name;+ const fz = fl.zCenter;+ const sign = fIdx === 0 ? -1 : 1;++ // 7 pipes in ascending slope toward side tower+ const flatPipes = [+ { zOff: -sign * 0.24, r: 0.055, h: 2.05 },+ { zOff: -sign * 0.16, r: 0.058, h: 2.18 },+ { zOff: -sign * 0.08, r: 0.062, h: 2.32 },+ { zOff: 0.0, r: 0.066, h: 2.48 },+ { zOff: sign * 0.08, r: 0.070, h: 2.64 },+ { zOff: sign * 0.16, r: 0.074, h: 2.82 },+ { zOff: sign * 0.24, r: 0.078, h: 3.0 },+ ];+ flatPipes.forEach((fp, idx) => {+ addDisplayPipe(`${fName}Pipe_${idx}`, 0.06, 1.92, fz + fp.zOff, fp.r, fp.h, caseGroup);+ });++ // Flat Entablature & Cornice+ createPart(`${fName}Entablature`, boxGeo(0.36, 0.18, 0.66), woodDark, {+ position: [0.06, 4.88, fz],+ parent: caseGroup+ });+ createPart(`${fName}Cornice`, boxGeo(0.42, 0.1, 0.72), woodLight, {+ position: [0.08, 5.0, fz],+ parent: caseGroup+ });++ // Pierced Tracery Pipe Shade (carved foliage valance)+ createPart(`${fName}Shade`, boxGeo(0.08, 0.36, 0.62), goldLeaf, {+ position: [0.1, 4.65, fz],+ parent: caseGroup+ });+ // Hanging drops+ [-0.2, 0.0, 0.2].forEach((pz, pIdx) => {+ createInstance(`${fName}Drop_${pIdx}`, shadePendantProto, {+ position: [0.12, 4.42, fz + pz],+ rotation: [180, 0, 0],+ parent: caseGroup+ });+ });++ // Flat roof cresting (carved decorative balustrade along top)+ createPart(`${fName}Cresting`, boxGeo(0.06, 0.22, 0.68), goldLeaf, {+ position: [0.08, 5.16, fz],+ parent: caseGroup+ });+ });++ // =========================================================================+ // 2. DETACHED CONSOLE (Centred at X = 1.48m, facing +X towards organist)+ // Complete church organ console with enclosed case, stepped manuals,+ // angled stop jambs, music desk, brass sconce lamps, and pedalboard.+ // =========================================================================+ const consoleGroup = createPivot('Console', [1.48, 0, 0], root);++ // Console plinth / base+ createPart('ConsolePlinth', boxGeo(0.82, 0.08, 1.48), woodDark, {+ position: [0, 0.08, 0],+ parent: consoleGroup+ });++ // Lower cabinet body+ createPart('ConsoleCabinet', boxGeo(0.74, 0.88, 1.4), woodMedium, {+ position: [-0.02, 0.54, 0],+ parent: consoleGroup+ });++ // Side panels with raised mouldings (full height up to Y = 1.34m)+ [-0.71, 0.71].forEach((sideZ, sIdx) => {+ const sName = sIdx === 0 ? 'Left' : 'Right';+ // Lower side panel+ createPart(`ConsoleLowerSide_${sName}`, boxGeo(0.66, 0.74, 0.04), woodDark, {+ position: [-0.02, 0.54, sideZ],+ parent: consoleGroup+ });+ // Upper side cheek case (enclosing the upper console, stop jambs, and desk)+ createPart(`ConsoleUpperSide_${sName}`, boxGeo(0.66, 0.44, 0.04), woodDark, {+ position: [-0.02, 1.13, sideZ],+ parent: consoleGroup+ });+ // Curved roll-top track moulding along upper cheek+ createPart(`ConsoleRollTrack_${sName}`, cylinderZGeo(0.05, 0.05, 0.05, 10), woodLight, {+ position: [0.28, 1.05, sideZ],+ parent: consoleGroup+ });+ });++ // Upper back panel enclosing behind the music desk up to the top lid+ createPart('ConsoleUpperBack', boxGeo(0.04, 0.44, 1.38), woodDark, {+ position: [-0.33, 1.13, 0],+ parent: consoleGroup+ });++ // Knee well / leg opening for the organist in the center+ createPart('ConsolePedestalL', boxGeo(0.68, 0.68, 0.26), woodDark, {+ position: [0.01, 0.44, -0.56],+ parent: consoleGroup+ });+ createPart('ConsolePedestalR', boxGeo(0.68, 0.68, 0.26), woodDark, {+ position: [0.01, 0.44, 0.56],+ parent: consoleGroup+ });+ createPart('KneeWellBack', boxGeo(0.04, 0.66, 0.88), woodDark, {+ position: [-0.28, 0.44, 0],+ parent: consoleGroup+ });++ // Keybed shelf (supports the manuals)+ createPart('KeybedShelf', boxGeo(0.58, 0.06, 1.18), woodDark, {+ position: [0.15, 0.73, 0],+ parent: consoleGroup+ });++ // Carved Console Cheeks (side cheeks enclosing the manuals)+ [-0.48, 0.48].forEach((cz, cIdx) => {+ const side = cIdx === 0 ? 'Left' : 'Right';+ createPart(`CheekBlock_${side}`, boxGeo(0.44, 0.26, 0.06), woodDark, {+ position: [0.14, 0.88, cz],+ parent: consoleGroup+ });+ createPart(`CheekScroll_${side}`, cylinderZGeo(0.07, 0.07, 0.07, 10), woodMedium, {+ position: [0.35, 0.82, cz],+ parent: consoleGroup+ });+ });++ // --- TWO MANUALS (Swell & Great Keyboards) ---+ // Stepped arrangement: Great (lower) at Y = 0.78, Swell (upper) at Y = 0.86+ const manuals = [+ { name: 'ManualGreat', posX: 0.22, posY: 0.78 },+ { name: 'ManualSwell', posX: 0.13, posY: 0.86 },+ ];++ let sharpKeyProto = null;+ manuals.forEach((m) => {+ // Ivory naturals keybed+ createPart(`${m.name}_Naturals`, boxGeo(0.14, 0.026, 0.84), keyWhite, {+ position: [m.posX, m.posY, 0],+ parent: consoleGroup+ });+ // Front lip bevel of natural keys+ createPart(`${m.name}_KeyLip`, boxGeo(0.02, 0.03, 0.84), keyWhite, {+ position: [m.posX + 0.07, m.posY - 0.002, 0],+ parent: consoleGroup+ });+ // Red felt strip behind keys+ createPart(`${m.name}_Felt`, boxGeo(0.024, 0.03, 0.84), feltRed, {+ position: [m.posX - 0.075, m.posY + 0.008, 0],+ parent: consoleGroup+ });++ // Black sharp keys in realistic octave pattern (groups of 2 and 3)+ const octaves = [-0.34, -0.17, 0.0, 0.17, 0.34];+ octaves.forEach((octZ, octIdx) => {+ const sharpOffsets = [-0.056, -0.028, 0.014, 0.040, 0.064];+ sharpOffsets.forEach((off, sIdx) => {+ const kZ = octZ + off;+ if (kZ < -0.40 || kZ > 0.40) return;++ if (!sharpKeyProto) {+ sharpKeyProto = createPart('SharpKeyProto', boxGeo(0.088, 0.024, 0.012), keyBlack, {+ position: [m.posX - 0.025, m.posY + 0.022, kZ],+ parent: consoleGroup+ });+ } else {+ createInstance(`${m.name}_Sharp_${octIdx}_${sIdx}`, sharpKeyProto, {+ position: [m.posX - 0.025, m.posY + 0.022, kZ],+ parent: consoleGroup+ });+ }+ });+ });+ });++ // --- STOP KNOBS DOWN EACH CHEEK ---+ // Terraced angled stop jambs (angled at 30 deg towards organist)+ let stopStemProto = null;+ let stopHeadProto = null;+ [-0.44, 0.44].forEach((jambZ, sideIdx) => {+ const side = sideIdx === 0 ? 'Left' : 'Right';+ const sign = sideIdx === 0 ? -1 : 1;++ // Angled stop jamb panel+ createPart(`StopJambPanel_${side}`, boxGeo(0.38, 0.38, 0.12), woodDark, {+ position: [0.08, 0.94, jambZ + sign * 0.16],+ rotation: [0, -sign * 25, 0],+ parent: consoleGroup+ });++ // 2 columns of 6 stop knobs on each jamb (24 stop knobs total)+ for (let col = 0; col < 2; col++) {+ for (let row = 0; row < 6; row++) {+ const kX = 0.20 - col * 0.07;+ const kY = 0.80 + row * 0.056;+ const kZ = jambZ + sign * (0.10 + col * 0.08);++ if (!stopStemProto) {+ stopStemProto = createPart('StopStemProto', cylinderXGeo(0.007, 0.007, 0.04, 6), woodDark, {+ position: [kX, kY, kZ],+ parent: consoleGroup+ });+ stopHeadProto = createPart('StopHeadProto', cylinderXGeo(0.016, 0.013, 0.018, 8), stopKnobWhite, {+ position: [kX + 0.025, kY, kZ],+ parent: consoleGroup+ });+ createPart('StopFaceLabel', decalBox(0.002, 0.02, 0.02), woodDark, {+ position: [kX + 0.035, kY, kZ],+ parent: consoleGroup+ });+ } else {+ createInstance(`StopStem_${side}_${col}_${row}`, stopStemProto, {+ position: [kX, kY, kZ],+ parent: consoleGroup+ });+ createInstance(`StopHead_${side}_${col}_${row}`, stopHeadProto, {+ position: [kX + 0.025, kY, kZ],+ parent: consoleGroup+ });+ }+ }+ }+ });++ // --- MUSIC DESK & CONSOLE TOP ---+ // Slanted music desk with slatted rack+ createPart('MusicDeskLedge', boxGeo(0.09, 0.03, 0.82), woodMedium, {+ position: [0.02, 0.98, 0],+ parent: consoleGroup+ });+ createPart('MusicDeskBack', boxGeo(0.024, 0.32, 0.8), woodDark, {+ position: [-0.04, 1.15, 0],+ rotation: [-15, 0, 0],+ parent: consoleGroup+ });+ // Carved desk grille slats+ for (let s = -3; s <= 3; s++) {+ createPart(`MusicDeskSlat_${s}`, boxGeo(0.02, 0.28, 0.025), woodLight, {+ position: [-0.028, 1.15, s * 0.11],+ rotation: [-15, 0, 0],+ parent: consoleGroup+ });+ }+ // Open Sheet Music Score on desk+ createPart('SheetMusicBook', boxGeo(0.012, 0.25, 0.36), scorePaper, {+ position: [-0.01, 1.15, 0],+ rotation: [-15, 0, 0],+ parent: consoleGroup+ });+ createPart('SheetMusicStaffL', boxGeo(0.014, 0.008, 0.13), woodDark, {+ position: [-0.002, 1.18, -0.08],+ rotation: [-15, 0, 0],+ parent: consoleGroup+ });+ createPart('SheetMusicStaffR', boxGeo(0.014, 0.008, 0.13), woodDark, {+ position: [-0.002, 1.18, 0.08],+ rotation: [-15, 0, 0],+ parent: consoleGroup+ });++ // Console Brass Desk Lamps (left and right sconces)+ [-0.45, 0.45].forEach((lampZ, lIdx) => {+ const side = lIdx === 0 ? 'Left' : 'Right';+ createPart(`DeskLampBase_${side}`, cylinderGeo(0.035, 0.04, 0.04, 8), brassMat, {+ position: [-0.02, 1.0, lampZ],+ parent: consoleGroup+ });+ createPart(`DeskLampStem_${side}`, cylinderGeo(0.012, 0.012, 0.22, 6), brassMat, {+ position: [-0.02, 1.12, lampZ],+ parent: consoleGroup+ });+ createPart(`DeskLampShade_${side}`, taperConeGeo(0.03, 0.065, 0.1, 'y', 10), brassMat, {+ position: [0.0, 1.25, lampZ],+ rotation: [25, 0, 0],+ parent: consoleGroup+ });+ });++ // Console Top Canopy / Roll-top Lid Housing (solidly rests on upper side and back panels at Y = 1.35m)+ createPart('ConsoleTopLid', boxGeo(0.74, 0.06, 1.46), woodDark, {+ position: [-0.03, 1.36, 0],+ parent: consoleGroup+ });+ createPart('ConsoleTopMoulding', boxGeo(0.78, 0.04, 1.5), woodLight, {+ position: [-0.02, 1.40, 0],+ parent: consoleGroup+ });++ // =========================================================================+ // 3. PEDALBOARD (Sits in the knee well on the dais floor Y = 0.04..0.18)+ // Concave radial 25-note pedalboard with expression shoes+ // =========================================================================+ const pedalGroup = createPivot('Pedalboard', [0, 0, 0], consoleGroup);++ // Pedal Frame (Toe rail, Heel rail, Side blocks)+ createPart('PedalFrameHeel', boxGeo(0.08, 0.06, 1.08), woodDark, {+ position: [0.46, 0.07, 0],+ parent: pedalGroup+ });+ createPart('PedalFrameToe', boxGeo(0.1, 0.09, 1.08), woodDark, {+ position: [-0.28, 0.08, 0],+ parent: pedalGroup+ });+ createPart('PedalFrameLeft', boxGeo(0.82, 0.08, 0.07), woodDark, {+ position: [0.09, 0.08, -0.54],+ parent: pedalGroup+ });+ createPart('PedalFrameRight', boxGeo(0.82, 0.08, 0.07), woodDark, {+ position: [0.09, 0.08, 0.54],+ parent: pedalGroup+ });++ // 25 Pedals: Concave curvature (middle pedals lower at Y=0.065, edge pedals Y=0.09)+ let pedalSharpProto = null;+ let pedalNatProto = null;+ const numPedals = 25;+ for (let i = 0; i < numPedals; i++) {+ const frac = i / (numPedals - 1);+ const pZ = -0.46 + frac * 0.92;+ // Slight concave arch+ const archY = Math.pow(Math.abs(frac - 0.5) * 2, 2) * 0.025;+ const isSharp = (i % 7 === 1 || i % 7 === 2 || i % 7 === 4 || i % 7 === 5 || i % 7 === 6);++ if (isSharp) {+ if (!pedalSharpProto) {+ pedalSharpProto = createPart('PedalSharpProto', boxGeo(0.38, 0.04, 0.024), woodDark, {+ position: [-0.08, 0.10 + archY, pZ],+ parent: pedalGroup+ });+ createPart('PedalSharpCapProto', boxGeo(0.38, 0.012, 0.022), keyBlack, {+ position: [-0.08, 0.125 + archY, pZ],+ parent: pedalGroup+ });+ } else {+ createInstance(`PedalSharp_${i}`, pedalSharpProto, {+ position: [-0.08, 0.10 + archY, pZ],+ parent: pedalGroup+ });+ }+ } else {+ if (!pedalNatProto) {+ pedalNatProto = createPart('PedalNatProto', boxGeo(0.72, 0.028, 0.026), woodLight, {+ position: [0.08, 0.065 + archY, pZ],+ parent: pedalGroup+ });+ } else {+ createInstance(`PedalNatural_${i}`, pedalNatProto, {+ position: [0.08, 0.065 + archY, pZ],+ parent: pedalGroup+ });+ }+ }+ }++ // Swell & Crescendo Expression Shoes (mounted into knee well)+ [-0.08, 0.08].forEach((shoeZ, sIdx) => {+ const sName = sIdx === 0 ? 'SwellShoe' : 'CrescendoShoe';+ createPart(sName, boxGeo(0.18, 0.035, 0.1), keyBlack, {+ position: [-0.18, 0.22, shoeZ],+ rotation: [16, 0, 0],+ parent: pedalGroup+ });+ createPart(`${sName}Plate`, boxGeo(0.14, 0.01, 0.08), brassMat, {+ position: [-0.18, 0.24, shoeZ],+ rotation: [16, 0, 0],+ parent: pedalGroup+ });+ });++ // Toe Studs (metal combination pistons along the toe frame)+ for (let t = -3; t <= 3; t++) {+ createPart(`ToeStud_${t}`, sphereGeo(0.016, 6, 6), brassMat, {+ position: [-0.22, 0.14, t * 0.12],+ parent: pedalGroup+ });+ }++ // =========================================================================+ // 4. ORGAN BENCH (Centred at X = 2.22m, facing -X towards console)+ // Perfectly spaced at ~0.30m from the keybed for authentic organ ergonomics.+ // =========================================================================+ const benchGroup = createPivot('OrganBench', [2.22, 0, 0], root);++ // Bench Seat (wide contoured oak plank)+ createPart('BenchSeat', boxGeo(0.36, 0.05, 1.26), woodMedium, {+ position: [0, 0.62, 0],+ parent: benchGroup+ });+ createPart('BenchSeatBevel', boxGeo(0.38, 0.02, 1.28), woodLight, {+ position: [0, 0.645, 0],+ parent: benchGroup+ });++ // Music storage shelf under the bench seat+ createPart('BenchMusicShelf', boxGeo(0.28, 0.03, 1.08), woodDark, {+ position: [0, 0.53, 0],+ parent: benchGroup+ });++ // Trestle Legs (Left & Right shaped uprights)+ [-0.52, 0.52].forEach((legZ, lIdx) => {+ const side = lIdx === 0 ? 'Left' : 'Right';+ // Main vertical leg upright+ createPart(`BenchLeg_${side}`, boxGeo(0.24, 0.54, 0.05), woodDark, {+ position: [0, 0.32, legZ],+ parent: benchGroup+ });+ // Arched cutout in leg (decorative panel)+ createPart(`BenchLegArch_${side}`, cylinderXGeo(0.07, 0.07, 0.06, 10), woodLight, {+ position: [0, 0.22, legZ],+ parent: benchGroup+ });+ // Sturdy wide foot on the dais floor+ createPart(`BenchFoot_${side}`, boxGeo(0.34, 0.07, 0.09), woodDark, {+ position: [0, 0.06, legZ],+ parent: benchGroup+ });+ // Top bracket supporting seat+ createPart(`BenchTopBracket_${side}`, boxGeo(0.32, 0.05, 0.08), woodMedium, {+ position: [0, 0.58, legZ],+ parent: benchGroup+ });+ });++ // Central Stretcher rail connecting the two legs+ createPart('BenchStretcher', boxGeo(0.06, 0.09, 1.02), woodMedium, {+ position: [0, 0.24, 0],+ parent: benchGroup+ });+ // Wedge keys pinning the stretcher through each leg+ [-0.56, 0.56].forEach((keyZ, kIdx) => {+ createPart(`BenchWedge_${kIdx}`, boxGeo(0.04, 0.12, 0.03), woodLight, {+ position: [0, 0.24, keyZ],+ parent: benchGroup+ });+ });++ return root;+}diff --git a/examples/planetarium-projector.kiln.js b/examples/planetarium-projector.kiln.jsnew file mode 100644index 00000000..c113b87e--- /dev/null+++ b/examples/planetarium-projector.kiln.js@@ -0,0 +1,487 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'PlanetariumProjector', category: 'prop', role: 'prop' };++async function build() {+ const root = createRoot('PlanetariumProjector');++ // --- Materials ---+ // Mid-century precision scientific instrument aesthetic:+ // Dark hammertone cast iron body, brass gears & optical bezels, satin stainless steel shafts,+ // deep blue optical glass elements, and matte industrial cable rubber.+ const castBody = gameMaterial(0x23272b, { metalness: 0.65, roughness: 0.45 });+ const darkIron = gameMaterial(0x17191c, { metalness: 0.55, roughness: 0.6 });+ const brass = gameMaterial(0xcfa032, { metalness: 0.88, roughness: 0.28 });+ const polishedSteel = gameMaterial(0x9ca3af, { metalness: 0.92, roughness: 0.18 });+ const lensGlass = gameMaterial(0x0c1e2e, { metalness: 0.95, roughness: 0.05 });+ const cableMat = gameMaterial(0x141414, { roughness: 0.85, metalness: 0.1 });++ // Reusable Geometries to optimize draw calls and triangle budget+ const boltGeo = cylinderGeo(0.016, 0.016, 0.025, 6);+ const gearToothSmallGeo = boxGeo(0.032, 0.035, 0.035);+ const gearToothMediumGeo = boxGeo(0.036, 0.038, 0.03);+ const gearSpokeGeo = cylinderGeo(0.012, 0.012, 0.74, 6);+ const cageBarGeo = cylinderYGeo(0.013, 0.013, 0.8, 6);+ const lensBaseGeo = cylinderGeo(0.05, 0.062, 0.025, 6);+ const lensBarrelGeo = cylinderGeo(0.036, 0.046, 0.055, 6);+ const lensGlassGeo = cylinderGeo(0.038, 0.038, 0.01, 6);+ const pinholeGeo = cylinderGeo(0.018, 0.018, 0.008, 6);+ const planetBarrelGeo = cylinderGeo(0.038, 0.044, 0.19, 6);+ const planetLensGeo = cylinderGeo(0.04, 0.04, 0.015, 6);++ // ==========================================+ // 1. TAPERED PEDESTAL BASE & CABLE TERMINAL+ // ==========================================+ // Stepped heavy casting at the floor (Y = 0)+ createPart('BaseFlange', cylinderGeo(1.05, 1.15, 0.06, 24), darkIron, {+ position: [0, 0.03, 0],+ parent: root,+ });++ createPart('BaseStep', cylinderGeo(0.88, 1.02, 0.08, 20), castBody, {+ position: [0, 0.1, 0],+ parent: root,+ });++ // Perimeter anchor bolts (12 bolts)+ for (let i = 0; i < 12; i++) {+ const a = (i / 12) * Math.PI * 2;+ createPart(`AnchorBolt_${i}`, boltGeo, polishedSteel, {+ position: [Math.cos(a) * 1.05, 0.07, Math.sin(a) * 1.05],+ parent: root,+ });+ }++ // Tapered column of the pedestal+ createPart('PedestalColumn', cylinderGeo(0.46, 0.8, 1.1, 20), castBody, {+ position: [0, 0.69, 0],+ parent: root,+ });++ // 4 reinforcing vertical flanges / ribs+ for (let i = 0; i < 4; i++) {+ const a = (i / 4) * Math.PI * 2 + Math.PI / 4;+ createPart(`PedestalRib_${i}`, boxGeo(0.06, 0.85, 0.16), darkIron, {+ position: [Math.cos(a) * 0.58, 0.62, Math.sin(a) * 0.58],+ rotation: [0, -a * (180 / Math.PI), 0],+ parent: root,+ });+ }++ // Electrical terminal & control housing on the pedestal+ createPart('JunctionBox', boxGeo(0.24, 0.32, 0.18), darkIron, {+ position: [0.52, 0.45, 0.28],+ rotation: [0, -25, 0],+ parent: root,+ });+ createPart('JunctionPlate', boxGeo(0.25, 0.15, 0.02), brass, {+ position: [0.53, 0.48, 0.38],+ rotation: [0, -25, 0],+ parent: root,+ });+ createPart('JunctionDial', cylinderGeo(0.04, 0.04, 0.03, 8), polishedSteel, {+ position: [0.55, 0.36, 0.37],+ rotation: [90, 0, -25],+ parent: root,+ });++ // Pedestal neck & Azimuth Ring Gear+ createPart('PedestalNeck', cylinderGeo(0.5, 0.46, 0.14, 18), darkIron, {+ position: [0, 1.31, 0],+ parent: root,+ });+ createPart('AzimuthRing', torusGeo(0.51, 0.024, 5, 16), brass, {+ position: [0, 1.39, 0],+ rotation: [90, 0, 0],+ parent: root,+ });+ for (let t = 0; t < 16; t++) {+ const ta = (t / 16) * Math.PI * 2;+ createPart(`AzTooth_${t}`, gearToothSmallGeo, brass, {+ position: [Math.cos(ta) * 0.52, 1.39, Math.sin(ta) * 0.52],+ rotation: [0, -ta * (180 / Math.PI), 0],+ parent: root,+ });+ }++ createPart('PedestalCrown', cylinderGeo(0.46, 0.5, 0.1, 18), castBody, {+ position: [0, 1.47, 0],+ parent: root,+ });++ // ==========================================+ // 2. YOKE, ELEVATION TRUNNIONS & GEAR CAGE+ // ==========================================+ createPart('MountBase', cylinderGeo(0.42, 0.46, 0.18, 16), darkIron, {+ position: [0, 1.61, 0],+ parent: root,+ });++ createPart('YokeSaddle', boxGeo(0.36, 0.22, 0.95), castBody, {+ position: [0, 1.76, 0],+ parent: root,+ });++ // Dual Trunnion arms (left and right)+ for (const [sideName, zSign] of [['L', -1], ['R', 1]]) {+ createPart(`YokeArm_${sideName}`, cylinderGeo(0.13, 0.18, 0.85, 10), castBody, {+ position: [0, 2.18, zSign * 0.48],+ parent: root,+ });++ createPart(`YokeStrut_${sideName}`, boxGeo(0.12, 0.6, 0.1), darkIron, {+ position: [-0.08, 2.05, zSign * 0.48],+ rotation: [0, 0, 15],+ parent: root,+ });++ // Elevation Trunnion Bearing Housing+ createPart(`TrunnionPillow_${sideName}`, cylinderZGeo(0.22, 0.22, 0.18, 14), darkIron, {+ position: [0, 2.6, zSign * 0.52],+ parent: root,+ });+ createPart(`TrunnionCap_${sideName}`, cylinderZGeo(0.23, 0.23, 0.05, 14), brass, {+ position: [0, 2.6, zSign * 0.62],+ parent: root,+ });+ for (let b = 0; b < 6; b++) {+ const ba = (b / 6) * Math.PI * 2;+ createPart(`TrunnionBolt_${sideName}_${b}`, boltGeo, polishedSteel, {+ position: [Math.cos(ba) * 0.16, 2.6 + Math.sin(ba) * 0.16, zSign * 0.65],+ rotation: [90, 0, 0],+ parent: root,+ });+ }++ // Elevation Ring Gear & Cage+ createPart(`ElevationRing_${sideName}`, torusGeo(0.42, 0.024, 5, 16), brass, {+ position: [0, 2.6, zSign * 0.38],+ parent: root,+ });+ createPart(`CageRingOuter_${sideName}`, torusGeo(0.45, 0.02, 4, 14), polishedSteel, {+ position: [0, 2.6, zSign * 0.32],+ parent: root,+ });++ // Radial gear teeth around the ring gear+ for (let t = 0; t < 14; t++) {+ const ta = (t / 14) * Math.PI * 2;+ createPart(`ElevTooth_${sideName}_${t}`, gearToothMediumGeo, brass, {+ position: [Math.cos(ta) * 0.43, 2.6 + Math.sin(ta) * 0.43, zSign * 0.38],+ rotation: [0, 0, ta * (180 / Math.PI)],+ parent: root,+ });+ }++ // Radial spokes linking ring to trunnion axle+ for (let s = 0; s < 6; s++) {+ const sa = (s / 6) * Math.PI;+ createPart(`GearSpoke_${sideName}_${s}`, gearSpokeGeo, polishedSteel, {+ position: [0, 2.6, zSign * 0.38],+ rotation: [0, 0, sa * (180 / Math.PI)],+ parent: root,+ });+ }+ }++ // Central trunnion axle connecting both sides+ createPart('TrunnionShaft', cylinderZGeo(0.09, 0.09, 1.25, 12), polishedSteel, {+ position: [0, 2.6, 0],+ parent: root,+ });++ // Elevation Drive Motor & Worm Gearbox+ createPart('ElevationMotor', cylinderZGeo(0.11, 0.11, 0.26, 10), darkIron, {+ position: [0.18, 2.42, -0.56],+ parent: root,+ });+ createPart('ElevationGearbox', boxGeo(0.18, 0.18, 0.16), castBody, {+ position: [0.08, 2.52, -0.54],+ parent: root,+ });+ createPart('MotorEndPlate', cylinderZGeo(0.115, 0.115, 0.03, 10), brass, {+ position: [0.18, 2.42, -0.7],+ parent: root,+ });++ // Counterweight arm and counterweight discs+ createPart('CounterweightBar', cylinderXGeo(0.045, 0.045, 0.65, 8), polishedSteel, {+ position: [-0.35, 2.6, 0],+ parent: root,+ });+ createPart('CounterweightDisc1', cylinderXGeo(0.24, 0.24, 0.14, 14), darkIron, {+ position: [-0.55, 2.6, 0],+ parent: root,+ });+ createPart('CounterweightDisc2', cylinderXGeo(0.22, 0.22, 0.1, 14), brass, {+ position: [-0.68, 2.6, 0],+ parent: root,+ });++ // ==========================================+ // 3. CENTRAL DUMBBELL FRAME & PLANET CAGES+ // ==========================================+ const dumbbellPivot = createPivot('DumbbellFrame', [0, 2.6, 0], root);+ dumbbellPivot.rotation.z = 38 * (Math.PI / 180); // Astronomical latitude tilt ~38°++ // Central declination drum / carrier+ createPart('CenterHub', cylinderYGeo(0.38, 0.38, 0.44, 16), darkIron, {+ position: [0, 0, 0],+ parent: dumbbellPivot,+ });+ createPart('CenterRingGear', torusGeo(0.41, 0.024, 5, 16), brass, {+ position: [0, 0, 0],+ rotation: [90, 0, 0],+ parent: dumbbellPivot,+ });+ for (let t = 0; t < 14; t++) {+ const ta = (t / 14) * Math.PI * 2;+ createPart(`CenterTooth_${t}`, gearToothSmallGeo, brass, {+ position: [Math.cos(ta) * 0.42, 0, Math.sin(ta) * 0.42],+ rotation: [0, -ta * (180 / Math.PI), 0],+ parent: dumbbellPivot,+ });+ }++ // Declination drive motor pod+ createPart('DeclinationDrive', cylinderXGeo(0.09, 0.09, 0.28, 10), castBody, {+ position: [0.32, 0, 0],+ parent: dumbbellPivot,+ });+ createPart('DeclinationDriveCap', cylinderXGeo(0.095, 0.095, 0.04, 10), brass, {+ position: [0.47, 0, 0],+ parent: dumbbellPivot,+ });++ const cageHeight = 0.82;+ const cageRadius = 0.33;+ const sphereDist = 0.28 + cageHeight + 0.5;++ for (const [hemi, sign] of [['North', 1], ['South', -1]]) {+ const cageCenterY = sign * (0.22 + cageHeight / 2);+ const collarY = sign * 0.22;+ const topCollarY = sign * (0.22 + cageHeight);++ // Inner & Outer Bulkheads+ createPart(`CageCollarInner_${hemi}`, cylinderYGeo(0.35, 0.35, 0.06, 16), castBody, {+ position: [0, collarY, 0],+ parent: dumbbellPivot,+ });+ createPart(`CageCollarOuter_${hemi}`, cylinderYGeo(0.35, 0.35, 0.06, 16), castBody, {+ position: [0, topCollarY, 0],+ parent: dumbbellPivot,+ });+ createPart(`CageRingGear_${hemi}`, torusGeo(0.36, 0.02, 4, 14), brass, {+ position: [0, topCollarY, 0],+ rotation: [90, 0, 0],+ parent: dumbbellPivot,+ });++ // 8 Longitudinal Cage Struts+ for (let j = 0; j < 8; j++) {+ const a = (j / 8) * Math.PI * 2;+ createPart(`CageStrut_${hemi}_${j}`, cageBarGeo, polishedSteel, {+ position: [Math.cos(a) * cageRadius, cageCenterY, Math.sin(a) * cageRadius],+ parent: dumbbellPivot,+ });+ }++ // Mid-cage intermediate ring+ createPart(`CageMidRing_${hemi}`, torusGeo(cageRadius, 0.015, 4, 14), brass, {+ position: [0, cageCenterY, 0],+ rotation: [90, 0, 0],+ parent: dumbbellPivot,+ });++ // Center internal axle+ createPart(`CageCoreShaft_${hemi}`, cylinderYGeo(0.08, 0.08, cageHeight, 10), darkIron, {+ position: [0, cageCenterY, 0],+ parent: dumbbellPivot,+ });++ // Clustered Planet Projector mechanisms inside cage+ const projectorCount = 3;+ for (let p = 0; p < projectorCount; p++) {+ const pAngle = (p / projectorCount) * Math.PI * 2 + (sign > 0 ? 0.3 : 1.2);+ const py = cageCenterY + (p - 1) * 0.2;+ const px = Math.cos(pAngle) * 0.16;+ const pz = Math.sin(pAngle) * 0.16;++ createPart(`PlanetMount_${hemi}_${p}`, boxGeo(0.08, 0.07, 0.1), darkIron, {+ position: [px, py, pz],+ rotation: [0, -pAngle * (180 / Math.PI), 0],+ parent: dumbbellPivot,+ });++ const barrelAngle = pAngle + (p % 2 === 0 ? 0.35 : -0.35);+ const bbx = Math.cos(barrelAngle) * 0.22;+ const bbz = Math.sin(barrelAngle) * 0.22;+ const pDir = new THREE.Vector3(Math.cos(barrelAngle), 0.3 * sign, Math.sin(barrelAngle)).normalize();+ const pBarrel = createPart(`PlanetBarrel_${hemi}_${p}`, planetBarrelGeo, brass, {+ position: [bbx, py + (sign * 0.03), bbz],+ parent: dumbbellPivot,+ });+ pBarrel.quaternion.setFromUnitVectors(new THREE.Vector3(0, 1, 0), pDir);++ const pLens = createPart(`PlanetLens_${hemi}_${p}`, planetLensGeo, lensGlass, {+ position: [bbx + pDir.x * 0.1, py + (sign * 0.03) + pDir.y * 0.1, bbz + pDir.z * 0.1],+ parent: dumbbellPivot,+ });+ pLens.quaternion.copy(pBarrel.quaternion);+ }++ // ==========================================+ // 4. STAR SPHERES (NORTH & SOUTH)+ // ==========================================+ const sphereY = sign * sphereDist;++ // Perforated Star Sphere Ball+ createPart(`StarSphere_${hemi}`, sphereGeo(0.5, 18, 12), castBody, {+ position: [0, sphereY, 0],+ parent: dumbbellPivot,+ });++ // Equator structural ring+ createPart(`SphereEquator_${hemi}`, torusGeo(0.51, 0.02, 4, 14), brass, {+ position: [0, sphereY, 0],+ rotation: [90, 0, 0],+ parent: dumbbellPivot,+ });++ // Latitude panel rib rings+ createPart(`SphereLatRib1_${hemi}`, torusGeo(0.44, 0.015, 4, 12), darkIron, {+ position: [0, sphereY + sign * 0.23, 0],+ rotation: [90, 0, 0],+ parent: dumbbellPivot,+ });+ createPart(`SphereLatRib2_${hemi}`, torusGeo(0.44, 0.015, 4, 12), darkIron, {+ position: [0, sphereY - sign * 0.23, 0],+ rotation: [90, 0, 0],+ parent: dumbbellPivot,+ });++ // Polar cap projector+ createPart(`PolarCap_${hemi}`, cylinderGeo(0.11, 0.15, 0.07, 10), brass, {+ position: [0, sphereY + sign * 0.5, 0],+ parent: dumbbellPivot,+ });++ // Perforated star pinholes around sphere equator (8 pinholes per sphere)+ for (let ph = 0; ph < 8; ph++) {+ const pha = (ph / 8) * Math.PI * 2 + 0.15;+ const phx = Math.cos(pha) * 0.505;+ const phz = Math.sin(pha) * 0.505;+ const pinPart = createPart(`StarPinhole_${hemi}_${ph}`, pinholeGeo, darkIron, {+ position: [phx, sphereY + (ph % 2 === 0 ? 0.08 : -0.08) * sign, phz],+ parent: dumbbellPivot,+ });+ pinPart.quaternion.setFromUnitVectors(new THREE.Vector3(0, 1, 0), new THREE.Vector3(phx, 0, phz).normalize());+ }++ // Studded Lens Barrels distributed across the star ball (22 precision lenses per sphere)+ const rings = [+ { latDeg: sign * 68, count: 3, rotOffset: 0.1 },+ { latDeg: sign * 42, count: 5, rotOffset: 0.3 },+ { latDeg: sign * 18, count: 6, rotOffset: 0.0 },+ { latDeg: -sign * 15, count: 5, rotOffset: 0.2 },+ { latDeg: -sign * 42, count: 3, rotOffset: 0.4 },+ ];++ let lensCount = 0;+ for (const r of rings) {+ const latRad = r.latDeg * (Math.PI / 180);+ const yLocal = Math.sin(latRad) * 0.5;+ const rPlane = Math.cos(latRad) * 0.5;++ for (let k = 0; k < r.count; k++) {+ const lon = (k / r.count) * Math.PI * 2 + r.rotOffset;+ const xLocal = Math.cos(lon) * rPlane;+ const zLocal = Math.sin(lon) * rPlane;++ const normalVec = new THREE.Vector3(xLocal / 0.5, yLocal / 0.5, zLocal / 0.5).normalize();+ const quat = new THREE.Quaternion().setFromUnitVectors(new THREE.Vector3(0, 1, 0), normalVec);++ const collar = createPart(`LensCollar_${hemi}_${lensCount}`, lensBaseGeo, darkIron, {+ position: [xLocal + normalVec.x * 0.012, sphereY + yLocal + normalVec.y * 0.012, zLocal + normalVec.z * 0.012],+ parent: dumbbellPivot,+ });+ collar.quaternion.copy(quat);++ const barrel = createPart(`LensBarrel_${hemi}_${lensCount}`, lensBarrelGeo, brass, {+ position: [xLocal + normalVec.x * 0.045, sphereY + yLocal + normalVec.y * 0.045, zLocal + normalVec.z * 0.045],+ parent: dumbbellPivot,+ });+ barrel.quaternion.copy(quat);++ const glass = createPart(`LensFront_${hemi}_${lensCount}`, lensGlassGeo, lensGlass, {+ position: [xLocal + normalVec.x * 0.074, sphereY + yLocal + normalVec.y * 0.074, zLocal + normalVec.z * 0.074],+ parent: dumbbellPivot,+ });+ glass.quaternion.copy(quat);++ lensCount++;+ }+ }++ // Special projector nacelles on equator+ for (let c = 0; c < 2; c++) {+ const cAngle = c * Math.PI + (sign > 0 ? 0 : Math.PI / 2);+ const cx = Math.cos(cAngle) * 0.52;+ const cz = Math.sin(cAngle) * 0.52;+ createPart(`SpecialProjector_${hemi}_${c}`, cylinderGeo(0.05, 0.065, 0.12, 6), polishedSteel, {+ position: [cx, sphereY, cz],+ rotation: [0, -cAngle * (180 / Math.PI), 90],+ parent: dumbbellPivot,+ });+ createPart(`SpecialLens_${hemi}_${c}`, cylinderGeo(0.052, 0.052, 0.02, 6), lensGlass, {+ position: [cx * 1.11, sphereY, cz * 1.11],+ rotation: [0, -cAngle * (180 / Math.PI), 90],+ parent: dumbbellPivot,+ });+ }+ }++ // ==========================================+ // 5. INDUSTRIAL CABLE TRUNK & CONDUITS+ // ==========================================+ const mainCablePath = [+ [0.12, 2.55, 0.45],+ [0.32, 2.25, 0.52],+ [0.46, 1.85, 0.5],+ [0.54, 1.4, 0.44],+ [0.56, 0.95, 0.38],+ [0.54, 0.55, 0.32],+ ];+ const mainCableGeo = pipeAlongPath(mainCablePath, 0.048, { bendRadius: 0.16, tubularSegments: 20, radialSegments: 6 });+ createPart('MainCableTrunk', mainCableGeo, cableMat, { parent: root });++ const clampPoints = [+ { pos: [0.46, 1.82, 0.5], rot: -20 },+ { pos: [0.54, 1.38, 0.44], rot: -25 },+ { pos: [0.56, 0.92, 0.38], rot: -28 },+ ];+ clampPoints.forEach((cp, idx) => {+ createPart(`CableClamp_${idx}`, boxGeo(0.08, 0.04, 0.14), brass, {+ position: cp.pos,+ rotation: [0, cp.rot, 0],+ parent: root,+ });+ });++ const motorConduitPath = [+ [0.18, 2.38, -0.62],+ [0.12, 2.1, -0.58],+ [0.05, 1.85, -0.48],+ ];+ const motorConduitGeo = pipeAlongPath(motorConduitPath, 0.025, { bendRadius: 0.1, tubularSegments: 12, radialSegments: 6 });+ createPart('MotorConduit', motorConduitGeo, cableMat, { parent: root });++ return root;+}diff --git a/examples/printing-press.kiln.js b/examples/printing-press.kiln.jsnew file mode 100644index 00000000..66e3796a--- /dev/null+++ b/examples/printing-press.kiln.js@@ -0,0 +1,397 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools, and cut off+// mid-run rather than finished -- by a provider limit, or by the+// dispatch deadline. The program below is what was on disk when the+// session ended; how many times it had looked at its own contact sheet+// by then is not recorded, so this one does not make the claim the+// others do.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'PrintingPress', category: 'prop' };++async function build() {+ const root = createRoot('PrintingPress');++ // ==========================================+ // MATERIALS PALETTE (12 PBR Materials)+ // ==========================================+ const oakDark = gameMaterial(0x382618, { roughness: 0.88 }); // Heavy structural timbers (cheeks, beams, feet)+ const oakMedium = gameMaterial(0x523b26, { roughness: 0.82 }); // Secondary woodwork (rails, carriage, table)+ const oakLight = gameMaterial(0x6e5136, { roughness: 0.78 }); // Furniture, tympan frame, hose+ const woodTurned = gameMaterial(0x694628, { roughness: 0.65 }); // Turned grips, finials, ink ball handles+ const ironWrought = gameMaterial(0x1a1c1e, { metalness: 0.84, roughness: 0.40 }); // Screw, lever, crank, bolts, straps+ const ironCast = gameMaterial(0x282a2d, { metalness: 0.76, roughness: 0.52 }); // Chase frame, platen iron plate+ const typeLead = gameMaterial(0x4a4d52, { metalness: 0.70, roughness: 0.42 }); // Cast lead movable type+ const brass = gameMaterial(0x9c7934, { metalness: 0.88, roughness: 0.30 }); // Thread collar nut, platen boss, tacks+ const stoneMarble = gameMaterial(0x2a2c2e, { roughness: 0.88 }); // Polished bed stone & inking slab+ const printerInk = gameMaterial(0x0a0a0c, { metalness: 0.12, roughness: 0.25 }); // Viscous black printer's ink+ const leather = gameMaterial(0x26170e, { roughness: 0.74 }); // Sheepskin balls, rounce girth straps+ const parchment = gameMaterial(0xe8ddc5, { roughness: 0.92 }); // Tympan vellum, frisket mask, paper stack++ // Shared Geometries for instancing / efficient draw calls+ const boltHeadGeo = cylinderGeo(0.018, 0.018, 0.02, 6);+ const pegGeo = cylinderGeo(0.012, 0.012, 0.03, 8);+ const tackGeo = sphereGeo(0.005, 8, 6);+ const ironStrapCornerGeo = boxGeo(0.055, 0.075, 0.055);++ // ==========================================+ // 1. MAIN TIMBER FRAME (CHEEKS, FEET, BEAMS, BRACES)+ // ==========================================+ const cheekZ = 0.41;+ const cheekH = 1.88;+ const cheekW_X = 0.20;+ const cheekW_Z = 0.16;++ // Base feet (skid runners on Y=0)+ // Main foot body+ const footL = createPart('FootL', boxGeo(0.92, 0.12, 0.20), oakDark, { position: [0, 0.06, -cheekZ], parent: root });+ const footR = createPart('FootR', boxGeo(0.92, 0.12, 0.20), oakDark, { position: [0, 0.06, cheekZ], parent: root });+ // Beveled toes at the ends of the feet+ createPart('FootL_ToeF', boxGeo(0.08, 0.08, 0.20), oakDark, { position: [0.48, 0.04, -cheekZ], parent: root });+ createPart('FootL_ToeB', boxGeo(0.08, 0.08, 0.20), oakDark, { position: [-0.48, 0.04, -cheekZ], parent: root });+ createPart('FootR_ToeF', boxGeo(0.08, 0.08, 0.20), oakDark, { position: [0.48, 0.04, cheekZ], parent: root });+ createPart('FootR_ToeB', boxGeo(0.08, 0.08, 0.20), oakDark, { position: [-0.48, 0.04, cheekZ], parent: root });++ // Upright Cheeks (vertical posts)+ createPart('CheekL', boxGeo(cheekW_X, cheekH, cheekW_Z), oakDark, { position: [0, 0.12 + cheekH / 2, -cheekZ], parent: root });+ createPart('CheekR', boxGeo(cheekW_X, cheekH, cheekW_Z), oakDark, { position: [0, 0.12 + cheekH / 2, cheekZ], parent: root });++ // 4 Diagonal Knee Braces (bracing feet to cheeks)+ beamBetween('KneeBraceL_Fwd', [0.36, 0.12, -cheekZ], [0.10, 0.50, -cheekZ], 0.038, oakDark, { segments: 8, parent: root });+ beamBetween('KneeBraceL_Aft', [-0.36, 0.12, -cheekZ], [-0.10, 0.50, -cheekZ], 0.038, oakDark, { segments: 8, parent: root });+ beamBetween('KneeBraceR_Fwd', [0.36, 0.12, cheekZ], [0.10, 0.50, cheekZ], 0.038, oakDark, { segments: 8, parent: root });+ beamBetween('KneeBraceR_Aft', [-0.36, 0.12, cheekZ], [-0.10, 0.50, cheekZ], 0.038, oakDark, { segments: 8, parent: root });++ // Base Tie / Summer Beam near floor+ createPart('SummerBeam', boxGeo(0.18, 0.14, cheekZ * 2 - cheekW_Z), oakDark, { position: [0, 0.20, 0], parent: root });+ // Treenails pinning summer beam into cheeks+ createPart('SummerPegL', pegGeo, oakLight, { position: [0, 0.20, -cheekZ - 0.085], rotation: [90, 0, 0], parent: root });+ createPart('SummerPegR', pegGeo, oakLight, { position: [0, 0.20, cheekZ + 0.085], rotation: [90, 0, 0], parent: root });++ // Winter Beam (massive beam at Y=0.72)+ createPart('WinterBeam', boxGeo(0.25, 0.20, cheekZ * 2 + 0.04), oakDark, { position: [0, 0.72, 0], parent: root });+ // Through-tenon mortise keys projecting through cheek outsides+ createPart('WinterKeyL', boxGeo(0.08, 0.07, 0.05), oakLight, { position: [0, 0.72, -cheekZ - 0.095], parent: root });+ createPart('WinterKeyR', boxGeo(0.08, 0.07, 0.05), oakLight, { position: [0, 0.72, cheekZ + 0.095], parent: root });+ // Supporting Corbel Brackets under winter beam inside cheeks+ createPart('WinterCorbelL', boxGeo(0.16, 0.10, 0.06), oakDark, { position: [0, 0.58, -cheekZ + 0.10], parent: root });+ createPart('WinterCorbelR', boxGeo(0.16, 0.10, 0.06), oakDark, { position: [0, 0.58, cheekZ - 0.10], parent: root });++ // Till Shelf at Y=1.16 (with square center cutout for hose)+ createPart('TillShelfFront', boxGeo(0.08, 0.04, cheekZ * 2 - cheekW_Z), oakMedium, { position: [0.09, 1.16, 0], parent: root });+ createPart('TillShelfBack', boxGeo(0.08, 0.04, cheekZ * 2 - cheekW_Z), oakMedium, { position: [-0.09, 1.16, 0], parent: root });++ // Head Beam (massive beam at Y=1.58 containing screw nut)+ createPart('HeadBeam', boxGeo(0.25, 0.23, cheekZ * 2 + 0.04), oakDark, { position: [0, 1.58, 0], parent: root });+ createPart('HeadKeyL', boxGeo(0.08, 0.07, 0.05), oakLight, { position: [0, 1.58, -cheekZ - 0.095], parent: root });+ createPart('HeadKeyR', boxGeo(0.08, 0.07, 0.05), oakLight, { position: [0, 1.58, cheekZ + 0.095], parent: root });+ // Corbel Brackets under head beam+ createPart('HeadCorbelL', boxGeo(0.16, 0.10, 0.06), oakDark, { position: [0, 1.43, -cheekZ + 0.10], parent: root });+ createPart('HeadCorbelR', boxGeo(0.16, 0.10, 0.06), oakDark, { position: [0, 1.43, cheekZ - 0.10], parent: root });++ // Cap Beam (top beam at Y=2.00)+ createPart('CapBeam', boxGeo(0.28, 0.12, 1.14), oakDark, { position: [0, 2.00, 0], parent: root });++ // Turned Acorn Finials above cheeks+ createPart('FinialL_Base', cylinderGeo(0.05, 0.065, 0.05, 14), woodTurned, { position: [0, 2.085, -cheekZ], parent: root });+ createPart('FinialL_Ball', sphereGeo(0.045, 14, 10), woodTurned, { position: [0, 2.14, -cheekZ], parent: root });+ createPart('FinialR_Base', cylinderGeo(0.05, 0.065, 0.05, 14), woodTurned, { position: [0, 2.085, cheekZ], parent: root });+ createPart('FinialR_Ball', sphereGeo(0.045, 14, 10), woodTurned, { position: [0, 2.14, cheekZ], parent: root });++ // Heavy Iron Cap Bolts with square nuts+ createPart('CapBoltL1', boltHeadGeo, ironWrought, { position: [0.07, 2.07, -cheekZ], parent: root });+ createPart('CapBoltL2', boltHeadGeo, ironWrought, { position: [-0.07, 2.07, -cheekZ], parent: root });+ createPart('CapBoltR1', boltHeadGeo, ironWrought, { position: [0.07, 2.07, cheekZ], parent: root });+ createPart('CapBoltR2', boltHeadGeo, ironWrought, { position: [-0.07, 2.07, cheekZ], parent: root });++ // ==========================================+ // 2. SCREW MECHANISM, HOSE, LEVER & PLATEN+ // ==========================================+ // Brass Nut Collars in Head Beam+ createPart('BrassNutTop', cylinderGeo(0.082, 0.092, 0.04, 16), brass, { position: [0, 1.70, 0], parent: root });+ createPart('BrassNutBottom', cylinderGeo(0.092, 0.082, 0.04, 16), brass, { position: [0, 1.46, 0], parent: root });++ // Threaded Iron Screw Spindle+ createPart('SpindleShaft', cylinderGeo(0.052, 0.052, 0.56, 16), ironWrought, { position: [0, 1.46, 0], parent: root });+ // Screw thread coils+ const threadRingGeo = torusGeo(0.056, 0.009, 8, 16);+ for (let i = 0; i < 9; i++) {+ createPart(`Thread_${i}`, threadRingGeo, ironWrought, { position: [0, 1.38 + i * 0.033, 0], rotation: [90, 0, 0], parent: root });+ }++ // Spindle Eye Collar (hub for lever bar) at Y=1.31+ createPart('SpindleEyeCollar', cylinderGeo(0.078, 0.078, 0.11, 16), ironWrought, { position: [0, 1.31, 0], parent: root });+ createPart('SpindleEyeRimT', torusGeo(0.078, 0.01, 8, 16), ironWrought, { position: [0, 1.36, 0], rotation: [90, 0, 0], parent: root });+ createPart('SpindleEyeRimB', torusGeo(0.078, 0.01, 8, 16), ironWrought, { position: [0, 1.26, 0], rotation: [90, 0, 0], parent: root });++ // Wooden Hose Sleeve (box guide)+ createPart('HoseBox', boxGeo(0.16, 0.19, 0.16), oakLight, { position: [0, 1.20, 0], parent: root });+ createPart('HosePlateTop', boxGeo(0.17, 0.015, 0.17), ironWrought, { position: [0, 1.295, 0], parent: root });+ createPart('HosePlateBottom', boxGeo(0.17, 0.015, 0.17), ironWrought, { position: [0, 1.105, 0], parent: root });+ // 4 Iron Suspension Cleats on Hose+ createPart('HoseCleatFL', cylinderGeo(0.008, 0.008, 0.03, 8), ironWrought, { position: [0.07, 1.12, -0.07], parent: root });+ createPart('HoseCleatFR', cylinderGeo(0.008, 0.008, 0.03, 8), ironWrought, { position: [0.07, 1.12, 0.07], parent: root });+ createPart('HoseCleatBL', cylinderGeo(0.008, 0.008, 0.03, 8), ironWrought, { position: [-0.07, 1.12, -0.07], parent: root });+ createPart('HoseCleatBR', cylinderGeo(0.008, 0.008, 0.03, 8), ironWrought, { position: [-0.07, 1.12, 0.07], parent: root });++ // Long Iron Lever Bar ("Devil's Tail")+ // Inserted into SpindleEye at [0, 1.31, 0] and swept out towards pressman's hand at +Z+ beamBetween('LeverBarInner', [0.05, 1.31, 0.05], [0.26, 1.31, 0.26], 0.020, ironWrought, { segments: 10, parent: root });+ beamBetween('LeverBarOuter', [0.26, 1.31, 0.26], [0.46, 1.31, 0.46], 0.017, ironWrought, { segments: 10, parent: root });+ // Turned wooden handle grip+ beamBetween('LeverGrip', [0.46, 1.31, 0.46], [0.68, 1.31, 0.68], 0.033, woodTurned, { segments: 14, parent: root });+ createPart('LeverPommel', sphereGeo(0.042, 14, 10), woodTurned, { position: [0.69, 1.31, 0.69], parent: root });++ // Platen Assembly+ const platenY = 0.99;+ createPart('PlatenOak', boxGeo(0.46, 0.07, 0.38), oakDark, { position: [0, platenY + 0.035, 0], parent: root });+ createPart('PlatenPlate', boxGeo(0.44, 0.012, 0.36), ironCast, { position: [0, platenY, 0], parent: root });+ // Central brass boss (cup receiving spindle steel toe)+ createPart('PlatenBoss', cylinderGeo(0.052, 0.062, 0.03, 16), brass, { position: [0, platenY + 0.08, 0], parent: root });++ // 4 Iron Corner Straps and Suspension Rigging on Platen+ createPart('PlatenCornerFL', ironStrapCornerGeo, ironWrought, { position: [0.21, platenY + 0.04, -0.17], parent: root });+ createPart('PlatenCornerFR', ironStrapCornerGeo, ironWrought, { position: [0.21, platenY + 0.04, 0.17], parent: root });+ createPart('PlatenCornerBL', ironStrapCornerGeo, ironWrought, { position: [-0.21, platenY + 0.04, -0.17], parent: root });+ createPart('PlatenCornerBR', ironStrapCornerGeo, ironWrought, { position: [-0.21, platenY + 0.04, 0.17], parent: root });++ beamBetween('PlatenCord_FL', [0.18, platenY + 0.07, -0.15], [0.07, 1.11, -0.07], 0.005, leather, { parent: root });+ beamBetween('PlatenCord_FR', [0.18, platenY + 0.07, 0.15], [0.07, 1.11, 0.07], 0.005, leather, { parent: root });+ beamBetween('PlatenCord_BL', [-0.18, platenY + 0.07, -0.15], [-0.07, 1.11, -0.07], 0.005, leather, { parent: root });+ beamBetween('PlatenCord_BR', [-0.18, platenY + 0.07, 0.15], [-0.07, 1.11, 0.07], 0.005, leather, { parent: root });++ // ==========================================+ // 3. RIBS (CRADLE RAILS) & FORESTAY+ // ==========================================+ const railZ = 0.22;+ const railH = 0.08;+ const railW = 0.07;+ const railY = 0.82;+ const railL = 1.62;++ // Longitudinal Oak Rails+ createPart('RailL', boxGeo(railL, railH, railW), oakMedium, { position: [0.37, railY, -railZ], parent: root });+ createPart('RailR', boxGeo(railL, railH, railW), oakMedium, { position: [0.37, railY, railZ], parent: root });+ // Polished Iron Track Plates on Rails+ createPart('IronTrackL', boxGeo(railL, 0.008, 0.04), ironWrought, { position: [0.37, railY + railH / 2 + 0.004, -railZ], parent: root });+ createPart('IronTrackR', boxGeo(railL, 0.008, 0.04), ironWrought, { position: [0.37, railY + railH / 2 + 0.004, railZ], parent: root });++ // Cross Transoms (ribs tying rails together)+ const transomW = railZ * 2 - railW;+ createPart('TransomRear', boxGeo(0.06, 0.06, transomW), oakMedium, { position: [-0.36, railY - 0.01, 0], parent: root });+ createPart('TransomMid', boxGeo(0.06, 0.06, transomW), oakMedium, { position: [0.37, railY - 0.01, 0], parent: root });+ createPart('TransomFront', boxGeo(0.06, 0.06, transomW), oakMedium, { position: [1.14, railY - 0.01, 0], parent: root });++ // Forestay (Front Trestle Legs at X=1.14)+ const foreLegH = railY - railH / 2;+ createPart('ForeLegL', boxGeo(0.075, foreLegH, 0.075), oakDark, { position: [1.14, foreLegH / 2, -railZ], parent: root });+ createPart('ForeLegR', boxGeo(0.075, foreLegH, 0.075), oakDark, { position: [1.14, foreLegH / 2, railZ], parent: root });+ // Forestay lower stretcher rail+ createPart('ForeLegCross', boxGeo(0.06, 0.06, railZ * 2 - 0.075), oakDark, { position: [1.14, 0.18, 0], parent: root });+ // Forestay diagonal angle struts+ beamBetween('ForeBraceL', [1.14, 0.22, -railZ], [0.84, railY - 0.04, -railZ], 0.026, oakDark, { segments: 8, parent: root });+ beamBetween('ForeBraceR', [1.14, 0.22, railZ], [0.84, railY - 0.04, railZ], 0.026, oakDark, { segments: 8, parent: root });++ // Rear Carriage Gallows (Upright slanting stay frame at rear of rails for tympan)+ beamBetween('GallowsLegL', [-0.36, railY + 0.04, -railZ + 0.02], [-0.44, railY + 0.40, -railZ + 0.02], 0.024, oakMedium, { segments: 8, parent: root });+ beamBetween('GallowsLegR', [-0.36, railY + 0.04, railZ - 0.02], [-0.44, railY + 0.40, railZ - 0.02], 0.024, oakMedium, { segments: 8, parent: root });+ createPart('GallowsCross', boxGeo(0.03, 0.03, railZ * 2 - 0.04), oakMedium, { position: [-0.44, railY + 0.40, 0], parent: root });++ // ==========================================+ // 4. COFFIN CARRIAGE, BED & CHASE+ // ==========================================+ // Coffin rolled forward along X to X=0.42+ const coffinX = 0.42;+ const coffinY = railY + railH / 2 + 0.04; // Y=0.90+ const coffinL = 0.72;+ const coffinW = 0.48;++ // Outer Coffin Box+ createPart('CoffinSideL', boxGeo(coffinL, 0.08, 0.05), oakMedium, { position: [coffinX, coffinY, -coffinW / 2 + 0.025], parent: root });+ createPart('CoffinSideR', boxGeo(coffinL, 0.08, 0.05), oakMedium, { position: [coffinX, coffinY, coffinW / 2 - 0.025], parent: root });+ createPart('CoffinEndFront', boxGeo(0.05, 0.08, coffinW), oakMedium, { position: [coffinX + coffinL / 2 - 0.025, coffinY, 0], parent: root });+ createPart('CoffinEndBack', boxGeo(0.05, 0.08, coffinW), oakMedium, { position: [coffinX - coffinL / 2 + 0.025, coffinY, 0], parent: root });+ createPart('CoffinFloor', boxGeo(coffinL - 0.08, 0.02, coffinW - 0.08), oakLight, { position: [coffinX, coffinY - 0.03, 0], parent: root });++ // Wrought Iron Corner Straps on Coffin+ createPart('CoffinBracketFL', ironStrapCornerGeo, ironWrought, { position: [coffinX + coffinL / 2 - 0.025, coffinY, -coffinW / 2 + 0.025], parent: root });+ createPart('CoffinBracketFR', ironStrapCornerGeo, ironWrought, { position: [coffinX + coffinL / 2 - 0.025, coffinY, coffinW / 2 - 0.025], parent: root });+ createPart('CoffinBracketBL', ironStrapCornerGeo, ironWrought, { position: [coffinX - coffinL / 2 + 0.025, coffinY, -coffinW / 2 + 0.025], parent: root });+ createPart('CoffinBracketBR', ironStrapCornerGeo, ironWrought, { position: [coffinX - coffinL / 2 + 0.025, coffinY, coffinW / 2 - 0.025], parent: root });++ // Polished Stone Bed (Marble / granite bed)+ createPart('MarbleBed', boxGeo(0.60, 0.03, 0.36), stoneMarble, { position: [coffinX, coffinY + 0.01, 0], parent: root });++ // Wrought Iron Chase (Locking frame)+ createPart('ChaseFrame', boxGeo(0.50, 0.018, 0.30), ironCast, { position: [coffinX, coffinY + 0.028, 0], parent: root });+ // Wooden Furniture (Spacers)+ createPart('FurnitureT', boxGeo(0.46, 0.016, 0.028), oakLight, { position: [coffinX, coffinY + 0.03, 0.116], parent: root });+ createPart('FurnitureB', boxGeo(0.46, 0.016, 0.028), oakLight, { position: [coffinX, coffinY + 0.03, -0.116], parent: root });+ createPart('FurnitureL', boxGeo(0.028, 0.016, 0.20), oakLight, { position: [coffinX - 0.216, coffinY + 0.03, 0], parent: root });+ createPart('FurnitureR', boxGeo(0.028, 0.016, 0.20), oakLight, { position: [coffinX + 0.216, coffinY + 0.03, 0], parent: root });+ // Wooden Quoins (Wedges locking the type)+ createPart('Quoin1', boxGeo(0.03, 0.018, 0.015), oakDark, { position: [coffinX + 0.19, coffinY + 0.032, 0.116], parent: root });+ createPart('Quoin2', boxGeo(0.03, 0.018, 0.015), oakDark, { position: [coffinX - 0.19, coffinY + 0.032, 0.116], parent: root });++ // Movable Type Columns (Inked lead type pages)+ createPart('TypeCol1', boxGeo(0.36, 0.018, 0.08), typeLead, { position: [coffinX, coffinY + 0.032, -0.05], parent: root });+ createPart('TypeCol2', boxGeo(0.36, 0.018, 0.08), typeLead, { position: [coffinX, coffinY + 0.032, 0.05], parent: root });+ // Inked text lines on type form+ const ruleGeo = boxGeo(0.34, 0.003, 0.011);+ for (let c = 0; c < 4; c++) {+ createPart(`Rule1_${c}`, ruleGeo, printerInk, { position: [coffinX, coffinY + 0.042, -0.08 + c * 0.02], parent: root });+ createPart(`Rule2_${c}`, ruleGeo, printerInk, { position: [coffinX, coffinY + 0.042, 0.02 + c * 0.02], parent: root });+ }++ // ==========================================+ // 5. HINGED TYMPAN & FRISKET (FOLDED OVER BED)+ // ==========================================+ const tympanY = coffinY + 0.05;+ // Outer Wooden Tympan Frame+ createPart('TympanSideL', boxGeo(0.56, 0.015, 0.03), oakLight, { position: [coffinX, tympanY, -0.17], parent: root });+ createPart('TympanSideR', boxGeo(0.56, 0.015, 0.03), oakLight, { position: [coffinX, tympanY, 0.17], parent: root });+ createPart('TympanEndF', boxGeo(0.03, 0.015, 0.34), oakLight, { position: [coffinX + 0.265, tympanY, 0], parent: root });+ createPart('TympanEndB', boxGeo(0.03, 0.015, 0.34), oakLight, { position: [coffinX - 0.265, tympanY, 0], parent: root });+ // Tympan parchment skin+ createPart('TympanVellum', boxGeo(0.50, 0.004, 0.32), parchment, { position: [coffinX, tympanY + 0.005, 0], parent: root });+ // Leather pull-ears on sides of tympan+ createPart('TympanEarL', boxGeo(0.04, 0.003, 0.03), leather, { position: [coffinX, tympanY + 0.008, -0.19], parent: root });+ createPart('TympanEarR', boxGeo(0.04, 0.003, 0.03), leather, { position: [coffinX, tympanY + 0.008, 0.19], parent: root });++ // Iron Hinges between Tympan and Coffin+ createPart('TympanHingeL', cylinderGeo(0.008, 0.008, 0.05, 8), ironWrought, { position: [coffinX - 0.28, tympanY, -0.12], rotation: [0, 0, 90], parent: root });+ createPart('TympanHingeR', cylinderGeo(0.008, 0.008, 0.05, 8), ironWrought, { position: [coffinX - 0.28, tympanY, 0.12], rotation: [0, 0, 90], parent: root });++ // Frisket Frame (Iron perimeter frame folded flat over tympan)+ const frisketY = tympanY + 0.012;+ createPart('FrisketIronFrame', boxGeo(0.52, 0.008, 0.32), ironWrought, { position: [coffinX, frisketY, 0], parent: root });+ // Paper aperture mask on frisket+ createPart('FrisketPaperMask', boxGeo(0.48, 0.004, 0.28), parchment, { position: [coffinX, frisketY + 0.004, 0], parent: root });+ // Cutout page apertures exposing the type columns below+ createPart('FrisketWindow1', boxGeo(0.32, 0.006, 0.07), printerInk, { position: [coffinX, frisketY + 0.005, -0.05], parent: root });+ createPart('FrisketWindow2', boxGeo(0.32, 0.006, 0.07), printerInk, { position: [coffinX, frisketY + 0.005, 0.05], parent: root });++ // ==========================================+ // 6. ROUNCE MECHANISM (WINCH, LEATHER STRAPS, CRANK)+ // ==========================================+ const spitY = 0.74;+ // Wooden Rounce Spit (Winch roller under rails)+ createPart('RounceSpitBarrel', cylinderZGeo(0.040, 0.040, railZ * 2 + 0.08, 16), woodTurned, { position: [coffinX, spitY, 0], parent: root });+ // Iron Journals / Axle Pins+ createPart('SpitJournalR', cylinderZGeo(0.014, 0.014, 0.12, 12), ironWrought, { position: [coffinX, spitY, railZ + 0.06], parent: root });++ // Leather Girth Straps+ beamBetween('LeatherGirthFwd', [coffinX, spitY, 0], [coffinX + coffinL / 2 - 0.05, coffinY - 0.02, 0], 0.045, leather, { segments: 8, parent: root });+ beamBetween('LeatherGirthAft', [coffinX, spitY, 0], [coffinX - coffinL / 2 + 0.05, coffinY - 0.02, 0], 0.045, leather, { segments: 8, parent: root });++ // Rounce Crank Handle on Right side (+Z)+ const crankZ = railZ + 0.11;+ createPart('RounceCrankHub', cylinderZGeo(0.026, 0.026, 0.03, 14), ironWrought, { position: [coffinX, spitY, crankZ], parent: root });+ // Angled forged crank arm+ beamBetween('RounceCrankArm', [coffinX, spitY, crankZ], [coffinX + 0.04, spitY + 0.14, crankZ], 0.013, ironWrought, { segments: 8, parent: root });+ // Iron crank spindle pin+ createPart('RounceCrankPin', cylinderZGeo(0.009, 0.009, 0.12, 10), ironWrought, { position: [coffinX + 0.04, spitY + 0.14, crankZ + 0.06], parent: root });+ // Ergonomically turned wooden handle grip+ createPart('RounceGrip', cylinderZGeo(0.023, 0.018, 0.10, 16), woodTurned, { position: [coffinX + 0.04, spitY + 0.14, crankZ + 0.06], parent: root });++ // ==========================================+ // 7. SIDE TABLE (BANK / INKING BENCH)+ // ==========================================+ const tableX = 0.44;+ const tableZ = -0.74;+ const tableH = 0.78;+ const tableL = 0.56;+ const tableW = 0.44;++ // Sturdy Tabletop (thick oak planks)+ createPart('TableTop', boxGeo(tableL, 0.045, tableW), oakMedium, { position: [tableX, tableH, tableZ], parent: root });+ // Planks grooved seam+ createPart('TableSeam', boxGeo(tableL, 0.004, 0.005), oakDark, { position: [tableX, tableH + 0.022, tableZ], parent: root });++ // 4 Chamfered Table Legs resting on Y=0+ const legH = tableH - 0.045;+ const tLegGeo = boxGeo(0.05, legH, 0.05);+ const legOffX = tableL / 2 - 0.045;+ const legOffZ = tableW / 2 - 0.045;+ createPart('TableLegFL', tLegGeo, oakDark, { position: [tableX + legOffX, legH / 2, tableZ - legOffZ], parent: root });+ createPart('TableLegFR', tLegGeo, oakDark, { position: [tableX + legOffX, legH / 2, tableZ + legOffZ], parent: root });+ createPart('TableLegBL', tLegGeo, oakDark, { position: [tableX - legOffX, legH / 2, tableZ - legOffZ], parent: root });+ createPart('TableLegBR', tLegGeo, oakDark, { position: [tableX - legOffX, legH / 2, tableZ + legOffZ], parent: root });++ // Perimeter Lower Stretchers+ const strXGeo = boxGeo(tableL - 0.09, 0.04, 0.035);+ const strZGeo = boxGeo(0.035, 0.04, tableW - 0.09);+ createPart('TableStrFront', strZGeo, oakDark, { position: [tableX + legOffX, 0.14, tableZ], parent: root });+ createPart('TableStrBack', strZGeo, oakDark, { position: [tableX - legOffX, 0.14, tableZ], parent: root });+ createPart('TableStrOuter', strXGeo, oakDark, { position: [tableX, 0.14, tableZ - legOffZ], parent: root });+ createPart('TableStrInner', strXGeo, oakDark, { position: [tableX, 0.14, tableZ + legOffZ], parent: root });++ // Joinery ties locking Table to Press Frame (Guarantees full part connectivity)+ beamBetween('TableTieFloor', [tableX, 0.14, tableZ + legOffZ], [tableX, 0.12, -railZ], 0.024, oakDark, { segments: 8, parent: root });+ beamBetween('TableTieRail', [tableX, tableH - 0.02, tableZ + legOffZ], [tableX, railY, -railZ], 0.028, oakDark, { segments: 8, parent: root });++ // ==========================================+ // 8. INKING EQUIPMENT & PAPER SHEETS+ // ==========================================+ // Inking Stone (Porphyry / Marble slab bordered in oak)+ const stoneX = tableX - 0.06;+ const stoneZ = tableZ;+ createPart('InkStoneBase', boxGeo(0.28, 0.025, 0.26), oakDark, { position: [stoneX, tableH + 0.03, stoneZ], parent: root });+ createPart('InkStoneMarble', boxGeo(0.25, 0.02, 0.23), stoneMarble, { position: [stoneX, tableH + 0.045, stoneZ], parent: root });+ createPart('InkPool', boxGeo(0.18, 0.005, 0.16), printerInk, { position: [stoneX, tableH + 0.056, stoneZ], parent: root });++ // Stone Ink Muller (Conical stone grinder used to work the ink)+ createPart('InkMullerBase', cylinderGeo(0.035, 0.045, 0.04, 16), stoneMarble, { position: [stoneX + 0.08, tableH + 0.065, stoneZ + 0.07], parent: root });+ createPart('InkMullerGrip', cylinderGeo(0.016, 0.026, 0.07, 14), stoneMarble, { position: [stoneX + 0.08, tableH + 0.12, stoneZ + 0.07], parent: root });+ createPart('InkMullerTop', sphereGeo(0.022, 12, 10), stoneMarble, { position: [stoneX + 0.08, tableH + 0.16, stoneZ + 0.07], parent: root });++ // Iron Ink Slice (Palette spatula for spreading ink)+ createPart('InkSliceBlade', boxGeo(0.11, 0.003, 0.028), ironWrought, { position: [stoneX + 0.14, tableH + 0.026, stoneZ - 0.10], rotation: [0, 25, 0], parent: root });+ createPart('InkSliceHandle', cylinderXGeo(0.008, 0.008, 0.08, 10), woodTurned, { position: [stoneX + 0.22, tableH + 0.032, stoneZ - 0.13], rotation: [0, 25, 0], parent: root });++ // Clean Paper Stack (Quires of handmade paper with wooden weight on top)+ const paperX = tableX + 0.14;+ const paperZ = tableZ + 0.08;+ createPart('PaperStack', boxGeo(0.18, 0.035, 0.14), parchment, { position: [paperX, tableH + 0.04, paperZ], parent: root });+ createPart('PaperWeight', boxGeo(0.14, 0.012, 0.08), oakDark, { position: [paperX, tableH + 0.064, paperZ], parent: root });++ // ==========================================+ // 9. INK BALLS (PELOTTES / DABBERS)+ // ==========================================+ // Ink Ball 1: Resting upright on the ink stone, loaded with ink+ const b1X = stoneX - 0.03;+ const b1Z = stoneZ - 0.02;+ const b1Y = tableH + 0.058;+ createPart('InkBall1_Skin', sphereGeo(0.062, 18, 14), leather, { position: [b1X, b1Y + 0.035, b1Z], scale: [1, 0.65, 1], parent: root });+ createPart('InkBall1_InkedFace', cylinderGeo(0.055, 0.058, 0.012, 18), printerInk, { position: [b1X, b1Y + 0.006, b1Z], parent: root });+ createPart('InkBall1_Stock', cylinderGeo(0.035, 0.055, 0.04, 16), woodTurned, { position: [b1X, b1Y + 0.075, b1Z], parent: root });+ // Ring of brass tack rivets+ for (let t = 0; t < 10; t++) {+ const angle = (t / 10) * Math.PI * 2;+ createPart(`Ball1Tack_${t}`, tackGeo, brass, { position: [b1X + Math.cos(angle) * 0.052, b1Y + 0.06, b1Z + Math.sin(angle) * 0.052], parent: root });+ }+ // Ergonomically turned handle and pommel+ beamBetween('InkBall1_Grip', [b1X, b1Y + 0.095, b1Z], [b1X, b1Y + 0.22, b1Z], 0.016, woodTurned, { segments: 14, parent: root });+ createPart('InkBall1_Pommel', sphereGeo(0.024, 12, 10), woodTurned, { position: [b1X, b1Y + 0.23, b1Z], parent: root });++ // Ink Ball 2: Resting tilted beside the stone on the table+ const b2X = tableX - 0.05;+ const b2Z = tableZ - 0.12;+ const b2Y = tableH + 0.025;+ createPart('InkBall2_Skin', sphereGeo(0.062, 18, 14), leather, { position: [b2X, b2Y + 0.035, b2Z], scale: [1, 0.65, 1], parent: root });+ createPart('InkBall2_InkedFace', cylinderGeo(0.055, 0.058, 0.012, 18), printerInk, { position: [b2X, b2Y + 0.006, b2Z], parent: root });+ createPart('InkBall2_Stock', cylinderGeo(0.035, 0.055, 0.04, 16), woodTurned, { position: [b2X, b2Y + 0.075, b2Z], parent: root });+ // Ring of brass tack rivets+ for (let t = 0; t < 10; t++) {+ const angle = (t / 10) * Math.PI * 2;+ createPart(`Ball2Tack_${t}`, tackGeo, brass, { position: [b2X + Math.cos(angle) * 0.052, b2Y + 0.06, b2Z + Math.sin(angle) * 0.052], parent: root });+ }+ // Tilted handle+ beamBetween('InkBall2_Grip', [b2X, b2Y + 0.095, b2Z], [b2X - 0.06, b2Y + 0.21, b2Z - 0.045], 0.016, woodTurned, { segments: 14, parent: root });+ createPart('InkBall2_Pommel', sphereGeo(0.024, 12, 10), woodTurned, { position: [b2X - 0.065, b2Y + 0.22, b2Z - 0.05], parent: root });++ return root;+}diff --git a/examples/pumpjack.kiln.js b/examples/pumpjack.kiln.jsnew file mode 100644index 00000000..66982c62--- /dev/null+++ b/examples/pumpjack.kiln.js@@ -0,0 +1,1011 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'Pumpjack', category: 'prop' };++async function build() {+ const root = createRoot('Pumpjack');++ // ==========================================+ // MATERIALS (Authentic industrial oilfield palette)+ // ==========================================+ // Industrial pumpjack painted steel (classic oilfield dark spruce green)+ const matBeamSteel = gameMaterial(0x244636, { metalness: 0.55, roughness: 0.45 });+ // Heavy structural dark steel (skid runners, brackets, gearbox casing)+ const matDarkSteel = gameMaterial(0x222527, { metalness: 0.7, roughness: 0.4 });+ // High-visibility safety orange (counterweights, moving hazard warnings)+ const matHazardOrange = gameMaterial(0xd35b1d, { metalness: 0.35, roughness: 0.45 });+ // Safety yellow (ladder, handrails, belt guard, handwheels)+ const matSafetyYellow = gameMaterial(0xdaa224, { metalness: 0.25, roughness: 0.4 });+ // Polished chrome / stainless steel (polished rod, wrist/crank pins, valve stems)+ const matPolishedSteel = gameMaterial(0xe2e4e8, { metalness: 0.95, roughness: 0.12 });+ // Multi-strand wire rope / steel cables+ const matWireCable = gameMaterial(0x404346, { metalness: 0.7, roughness: 0.45 });+ // Wellhead red oxide primer (casing head, valves, flow tee)+ const matWellhead = gameMaterial(0x782c24, { metalness: 0.4, roughness: 0.5 });+ // Reinforced concrete footings+ const matConcrete = gameMaterial(0x86847e, { metalness: 0.08, roughness: 0.92 });+ // Crushed gravel foundation pad+ const matGravel = gameMaterial(0x6e6a62, { metalness: 0.05, roughness: 0.98 });+ // Cast iron (rough gearbox hubs, motor mounts)+ const matCastIron = gameMaterial(0x2f3235, { metalness: 0.5, roughness: 0.65 });+ // Brass / bronze (stuffing box gland, pressure gauge)+ const matBrass = gameMaterial(0xb58f44, { metalness: 0.8, roughness: 0.3 });++ // Shared bolt and rivet geometries+ const boltHexY = cylinderYGeo(0.024, 0.024, 0.035, 6);+ const boltHexX = cylinderXGeo(0.022, 0.022, 0.035, 6);+ const boltHexZ = cylinderZGeo(0.022, 0.022, 0.035, 6);++ // ==========================================+ // 1. GRAVEL PAD & CONCRETE FOUNDATION PIERS+ // ==========================================+ // Main gravel bed (ground rests at Y=0)+ createPart('GravelPad', boxGeo(8.6, 0.12, 3.8), matGravel, {+ position: [-0.3, 0.06, 0],+ parent: root,+ });++ // Perimeter retaining timbers+ createPart('BorderTimber_Front', boxGeo(0.16, 0.14, 3.8), matDarkSteel, {+ position: [4.0, 0.07, 0],+ parent: root,+ });+ createPart('BorderTimber_Back', boxGeo(0.16, 0.14, 3.8), matDarkSteel, {+ position: [-4.6, 0.07, 0],+ parent: root,+ });+ createPart('BorderTimber_Left', boxGeo(8.6, 0.14, 0.16), matDarkSteel, {+ position: [-0.3, 0.07, -1.9],+ parent: root,+ });+ createPart('BorderTimber_Right', boxGeo(8.6, 0.14, 0.16), matDarkSteel, {+ position: [-0.3, 0.07, 1.9],+ parent: root,+ });++ // Concrete foundation blocks resting on gravel+ createPart('ConcreteFooting_Front', boxGeo(1.6, 0.14, 2.2), matConcrete, {+ position: [0.75, 0.19, 0],+ parent: root,+ });+ createPart('ConcreteFooting_Mid', boxGeo(1.4, 0.14, 2.2), matConcrete, {+ position: [-0.65, 0.19, 0],+ parent: root,+ });+ createPart('ConcreteFooting_Rear', boxGeo(2.6, 0.14, 2.2), matConcrete, {+ position: [-2.55, 0.19, 0],+ parent: root,+ });+ createPart('ConcreteFooting_Wellhead', boxGeo(1.1, 0.14, 1.1), matConcrete, {+ position: [3.3, 0.19, 0],+ parent: root,+ });++ // ==========================================+ // 2. HEAVY STEEL SKID FRAME (OILFIELD RUNNERS)+ // ==========================================+ const skidY = 0.36;+ const skidHeight = 0.22;+ const skidWidth = 0.2;+ const skidLength = 7.0;++ for (const zSide of [-0.75, 0.75]) {+ const sideName = zSide < 0 ? 'L' : 'R';+ createPart(`SkidRunner_${sideName}`, boxGeo(skidLength, skidHeight, skidWidth), matDarkSteel, {+ position: [-0.5, skidY, zSide],+ parent: root,+ });+ createPart(`SkidRunner_TFlange_${sideName}`, boxGeo(skidLength, 0.025, skidWidth + 0.08), matDarkSteel, {+ position: [-0.5, skidY + skidHeight / 2 + 0.012, zSide],+ parent: root,+ });+ createPart(`SkidRunner_BFlange_${sideName}`, boxGeo(skidLength, 0.025, skidWidth + 0.08), matDarkSteel, {+ position: [-0.5, skidY - skidHeight / 2 - 0.012, zSide],+ parent: root,+ });++ // Angled sled noses (turned up for truck winching)+ createPart(`SkidNose_F_${sideName}`, boxGeo(0.5, skidHeight, skidWidth), matDarkSteel, {+ position: [3.18, skidY + 0.09, zSide],+ rotation: [0, 0, 24],+ parent: root,+ });+ createPart(`SkidNose_R_${sideName}`, boxGeo(0.5, skidHeight, skidWidth), matDarkSteel, {+ position: [-4.18, skidY + 0.09, zSide],+ rotation: [0, 0, -24],+ parent: root,+ });++ // Towing eyes / lifting shackle lugs+ createPart(`TowEye_F_${sideName}`, torusGeo(0.08, 0.022, 8, 14), matDarkSteel, {+ position: [3.42, skidY + 0.18, zSide],+ rotation: [0, 90, 0],+ parent: root,+ });+ createPart(`TowEye_R_${sideName}`, torusGeo(0.08, 0.022, 8, 14), matDarkSteel, {+ position: [-4.42, skidY + 0.18, zSide],+ rotation: [0, 90, 0],+ parent: root,+ });+ }++ // Cross-members connecting runners+ const crossXPositions = [-3.8, -3.0, -2.0, -0.65, 0.75, 2.0, 2.85];+ for (let i = 0; i < crossXPositions.length; i++) {+ const cx = crossXPositions[i];+ createPart(`SkidCross_${i}`, boxGeo(0.2, 0.2, 1.3), matDarkSteel, {+ position: [cx, skidY, 0],+ parent: root,+ });+ createPart(`SkidGusset_${i}_L`, boxGeo(0.18, 0.02, 0.18), matDarkSteel, {+ position: [cx, skidY + 0.11, -0.65],+ parent: root,+ });+ createPart(`SkidGusset_${i}_R`, boxGeo(0.18, 0.02, 0.18), matDarkSteel, {+ position: [cx, skidY + 0.11, 0.65],+ parent: root,+ });+ }++ // Anchor hold-down clamps bolting skid to concrete piers+ const clampXPositions = [-3.5, -2.4, -0.65, 0.75, 2.4];+ for (let i = 0; i < clampXPositions.length; i++) {+ const clx = clampXPositions[i];+ for (const zSide of [-0.92, 0.92]) {+ createPart(`SkidClamp_${i}_${zSide > 0 ? 'R' : 'L'}`, boxGeo(0.12, 0.15, 0.14), matDarkSteel, {+ position: [clx, 0.28, zSide],+ parent: root,+ });+ createPart(`SkidBolt_${i}_${zSide > 0 ? 'R' : 'L'}`, boltHexY, matDarkSteel, {+ position: [clx, 0.36, zSide],+ parent: root,+ });+ }+ }++ // ==========================================+ // 3. SAMSON POST (4-LEG PYRAMID TRUSS TOWER)+ // ==========================================+ const samsonTopY = 3.3;+ const postShoeY = skidY + 0.12;++ const legCoords = [+ { name: 'FL', base: [0.75, postShoeY, -0.65], top: [0.08, samsonTopY, -0.24] },+ { name: 'FR', base: [0.75, postShoeY, 0.65], top: [0.08, samsonTopY, 0.24] },+ { name: 'BL', base: [-0.65, postShoeY, -0.65], top: [-0.04, samsonTopY, -0.24] },+ { name: 'BR', base: [-0.65, postShoeY, 0.65], top: [-0.04, samsonTopY, 0.24] },+ ];++ for (const leg of legCoords) {+ createPart(`LegShoe_${leg.name}`, boxGeo(0.28, 0.04, 0.28), matDarkSteel, {+ position: [leg.base[0], leg.base[1] + 0.01, leg.base[2]],+ parent: root,+ });+ for (const dx of [-0.09, 0.09]) {+ for (const dz of [-0.09, 0.09]) {+ createPart(`LegShoeBolt_${leg.name}_${dx}_${dz}`, boltHexY, matDarkSteel, {+ position: [leg.base[0] + dx, leg.base[1] + 0.035, leg.base[2] + dz],+ parent: root,+ });+ }+ }+ beamBetween(`LegColumn_${leg.name}`, leg.base, leg.top, 0.065, matBeamSteel, { parent: root });+ }++ // Horizontal perimeter ring struts+ const strutTiers = [+ { y: 1.25, name: 'Tier1' },+ { y: 2.25, name: 'Tier2' },+ ];++ for (const tier of strutTiers) {+ const t = (tier.y - postShoeY) / (samsonTopY - postShoeY);+ const flX = 0.75 + t * (0.08 - 0.75);+ const flZ = -0.65 + t * (-0.24 - -0.65);+ const frX = 0.75 + t * (0.08 - 0.75);+ const frZ = 0.65 + t * (0.24 - 0.65);+ const blX = -0.65 + t * (-0.04 - -0.65);+ const blZ = -0.65 + t * (-0.24 - -0.65);+ const brX = -0.65 + t * (-0.04 - -0.65);+ const brZ = 0.65 + t * (0.24 - 0.65);++ beamBetween(`Strut_F_${tier.name}`, [flX, tier.y, flZ], [frX, tier.y, frZ], 0.04, matBeamSteel, { parent: root });+ beamBetween(`Strut_B_${tier.name}`, [blX, tier.y, blZ], [brX, tier.y, brZ], 0.04, matBeamSteel, { parent: root });+ beamBetween(`Strut_L_${tier.name}`, [blX, tier.y, blZ], [flX, tier.y, flZ], 0.04, matBeamSteel, { parent: root });+ beamBetween(`Strut_R_${tier.name}`, [brX, tier.y, brZ], [frX, tier.y, frZ], 0.04, matBeamSteel, { parent: root });+ }++ // Cross diagonal lattice bracing on all 4 faces+ beamBetween('Diag_L1_A', [-0.65, postShoeY, -0.65], [0.38, 1.25, -0.42], 0.032, matBeamSteel, { parent: root });+ beamBetween('Diag_L1_B', [0.75, postShoeY, -0.65], [-0.32, 1.25, -0.42], 0.032, matBeamSteel, { parent: root });+ beamBetween('Diag_L2_A', [-0.32, 1.25, -0.42], [0.18, 2.25, -0.3], 0.032, matBeamSteel, { parent: root });+ beamBetween('Diag_L2_B', [0.38, 1.25, -0.42], [-0.15, 2.25, -0.3], 0.032, matBeamSteel, { parent: root });+ beamBetween('Diag_L3', [-0.15, 2.25, -0.3], [0.08, samsonTopY, -0.24], 0.032, matBeamSteel, { parent: root });++ beamBetween('Diag_R1_A', [-0.65, postShoeY, 0.65], [0.38, 1.25, 0.42], 0.032, matBeamSteel, { parent: root });+ beamBetween('Diag_R1_B', [0.75, postShoeY, 0.65], [-0.32, 1.25, 0.42], 0.032, matBeamSteel, { parent: root });+ beamBetween('Diag_R2_A', [-0.32, 1.25, 0.42], [0.18, 2.25, 0.3], 0.032, matBeamSteel, { parent: root });+ beamBetween('Diag_R2_B', [0.38, 1.25, 0.42], [-0.15, 2.25, 0.3], 0.032, matBeamSteel, { parent: root });+ beamBetween('Diag_R3', [-0.15, 2.25, 0.3], [0.08, samsonTopY, 0.24], 0.032, matBeamSteel, { parent: root });++ beamBetween('Diag_F1_A', [0.75, postShoeY, -0.65], [0.38, 1.25, 0.42], 0.032, matBeamSteel, { parent: root });+ beamBetween('Diag_F1_B', [0.75, postShoeY, 0.65], [0.38, 1.25, -0.42], 0.032, matBeamSteel, { parent: root });+ beamBetween('Diag_F2_A', [0.38, 1.25, -0.42], [0.18, 2.25, 0.3], 0.032, matBeamSteel, { parent: root });+ beamBetween('Diag_F2_B', [0.38, 1.25, 0.42], [0.18, 2.25, -0.3], 0.032, matBeamSteel, { parent: root });++ beamBetween('Diag_B1_A', [-0.65, postShoeY, -0.65], [-0.32, 1.25, 0.42], 0.032, matBeamSteel, { parent: root });+ beamBetween('Diag_B1_B', [-0.65, postShoeY, 0.65], [-0.32, 1.25, -0.42], 0.032, matBeamSteel, { parent: root });+ beamBetween('Diag_B2_A', [-0.32, 1.25, -0.42], [-0.15, 2.25, 0.3], 0.032, matBeamSteel, { parent: root });+ beamBetween('Diag_B2_B', [-0.32, 1.25, 0.42], [-0.15, 2.25, -0.3], 0.032, matBeamSteel, { parent: root });++ // ==========================================+ // 4. SAMSON HEAD, CENTER SADDLE BEARING & SIDE PLATFORM+ // ==========================================+ const platX = 0.02;+ const platY = samsonTopY + 0.02;++ // Center Saddle Bearing Structure+ // Left pillow block+ createPart('SaddlePillow_L', boxGeo(0.36, 0.24, 0.14), matDarkSteel, {+ position: [platX, platY + 0.12, -0.22],+ parent: root,+ });+ createPart('SaddleCap_L', cylinderXGeo(0.1, 0.1, 0.14, 14), matDarkSteel, {+ position: [platX, platY + 0.24, -0.22],+ parent: root,+ });+ // Right pillow block+ createPart('SaddlePillow_R', boxGeo(0.36, 0.24, 0.14), matDarkSteel, {+ position: [platX, platY + 0.12, 0.22],+ parent: root,+ });+ createPart('SaddleCap_R', cylinderXGeo(0.1, 0.1, 0.14, 14), matDarkSteel, {+ position: [platX, platY + 0.24, 0.22],+ parent: root,+ });++ // Saddle center trunnion shaft along Z+ const pivotCenterY = platY + 0.24;+ createPart('SaddleCenterShaft', cylinderZGeo(0.08, 0.08, 0.76, 16), matPolishedSteel, {+ position: [platX, pivotCenterY, 0],+ parent: root,+ });++ // SIDE MAINTENANCE PLATFORM (Mounted strictly on the +Z / ladder side!)+ // Leaves the center open so the walking beam never intersects the handrail!+ const platPosZ = 0.56;+ const platWidthZ = 0.54;+ const platLengthX = 0.92;++ createPart('SamsonPlatform', boxGeo(platLengthX, 0.05, platWidthZ), matDarkSteel, {+ position: [platX, platY, platPosZ],+ parent: root,+ });+ // Platform support brackets extending from Samson post legs+ beamBetween('PlatSupport_F', [0.08, samsonTopY, 0.24], [platX + 0.42, platY - 0.03, platPosZ + 0.2], 0.035, matDarkSteel, { parent: root });+ beamBetween('PlatSupport_B', [-0.04, samsonTopY, 0.24], [platX - 0.42, platY - 0.03, platPosZ + 0.2], 0.035, matDarkSteel, { parent: root });++ // Toe boards (kickplates) on platform perimeter+ createPart('ToeBoard_Outer', boxGeo(platLengthX, 0.1, 0.025), matSafetyYellow, {+ position: [platX, platY + 0.05, platPosZ + platWidthZ / 2 - 0.012],+ parent: root,+ });+ createPart('ToeBoard_Front', boxGeo(0.025, 0.1, platWidthZ), matSafetyYellow, {+ position: [platX + platLengthX / 2 - 0.012, platY + 0.05, platPosZ],+ parent: root,+ });+ createPart('ToeBoard_Back', boxGeo(0.025, 0.1, platWidthZ), matSafetyYellow, {+ position: [platX - platLengthX / 2 + 0.012, platY + 0.05, platPosZ],+ parent: root,+ });++ // Service Ladder climbing up to the platform on the +Z side+ const ladderBottom = [-0.65, skidY + 0.14, 0.85];+ const ladderTop = [-0.15, platY, platPosZ + 0.15];++ createLadder('SamsonLadder', {+ bottom: ladderBottom,+ top: ladderTop,+ width: 0.38,+ rungCount: 11,+ railRadius: 0.022,+ rungRadius: 0.016,+ material: matSafetyYellow,+ parent: root,+ });++ // Mounting standoff brackets securing ladder to the Samson post legs+ beamBetween('LadderStandoff_Bot', [-0.65, 0.8, 0.65], [-0.65, 0.8, 0.85], 0.025, matDarkSteel, { parent: root });+ beamBetween('LadderStandoff_Mid', [-0.35, 1.8, 0.45], [-0.35, 1.8, 0.72], 0.025, matDarkSteel, { parent: root });+ beamBetween('LadderStandoff_Top', [-0.15, 2.9, 0.32], [-0.15, 2.9, 0.66], 0.025, matDarkSteel, { parent: root });++ // Safety Handrail System (3-sided around platform: Back, Outer Right, Front)+ // Completely clear of the walking beam center!+ const railH = 0.95;+ const rZ_outer = platPosZ + platWidthZ / 2 - 0.02;+ const rZ_inner = platPosZ - platWidthZ / 2 + 0.04;+ const rX_back = platX - platLengthX / 2 + 0.03;+ const rX_mid = platX;+ const rX_front = platX + platLengthX / 2 - 0.03;++ // Vertical stanchion posts+ beamBetween('RailPost_BR', [rX_back, platY, rZ_outer], [rX_back, platY + railH, rZ_outer], 0.022, matSafetyYellow, { parent: root });+ beamBetween('RailPost_MR', [rX_mid, platY, rZ_outer], [rX_mid, platY + railH, rZ_outer], 0.022, matSafetyYellow, { parent: root });+ beamBetween('RailPost_FR', [rX_front, platY, rZ_outer], [rX_front, platY + railH, rZ_outer], 0.022, matSafetyYellow, { parent: root });+ beamBetween('RailPost_BI', [rX_back, platY, rZ_inner], [rX_back, platY + railH, rZ_inner], 0.022, matSafetyYellow, { parent: root });+ beamBetween('RailPost_FI', [rX_front, platY, rZ_inner], [rX_front, platY + railH, rZ_inner], 0.022, matSafetyYellow, { parent: root });++ // Outer top and mid rails+ beamBetween('RailTop_Outer', [rX_back, platY + railH, rZ_outer], [rX_front, platY + railH, rZ_outer], 0.022, matSafetyYellow, { parent: root });+ beamBetween('RailMid_Outer', [rX_back, platY + railH * 0.5, rZ_outer], [rX_front, platY + railH * 0.5, rZ_outer], 0.018, matSafetyYellow, { parent: root });++ // Back top and mid rails+ beamBetween('RailTop_Back', [rX_back, platY + railH, rZ_inner], [rX_back, platY + railH, rZ_outer], 0.022, matSafetyYellow, { parent: root });+ beamBetween('RailMid_Back', [rX_back, platY + railH * 0.5, rZ_inner], [rX_back, platY + railH * 0.5, rZ_outer], 0.018, matSafetyYellow, { parent: root });++ // Front top and mid rails+ beamBetween('RailTop_Front', [rX_front, platY + railH, rZ_inner], [rX_front, platY + railH, rZ_outer], 0.022, matSafetyYellow, { parent: root });+ beamBetween('RailMid_Front', [rX_front, platY + railH * 0.5, rZ_inner], [rX_front, platY + railH * 0.5, rZ_outer], 0.018, matSafetyYellow, { parent: root });++ // ==========================================+ // 5. WALKING BEAM (MID-STROKE PIVOTED ASSEMBLY)+ // ==========================================+ const tiltDeg = -9.5;+ const tiltRad = (tiltDeg * Math.PI) / 180;++ const walkingBeamGroup = new THREE.Group();+ walkingBeamGroup.position.set(platX, pivotCenterY, 0);+ walkingBeamGroup.rotation.z = tiltRad;+ root.add(walkingBeamGroup);++ // Center saddle clamp housing+ createPart('SaddleCenterHousing', boxGeo(0.65, 0.28, 0.44), matDarkSteel, {+ position: [0, -0.06, 0],+ parent: walkingBeamGroup,+ });+ for (const bx of [-0.24, 0.24]) {+ for (const bz of [-0.17, 0.17]) {+ createPart(`SaddleClampBolt_${bx}_${bz}`, boltHexY, matDarkSteel, {+ position: [bx, 0.09, bz],+ parent: walkingBeamGroup,+ });+ }+ }++ // Walking Beam I-beam profile (Length: 5.6m total)+ const beamLength = 5.6;+ const beamLocalCenterX = 0.2;+ const webH = 0.44;+ const webThick = 0.08;+ const flangeW = 0.38;+ const flangeThick = 0.035;++ createPart('WalkingBeam_Web', boxGeo(beamLength, webH, webThick), matBeamSteel, {+ position: [beamLocalCenterX, 0.22, 0],+ parent: walkingBeamGroup,+ });+ createPart('WalkingBeam_TopFlange', boxGeo(beamLength, flangeThick, flangeW), matBeamSteel, {+ position: [beamLocalCenterX, 0.22 + webH / 2 + flangeThick / 2, 0],+ parent: walkingBeamGroup,+ });+ createPart('WalkingBeam_BotFlange', boxGeo(beamLength, flangeThick, flangeW), matBeamSteel, {+ position: [beamLocalCenterX, 0.22 - webH / 2 - flangeThick / 2, 0],+ parent: walkingBeamGroup,+ });++ // Vertical web stiffener plates+ const stiffenerPositions = [-2.4, -1.8, -1.1, -0.4, 0.4, 1.1, 1.8, 2.5];+ const stiffGeo = boxGeo(0.025, webH - 0.01, 0.14);+ for (let i = 0; i < stiffenerPositions.length; i++) {+ const sx = stiffenerPositions[i];+ createPart(`BeamStiff_L_${i}`, stiffGeo, matBeamSteel, {+ position: [sx, 0.22, -0.1],+ parent: walkingBeamGroup,+ });+ createPart(`BeamStiff_R_${i}`, stiffGeo, matBeamSteel, {+ position: [sx, 0.22, 0.1],+ parent: walkingBeamGroup,+ });+ }++ // ==========================================+ // 6. HORSEHEAD ASSEMBLY (FRONT +X END OF BEAM)+ // ==========================================+ const horseHeadGroup = new THREE.Group();+ horseHeadGroup.position.set(2.65, 0.22, 0);+ walkingBeamGroup.add(horseHeadGroup);++ // Top mount collar / socket to walking beam+ createPart('HorseHead_MountSaddle', boxGeo(0.55, 0.52, 0.42), matDarkSteel, {+ position: [-0.15, 0, 0],+ parent: horseHeadGroup,+ });++ // Structural cheek plates (gussets)+ const cheekThick = 0.025;+ const cheekSpacing = 0.28;+ for (const side of [-1, 1]) {+ const sName = side < 0 ? 'L' : 'R';+ const cz = (side * cheekSpacing) / 2;++ createPart(`HorseCheek_Upper_${sName}`, boxGeo(0.75, 0.7, cheekThick), matBeamSteel, {+ position: [0.25, 0.35, cz],+ rotation: [0, 0, 18],+ parent: horseHeadGroup,+ });+ createPart(`HorseCheek_Lower_${sName}`, boxGeo(0.75, 0.8, cheekThick), matBeamSteel, {+ position: [0.22, -0.42, cz],+ rotation: [0, 0, -22],+ parent: horseHeadGroup,+ });+ createPart(`HorseCheek_Mid_${sName}`, boxGeo(0.85, 0.75, cheekThick), matBeamSteel, {+ position: [0.28, -0.05, cz],+ parent: horseHeadGroup,+ });+ }++ // Cross stiffener plates between cheek plates+ for (let dy = -0.6; dy <= 0.6; dy += 0.3) {+ createPart(`HorseCrossStiff_${dy.toFixed(1)}`, boxGeo(0.2, 0.03, cheekSpacing), matBeamSteel, {+ position: [0.25, dy, 0],+ parent: horseHeadGroup,+ });+ }++ // Horsehead Curved Arc Track (Perimeter cable track)+ const arcSegments = 16;+ const arcMinDeg = -46;+ const arcMaxDeg = 46;+ const arcStep = (arcMaxDeg - arcMinDeg) / (arcSegments - 1);+ const arcRadius = 0.75;+ const arcCenter = [-0.1, -0.05];++ let topArcX = 0;+ let topArcY = 0;++ for (let i = 0; i < arcSegments; i++) {+ const deg = arcMinDeg + i * arcStep;+ const rad = (deg * Math.PI) / 180;+ const ax = arcCenter[0] + Math.cos(rad) * arcRadius;+ const ay = arcCenter[1] + Math.sin(rad) * arcRadius * 1.35;++ if (i === arcSegments - 1) {+ topArcX = ax;+ topArcY = ay;+ }++ createPart(`HorseArcFace_${i}`, boxGeo(0.04, 0.16, 0.38), matBeamSteel, {+ position: [ax, ay, 0],+ rotation: [0, 0, -deg],+ parent: horseHeadGroup,+ });+ createPart(`HorseArcRim_L_${i}`, boxGeo(0.06, 0.15, 0.03), matDarkSteel, {+ position: [ax + 0.01, ay, -0.18],+ rotation: [0, 0, -deg],+ parent: horseHeadGroup,+ });+ createPart(`HorseArcRim_R_${i}`, boxGeo(0.06, 0.15, 0.03), matDarkSteel, {+ position: [ax + 0.01, ay, 0.18],+ rotation: [0, 0, -deg],+ parent: horseHeadGroup,+ });+ createPart(`HorseArcDivider_${i}`, boxGeo(0.05, 0.15, 0.025), matDarkSteel, {+ position: [ax + 0.01, ay, 0],+ rotation: [0, 0, -deg],+ parent: horseHeadGroup,+ });+ }++ // Solid top cap plate bridging cheek plates and top arc+ createPart('HorseTopCap', boxGeo(0.25, 0.05, 0.38), matDarkSteel, {+ position: [topArcX - 0.06, topArcY - 0.02, 0],+ parent: horseHeadGroup,+ });++ // Top cable keeper horns / anchor brackets (firmly anchored to top cap plate)+ createPart('HorseCableHorn_L', cylinderXGeo(0.04, 0.04, 0.14, 10), matDarkSteel, {+ position: [topArcX - 0.04, topArcY + 0.03, -0.1],+ parent: horseHeadGroup,+ });+ createPart('HorseCableHorn_R', cylinderXGeo(0.04, 0.04, 0.14, 10), matDarkSteel, {+ position: [topArcX - 0.04, topArcY + 0.03, 0.1],+ parent: horseHeadGroup,+ });++ // ==========================================+ // 7. EQUALIZER BEAM & BEARINGS (REAR OF WALKING BEAM)+ // ==========================================+ const eqLocalX = -2.48;+ const eqLocalY = 0.12;++ createPart('EqualizerTrunnionHousing', boxGeo(0.4, 0.3, 0.36), matDarkSteel, {+ position: [eqLocalX, eqLocalY - 0.12, 0],+ parent: walkingBeamGroup,+ });+ createPart('EqualizerTrunnionShaft', cylinderXGeo(0.07, 0.07, 0.36, 12), matPolishedSteel, {+ position: [eqLocalX, eqLocalY - 0.22, 0],+ parent: walkingBeamGroup,+ });++ // Equalizer Beam (transverse crossbar spanning across Z)+ const eqBarSpan = 1.48;+ createPart('EqualizerCrossBeam', boxGeo(0.18, 0.22, eqBarSpan), matBeamSteel, {+ position: [eqLocalX, eqLocalY - 0.22, 0],+ parent: walkingBeamGroup,+ });+ createPart('Equalizer_TFlange', boxGeo(0.24, 0.02, eqBarSpan), matBeamSteel, {+ position: [eqLocalX, eqLocalY - 0.1, 0],+ parent: walkingBeamGroup,+ });+ createPart('Equalizer_BFlange', boxGeo(0.24, 0.02, eqBarSpan), matBeamSteel, {+ position: [eqLocalX, eqLocalY - 0.34, 0],+ parent: walkingBeamGroup,+ });++ for (const side of [-1, 1]) {+ const sName = side < 0 ? 'L' : 'R';+ const ez = side * 0.72;+ createPart(`EqBearingHousing_${sName}`, cylinderZGeo(0.09, 0.09, 0.14, 12), matDarkSteel, {+ position: [eqLocalX, eqLocalY - 0.22, ez],+ parent: walkingBeamGroup,+ });+ createPart(`EqWristPin_${sName}`, cylinderZGeo(0.05, 0.05, 0.18, 12), matPolishedSteel, {+ position: [eqLocalX, eqLocalY - 0.22, ez],+ parent: walkingBeamGroup,+ });+ }++ // ==========================================+ // 8. WELLHEAD & BRIDLE CABLE SUSPENSION+ // ==========================================+ const wellheadX = 3.3;++ createPart('Wellhead_BaseFlange', cylinderYGeo(0.38, 0.42, 0.16, 16), matDarkSteel, {+ position: [wellheadX, 0.34, 0],+ parent: root,+ });+ for (let a = 0; a < 8; a++) {+ const ang = (a * Math.PI) / 4;+ createPart(`WellheadBaseBolt_${a}`, boltHexY, matDarkSteel, {+ position: [wellheadX + Math.cos(ang) * 0.34, 0.43, Math.sin(ang) * 0.34],+ parent: root,+ });+ }++ createPart('Wellhead_CasingSpool', cylinderYGeo(0.22, 0.26, 0.35, 14), matWellhead, {+ position: [wellheadX, 0.58, 0],+ parent: root,+ });+ createPart('Wellhead_Flange1', cylinderYGeo(0.32, 0.32, 0.08, 16), matWellhead, {+ position: [wellheadX, 0.78, 0],+ parent: root,+ });++ // Master gate valve+ createPart('Wellhead_MasterValve', boxGeo(0.36, 0.32, 0.36), matWellhead, {+ position: [wellheadX, 0.98, 0],+ parent: root,+ });+ createPart('Wellhead_ValveBonnet', cylinderXGeo(0.08, 0.08, 0.18, 10), matWellhead, {+ position: [wellheadX + 0.24, 0.98, 0],+ parent: root,+ });+ createPart('Wellhead_HandwheelRim', torusGeo(0.14, 0.02, 8, 16), matSafetyYellow, {+ position: [wellheadX + 0.34, 0.98, 0],+ rotation: [0, 90, 0],+ parent: root,+ });+ createPart('Wellhead_HandwheelSpoke1', cylinderYGeo(0.012, 0.012, 0.28, 6), matSafetyYellow, {+ position: [wellheadX + 0.34, 0.98, 0],+ parent: root,+ });+ createPart('Wellhead_HandwheelSpoke2', cylinderZGeo(0.012, 0.012, 0.28, 6), matSafetyYellow, {+ position: [wellheadX + 0.34, 0.98, 0],+ parent: root,+ });++ // Flow Tee+ createPart('Wellhead_FlowTee', cylinderYGeo(0.16, 0.16, 0.34, 12), matWellhead, {+ position: [wellheadX, 1.28, 0],+ parent: root,+ });++ // Horizontal production flow line exiting to right (+Z)+ createPart('Wellhead_FlowLineSpool', cylinderZGeo(0.07, 0.07, 0.45, 10), matWellhead, {+ position: [wellheadX, 1.28, 0.3],+ parent: root,+ });+ createPart('Wellhead_FlowValve', boxGeo(0.2, 0.2, 0.2), matWellhead, {+ position: [wellheadX, 1.28, 0.58],+ parent: root,+ });+ // Valve stem connecting valve body to handwheel (resolves QA warning)+ createPart('Wellhead_FlowValveStem', cylinderYGeo(0.016, 0.016, 0.14, 8), matPolishedSteel, {+ position: [wellheadX, 1.35, 0.58],+ parent: root,+ });+ createPart('Wellhead_FlowHandwheel', torusGeo(0.09, 0.015, 8, 14), matSafetyYellow, {+ position: [wellheadX, 1.42, 0.58],+ rotation: [90, 0, 0],+ parent: root,+ });+ createPart('Wellhead_FlowPipeExit', cylinderZGeo(0.05, 0.05, 0.5, 8), matDarkSteel, {+ position: [wellheadX, 1.28, 0.9],+ parent: root,+ });++ // Pressure gauge+ createPart('PressureGaugeStem', cylinderYGeo(0.016, 0.016, 0.12, 6), matBrass, {+ position: [wellheadX, 1.5, -0.1],+ parent: root,+ });+ createPart('PressureGaugeBody', cylinderZGeo(0.07, 0.07, 0.035, 12), matBrass, {+ position: [wellheadX, 1.6, -0.1],+ parent: root,+ });+ createPart('PressureGaugeDial', cylinderZGeo(0.062, 0.062, 0.038, 12), matPolishedSteel, {+ position: [wellheadX, 1.6, -0.09],+ parent: root,+ });++ // Stuffing Box / Packing Gland+ createPart('StuffingBox', cylinderYGeo(0.13, 0.13, 0.32, 14), matBrass, {+ position: [wellheadX, 1.58, 0],+ parent: root,+ });+ createPart('PackingGlandCap', cylinderYGeo(0.15, 0.15, 0.08, 14), matDarkSteel, {+ position: [wellheadX, 1.76, 0],+ parent: root,+ });++ // Polished Rod+ createPart('PolishedRod', cylinderYGeo(0.024, 0.024, 1.8, 16), matPolishedSteel, {+ position: [wellheadX, 2.5, 0],+ parent: root,+ });++ // Carrier Bar holding the polished rod clamp+ const carrierY = 2.45;+ createPart('CarrierBarBody', boxGeo(0.16, 0.1, 0.56), matDarkSteel, {+ position: [wellheadX, carrierY, 0],+ parent: root,+ });+ createPart('PolishedRodClamp', boxGeo(0.14, 0.12, 0.14), matDarkSteel, {+ position: [wellheadX, carrierY + 0.11, 0],+ parent: root,+ });+ createPart('ClampBolt1', boltHexX, matPolishedSteel, {+ position: [wellheadX + 0.08, carrierY + 0.11, -0.04],+ parent: root,+ });+ createPart('ClampBolt2', boltHexX, matPolishedSteel, {+ position: [wellheadX + 0.08, carrierY + 0.11, 0.04],+ parent: root,+ });++ createPart('CarrierSocket_L', cylinderYGeo(0.035, 0.035, 0.12, 10), matDarkSteel, {+ position: [wellheadX, carrierY, -0.2],+ parent: root,+ });+ createPart('CarrierSocket_R', cylinderYGeo(0.035, 0.035, 0.12, 10), matDarkSteel, {+ position: [wellheadX, carrierY, 0.2],+ parent: root,+ });++ // Bridle wire ropes running from carrier bar sockets straight up tangentially to horsehead arc+ const bridleTopY = 3.52;+ beamBetween('BridleWire_L', [wellheadX, carrierY + 0.06, -0.2], [wellheadX, bridleTopY, -0.2], 0.012, matWireCable, { parent: root });+ beamBetween('BridleWire_R', [wellheadX, carrierY + 0.06, 0.2], [wellheadX, bridleTopY, 0.2], 0.012, matWireCable, { parent: root });++ createPart('BridleSpreader', boxGeo(0.03, 0.03, 0.44), matDarkSteel, {+ position: [wellheadX, 3.0, 0],+ parent: root,+ });++ // ==========================================+ // 9. GEAR REDUCER (DOUBLE REDUCTION GEARBOX)+ // ==========================================+ const reducerX = -1.85;+ const reducerBaseY = skidY + 0.12;++ createPart('ReducerSubBase_L', boxGeo(1.4, 0.12, 0.22), matDarkSteel, {+ position: [reducerX, reducerBaseY + 0.06, -0.55],+ parent: root,+ });+ createPart('ReducerSubBase_R', boxGeo(1.4, 0.12, 0.22), matDarkSteel, {+ position: [reducerX, reducerBaseY + 0.06, 0.55],+ parent: root,+ });++ createPart('Reducer_LowerSump', boxGeo(1.25, 0.52, 0.94), matDarkSteel, {+ position: [reducerX, reducerBaseY + 0.38, 0],+ parent: root,+ });+ createPart('Reducer_SplitFlange', boxGeo(1.36, 0.04, 1.04), matDarkSteel, {+ position: [reducerX, reducerBaseY + 0.64, 0],+ parent: root,+ });+ createPart('Reducer_UpperCover', boxGeo(1.15, 0.44, 0.86), matDarkSteel, {+ position: [reducerX, reducerBaseY + 0.88, 0],+ parent: root,+ });+ createPart('Reducer_Hatch', boxGeo(0.5, 0.03, 0.45), matDarkSteel, {+ position: [reducerX, reducerBaseY + 1.11, 0],+ parent: root,+ });+ createPart('Reducer_Breather', cylinderYGeo(0.02, 0.02, 0.14, 8), matDarkSteel, {+ position: [reducerX + 0.35, reducerBaseY + 1.17, 0.15],+ parent: root,+ });+ createPart('Reducer_BreatherCap', cylinderYGeo(0.045, 0.045, 0.04, 8), matDarkSteel, {+ position: [reducerX + 0.35, reducerBaseY + 1.25, 0.15],+ parent: root,+ });++ const crankShaftY = reducerBaseY + 0.64;++ createPart('ReducerBearingHub_L', cylinderZGeo(0.24, 0.24, 0.14, 16), matDarkSteel, {+ position: [reducerX, crankShaftY, -0.52],+ parent: root,+ });+ createPart('ReducerBearingHub_R', cylinderZGeo(0.24, 0.24, 0.14, 16), matDarkSteel, {+ position: [reducerX, crankShaftY, 0.52],+ parent: root,+ });++ for (let b = 0; b < 6; b++) {+ const bang = (b * Math.PI) / 3;+ createPart(`ReducerBolt_L_${b}`, boltHexZ, matDarkSteel, {+ position: [reducerX + Math.cos(bang) * 0.18, crankShaftY + Math.sin(bang) * 0.18, -0.58],+ parent: root,+ });+ createPart(`ReducerBolt_R_${b}`, boltHexZ, matDarkSteel, {+ position: [reducerX + Math.cos(bang) * 0.18, crankShaftY + Math.sin(bang) * 0.18, 0.58],+ parent: root,+ });+ }++ createPart('SlowSpeedCrankshaft', cylinderZGeo(0.1, 0.1, 1.48, 16), matDarkSteel, {+ position: [reducerX, crankShaftY, 0],+ parent: root,+ });++ // ==========================================+ // 10. CRANKS, SAFETY ORANGE COUNTERWEIGHTS & PITMAN ARMS+ // ==========================================+ const crankAngleDeg = 50;+ const crankRad = (crankAngleDeg * Math.PI) / 180;+ const strokeRadius = 0.66;++ const pinX = reducerX + Math.cos(crankRad) * strokeRadius;+ const pinY = crankShaftY + Math.sin(crankRad) * strokeRadius;++ const eqRelX = eqLocalX;+ const eqRelY = eqLocalY - 0.22;+ const eqWorldX = platX + eqRelX * Math.cos(tiltRad) - eqRelY * Math.sin(tiltRad);+ const eqWorldY = pivotCenterY + eqRelX * Math.sin(tiltRad) + eqRelY * Math.cos(tiltRad);++ for (const side of [-1, 1]) {+ const sName = side < 0 ? 'L' : 'R';+ const crankZ = side * 0.72;++ createPart(`CrankHub_${sName}`, cylinderZGeo(0.18, 0.18, 0.12, 16), matDarkSteel, {+ position: [reducerX, crankShaftY, crankZ],+ parent: root,+ });++ const crankArmLen = 1.6;+ createPart(`CrankArm_${sName}`, boxGeo(crankArmLen, 0.24, 0.09), matDarkSteel, {+ position: [reducerX, crankShaftY, crankZ],+ rotation: [0, 0, crankAngleDeg],+ parent: root,+ });++ // 3 stroke adjustment holes+ for (const rHole of [0.48, 0.66, 0.84]) {+ const hx = reducerX + Math.cos(crankRad) * rHole;+ const hy = crankShaftY + Math.sin(crankRad) * rHole;+ createPart(`StrokeHoleRing_${sName}_${rHole}`, cylinderZGeo(0.065, 0.065, 0.095, 12), matDarkSteel, {+ position: [hx, hy, crankZ],+ parent: root,+ });+ }++ // Active Crank Pin+ const pinZ = crankZ + side * 0.08;+ createPart(`ActiveCrankPin_${sName}`, cylinderZGeo(0.055, 0.055, 0.18, 14), matPolishedSteel, {+ position: [pinX, pinY, pinZ],+ parent: root,+ });+ createPart(`CrankPinNut_${sName}`, cylinderZGeo(0.075, 0.075, 0.04, 8), matDarkSteel, {+ position: [pinX, pinY, pinZ + side * 0.09],+ parent: root,+ });++ // HIGH-VISIBILITY SAFETY HAZARD COUNTERWEIGHTS+ // Bold safety orange finish ensures high visual read on both sides!+ const cwAngleDeg = crankAngleDeg + 180;+ const cwRad = (cwAngleDeg * Math.PI) / 180;+ const cwCenterX = reducerX + Math.cos(cwRad) * 0.52;+ const cwCenterY = crankShaftY + Math.sin(cwRad) * 0.52;++ // Main heavy counterweight body (safety hazard orange)+ createPart(`CounterWeight_Main_${sName}`, boxGeo(0.9, 0.64, 0.22), matHazardOrange, {+ position: [cwCenterX, cwCenterY, crankZ],+ rotation: [0, 0, crankAngleDeg],+ parent: root,+ });+ // Auxiliary bolted segment (safety hazard orange)+ createPart(`CounterWeight_Aux_${sName}`, boxGeo(0.82, 0.52, 0.16), matHazardOrange, {+ position: [cwCenterX + Math.cos(cwRad) * 0.18, cwCenterY + Math.sin(cwRad) * 0.18, crankZ + side * 0.12],+ rotation: [0, 0, crankAngleDeg],+ parent: root,+ });+ // Heavy clamping plate (contrasting dark steel)+ createPart(`CounterWeight_Clamp_${sName}`, boxGeo(0.4, 0.14, 0.28), matDarkSteel, {+ position: [cwCenterX, cwCenterY, crankZ],+ rotation: [0, 0, crankAngleDeg],+ parent: root,+ });+ // Clamping bolts+ for (const d of [-0.25, 0.25]) {+ const bx = cwCenterX + Math.cos(cwRad + Math.PI / 2) * d;+ const by = cwCenterY + Math.sin(cwRad + Math.PI / 2) * d;+ createPart(`CounterWeightBolt_${sName}_${d}`, cylinderZGeo(0.03, 0.03, 0.32, 8), matDarkSteel, {+ position: [bx, by, crankZ],+ parent: root,+ });+ }++ // PITMAN ARMS+ const eqWorldZ = side * 0.72;+ const pitmanBottomZ = pinZ;++ createPart(`PitmanBigEnd_${sName}`, cylinderZGeo(0.09, 0.09, 0.14, 14), matDarkSteel, {+ position: [pinX, pinY, pitmanBottomZ],+ parent: root,+ });+ createPart(`PitmanSmallEnd_${sName}`, cylinderZGeo(0.08, 0.08, 0.14, 14), matDarkSteel, {+ position: [eqWorldX, eqWorldY, eqWorldZ],+ parent: root,+ });++ beamBetween(`PitmanArmColumn_${sName}`, [pinX, pinY, pitmanBottomZ], [eqWorldX, eqWorldY, eqWorldZ], 0.055, matBeamSteel, { parent: root });+ beamBetween(`PitmanRib1_${sName}`, [pinX + 0.03, pinY, pitmanBottomZ], [eqWorldX + 0.03, eqWorldY, eqWorldZ], 0.025, matBeamSteel, { parent: root });+ beamBetween(`PitmanRib2_${sName}`, [pinX - 0.03, pinY, pitmanBottomZ], [eqWorldX - 0.03, eqWorldY, eqWorldZ], 0.025, matBeamSteel, { parent: root });+ }++ // ==========================================+ // 11. PRIME MOVER (ELECTRIC MOTOR) & BELT DRIVE+ // ==========================================+ const motorX = -3.25;+ const motorBaseY = skidY + 0.12;++ createPart('MotorSlideRail_L', boxGeo(0.9, 0.08, 0.12), matDarkSteel, {+ position: [motorX, motorBaseY + 0.04, -0.45],+ parent: root,+ });+ createPart('MotorSlideRail_R', boxGeo(0.9, 0.08, 0.12), matDarkSteel, {+ position: [motorX, motorBaseY + 0.04, 0.15],+ parent: root,+ });+ createPart('MotorTensionScrew_L', cylinderXGeo(0.016, 0.016, 0.35, 8), matPolishedSteel, {+ position: [motorX - 0.48, motorBaseY + 0.04, -0.45],+ parent: root,+ });+ createPart('MotorTensionScrew_R', cylinderXGeo(0.016, 0.016, 0.35, 8), matPolishedSteel, {+ position: [motorX - 0.48, motorBaseY + 0.04, 0.15],+ parent: root,+ });++ createPart('MotorCradle', boxGeo(0.72, 0.12, 0.65), matDarkSteel, {+ position: [motorX, motorBaseY + 0.14, -0.15],+ parent: root,+ });++ const motorCenterY = motorBaseY + 0.46;+ const motorCenterZ = -0.15;+ createPart('MotorStatorBody', cylinderXGeo(0.26, 0.26, 0.64, 18), matBeamSteel, {+ position: [motorX, motorCenterY, motorCenterZ],+ parent: root,+ });++ for (let f = 0; f < 10; f++) {+ const fang = (f * Math.PI) / 5;+ const fx = motorX;+ const fy = motorCenterY + Math.cos(fang) * 0.27;+ const fz = motorCenterZ + Math.sin(fang) * 0.27;+ createPart(`MotorFin_${f}`, boxGeo(0.56, 0.02, 0.03), matBeamSteel, {+ position: [fx, fy, fz],+ rotation: [(-fang * 180) / Math.PI, 0, 0],+ parent: root,+ });+ }++ createPart('MotorEndBell_Front', cylinderXGeo(0.24, 0.24, 0.08, 16), matDarkSteel, {+ position: [motorX + 0.34, motorCenterY, motorCenterZ],+ parent: root,+ });+ createPart('MotorEndBell_Rear', cylinderXGeo(0.24, 0.24, 0.08, 16), matDarkSteel, {+ position: [motorX - 0.34, motorCenterY, motorCenterZ],+ parent: root,+ });+ createPart('MotorFanCowl', cylinderXGeo(0.25, 0.25, 0.12, 16), matDarkSteel, {+ position: [motorX - 0.42, motorCenterY, motorCenterZ],+ parent: root,+ });++ createPart('MotorJunctionBox', boxGeo(0.18, 0.2, 0.16), matSafetyYellow, {+ position: [motorX + 0.1, motorCenterY + 0.25, motorCenterZ + 0.18],+ parent: root,+ });++ createPart('MotorDriveShaft', cylinderZGeo(0.045, 0.045, 0.38, 12), matPolishedSteel, {+ position: [motorX, motorCenterY, motorCenterZ - 0.38],+ parent: root,+ });+ createPart('MotorPulley', cylinderZGeo(0.16, 0.16, 0.14, 16), matDarkSteel, {+ position: [motorX, motorCenterY, -0.48],+ parent: root,+ });++ const inputSheaveX = reducerX - 0.35;+ const inputSheaveY = crankShaftY - 0.12;+ createPart('ReducerInputSheave', cylinderZGeo(0.36, 0.36, 0.14, 18), matDarkSteel, {+ position: [inputSheaveX, inputSheaveY, -0.48],+ parent: root,+ });++ // ==========================================+ // 12. BELT GUARD ENCLOSURE+ // ==========================================+ const bgCenterX = (motorX + inputSheaveX) / 2;+ const bgCenterY = (motorCenterY + inputSheaveY) / 2;+ const bgZ = -0.48;++ createPart('BeltGuard_MainCase', boxGeo(1.48, 0.82, 0.22), matSafetyYellow, {+ position: [bgCenterX, bgCenterY, bgZ],+ parent: root,+ });+ createPart('BeltGuard_FrontCap', cylinderYGeo(0.41, 0.41, 0.22, 14), matSafetyYellow, {+ position: [bgCenterX + 0.74, bgCenterY, bgZ],+ rotation: [90, 0, 0],+ parent: root,+ });+ createPart('BeltGuard_RearCap', cylinderYGeo(0.41, 0.41, 0.22, 14), matSafetyYellow, {+ position: [bgCenterX - 0.74, bgCenterY, bgZ],+ rotation: [90, 0, 0],+ parent: root,+ });++ createPart('BeltGuard_TopRim', boxGeo(1.5, 0.04, 0.25), matSafetyYellow, {+ position: [bgCenterX, bgCenterY + 0.42, bgZ],+ parent: root,+ });+ createPart('BeltGuard_BotRim', boxGeo(1.5, 0.04, 0.25), matSafetyYellow, {+ position: [bgCenterX, bgCenterY - 0.42, bgZ],+ parent: root,+ });++ createPart('BeltGuard_VentPanel', boxGeo(1.2, 0.58, 0.02), matDarkSteel, {+ position: [bgCenterX, bgCenterY, bgZ - 0.115],+ parent: root,+ });++ beamBetween('BeltGuardSupport_F', [inputSheaveX, skidY + 0.12, -0.65], [inputSheaveX, bgCenterY - 0.2, bgZ], 0.03, matDarkSteel, { parent: root });+ beamBetween('BeltGuardSupport_R', [motorX, skidY + 0.12, -0.65], [motorX, bgCenterY - 0.2, bgZ], 0.03, matDarkSteel, { parent: root });++ createPart('SafetyWarningPlate', boxGeo(0.24, 0.16, 0.02), matSafetyYellow, {+ position: [bgCenterX, bgCenterY, bgZ - 0.13],+ parent: root,+ });++ return root;+}diff --git a/examples/radio-telescope.kiln.js b/examples/radio-telescope.kiln.jsnew file mode 100644index 00000000..1bd4bfb5--- /dev/null+++ b/examples/radio-telescope.kiln.js@@ -0,0 +1,669 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.++const meta = { name: 'RadioTelescope', category: 'prop' };++function build() {+ const root = createRoot('RadioTelescope');++ // Materials+ const concreteMat = gameMaterial(0x828585, { roughness: 0.95, metalness: 0.05 });+ const dishWhiteMat = gameMaterial(0xededec, { roughness: 0.55, metalness: 0.15 });+ const dishRearMat = gameMaterial(0xc5cad1, { roughness: 0.65, metalness: 0.25 });+ const steelMountMat = gameMaterial(0x526173, { roughness: 0.45, metalness: 0.65 });+ const steelTrussMat = gameMaterial(0x8da0b8, { roughness: 0.4, metalness: 0.55 });+ const machineryDarkMat = gameMaterial(0x273142, { roughness: 0.35, metalness: 0.8 });+ const accentYellowMat = gameMaterial(0xd97706, { roughness: 0.4, metalness: 0.15 });+ const goldMat = gameMaterial(0xd4af37, { roughness: 0.25, metalness: 0.9 });++ // ---------------------------------------------------------------------------+ // 1. STATIONARY PEDESTAL & FOUNDATION (Y = 0 to Y = 2.20m)+ // ---------------------------------------------------------------------------++ // Concrete foundation pad (sitting directly on Y = 0)+ createPart('PadBase', cylinderGeo(5.0, 5.2, 0.15, 12), concreteMat, {+ position: [0, 0.075, 0],+ parent: root,+ });+ createPart('PadOctagon', cylinderGeo(4.5, 4.5, 0.25, 12), concreteMat, {+ position: [0, 0.275, 0],+ parent: root,+ });++ // 8 radial foundation anchor piers with bolt fixtures+ for (let i = 0; i < 8; i++) {+ const angle = (i / 8) * Math.PI * 2;+ const fx = Math.cos(angle) * 3.5;+ const fz = Math.sin(angle) * 3.5;+ createPart(`AnchorFoot_${i}`, boxGeo(0.7, 0.22, 0.7), machineryDarkMat, {+ position: [fx, 0.45, fz],+ parent: root,+ });+ createPart(`AnchorBolt_${i}`, cylinderGeo(0.04, 0.04, 0.1, 6), steelMountMat, {+ position: [fx, 0.6, fz],+ parent: root,+ });+ }++ // Circular azimuth rail track ring+ const azRailGeo = torusGeo(2.4, 0.06, 12, 48);+ createPart('AzimuthTrack', azRailGeo, machineryDarkMat, {+ position: [0, 0.42, 0],+ rotation: [90, 0, 0],+ parent: root,+ });++ // Stationary pedestal column (tapered 12-sided structural tower)+ createPart('PedestalBaseFlange', cylinderGeo(2.35, 2.45, 0.15, 12), machineryDarkMat, {+ position: [0, 0.475, 0],+ parent: root,+ });+ createPart('PedestalColumn', cylinderGeo(1.95, 2.25, 1.55, 12), steelMountMat, {+ position: [0, 1.325, 0],+ parent: root,+ });+ createPart('PedestalTopFlange', cylinderGeo(2.15, 1.95, 0.15, 12), machineryDarkMat, {+ position: [0, 2.15, 0],+ parent: root,+ });++ // Pedestal maintenance access door on -X side+ createPart('PedestalDoorFrame', boxGeo(0.08, 1.25, 0.75), machineryDarkMat, {+ position: [-2.05, 1.2, 0],+ parent: root,+ });+ createPart('PedestalDoor', boxGeo(0.04, 1.15, 0.65), accentYellowMat, {+ position: [-2.07, 1.2, 0],+ parent: root,+ });++ // 4 stationary azimuth drive units+ for (let i = 0; i < 4; i++) {+ const ang = (i / 4) * Math.PI * 2 + Math.PI / 4;+ const mx = Math.cos(ang) * 2.38;+ const mz = Math.sin(ang) * 2.38;+ createPart(`AzDriveMotor_${i}`, cylinderGeo(0.22, 0.22, 0.5, 8), machineryDarkMat, {+ position: [mx, 0.65, mz],+ parent: root,+ });+ createPart(`AzDriveGear_${i}`, cylinderGeo(0.26, 0.26, 0.16, 12), accentYellowMat, {+ position: [mx, 0.45, mz],+ parent: root,+ });+ }++ // Rotary cable festoon guide on pedestal below turntable+ const cableGuide = torusGeo(2.1, 0.04, 8, 24);+ createPart('AzCableGuide', cableGuide, machineryDarkMat, {+ position: [0, 2.05, 0],+ rotation: [90, 0, 0],+ parent: root,+ });++ // Exterior ground-to-turntable access ladder+ createLadder('GroundLadder', {+ bottom: [-2.42, 0.4, 0.7],+ top: [-2.42, 2.2, 0.7],+ width: 0.45,+ rungCount: 6,+ material: machineryDarkMat,+ parent: root,+ });++ // ---------------------------------------------------------------------------+ // 2. AZIMUTH MOUNT & YOKE (Joint_Azimuth, Y = 2.20m)+ // ---------------------------------------------------------------------------+ const azPivotPos = [0, 2.20, 0];+ const azDeckGeo = cylinderGeo(2.55, 2.55, 0.22, 36);+ const jointAzimuth = createPart('Azimuth', azDeckGeo, steelMountMat, {+ position: azPivotPos,+ pivot: azPivotPos,+ parent: root,+ });+ jointAzimuth.name = 'Joint_Azimuth';++ // Turntable deck perimeter trim+ createPart('DeckRim', torusGeo(2.55, 0.05, 8, 36), machineryDarkMat, {+ position: [0, 0.08, 0],+ rotation: [90, 0, 0],+ parent: jointAzimuth,+ });++ // Perimeter handrail (open in front sector for dish swing clearance)+ const railRadius = 2.46;+ const numRailPosts = 16;+ for (let i = 0; i < numRailPosts; i++) {+ const a1 = (i / numRailPosts) * Math.PI * 2;+ const a2 = ((i + 1) / numRailPosts) * Math.PI * 2;+ const midAngle = (a1 + a2) / 2;+ const isFrontSector = Math.abs(midAngle) < 0.4 || Math.abs(midAngle - Math.PI * 2) < 0.4;++ const px = Math.cos(a1) * railRadius;+ const pz = Math.sin(a1) * railRadius;+ const nx = Math.cos(a2) * railRadius;+ const nz = Math.sin(a2) * railRadius;++ createPart(`RailPost_${i}`, cylinderGeo(0.022, 0.022, 0.95, 6), machineryDarkMat, {+ position: [px, 0.58, pz],+ parent: jointAzimuth,+ });++ if (!isFrontSector) {+ beamBetween(`RailTop_${i}`, [px, 1.05, pz], [nx, 1.05, nz], 0.022, machineryDarkMat, {+ segments: 6,+ parent: jointAzimuth,+ });+ beamBetween(`RailMid_${i}`, [px, 0.55, pz], [nx, 0.55, nz], 0.018, machineryDarkMat, {+ segments: 6,+ parent: jointAzimuth,+ });+ }+ }++ // Equipment / Machinery cabin on turntable deck (-X)+ createPart('EquipCabin', boxGeo(1.6, 1.45, 1.9), steelMountMat, {+ position: [-1.15, 0.82, 0],+ parent: jointAzimuth,+ });+ createPart('CabinDoor', boxGeo(0.04, 1.25, 0.7), machineryDarkMat, {+ position: [-0.33, 0.72, 0],+ parent: jointAzimuth,+ });+ createPart('CabinHvac', boxGeo(0.7, 0.4, 0.9), machineryDarkMat, {+ position: [-1.15, 1.75, 0],+ parent: jointAzimuth,+ });+ createPart('CabinHvacFan', cylinderYGeo(0.25, 0.25, 0.06, 12), accentYellowMat, {+ position: [-1.15, 1.98, 0],+ parent: jointAzimuth,+ });++ // Twin A-frame Stanchion Towers+ const towerZ = 2.15;+ const towerHeight = 4.90; // World Y = 7.10m for complete dish clearance+ [-towerZ, towerZ].forEach((tz, idx) => {+ const side = idx === 0 ? 'L' : 'R';++ // Front main column+ beamBetween(`TowerFront_${side}`, [0.95, 0.1, tz], [0, towerHeight, tz], 0.15, steelMountMat, {+ segments: 8,+ parent: jointAzimuth,+ });+ // Rear main column+ beamBetween(`TowerRear_${side}`, [-0.95, 0.1, tz], [0, towerHeight, tz], 0.15, steelMountMat, {+ segments: 8,+ parent: jointAzimuth,+ });+ // Horizontal cross ties+ beamBetween(`TowerCrossLow_${side}`, [0.65, 1.6, tz], [-0.65, 1.6, tz], 0.08, steelMountMat, {+ segments: 6,+ parent: jointAzimuth,+ });+ beamBetween(`TowerCrossHigh_${side}`, [0.35, 3.3, tz], [-0.35, 3.3, tz], 0.08, steelMountMat, {+ segments: 6,+ parent: jointAzimuth,+ });+ // Lattice X-braces+ beamBetween(`TowerDiagA_${side}`, [0.65, 1.6, tz], [-0.35, 3.3, tz], 0.05, steelTrussMat, {+ segments: 6,+ parent: jointAzimuth,+ });+ beamBetween(`TowerDiagB_${side}`, [-0.65, 1.6, tz], [0.35, 3.3, tz], 0.05, steelTrussMat, {+ segments: 6,+ parent: jointAzimuth,+ });++ // Top bearing block+ createPart(`BearingBlock_${side}`, boxGeo(0.8, 0.65, 0.45), steelMountMat, {+ position: [0, towerHeight, tz],+ parent: jointAzimuth,+ });+ createPart(`BearingCap_${side}`, cylinderZGeo(0.32, 0.32, 0.5, 16), machineryDarkMat, {+ position: [0, towerHeight, tz],+ parent: jointAzimuth,+ });+ });++ // Cross tie beams connecting Left and Right towers across back (-X)+ beamBetween('TowerTieLow', [-0.75, 1.6, -towerZ], [-0.75, 1.6, towerZ], 0.11, steelMountMat, {+ segments: 8,+ parent: jointAzimuth,+ });+ beamBetween('TowerTieHigh', [-0.4, 3.3, -towerZ], [-0.4, 3.3, towerZ], 0.11, steelMountMat, {+ segments: 8,+ parent: jointAzimuth,+ });+ beamBetween('TowerTieDiagA', [-0.75, 1.6, -towerZ], [-0.4, 3.3, towerZ], 0.06, steelTrussMat, {+ segments: 6,+ parent: jointAzimuth,+ });+ beamBetween('TowerTieDiagB', [-0.75, 1.6, towerZ], [-0.4, 3.3, -towerZ], 0.06, steelTrussMat, {+ segments: 6,+ parent: jointAzimuth,+ });++ // Tower ladder on Left tower up to elevation bearing platform+ createLadder('TowerLadderL', {+ bottom: [-0.95, 0.2, -towerZ - 0.22],+ top: [0, towerHeight - 0.4, -towerZ - 0.22],+ width: 0.4,+ rungCount: 14,+ material: machineryDarkMat,+ parent: jointAzimuth,+ });+ // Bearing maintenance platform on Left tower+ createPart('TowerPlatformL', boxGeo(0.8, 0.06, 0.8), machineryDarkMat, {+ position: [0, towerHeight - 0.35, -towerZ - 0.4],+ parent: jointAzimuth,+ });++ // Elevation drive motor and gearbox mounted on Right tower+ createPart('ElevDriveBox', boxGeo(0.55, 0.65, 0.45), machineryDarkMat, {+ position: [0.35, towerHeight - 0.55, towerZ - 0.3],+ parent: jointAzimuth,+ });+ createPart('ElevPinion', cylinderZGeo(0.18, 0.18, 0.3, 12), accentYellowMat, {+ position: [0.35, towerHeight - 0.55, towerZ - 0.62],+ parent: jointAzimuth,+ });++ // ---------------------------------------------------------------------------+ // 3. ELEVATION ASSEMBLY (Joint_Elevation, pivot at [0, towerHeight, 0])+ // ---------------------------------------------------------------------------+ const elPivotPos = [0, towerHeight, 0];+ const elAxleGeo = cylinderZGeo(0.24, 0.24, 4.3, 16);+ const jointElevation = createPart('Elevation', elAxleGeo, machineryDarkMat, {+ position: elPivotPos,+ pivot: elPivotPos,+ parent: jointAzimuth,+ });+ jointElevation.name = 'Joint_Elevation';++ // Semicircular Elevation Bull Gear Sector+ const gearZ = towerZ - 0.62;+ const gearR = 1.35;+ const gearSegments = 16;+ for (let g = 0; g < gearSegments; g++) {+ const a1 = -0.6 + (g / gearSegments) * 2.1;+ const a2 = -0.6 + ((g + 1) / gearSegments) * 2.1;+ const gx1 = Math.sin(a1) * gearR;+ const gy1 = -Math.cos(a1) * gearR;+ const gx2 = Math.sin(a2) * gearR;+ const gy2 = -Math.cos(a2) * gearR;++ beamBetween(`GearRim_${g}`, [gx1, gy1, gearZ], [gx2, gy2, gearZ], 0.08, machineryDarkMat, {+ segments: 6,+ parent: jointElevation,+ });+ if (g % 3 === 0) {+ beamBetween(`GearSpoke_${g}`, [0, 0, gearZ], [gx1, gy1, gearZ], 0.05, steelMountMat, {+ segments: 6,+ parent: jointElevation,+ });+ }+ createPart(`GearTooth_${g}`, boxGeo(0.08, 0.05, 0.12), accentYellowMat, {+ position: [gx1, gy1, gearZ],+ rotation: [0, 0, (a1 * 180) / Math.PI],+ parent: jointElevation,+ });+ }++ // Heavy Boxed Counterweight System+ const cwZ = 1.55;+ [-cwZ, cwZ].forEach((cz, idx) => {+ const side = idx === 0 ? 'L' : 'R';+ beamBetween(`CwArm_${side}`, [0, 0, cz], [-1.8, -0.5, cz], 0.22, steelMountMat, {+ segments: 6,+ parent: jointElevation,+ });+ beamBetween(`CwBrace_${side}`, [0.5, 0, cz * 0.7], [-1.8, -0.5, cz], 0.09, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });+ });++ // Main transverse counterweight ballast block+ createPart('CwBallastMain', boxGeo(0.9, 0.9, 3.4), machineryDarkMat, {+ position: [-1.8, -0.5, 0],+ parent: jointElevation,+ });+ createPart('CwBallastEndL', boxGeo(0.92, 0.92, 0.35), accentYellowMat, {+ position: [-1.8, -0.5, -1.6],+ parent: jointElevation,+ });+ createPart('CwBallastEndR', boxGeo(0.92, 0.92, 0.35), accentYellowMat, {+ position: [-1.8, -0.5, 1.6],+ parent: jointElevation,+ });++ // Central Torque Box / Dish Hub Cradle+ createPart('DishHubDrum', cylinderXGeo(1.25, 1.35, 0.85, 16), steelMountMat, {+ position: [0.5, 0, 0],+ parent: jointElevation,+ });+ createPart('DishHubFrontPlate', cylinderXGeo(1.4, 1.4, 0.12, 16), machineryDarkMat, {+ position: [0.92, 0, 0],+ parent: jointElevation,+ });++ // Structural cradle gussets between torque axle and hub+ [-1.2, 1.2].forEach((gz, gIdx) => {+ createPart(`HubGusset_${gIdx}`, boxGeo(0.6, 0.3, 0.08), steelMountMat, {+ position: [0.35, 0.2, gz],+ rotation: [0, 0, -25],+ parent: jointElevation,+ });+ });++ // ---------------------------------------------------------------------------+ // 4. PARABOLIC DISH REFLECTOR (Facing +X forward)+ // ---------------------------------------------------------------------------+ const dishVertexX = 0.92;+ const f4 = 11.2;+ const dishRadius = 3.8;+ const numRadSteps = 16;+ const dishProfile = [];++ for (let i = 0; i <= numRadSteps; i++) {+ const r = 0.25 + (dishRadius - 0.25) * (i / numRadSteps);+ const x = dishVertexX + (r * r) / f4;+ dishProfile.push([r, x]);+ }+ const rimX = dishVertexX + (dishRadius * dishRadius) / f4;+ dishProfile.push([dishRadius + 0.06, rimX]);+ dishProfile.push([dishRadius + 0.06, rimX - 0.08]);++ for (let i = numRadSteps; i >= 0; i--) {+ const r = 0.45 + (dishRadius - 0.45) * (i / numRadSteps);+ const x = dishVertexX + (r * r) / f4 - 0.08;+ dishProfile.push([r, x]);+ }+ dishProfile.push([0.45, dishVertexX - 0.06]);++ const dishGeo = revolveGeo(dishProfile, { axis: [1, 0, 0], segments: 48 });+ createPart('ParabolicDish', dishGeo, dishWhiteMat, {+ parent: jointElevation,+ });++ createPart('VertexCone', coneXGeo(0.28, 0.28, 16), machineryDarkMat, {+ position: [dishVertexX + 0.14, 0, 0],+ parent: jointElevation,+ });++ // 16 radial panel seams on front face+ const numSeams = 16;+ for (let i = 0; i < numSeams; i++) {+ const ang = (i / numSeams) * Math.PI * 2;+ const cosA = Math.cos(ang);+ const sinA = Math.sin(ang);+ const p1 = [dishVertexX + 0.02, cosA * 0.32, sinA * 0.32];+ const p2 = [rimX + 0.01, cosA * (dishRadius - 0.02), sinA * (dishRadius - 0.02)];+ beamBetween(`DishSeam_${i}`, p1, p2, 0.012, machineryDarkMat, {+ segments: 5,+ parent: jointElevation,+ });+ }++ // ---------------------------------------------------------------------------+ // 5. BACK-UP STRUCTURE (BUS) SPACE FRAME TRUSS+ // ---------------------------------------------------------------------------+ const busHubR = 1.2;+ const busHubX = 0.45;+ const busMidR = 2.45;+ const busMidX = dishVertexX + (busMidR * busMidR) / f4 - 0.45;+ const busRimR = 3.65;+ const busRimX = dishVertexX + (busRimR * busRimR) / f4 - 0.25;++ for (let i = 0; i < numSeams; i++) {+ const ang = (i / numSeams) * Math.PI * 2;+ const cosA = Math.cos(ang);+ const sinA = Math.sin(ang);++ const nHub = [busHubX, cosA * busHubR, sinA * busHubR];+ const nMidFront = [dishVertexX + (busMidR * busMidR) / f4 - 0.08, cosA * busMidR, sinA * busMidR];+ const nRimFront = [dishVertexX + (busRimR * busRimR) / f4 - 0.08, cosA * busRimR, sinA * busRimR];+ const nMidRear = [busMidX, cosA * busMidR, sinA * busMidR];+ const nRimRear = [busRimX, cosA * busRimR, sinA * busRimR];++ beamBetween(`BusRearChordInner_${i}`, nHub, nMidRear, 0.055, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });+ beamBetween(`BusRearChordOuter_${i}`, nMidRear, nRimRear, 0.045, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });++ beamBetween(`BusFrontChordInner_${i}`, [dishVertexX + 0.05, cosA * busHubR, sinA * busHubR], nMidFront, 0.045, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });+ beamBetween(`BusFrontChordOuter_${i}`, nMidFront, nRimFront, 0.04, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });++ beamBetween(`BusWebMid_${i}`, nMidFront, nMidRear, 0.04, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });+ beamBetween(`BusWebRim_${i}`, nRimFront, nRimRear, 0.035, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });+ beamBetween(`BusWebDiagInner_${i}`, [dishVertexX + 0.05, cosA * busHubR, sinA * busHubR], nMidRear, 0.035, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });+ beamBetween(`BusWebDiagOuter_${i}`, nMidFront, nRimRear, 0.035, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });++ const nextAng = ((i + 1) / numSeams) * Math.PI * 2;+ const nextCos = Math.cos(nextAng);+ const nextSin = Math.sin(nextAng);+ const nextMidRear = [busMidX, nextCos * busMidR, nextSin * busMidR];+ const nextRimRear = [busRimX, nextCos * busRimR, nextSin * busRimR];++ beamBetween(`BusRingMid_${i}`, nMidRear, nextMidRear, 0.045, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });+ beamBetween(`BusRingRim_${i}`, nRimRear, nextRimRear, 0.04, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });+ }++ // ---------------------------------------------------------------------------+ // 6. SYMMETRICAL LATTICE FEED TRIPOD & APEX RECEIVER+ // ---------------------------------------------------------------------------+ const focalX = dishVertexX + 2.80;+ const feedApexX = focalX + 0.28;++ // 3 tripod legs: Top (0°), Bottom-Right (120°), Bottom-Left (240°)+ const tripodPhis = [0, (2 * Math.PI) / 3, (4 * Math.PI) / 3];+ const legRimR = 3.65;+ const legRimX = dishVertexX + (legRimR * legRimR) / f4;+ const apexR = 0.32;+ const numLacingBays = 6;++ tripodPhis.forEach((phi, legIdx) => {+ const tag = ['Top', 'BotR', 'BotL'][legIdx];+ const ry = Math.cos(phi);+ const rz = Math.sin(phi);+ const ty = -Math.sin(phi);+ const tz = Math.cos(phi);++ const chordSpreadBase = 0.28;+ const chordSpreadApex = 0.10;++ const pOuterBase = [+ legRimX,+ ry * legRimR + ty * chordSpreadBase,+ rz * legRimR + tz * chordSpreadBase,+ ];+ const pInnerBase = [+ legRimX,+ ry * legRimR - ty * chordSpreadBase,+ rz * legRimR - tz * chordSpreadBase,+ ];+ const pOuterApex = [+ feedApexX - 0.12,+ ry * apexR + ty * chordSpreadApex,+ rz * apexR + tz * chordSpreadApex,+ ];+ const pInnerApex = [+ feedApexX - 0.12,+ ry * apexR - ty * chordSpreadApex,+ rz * apexR - tz * chordSpreadApex,+ ];++ beamBetween(`LegChordOuter_${tag}`, pOuterBase, pOuterApex, 0.045, steelTrussMat, {+ segments: 8,+ parent: jointElevation,+ });+ beamBetween(`LegChordInner_${tag}`, pInnerBase, pInnerApex, 0.045, steelTrussMat, {+ segments: 8,+ parent: jointElevation,+ });++ createPart(`LegFoot_${tag}`, boxGeo(0.2, 0.2, 0.38), machineryDarkMat, {+ position: [legRimX - 0.04, ry * legRimR, rz * legRimR],+ rotation: [0, 0, (phi * 180) / Math.PI],+ parent: jointElevation,+ });++ for (let b = 0; b < numLacingBays; b++) {+ const t0 = b / numLacingBays;+ const t1 = (b + 1) / numLacingBays;++ const o0 = [+ pOuterBase[0] + (pOuterApex[0] - pOuterBase[0]) * t0,+ pOuterBase[1] + (pOuterApex[1] - pOuterBase[1]) * t0,+ pOuterBase[2] + (pOuterApex[2] - pOuterBase[2]) * t0,+ ];+ const i0 = [+ pInnerBase[0] + (pInnerApex[0] - pInnerBase[0]) * t0,+ pInnerBase[1] + (pInnerApex[1] - pInnerBase[1]) * t0,+ pInnerBase[2] + (pInnerApex[2] - pInnerBase[2]) * t0,+ ];+ const o1 = [+ pOuterBase[0] + (pOuterApex[0] - pOuterBase[0]) * t1,+ pOuterBase[1] + (pOuterApex[1] - pOuterBase[1]) * t1,+ pOuterBase[2] + (pOuterApex[2] - pOuterBase[2]) * t1,+ ];+ const i1 = [+ pInnerBase[0] + (pInnerApex[0] - pInnerBase[0]) * t1,+ pInnerBase[1] + (pInnerApex[1] - pInnerBase[1]) * t1,+ pInnerBase[2] + (pInnerApex[2] - pInnerBase[2]) * t1,+ ];++ beamBetween(`LegSpacer_${tag}_${b}`, o0, i0, 0.022, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });+ if (b % 2 === 0) {+ beamBetween(`LegDiag_${tag}_${b}`, o0, i1, 0.022, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });+ } else {+ beamBetween(`LegDiag_${tag}_${b}`, i0, o1, 0.022, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });+ }+ }++ // Subreflector apex mounting struts connecting hub to subreflector rim+ beamBetween(`SubrefStrut_${tag}`, [feedApexX - 0.1, ry * apexR, rz * apexR], [focalX + 0.05, ry * 0.45, rz * 0.45], 0.025, steelTrussMat, {+ segments: 6,+ parent: jointElevation,+ });+ });++ // Apex feed support collar+ createPart('ApexHubCollar', cylinderXGeo(0.48, 0.45, 0.25, 12), machineryDarkMat, {+ position: [feedApexX - 0.1, 0, 0],+ parent: jointElevation,+ });++ // Cassegrain Subreflector (hyperbolic dish facing backward -X)+ const subrefProfile = [+ [0.02, focalX - 0.04],+ [0.2, focalX - 0.03],+ [0.4, focalX],+ [0.48, focalX + 0.06],+ [0.5, focalX + 0.08],+ [0.48, focalX + 0.10],+ [0.2, focalX + 0.11],+ [0.02, focalX + 0.12],+ ];+ const subrefGeo = revolveGeo(subrefProfile, { axis: [1, 0, 0], segments: 32 });+ createPart('Subreflector', subrefGeo, dishWhiteMat, {+ parent: jointElevation,+ });++ // Cryogenic receiver dewar / electronics package behind subreflector+ createPart('ReceiverCanister', cylinderXGeo(0.28, 0.28, 0.45, 16), machineryDarkMat, {+ position: [focalX + 0.35, 0, 0],+ parent: jointElevation,+ });+ createPart('ReceiverEndCap', cylinderXGeo(0.3, 0.28, 0.08, 16), accentYellowMat, {+ position: [focalX + 0.60, 0, 0],+ parent: jointElevation,+ });++ // Gold primary feed horn at center of main dish+ createPart('FeedHornBase', cylinderXGeo(0.14, 0.14, 0.25, 16), machineryDarkMat, {+ position: [dishVertexX + 0.24, 0, 0],+ parent: jointElevation,+ });+ createPart('FeedHornCone', coneXGeo(0.24, 0.4, 16), goldMat, {+ position: [dishVertexX + 0.56, 0, 0],+ parent: jointElevation,+ });+ createPart('FeedHornFlare', torusGeo(0.24, 0.03, 8, 24), goldMat, {+ position: [dishVertexX + 0.76, 0, 0],+ rotation: [0, 90, 0],+ parent: jointElevation,+ });++ // 3 tension guy wires anchoring apex to dish rim+ tripodPhis.forEach((phi, idx) => {+ const ry = Math.cos(phi) * (dishRadius - 0.3);+ const rz = Math.sin(phi) * (dishRadius - 0.3);+ beamBetween(`GuyWire_${idx}`, [focalX, 0, 0], [legRimX - 0.1, ry, rz], 0.008, machineryDarkMat, {+ segments: 4,+ parent: jointElevation,+ });+ });++ return root;+}++function animate() {+ return [+ createClip('Scan', 8, [+ rotationTrack('Joint_Azimuth', [+ { time: 0, rotation: [0, 0, 0] },+ { time: 2, rotation: [0, 30, 0] },+ { time: 4, rotation: [0, 0, 0] },+ { time: 6, rotation: [0, -30, 0] },+ { time: 8, rotation: [0, 0, 0] },+ ]),+ rotationTrack('Joint_Elevation', [+ { time: 0, rotation: [0, 0, 10] },+ { time: 2, rotation: [0, 0, 35] },+ { time: 4, rotation: [0, 0, 60] },+ { time: 6, rotation: [0, 0, 35] },+ { time: 8, rotation: [0, 0, 10] },+ ]),+ ]),+ ];+}diff --git a/examples/rigid-airship.kiln.js b/examples/rigid-airship.kiln.jsnew file mode 100644index 00000000..714eab44--- /dev/null+++ b/examples/rigid-airship.kiln.js@@ -0,0 +1,112 @@+// Authored by: gpt-6-astra, via codex.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'RigidAirship', category: 'vehicle' };+// +X bow; closed fabric envelope. The grounded mooring mast supports the moored scene.+function build() {+ const root = createRoot('RigidAirship');+ const fabric = gameMaterial(0xaeb7b6,{roughness:0.83,flatShading:false});+ const seam = gameMaterial(0x8f9c9c,{roughness:0.85});+ const steel = gameMaterial(0x3c505b,{metalness:0.6,roughness:0.48});+ const silver = gameMaterial(0x94a2a7,{metalness:0.65,roughness:0.4});+ const paint = gameMaterial(0x234750,{roughness:0.68});+ const glass = gameMaterial(0x214653,{metalness:0.35,roughness:0.18});+ const wood = gameMaterial(0x604630,{roughness:0.65});+ let serial=0;+ function part(n,g,m,p,r=[0,0,0],sc=[1,1,1],parent=root){return createPart(n,g,m,{position:p,rotation:r,scale:sc,parent});}+ function beam(n,a,b,r,m=steel,parent=root){return beamBetween(n+'_'+serial++,a,b,r,m,{segments:4,parent});}+ const profile=[[0,-24],[0.65,-23],[1.9,-20],[3.6,-16],[4.6,-11],[5,-5],[5,3],[4.65,10],[3.65,17],[2,22],[0.65,23.7],[0,24]];+ function rad(x){+ for(let j=1;j<profile.length;j++)if(x<=profile[j][1]){+ const a=profile[j-1],b=profile[j];return a[0]+(b[0]-a[0])*(x-a[1])/(b[1]-a[1]);+ }return 0;+ }+ part('ClosedFabricEnvelope',lathe(profile,48),fabric,[0,16,0],[0,0,-90]);+ // Very shallow surface tapes; the complete opaque envelope remains underneath every tape.+ for(let x=-20;x<=22;x+=3){+ const p=[[-0.022,rad(x-0.022)+0.012],[0.022,rad(x+0.022)+0.012]];+ part('CoveredRingSeam_'+x,lathe(p.map(v=>[v[1],x+v[0]]),48),seam,[0,16,0],[0,0,-90]);+ }+ for(let k=0;k<12;k++){+ const t=k*Math.PI/6;+ const pts=profile.slice(1,-1).map(p=>[p[1],16+(p[0]+0.006)*Math.cos(t),(p[0]+0.006)*Math.sin(t)]);+ for(let j=1;j<pts.length;j++)beam('CoveredLongitudinalTape',pts[j-1],pts[j],0.016,seam);+ }+ for(const x of [-13,18]){+ part('PaintedRegistrationBand_'+x,lathe([[rad(x-0.28)+0.014,x-0.28],[rad(x+0.28)+0.014,x+0.28]],48),paint,[0,16,0],[0,0,-90]);+ }+ // Glazing is applied over the intact hull: no missing skin or cutaway.+ for(const s of [-1,1])for(let i=0;i<18;i++){+ const x=-8+i*1.12,z=s*(rad(x)+0.02);+ part('PromenadeWindowFrame_'+s+'_'+i,boxGeo(0.56,0.6,0.09),silver,[x,15.9,z]);+ part('PromenadeGlazing_'+s+'_'+i,boxGeo(0.43,0.46,0.025),glass,[x,15.9,z+s*0.055]);+ }+ const gondola=createPivot('ControlGondola',[12.4,11.3,0],root);+ part('BridgeLowerHull',sphereGeo(1,20,10),fabric,[0,-0.3,0],[0,0,0],[3,0.68,1.02],gondola);+ part('BridgeCabin',boxGeo(4.7,1.15,1.75),fabric,[0,0.08,0],[0,0,0],[1,1,1],gondola);+ part('BridgeCanopy',boxGeo(5.05,0.16,1.98),paint,[0,0.72,0],[0,0,0],[1,1,1],gondola);+ for(const s of [-1,1])for(let i=0;i<6;i++)+ part('BridgeSideGlass_'+s+'_'+i,boxGeo(0.57,0.66,0.05),glass,[-1.95+i*0.75,0.18,s*0.89],[0,0,0],[1,1,1],gondola);+ for(const s of [-1,1])part('BridgeForwardGlass_'+s,boxGeo(0.05,0.67,0.67),glass,[2.37,0.18,s*0.42],[0,0,0],[1,1,1],gondola);+ for(const s of [-1,1])for(const x of [-8,7]){+ const z=s*5.8,y=13.7,id=x+'_'+s;+ part('EngineCar_'+id,sphereGeo(1,16,8),fabric,[x,y,z],[0,0,0],[1.9,0.62,0.64]);+ beam('EngineFrontOutrigger',[x+0.8,14.4,s*4.3],[x+0.7,y,z],0.11);+ beam('EngineRearOutrigger',[x-0.9,14.4,s*4.3],[x-0.7,y,z],0.11);+ beam('EngineDiagonal',[x-1.2,14.9,s*4.2],[x+0.7,y,z],0.075);+ part('EngineIntake_'+id,cylinderXGeo(0.36,0.36,0.15,12),steel,[x+1.75,y,z]);+ part('PropellerHub_'+id,sphereGeo(0.25,12,8),silver,[x+2.06,y,z],[0,0,0],[1.6,1,1]);+ for(let k=0;k<3;k++){+ const a=k*120+20,t=a*Math.PI/180;+ part('TractorPropeller_'+id+'_'+k,sphereGeo(1,8,6),wood,[x+1.96,y+0.79*Math.cos(t),z+0.79*Math.sin(t)],[a,0,-12],[0.085,0.96,0.17]);+ }+ for(let i=0;i<4;i++)part('EngineVent_'+id+'_'+i,boxGeo(0.11,0.35,0.035),steel,[x-0.4+i*0.24,y,z+s*0.625]);+ beam('Exhaust',[x-0.5,y+0.42,z],[x-1.2,y+0.88,z],0.09);+ }+ // Closed tapered fin slabs with explicit shared trailing-edge coordinates.+ function finSlab(points,thickness){+ const v=[];for(const y of [-thickness/2,thickness/2])for(const p of points)v.push(p[0],y,p[1]);+ const g=new THREE.BufferGeometry();+ g.setAttribute('position',new THREE.Float32BufferAttribute(v,3));+ g.setIndex([0,2,1,0,3,2,4,5,6,4,6,7,0,1,5,0,5,4,1,2,6,1,6,5,2,3,7,2,7,6,3,0,4,3,4,7]);+ g.computeVertexNormals();return g;+ }+ for(let k=0;k<4;k++){+ const tail=createPivot('TailFinAssembly_'+k,[-18.3,16,0],root);+ tail.rotation.x=k*Math.PI/2;+ part('FabricFin_'+k,finSlab([[-3.7,0],[3.7,0],[0,6.35],[-2.5,6.35]],0.2),fabric,[0,0,0],[0,0,0],[1,1,1],tail);+ part('HingedTailSurface_'+k,finSlab([[-4.6,0],[-3.62,0],[-2.42,6.35],[-3.15,6.35]],0.14),paint,[0,0,0],[0,0,0],[1,1,1],tail);+ beam('TailHinge',[-3.7,0,0],[-2.5,0,6.35],0.045,silver,tail);+ const t=k*Math.PI/2;+ for(const s of [-1,1])beam('TautFinBrace',[-12,16-2.6*Math.sin(t)+s*3.3*Math.cos(t),2.6*Math.cos(t)-s*3.3*Math.sin(t)],[-19.2,16-5.8*Math.sin(t),5.8*Math.cos(t)],0.027,steel);+ }+ part('NoseReinforcementPlate',lathe([[0,24.17],[0.72,23.7],[0.84,23.52]],48),silver,[0,16,0],[0,0,-90]);+ part('BowCouplingSocket',cylinderXGeo(0.22,0.3,0.65,12),steel,[24.22,16,0]);+ const mast=createPivot('MooringMast',[26,0,0],root);+ const corners=[[-1,-1],[-1,1],[1,1],[1,-1]];+ function half(y){return 2-1.55*(y/16);}+ for(let c=0;c<4;c++){+ const [a,b]=corners[c];+ part('MastFoot_'+c,boxGeo(1.15,0.3,1.15),steel,[a*2,0.15,b*2],[0,0,0],[1,1,1],mast);+ beam('MastLeg',[a*2,0.3,b*2],[a*0.45,16,b*0.45],0.13,steel,mast);+ for(let j=0;j<6;j++){+ const y0=0.5+j*2.5,y1=y0+2.5,[d,e]=corners[(c+1)%4];+ beam('LatticeHorizontal',[a*half(y0),y0,b*half(y0)],[d*half(y0),y0,e*half(y0)],0.075,steel,mast);+ beam('LatticeDiagonalA',[a*half(y0),y0,b*half(y0)],[d*half(y1),y1,e*half(y1)],0.06,steel,mast);+ beam('LatticeDiagonalB',[d*half(y0),y0,e*half(y0)],[a*half(y1),y1,b*half(y1)],0.06,steel,mast);+ part('RivetedGusset_'+c+'_'+j,boxGeo(0.25,0.28,0.14),silver,[a*half(y0),y0,b*half(y0)],[0,0,0],[1,1,1],mast);+ for(const dy of [-0.075,0.075])part('MastRivet_'+c+'_'+j+'_'+dy,sphereGeo(0.044,6,2),steel,[a*half(y0),y0+dy,b*(half(y0)+0.08)],[0,0,0],[1,1,0.65],mast);+ }+ }+ part('MastHeadPlatform',boxGeo(1.45,0.22,1.45),steel,[0,15.8,0],[0,0,0],[1,1,1],mast);+ part('RotatingMastHead',cylinderYGeo(0.44,0.5,0.55,16),silver,[0,16.15,0],[0,0,0],[1,1,1],mast);+ beam('CouplingArm',[-1.65,16,0],[0,16.25,0],0.2,steel,mast);+ beam('CouplingArmBrace',[-1.65,16,0],[0,15.25,0],0.12,steel,mast);+ return root;+}diff --git a/examples/robot-arm.kiln.js b/examples/robot-arm.kiln.jsnew file mode 100644index 00000000..ae31f805--- /dev/null+++ b/examples/robot-arm.kiln.js@@ -0,0 +1,427 @@+// A six-axis industrial robot arm.+//+// Authored by: Claude Opus 5, via Claude Code. Every part below was written by+// the model itself, looking at its own renders through the Kiln tools and+// revising. Not a line of it is hand-authored.+//+// This is the ANIMATION example, and the reason it is an arm rather than+// something with one moving part is that a robot is the case where the rig is+// the asset. Six joints, each one hanging off the last, and the only thing the+// animation says is what angle each joint is at. Every position in the clip+// below falls out of that chain -- there is not one world-space coordinate in+// `animate()`, because there cannot be: the tool flange's position is whatever+// five joints upstream of it decided, and if a link length changes here the+// whole cycle still works.+//+// That is the difference between a rig and a set of moving parts. The beam+// engine this replaced solved its linkage numerically and then drove five parts+// with five separate answers; break one and the mechanism comes apart on+// screen. Here the parts cannot come apart, because none of them knows where it+// is.+//+// The chain, shoulder outward, is the standard 6R wrist-partitioned layout:+//+// J1 waist about Y the whole robot swings+// J2 shoulder about Z upper arm pitches+// J3 elbow about Z forearm pitches+// J4 roll about Y forearm rotates about its own axis+// J5 wrist about Z tool pitches+// J6 flange about Y tool rotates about its own axis+//+// Axes alternate perpendicular / parallel in exactly that pattern on every+// articulated arm ever built, because it is what puts three axes through one+// point at the wrist and makes the inverse kinematics solvable in closed form.+// Nothing here solves IK, but getting the axis assignment right is what makes+// the motion read as a robot instead of as a puppet.+//+// Proportions are off a mid-size floor-standing arm in the 1.5 m / 20 kg class+// -- a Fanuc M-20 or an ABB IRB 1600. The tell on those is not the arm, it is+// the COUNTERWEIGHT: a mass hung behind the shoulder so J2 is not fighting the+// whole arm at every angle. Robots that do not have it look like toys, and the+// first pass of this file did not have it and did.+//+// Verified by walking the clip and reading the tool flange's world position+// rather than by looking at it, because "the arm reaches down" is exactly the+// kind of claim a 3/4 render will let you get away with being wrong about. It+// was: the first pass's pick pose put the flange at y = 1.231 against a home of+// y = 1.088, so the robot reached UP to pick and the six-frame filmstrip looked+// entirely convincing doing it. Corrected, the cycle now reads+//+// home 1.088 -> pick 0.616 -> lift 1.214 -> traverse 1.251+// -> place 0.661 -> withdraw 1.214 -> home 1.088+//+// and returns to (1.109, 1.088, 0.135) at t = DUR, bit for bit the pose it+// started in, so the clip loops without a jump. All 8 tracks bind.+//+// Known limit: the dress pack is rigid. On a real arm the cable loop between+// the base and the upper arm flexes through the whole cycle, and doing that+// properly needs the conduit re-solved per keyframe. Everything that moves here+// is parented to exactly one link, so the loop lives on the forearm where one+// link's motion carries it honestly, and the base cable stops at the turret.+const meta = { name: 'RobotArm', category: 'prop', role: 'hero' };++// Link geometry. `animate()` poses the same chain `build()` assembled, so the+// numbers that define it live at module scope rather than inside either one.+const PLINTH_Y = 0.178; // top of the cast pedestal, where J1 sits+const SHOULDER = [0, 0.455, 0.135]; // J2, relative to J1+const L_UPPER = 0.72; // J2 to J3+const L_FORE = 0.60; // J3 to J5+const L_WRIST = 0.135; // J5 to the tool flange+const JAW_OPEN = 0.062; // jaw centres, fully open+const JAW_SHUT = 0.031;+const JAW_Y = 0.150; // jaw centres above the flange face++// The pose the asset is stored in, and the pose the cycle starts and ends at.+// Reaching forward and slightly down, elbow well bent -- a robot parked at any+// angle looks broken, and a robot standing straight up looks like a lamp post.+const HOME = { j1: 0, j2: -34, j3: -62, j4: 0, j5: -30, j6: 0 };++async function build() {+ const root = createRoot('RobotArm');+ const uv = (g) => autoUnwrap(g, { resolution: 1024 });+ const RAD = Math.PI / 180;++ // ---------- Materials ----------+ // The body enamel. A painted machine is a DIELECTRIC with a clearcoat: the+ // gloss comes from low roughness, not from metalness. Run an orange body at+ // metalness 0.8 and it stops being orange and starts being a mirror that+ // happens to be tinted, which is how a robot ends up looking like a toy made+ // of foil. Metalness stays at zero and the paint stays paint.+ const enamelAlbedo = proceduralTexture({+ schemaVersion: 2, size: 1024, usage: 'albedo', name: 'Enamel',+ layers: [+ { op: 'solid', color: 0xc4550f },+ { op: 'gradient', from: 0xd66a1c, to: 0x97400b, angleDeg: 90, blend: 'overlay', opacity: 0.42 },+ // Orange peel. Real machine enamel is sprayed, not poured, and the very+ // fine texture is most of what stops a large flat casting reading as+ // plastic under a hard light.+ { op: 'noise', colorA: 0xb24c0e, colorB: 0xd2601a, scale: 220, octaves: 4, seed: 7, blend: 'overlay', opacity: 0.28 },+ ],+ });+ const enamel = pbrMaterial({+ albedo: enamelAlbedo,+ normal: normalMapFromHeight(enamelAlbedo, { strength: 0.35 }),+ roughness: 0.43, metalness: 0.0,+ });++ // Machined aluminium: the joint housings, bearing covers and the flange. This+ // one IS metal, and it is the contrast that tells the reader which parts are+ // structure and which are skin.+ const alloyAlbedo = proceduralTexture({+ schemaVersion: 2, size: 512, usage: 'albedo', name: 'Alloy',+ layers: [+ { op: 'solid', color: 0x9aa0a6 },+ { op: 'noise', colorA: 0x848a90, colorB: 0xb2b8be, scale: 130, octaves: 4, seed: 19, blend: 'overlay', opacity: 0.35 },+ ],+ });+ const alloy = pbrMaterial({+ albedo: alloyAlbedo,+ normal: normalMapFromHeight(alloyAlbedo, { strength: 1.1 }),+ roughness: 0.44, metalness: 0.88,+ });++ const steel = gameMaterial(0x6f757b, { roughness: 0.32, metalness: 0.95 });+ // Rubber boots and cable. Dielectric, and rough enough that it never picks up+ // a highlight -- black plastic that shines reads as wet.+ const rubber = gameMaterial(0x232527, { roughness: 0.88, metalness: 0.0 });+ const chainMat = gameMaterial(0x33383d, { roughness: 0.62, metalness: 0.0 });+ const darkTrim = gameMaterial(0x2c2f33, { roughness: 0.55, metalness: 0.1 });+ const beacon = gameMaterial(0xffbe4d, {+ emissive: 0xff9b1a, emissiveIntensity: 2.4, roughness: 0.35,+ });++ // Hazard banding on the pedestal skirt. Real cells put it exactly here, at+ // the height a person walks into.+ const hazard = pbrMaterial({+ albedo: proceduralTexture({+ schemaVersion: 2, size: 512, usage: 'albedo', name: 'Hazard',+ layers: [+ { op: 'solid', color: 0xf0c419 },+ { op: 'stripes', colorA: 0xf0c419, colorB: 0x1b1c1e, count: 22, angleDeg: 52 },+ ],+ }),+ roughness: 0.55, metalness: 0.0,+ });++ const box = async (name, w, h, d, position, mat, opts = {}) =>+ createPart(name, await uv(await roundedBoxGeo(w, h, d, opts.r ?? 0.008), opts.res ?? 512), mat, {+ position, rotation: opts.rotation, parent: opts.parent ?? root,+ });+ const plain = (name, geo, mat, position, parent, rotation) =>+ createPart(name, geo, mat, { position, rotation, parent });++ // A ring of fasteners round a bearing cover. Every joint on a real arm has+ // one, and their absence is the single loudest thing about an untextured+ // robot: the housings look moulded rather than bolted.+ const boltCircle = (name, count, radius, z, mat, parent, y = 0) => {+ for (let i = 0; i < count; i++) {+ const a = (i / count) * Math.PI * 2;+ plain(`${name}_${i}`, cylinderZGeo(0.010, 0.010, 0.012, 6), mat,+ [Math.cos(a) * radius, y + Math.sin(a) * radius, z], parent);+ }+ };++ // ---------- Base ----------+ // Anchor plate, pedestal casting and the connector box, all static.+ await box('AnchorPlate', 0.56, 0.030, 0.56, [0, 0.015, 0], darkTrim, { r: 0.010 });+ for (const sx of [-1, 1]) {+ for (const sz of [-1, 1]) {+ plain(`Anchor_${sx}${sz}`, cylinderGeo(0.020, 0.020, 0.048, 6), steel,+ [sx * 0.235, 0.038, sz * 0.235], root);+ }+ }+ // The base is a SQUAT DRUM, not a taper. The first pass revolved a smooth+ // cone from the anchor plate to the turret and the whole machine read as a+ // traffic cone with an arm on it. A real base is nearly cylindrical, sits on+ // a cast flange, and gets its shape from ribs rather than from draft.+ createPart('Pedestal', await uv(await revolveProfile([+ [0.000, 0.026], [0.266, 0.026], [0.266, 0.050], [0.216, 0.074],+ [0.206, 0.092], [0.204, 0.178], [0.000, 0.178],+ ], { segments: 44, axis: 'y', smooth: true })), enamel, { position: [0, 0, 0], parent: root });+ // Cast ribs round the flange. Six of them, which is what carries the moment+ // out to the anchor bolts and what stops the drum reading as a bucket.+ for (let i = 0; i < 6; i++) {+ const a = (i / 6) * Math.PI * 2 + Math.PI / 6;+ await box(`BaseRib_${i}`, 0.090, 0.052, 0.026,+ [Math.cos(a) * 0.208, 0.052, Math.sin(a) * 0.208], enamel,+ { r: 0.008, res: 256, rotation: [0, -(a * 180) / Math.PI, 0] });+ }+ // Black skirt at the parting line. Two-tone at the base is the cheapest+ // value break on the whole machine and the one a photograph always shows.+ plain('BaseSkirt', cylinderGeo(0.270, 0.270, 0.026, 44), darkTrim, [0, 0.039, 0], root);+ plain('HazardBand', cylinderGeo(0.208, 0.208, 0.038, 44), hazard, [0, 0.126, 0], root);+ // Controller umbilical: connector panel on the back with cable glands, and+ // the trunk cable running out of frame the way it does in a real cell.+ await box('ConnectorBox', 0.16, 0.17, 0.26, [-0.212, 0.104, 0], darkTrim, { r: 0.014 });+ await box('ConnectorFace', 0.020, 0.13, 0.21, [-0.296, 0.104, 0], steel, { r: 0.005 });+ for (const cz of [-0.072, 0, 0.072]) {+ plain(`Gland_${cz.toFixed(2)}`, cylinderXGeo(0.028, 0.028, 0.062, 12), steel,+ [-0.312, 0.104, cz], root);+ plain(`GlandNut_${cz.toFixed(2)}`, cylinderXGeo(0.034, 0.034, 0.018, 6), alloy,+ [-0.322, 0.104, cz], root);+ }+ plain('Umbilical', capsuleXGeo(0.034, 0.22, 10), rubber, [-0.430, 0.104, 0], root);+ // Corrugation on the trunk, so it reads as flexible conduit and not as pipe.+ for (let i = 0; i < 9; i++) {+ plain(`UmbRib_${i}`, torusGeo(0.036, 0.006, 6, 14), rubber,+ [-0.348 - i * 0.024, 0.104, 0], root, [0, 90, 0]);+ }++ // ---------- J1: waist ----------+ const waist = createPivot('Waist', [0, PLINTH_Y, 0], root);+ // A DRUM, not a cone. The first two passes revolved a continuous taper from+ // the anchor plate to the shoulder, and the whole lower half read as a+ // traffic cone: the eye sees one uninterrupted draft angle and stops+ // believing there is a rotating joint anywhere in it. A real J1 housing is+ // near-cylindrical and the shape comes from the STEP where it meets the base.+ createPart('Turret', await uv(await revolveProfile([+ [0.000, 0.000], [0.198, 0.000], [0.198, 0.226], [0.190, 0.262],+ [0.164, 0.294], [0.000, 0.300],+ ], { segments: 44, axis: 'y', smooth: true })), enamel, { position: [0, 0, 0], parent: waist });+ // The J1 gearbox seam. A turret with no visible joint line looks turned from+ // one billet; the seam is what says it rotates.+ plain('WaistSeam', cylinderGeo(0.206, 0.206, 0.018, 44), darkTrim, [0, 0.006, 0], waist);+ // Cable riser up the back of the turret. It stops at the turret because that+ // is the last link it can be rigidly parented to without lying about how a+ // dress pack behaves across a joint.+ plain('Riser', capsuleGeo(0.030, 0.20, 10), rubber, [-0.176, 0.150, -0.058], waist, [0, 0, -4]);+ for (let i = 0; i < 7; i++) {+ plain(`RiserRib_${i}`, torusGeo(0.032, 0.005, 6, 12), rubber,+ [-0.178 + i * 0.0022, 0.062 + i * 0.030, -0.058], waist, [90, 0, 4]);+ }+ await box('RiserClamp', 0.048, 0.030, 0.052, [-0.174, 0.258, -0.058], alloy,+ { r: 0.006, parent: waist, res: 256 });+ // Shoulder yoke: the casting that carries J2 up and out to one side. The+ // offset is the whole reason a robot can fold its arm past its own base.+ await box('Yoke', 0.30, 0.30, 0.20, [0, 0.360, 0.020], enamel,+ { r: 0.045, parent: waist, res: 1024 });+ plain('YokeBoss', cylinderZGeo(0.118, 0.118, 0.110, 28), darkTrim, [0, 0.455, 0.008], waist);+ boltCircle('YokeBolt', 8, 0.086, 0.066, steel, waist, 0.455);+ // The step where the housing narrows into its top cap. Without a crisp ring+ // here the drum blends into the yoke and the turret reads as one blob.+ plain('TurretStep', cylinderGeo(0.202, 0.202, 0.012, 44), darkTrim, [0, 0.228, 0], waist);+ // Maker's plate. Blank, because proceduralTexture has no text op -- but a+ // machine with nowhere for a serial number to live looks like a render.+ await box('NamePlate', 0.004, 0.052, 0.100, [0.196, 0.150, 0.030], steel,+ { r: 0.001, parent: waist, res: 128 });+ plain('Beacon', sphereGeo(0.040, 14, 8), beacon, [-0.086, 0.318, -0.076], waist);+ plain('BeaconBase', cylinderGeo(0.034, 0.040, 0.030, 12), darkTrim, [-0.086, 0.296, -0.076], waist);++ // ---------- J2: upper arm ----------+ const shoulder = createPivot('Shoulder', SHOULDER, waist);+ shoulder.rotation.z = HOME.j2 * RAD;+ // The casting, as a side silhouette extruded across. An arm modelled as a box+ // reads as scaffolding; what makes it read as a casting is that the section+ // narrows toward the joint it has less load at.+ createPart('UpperArm', await uv(await extrudeProfile([+ [-0.165, -0.070], [0.150, -0.070], [0.132, 0.100], [0.106, 0.380],+ [0.086, L_UPPER], [-0.086, L_UPPER], [-0.106, 0.380], [-0.140, 0.100],+ ], { depth: 0.170, axis: 'z', bevel: 0.016 })), enamel, { position: [0, 0, 0], parent: shoulder });+ // Ribs. Two raised strips down the outer face, which is what a real casting+ // uses instead of thickness.+ for (const sz of [-1, 1]) {+ for (const rx of [-0.054, 0.054]) {+ await box(`ArmRib_${sz}_${rx.toFixed(3)}`, 0.034, 0.58, 0.016, [rx, 0.340, sz * 0.086], enamel,+ { r: 0.007, parent: shoulder, res: 256 });+ }+ }+ plain('ShoulderCover', cylinderZGeo(0.112, 0.112, 0.182, 28), alloy, [0, 0, 0], shoulder);+ boltCircle('ShoulderBolt', 8, 0.082, 0.094, steel, shoulder);+ // The counterweight. Without it the arm is a lever with nothing on the short+ // end and the machine reads as underbuilt -- but hung off the casting as a+ // separate dark brick, as the first pass had it, it reads as luggage. It is+ // part of the SAME casting: enamel body continuous with the arm, and only the+ // machined ballast plates on the back face are a different material.+ await box('CounterHousing', 0.20, 0.185, 0.176, [-0.168, -0.030, 0], enamel,+ { r: 0.026, parent: shoulder, res: 512 });+ for (const px of [-0.252, -0.268]) {+ await box(`Ballast_${px.toFixed(3)}`, 0.016, 0.150, 0.150, [px, -0.030, 0], steel,+ { r: 0.004, parent: shoulder, res: 256 });+ }+ plain('CounterBolt', cylinderXGeo(0.016, 0.016, 0.070, 8), alloy, [-0.282, -0.030, 0], shoulder);++ // ---------- J3: elbow, and J4: forearm roll ----------+ const elbow = createPivot('Elbow', [0, L_UPPER, 0], shoulder);+ elbow.rotation.z = HOME.j3 * RAD;+ plain('ElbowCover', cylinderZGeo(0.100, 0.100, 0.192, 28), darkTrim, [0, 0, 0], elbow);+ boltCircle('ElbowBolt', 8, 0.072, 0.098, steel, elbow);++ const roll = createPivot('Roll', [0, 0, 0], elbow);+ // The J4 barrel. It is a plain cylinder on purpose: a rotating section reads+ // as rotating only if it is a surface of revolution about its own axis, and+ // any feature on it that is not would give the roll away as a cheat.+ plain('RollBarrel', cylinderGeo(0.092, 0.092, 0.180, 28), darkTrim, [0, 0.075, 0], roll);+ plain('RollCollar', cylinderGeo(0.100, 0.100, 0.022, 24), darkTrim, [0, 0.164, 0], roll);+ createPart('ForearmA', await uv(await extrudeProfile([+ [-0.128, 0.170], [0.128, 0.170], [0.116, 0.250], [0.100, 0.360],+ [-0.100, 0.360], [-0.116, 0.250],+ ], { depth: 0.152, axis: 'z', bevel: 0.014 })), enamel, { position: [0, 0, 0], parent: roll });+ createPart('ForearmB', await uv(await extrudeProfile([+ [-0.100, 0.352], [0.100, 0.352], [0.078, 0.480], [0.070, L_FORE],+ [-0.070, L_FORE], [-0.078, 0.480],+ ], { depth: 0.104, axis: 'z', bevel: 0.012 })), enamel, { position: [0, 0, 0], parent: roll });+ for (const sz of [-1, 1]) {+ await box(`ForeRib_${sz}`, 0.026, 0.185, 0.014, [-0.040, 0.262, sz * 0.076], enamel,+ { r: 0.005, parent: roll, res: 256 });+ await box(`ForeRib2_${sz}`, 0.022, 0.210, 0.012, [-0.030, 0.470, sz * 0.052], enamel,+ { r: 0.004, parent: roll, res: 256 });+ }+ // Dress pack: an energy chain clipped along the top of the forearm. Sixteen+ // discrete links rather than a tube, because the thing that makes a cable+ // carrier recognisable is that it is made of repeated rigid links.+ for (let i = 0; i < 16; i++) {+ const f = i / 15;+ const y = 0.190 + f * 0.400;+ const x = 0.118 + Math.sin(f * Math.PI) * 0.022;+ await box(`Chain_${i}`, 0.044, 0.026, 0.070, [x, y, -0.020], chainMat,+ { r: 0.005, parent: roll, res: 256, rotation: [0, 0, -6] });+ }+ plain('ChainAnchor', cylinderZGeo(0.026, 0.026, 0.086, 10), darkTrim, [0.124, 0.180, -0.020], roll);++ // ---------- J5: wrist, J6: flange ----------+ const wrist = createPivot('Wrist', [0, L_FORE, 0], roll);+ wrist.rotation.z = HOME.j5 * RAD;+ await box('WristHousing', 0.142, 0.150, 0.128, [0, 0.028, 0], alloy,+ { r: 0.022, parent: wrist, res: 512 });+ for (const sz of [-1, 1]) {+ plain(`WristBoss_${sz > 0 ? 'R' : 'L'}`, cylinderZGeo(0.058, 0.058, 0.024, 20), alloy,+ [0, 0, sz * 0.062], wrist);+ }+ plain('WristBoot', cylinderGeo(0.062, 0.070, 0.040, 20), rubber, [0, 0.108, 0], wrist);++ const flange = createPivot('Flange', [0, L_WRIST, 0], wrist);+ plain('Flange', cylinderGeo(0.056, 0.056, 0.020, 24), steel, [0, 0.010, 0], flange);+ for (let i = 0; i < 6; i++) {+ const a = (i / 6) * Math.PI * 2;+ plain(`FlangeBolt_${i}`, cylinderGeo(0.007, 0.007, 0.026, 6), darkTrim,+ [Math.cos(a) * 0.040, 0.014, Math.sin(a) * 0.040], flange);+ }+ // Tool: a two-finger parallel gripper. In a hero shot the eye lands on the+ // end of the arm and stops there, so the tool carries proportionally more+ // detail than anything else on the machine. The first pass gave it a 98 mm+ // body and it read as a stub -- a real gripper on a 20 kg arm is a fist-sized+ // block with a visible actuator, hoses and hard-anodised fingers.+ plain('ToolChanger', cylinderGeo(0.052, 0.052, 0.046, 24), alloy, [0, 0.043, 0], flange);+ plain('ToolCollar', cylinderGeo(0.058, 0.058, 0.012, 24), steel, [0, 0.062, 0], flange);+ await box('GripperBody', 0.116, 0.092, 0.168, [0, 0.116, 0], alloy,+ { r: 0.014, parent: flange, res: 512 });+ // Pneumatic actuator across the back of the body, and the two hoses that+ // drive it. Fittings are what stop a gripper reading as a moulded blob.+ plain('GripCyl', cylinderZGeo(0.030, 0.030, 0.150, 20), darkTrim, [-0.052, 0.116, 0], flange);+ for (const sz of [-1, 1]) {+ plain(`GripFitting_${sz > 0 ? 'R' : 'L'}`, cylinderZGeo(0.010, 0.010, 0.026, 8), steel,+ [-0.052, 0.116, sz * 0.086], flange);+ plain(`GripHose_${sz > 0 ? 'R' : 'L'}`, capsuleXGeo(0.008, 0.075, 6), rubber,+ [-0.086, 0.086, sz * 0.086], flange, [0, 0, 42]);+ }+ // Sensor block: the little inductive switch that tells the cell the jaws+ // closed. Small, and the kind of thing only present when someone looked.+ await box('GripSensor', 0.024, 0.030, 0.036, [0.062, 0.140, 0.052], darkTrim,+ { r: 0.004, parent: flange, res: 256 });+ plain('GripLed', sphereGeo(0.008, 8, 6), beacon, [0.072, 0.152, 0.052], flange);+ plain('GripRail', cylinderZGeo(0.012, 0.012, 0.172, 14), steel, [0.034, 0.164, 0], flange);+ plain('GripRail2', cylinderZGeo(0.012, 0.012, 0.172, 14), steel, [-0.030, 0.164, 0], flange);++ for (const [nm, sz] of [['JawA', 1], ['JawB', -1]]) {+ const jaw = createPivot(nm, [0, JAW_Y, sz * JAW_OPEN], flange);+ await box(`${nm}_Carriage`, 0.092, 0.052, 0.044, [0, 0.008, 0], alloy,+ { r: 0.007, parent: jaw });+ await box(`${nm}_Finger`, 0.058, 0.112, 0.028, [0, 0.086, sz * -0.008], darkTrim,+ { r: 0.006, parent: jaw });+ // Stepped jaw. A flat finger grips nothing; the step is the part that+ // actually locates a workpiece, and it is the silhouette that says so.+ await box(`${nm}_Step`, 0.040, 0.034, 0.020, [0.006, 0.128, sz * -0.024], darkTrim,+ { r: 0.004, parent: jaw, res: 256 });+ await box(`${nm}_Pad`, 0.044, 0.070, 0.008, [0, 0.078, sz * -0.026], rubber,+ { r: 0.003, parent: jaw, res: 256 });+ }++ return root;+}++// The cycle: pick left, traverse right, place, come home. Written as joint+// angles at times, which is the only thing a rig should ever be given -- the+// tool never appears in this function, because where the tool goes is an+// OUTPUT of the chain, not an input to it. Which is also why the poses below+// have to be checked by reading the flange back out of the posed scene: you+// cannot tell from a column of angles whether the arm is reaching down.+function animate() {+ const DUR = 7.2;++ // Each row is one pose of the whole arm. Reading down a column shows one+ // joint's motion; reading across a row shows the robot at one instant, which+ // is the view that catches a pose that collides with the machine's own base.+ // t j1 j2 j3 j4 j5 j6 jaw+ const POSE = [+ [0.00, HOME.j1, HOME.j2, HOME.j3, HOME.j4, HOME.j5, HOME.j6, JAW_OPEN],+ [0.80, -52, -38, -56, 0, -28, -20, JAW_OPEN], // swing over the pick, arm high+ [1.45, -52, -46, -84, 0, -36, -20, JAW_OPEN], // descend onto it+ [1.90, -52, -46, -84, 0, -36, -20, JAW_SHUT], // close+ [2.55, -52, -30, -58, 0, -30, -20, JAW_SHUT], // lift clear+ [3.60, 46, -32, -56, 74, -28, 40, JAW_SHUT], // traverse, rolling the part over+ [4.35, 46, -46, -84, 74, -36, 40, JAW_SHUT], // set down+ [4.80, 46, -46, -84, 74, -36, 40, JAW_OPEN], // release+ [5.45, 46, -30, -58, 74, -30, 40, JAW_OPEN], // withdraw+ [6.50, 8, -34, -60, 12, -30, 6, JAW_OPEN], // sweep back+ [DUR, HOME.j1, HOME.j2, HOME.j3, HOME.j4, HOME.j5, HOME.j6, JAW_OPEN],+ ];++ const at = (col, axis) => POSE.map((p) => ({+ time: p[0],+ rotation: axis === 'y' ? [0, p[col], 0] : [0, 0, p[col]],+ }));++ return [createClip('PickAndPlace', DUR, [+ rotationTrack('Joint_Waist', at(1, 'y')),+ rotationTrack('Joint_Shoulder', at(2, 'z')),+ rotationTrack('Joint_Elbow', at(3, 'z')),+ rotationTrack('Joint_Roll', at(4, 'y')),+ rotationTrack('Joint_Wrist', at(5, 'z')),+ rotationTrack('Joint_Flange', at(6, 'y')),+ // The jaws are the one thing driven by position rather than angle, and the+ // track carries the FULL local position, not an offset from where the pivot+ // was created -- a position track replaces the pivot's transform outright.+ positionTrack('Joint_JawA', POSE.map((p) => ({ time: p[0], position: [0, JAW_Y, p[7]] }))),+ positionTrack('Joint_JawB', POSE.map((p) => ({ time: p[0], position: [0, JAW_Y, -p[7]] }))),+ ])];+}diff --git a/examples/steam-locomotive.kiln.js b/examples/steam-locomotive.kiln.jsnew file mode 100644index 00000000..ded926bc--- /dev/null+++ b/examples/steam-locomotive.kiln.js@@ -0,0 +1,422 @@+// Authored by: opencode-go/muse-spark-1.3-contributor, via opencode.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.+//+// Refined later, in this repository, with `kiln_edit`: the cab roof was cut+// back to a real eave and lifted off near-black, having read from above as a+// slab wider than the boiler.+// The attribution above is for the authoring run, which had none of this in+// scope. Both passes went through the same tools; only the second one could+// see the gallery it was going into.++const meta = { name: 'SteamLocomotive', category: 'prop' };++async function build() {+ const root = createRoot('SteamLocomotive');++ // ---------- materials ----------+ const black = gameMaterial(0x18191c, { roughness: 0.55, metalness: 0.45 });+ const boilerGreen = gameMaterial(0x1d3a2a, { roughness: 0.5, metalness: 0.35 });+ const smokebox = gameMaterial(0x232326, { roughness: 0.7, metalness: 0.3 });+ const steel = gameMaterial(0x9aa0a8, { roughness: 0.32, metalness: 0.9 });+ const darkSteel = gameMaterial(0x4a4e55, { roughness: 0.5, metalness: 0.8 });+ const rodSteel = gameMaterial(0xb9bec6, { roughness: 0.28, metalness: 0.92 });+ const brass = gameMaterial(0xc09a3e, { roughness: 0.3, metalness: 0.95 });+ const copper = gameMaterial(0x8e4a2f, { roughness: 0.4, metalness: 0.9 });+ const cabRed = gameMaterial(0x6e1f1f, { roughness: 0.6, metalness: 0.2 });+ const beamRed = gameMaterial(0x8c2323, { roughness: 0.62, metalness: 0.15 });+ // Slate rather than 0x101011. The cab roof is the largest unbroken surface+ // on the locomotive and the only one seen from directly above; at near-black+ // it returned nothing at all and read from the top view as a hole cut in the+ // engine.+ const roofBlack = gameMaterial(0x2b2c30, { roughness: 0.8, metalness: 0.2 });+ const glass = glassMaterial(0x9fc4d8, { opacity: 0.45, roughness: 0.15, metalness: 0.1 });+ const lampLens = gameMaterial(0xffe9b0, { emissive: 0xffc861, emissiveIntensity: 0.9, roughness: 0.4 });+ const whitewall = gameMaterial(0xd8d5cc, { roughness: 0.7 });+ const tireMat = gameMaterial(0x2c2e33, { roughness: 0.45, metalness: 0.7 });++ const Xd = [0.6, -0.75, -2.1]; // 3 driving axles (4-6-2: 3 drivers)+ const Yd = 0.82, crankR = 0.38; // tire outer 0.82 -> tread touches Y=0+ const Zdriver = 0.78;+ const ponyX = [2.5, 3.35], ponyY = 0.41, Zpony = 0.7; // leading truck (4 wheels)+ const trailX = -3.35, trailY = 0.41; // trailing truck (2 wheels)+ const cabW = 2.3, floorY = 1.6;++ // ---------- frames ----------+ for (const s of [1, -1]) {+ createPart('FrameSide_' + s, boxGeo(8.6, 0.34, 0.12), cabRed,+ { position: [0.3, 1.02, s * 0.62], parent: root });+ createPart('Footplate_' + s, boxGeo(8.9, 0.07, 0.5), black,+ { position: [0.35, 1.56, s * 0.95], parent: root });+ createPart('Valance_' + s, boxGeo(8.9, 0.16, 0.04), boilerGreen,+ { position: [0.35, 1.45, s * 1.19], parent: root });+ }+ createPart('BufferBeam', boxGeo(0.22, 0.4, 2.3), beamRed,+ { position: [4.5, 1.15, 0], parent: root });+ createPart('RearBeam', boxGeo(0.22, 0.4, 2.3), beamRed,+ { position: [-4.0, 1.15, 0], parent: root });+ createPart('PilotDeck', boxGeo(1.0, 0.08, 2.0), darkSteel,+ { position: [4.15, 1.5, 0], parent: root });+ for (const x of Xd) {+ createPart('Axle_' + x, cylinderZGeo(0.09, 0.09, 1.7, 12), darkSteel,+ { position: [x, Yd, 0], parent: root });+ for (const s of [1, -1]) {+ createPart('Axlebox_' + x + '_' + s, boxGeo(0.34, 0.3, 0.2), darkSteel,+ { position: [x, Yd, s * 0.62], parent: root });+ createPart('LeafSpring_' + x + '_' + s, boxGeo(0.7, 0.09, 0.1), steel,+ { position: [x, 1.28, s * 0.62], parent: root });+ createPart('SpringHanger_' + x + '_' + s, boxGeo(0.06, 0.18, 0.06), darkSteel,+ { position: [x + 0.3, 1.15, s * 0.62], parent: root });+ }+ }++ // ---------- boiler ----------+ createPart('BoilerBarrel', cylinderXGeo(0.85, 0.85, 5.0, 28), boilerGreen,+ { position: [0.75, 2.15, 0], parent: root });+ createPart('Smokebox', cylinderXGeo(0.88, 0.88, 0.85, 28), smokebox,+ { position: [3.65, 2.15, 0], parent: root });+ createPart('SmokeboxDoor', sphereGeo(0.88, 24, 8), smokebox,+ { position: [4.07, 2.15, 0], scale: [0.28, 1, 1], parent: root });+ createPart('DoorRim', torusGeo(0.68, 0.045, 8, 28), darkSteel,+ { position: [4.28, 2.15, 0], rotation: [0, 90, 0], parent: root });+ createPart('DoorDart', cylinderXGeo(0.05, 0.05, 0.35, 10), steel,+ { position: [4.35, 2.15, 0], parent: root });+ createPart('DartHandle', torusGeo(0.12, 0.025, 6, 14), steel,+ { position: [4.5, 2.15, 0], rotation: [0, 90, 0], parent: root });+ for (const bx of [-1.2, -0.3, 0.6, 1.5, 2.4]) {+ createPart('BoilerBand_' + bx, torusGeo(0.86, 0.028, 8, 36), brass,+ { position: [bx, 2.15, 0], rotation: [0, 90, 0], parent: root });+ }+ createPart('Firebox', boxGeo(1.3, 1.5, 1.9), boilerGreen,+ { position: [-2.2, 2.0, 0], parent: root });+ createPart('FireboxThroat', cylinderXGeo(0.7, 0.85, 0.6, 20), boilerGreen,+ { position: [-1.85, 2.1, 0], parent: root });+ for (const wx of [-2.5, -2.1, -1.7]) {+ for (const s of [1, -1]) {+ createPart('Washout_' + wx + '_' + s, cylinderZGeo(0.05, 0.05, 0.06, 8), brass,+ { position: [wx, 1.7, s * 0.96], parent: root });+ }+ }++ // ---------- stack / domes / top furniture ----------+ createPart('StackBase', taperConeGeo(0.42, 0.26, 0.35, 'y', 20), black,+ { position: [3.55, 3.0, 0], parent: root });+ createPart('StackBarrel', cylinderGeo(0.24, 0.28, 0.75, 20), black,+ { position: [3.55, 3.5, 0], parent: root });+ createPart('StackFlare', taperConeGeo(0.24, 0.4, 0.35, 'y', 20), black,+ { position: [3.55, 4.02, 0], parent: root });+ createPart('StackRim', torusGeo(0.39, 0.035, 8, 24), copper,+ { position: [3.55, 4.2, 0], rotation: [90, 0, 0], parent: root });+ createPart('SteamDomeBase', cylinderGeo(0.42, 0.48, 0.25, 20), copper,+ { position: [0.9, 2.95, 0], parent: root });+ createPart('SteamDome', sphereGeo(0.42, 20, 12), brass,+ { position: [0.9, 3.1, 0], scale: [1, 0.95, 1], parent: root });+ createPart('SandDomeBase', cylinderGeo(0.36, 0.42, 0.22, 20), brass,+ { position: [1.85, 2.92, 0], parent: root });+ createPart('SandDome', sphereGeo(0.36, 20, 12), copper,+ { position: [1.85, 3.05, 0], scale: [1, 0.9, 1], parent: root });+ createPart('SandPipeL', cylinderGeo(0.03, 0.03, 1.1, 8), darkSteel,+ { position: [1.95, 2.3, 0.8], parent: root });+ createPart('SandPipeR', cylinderGeo(0.03, 0.03, 1.1, 8), darkSteel,+ { position: [1.95, 2.3, -0.8], parent: root });+ createPart('Whistle', cylinderGeo(0.05, 0.05, 0.4, 10), brass,+ { position: [-1.3, 3.15, 0.25], parent: root });+ createPart('WhistleBell', sphereGeo(0.06, 10, 6), brass,+ { position: [-1.3, 3.36, 0.25], parent: root });+ createPart('SafetyValve', cylinderGeo(0.09, 0.11, 0.22, 12), brass,+ { position: [-0.6, 3.0, 0], parent: root });+ createPart('BellYokeA', boxGeo(0.06, 0.3, 0.06), darkSteel,+ { position: [2.5, 3.15, 0.14], parent: root });+ createPart('BellYokeB', boxGeo(0.06, 0.3, 0.06), darkSteel,+ { position: [2.5, 3.15, -0.14], parent: root });+ createPart('Bell', coneGeo(0.16, 0.28, 16), brass,+ { position: [2.5, 3.15, 0], parent: root });+ createPart('Generator', cylinderXGeo(0.09, 0.09, 0.35, 12), darkSteel,+ { position: [2.9, 2.95, 0.35], parent: root });+ createPart('AirPump', cylinderGeo(0.22, 0.22, 0.55, 16), black,+ { position: [3.3, 1.9, -0.95], parent: root });+ createPart('AirReservoir', cylinderXGeo(0.3, 0.3, 1.6, 16), black,+ { position: [0.2, 1.35, 0.0], parent: root });+ // exhaust saddle (cylinders -> smokebox), ashpan, injector plumbing+ createPart('Saddle', boxGeo(0.75, 0.55, 1.5), smokebox,+ { position: [3.35, 1.35, 0], parent: root });+ createPart('Ashpan', boxGeo(1.1, 0.45, 1.2), black,+ { position: [-2.2, 1.05, 0], parent: root });+ for (const s of [1, -1]) {+ beamBetween('InjectorFeed_' + s, [-1.9, 1.35, s * 0.7], [2.2, 1.05, s * 0.95], 0.03, copper, { parent: root });+ beamBetween('InjectorDelivery_' + s, [-1.9, 1.2, s * 0.7], [1.2, 1.0, s * 0.9], 0.025, steel, { parent: root });+ }+ // brake shoes + hangers at every driver (static rigging)+ for (const x of Xd) {+ for (const s of [1, -1]) {+ createPart('BrakeShoe_' + x + '_' + s, boxGeo(0.12, 0.32, 0.1), darkSteel,+ { position: [x + 0.76, 0.47, s * 0.78], rotation: [0, 0, -25], parent: root });+ createPart('BrakeHanger_' + x + '_' + s, boxGeo(0.06, 0.7, 0.06), darkSteel,+ { position: [x + 0.76, 0.85, s * 0.66], parent: root });+ }+ }++ // handrails along boiler+ for (const s of [1, -1]) {+ beamBetween('Handrail_' + s, [-1.6, 2.55, s * 0.88], [3.2, 2.55, s * 0.9], 0.02, steel, { parent: root });+ for (const hx of [-1.0, 0.2, 1.4, 2.6]) {+ createPart('Stanchion_' + hx + '_' + s, cylinderGeo(0.015, 0.015, 0.35, 6), steel,+ { position: [hx, 2.42, s * 0.86], parent: root });+ }+ }++ // ---------- cylinders + crosshead guides (static) ----------+ for (const s of [1, -1]) {+ createPart('Cylinder_' + s, cylinderXGeo(0.32, 0.32, 1.0, 18), darkSteel,+ { position: [2.7, 0.95, s * 1.0], parent: root });+ createPart('CylinderCapF_' + s, cylinderXGeo(0.34, 0.34, 0.1, 18), steel,+ { position: [3.22, 0.95, s * 1.0], parent: root });+ createPart('CylinderCapR_' + s, cylinderXGeo(0.34, 0.34, 0.1, 18), steel,+ { position: [2.18, 0.95, s * 1.0], parent: root });+ createPart('GuideBarTop_' + s, boxGeo(1.5, 0.06, 0.08), steel,+ { position: [1.45, 1.12, s * 1.0], parent: root });+ createPart('GuideBarBot_' + s, boxGeo(1.5, 0.06, 0.08), steel,+ { position: [1.45, 0.78, s * 1.0], parent: root });+ createPart('ValveChest_' + s, cylinderXGeo(0.16, 0.16, 0.9, 12), darkSteel,+ { position: [2.7, 1.38, s * 1.0], parent: root });+ }++ // ---------- driving wheels on real pivots (spoked + counterweight + crank) ----------+ const tireGeo = torusGeo(0.72, 0.1, 10, 30);+ const hubGeo = cylinderZGeo(0.15, 0.15, 0.2, 14);+ const spokeGeo = boxGeo(0.62, 0.1, 0.07);+ for (let i = 0; i < Xd.length; i++) {+ for (const s of [1, -1]) {+ const side = s > 0 ? 'R' : 'L';+ const j = createPivot('Driver' + (i + 1) + side, [Xd[i], Yd, s * Zdriver], root);+ createPart('Tire_D' + i + side, tireGeo, tireMat, { position: [0, 0, 0], parent: j });+ createPart('Hub_D' + i + side, hubGeo, darkSteel, { position: [0, 0, 0], parent: j });+ for (let k = 0; k < 12; k++) {+ const a = k * 30, rad = a * Math.PI / 180;+ createPart('Spoke_D' + i + side + '_' + k, spokeGeo, darkSteel,+ { position: [Math.cos(rad) * 0.42, Math.sin(rad) * 0.42, 0], rotation: [0, 0, a], parent: j });+ }+ createPart('Counterweight_D' + i + side, boxGeo(0.34, 0.5, 0.09), darkSteel,+ { position: [-0.42, 0, 0], parent: j });+ createPart('CounterweightTop_D' + i + side, boxGeo(0.5, 0.24, 0.09), darkSteel,+ { position: [-0.3, 0.28, 0], rotation: [0, 0, 25], parent: j });+ createPart('CrankPin_D' + i + side, cylinderZGeo(0.055, 0.055, 0.3, 10), rodSteel,+ { position: [crankR, 0, s * 0.16], parent: j });+ }+ }++ // ---------- pony + trailing truck wheels on pivots ----------+ const ponyTire = torusGeo(0.34, 0.07, 8, 22);+ const ponyDisc = cylinderZGeo(0.34, 0.34, 0.07, 20);+ const ponyHub = cylinderZGeo(0.09, 0.09, 0.16, 10);+ let pi = 0;+ for (const x of ponyX) for (const s of [1, -1]) {+ pi++;+ const j = createPivot('Pony' + pi, [x, ponyY, s * Zpony], root);+ createPart('PonyTire_' + pi, ponyTire, tireMat, { position: [0, 0, 0], parent: j });+ createPart('PonyDisc_' + pi, ponyDisc, darkSteel, { position: [0, 0, 0], parent: j });+ createPart('PonyHub_' + pi, ponyHub, steel, { position: [0, 0, 0], parent: j });+ }+ let ti = 0;+ for (const s of [1, -1]) {+ ti++;+ const j = createPivot('Trail' + ti, [trailX, trailY, s * Zpony], root);+ createPart('TrailTire_' + ti, ponyTire, tireMat, { position: [0, 0, 0], parent: j });+ createPart('TrailDisc_' + ti, ponyDisc, darkSteel, { position: [0, 0, 0], parent: j });+ createPart('TrailHub_' + ti, ponyHub, steel, { position: [0, 0, 0], parent: j });+ }+ createPart('PonyFrame', boxGeo(1.8, 0.22, 1.5), darkSteel, { position: [2.92, 0.72, 0], parent: root });+ createPart('TrailFrame', boxGeo(1.0, 0.22, 1.5), darkSteel, { position: [-3.35, 0.72, 0], parent: root });++ // ---------- coupling rods on pivots (orbit with crank circle) ----------+ for (const s of [1, -1]) {+ const side = s > 0 ? 'R' : 'L';+ const j = createPivot('Couple' + side, [-0.75, Yd, s * (Zdriver + 0.24)], root);+ createPart('CoupleBar_' + side, boxGeo(3.5, 0.15, 0.07), rodSteel, { position: [0, 0, 0], parent: j });+ for (const x of Xd) {+ createPart('RodBoss_' + side + '_' + x, cylinderZGeo(0.11, 0.11, 0.1, 12), rodSteel,+ { position: [x + 0.75, 0, 0], parent: j });+ }+ }++ // ---------- crossheads + main rods + valve stems on pivots ----------+ for (const s of [1, -1]) {+ const side = s > 0 ? 'R' : 'L';+ const jc = createPivot('Crosshead' + side, [1.45, 0.95, s * 1.0], root);+ createPart('CrossheadBlock_' + side, boxGeo(0.3, 0.22, 0.14), steel, { position: [0, 0, 0], parent: jc });+ createPart('PistonRod_' + side, cylinderXGeo(0.035, 0.035, 1.1, 8), rodSteel, { position: [0.7, 0, 0], parent: jc });+ createPart('CrossheadShoe_' + side, boxGeo(0.34, 0.06, 0.2), darkSteel, { position: [0, 0.11, 0], parent: jc });+ const jm = createPivot('MainRod' + side, [1.0, 0.9, s * (Zdriver + 0.24)], root);+ createPart('MainRodBar_' + side, boxGeo(1.9, 0.13, 0.06), rodSteel, { position: [0, 0, 0], parent: jm });+ createPart('MainRodBigEnd_' + side, cylinderZGeo(0.14, 0.14, 0.09, 14), rodSteel, { position: [-0.02, -0.08, 0], parent: jm });+ createPart('MainRodSmallEnd_' + side, cylinderZGeo(0.09, 0.09, 0.09, 12), rodSteel, { position: [0.45, 0.05, 0], parent: jm });+ createPart('EccentricRod_' + side, boxGeo(1.17, 0.07, 0.05), rodSteel, { position: [0.49, 0.2, 0], rotation: [0, 0, 28.7], parent: jm });+ const jv = createPivot('Valve' + side, [2.2, 1.38, s * 1.0], root);+ createPart('ValveStem_' + side, cylinderXGeo(0.03, 0.03, 1.2, 8), rodSteel, { position: [0, 0, 0], parent: jv });+ createPart('ValveBob_' + side, sphereGeo(0.05, 8, 6), rodSteel, { position: [0.6, 0, 0], parent: jv });+ }++ // ---------- cab ----------+ createPart('CabFloor', boxGeo(2.1, 0.1, cabW), darkSteel, { position: [-3.0, floorY, 0], parent: root });+ for (const s of [1, -1]) {+ createPart('CabSideLow_' + s, boxGeo(2.0, 1.0, 0.08), boilerGreen, { position: [-3.0, 2.15, s * 1.11], parent: root });+ createPart('CabPillarF_' + s, boxGeo(0.28, 0.75, 0.08), boilerGreen, { position: [-2.15, 3.0, s * 1.11], parent: root });+ createPart('CabPillarR_' + s, boxGeo(0.28, 0.75, 0.08), boilerGreen, { position: [-3.85, 3.0, s * 1.11], parent: root });+ createPart('CabTopRail_' + s, boxGeo(2.0, 0.22, 0.08), boilerGreen, { position: [-3.0, 3.5, s * 1.11], parent: root });+ createPart('CabGlass_' + s, boxGeo(1.44, 0.62, 0.02), glass, { position: [-3.0, 3.0, s * 1.11], parent: root });+ createPart('CabTrimLow_' + s, boxGeo(2.0, 0.08, 0.1), cabRed, { position: [-3.0, 2.68, s * 1.11], parent: root });+ }+ createPart('CabFrontLow', boxGeo(0.08, 1.0, cabW), boilerGreen, { position: [-2.0, 2.15, 0], parent: root });+ createPart('CabFrontMidL', boxGeo(0.08, 0.8, 0.62), boilerGreen, { position: [-2.0, 3.0, 0.72], parent: root });+ createPart('CabFrontMidR', boxGeo(0.08, 0.8, 0.62), boilerGreen, { position: [-2.0, 3.0, -0.72], parent: root });+ createPart('CabFrontMidC', boxGeo(0.08, 0.8, 0.5), boilerGreen, { position: [-2.0, 3.0, 0], parent: root });+ createPart('CabFrontTop', boxGeo(0.08, 0.3, cabW), boilerGreen, { position: [-2.0, 3.62, 0], parent: root });+ for (const s of [1, -1]) {+ createPart('CabFrontGlass_' + s, boxGeo(0.02, 0.55, 0.42), glass, { position: [-2.0, 3.05, s * 0.36], parent: root });+ }+ for (const s of [1, -1]) {+ createPart('CabRearPost_' + s, boxGeo(0.12, 2.3, 0.12), boilerGreen, { position: [-3.95, 2.75, s * 1.09], parent: root });+ }+ createPart('CabRearBeam', boxGeo(0.12, 0.25, cabW), boilerGreen, { position: [-3.95, 3.75, 0], parent: root });+ // The cab is 1.95 m long between its posts and 2.30 m across its outer+ // panels. A 2.70 by 2.90 roof overhung it by 0.375 m at each end and 0.30 m+ // at each side, which made the widest thing on the locomotive a flat plate+ // floating over the cab rather than a roof sitting on it. 0.20 m of eave all+ // round is what a cab roof actually carries.+ const cabRoofGeo = await roundedBoxGeo(2.35, 0.12, 2.7, 0.05);+ createPart('CabRoof', cabRoofGeo, roofBlack, { position: [-3.0, 3.94, 0], parent: root });+ createPart('Backhead', cylinderXGeo(0.7, 0.7, 0.5, 20), black, { position: [-2.1, 2.4, 0], parent: root });+ createPart('GaugePanel', boxGeo(0.06, 0.5, 0.9), roofBlack, { position: [-2.32, 2.95, 0], parent: root });+ for (const s of [1, -1]) {+ createPart('Gauge_' + s, cylinderXGeo(0.09, 0.09, 0.06, 12), brass, { position: [-2.35, 3.0, s * 0.25], parent: root });+ createPart('GaugeFace_' + s, cylinderXGeo(0.07, 0.07, 0.065, 12), whitewall, { position: [-2.35, 3.0, s * 0.25], parent: root });+ createPart('SeatPost_' + s, boxGeo(0.12, 0.55, 0.12), darkSteel, { position: [-3.5, 1.92, s * 0.7], parent: root });+ createPart('Seat_' + s, boxGeo(0.5, 0.1, 0.5), cabRed, { position: [-3.5, 2.2, s * 0.7], parent: root });+ createPart('SeatBack_' + s, boxGeo(0.1, 0.6, 0.5), cabRed, { position: [-3.72, 2.5, s * 0.7], parent: root });+ }+ createPart('ThrottleLever', boxGeo(0.06, 0.7, 0.06), steel, { position: [-2.5, 2.6, 0.4], rotation: [0, 0, -20], parent: root });+ createPart('FireboxDoor', boxGeo(0.1, 0.5, 0.5), copper, { position: [-2.38, 2.1, 0], parent: root });++ // ---------- cowcatcher (pilot) ----------+ beamBetween('PilotFrameL', [4.55, 1.3, 0.9], [5.35, 0.15, 0.9], 0.05, beamRed, { parent: root });+ beamBetween('PilotFrameR', [4.55, 1.3, -0.9], [5.35, 0.15, -0.9], 0.05, beamRed, { parent: root });+ beamBetween('PilotBottom', [5.35, 0.15, 0.95], [5.35, 0.15, -0.95], 0.05, beamRed, { parent: root });+ for (let k = 0; k < 9; k++) {+ const z = 0.8 - k * 0.2;+ beamBetween('PilotSlat_' + k, [4.55, 1.25, z * 0.9], [5.35, 0.15, z], 0.03, beamRed, { parent: root });+ }+ createPart('Coupler', boxGeo(0.4, 0.15, 0.15), darkSteel, { position: [4.7, 1.0, 0], parent: root });++ // ---------- headlamp + markers + plates ----------+ createPart('HeadlampBracket', boxGeo(0.15, 0.25, 0.15), black, { position: [3.9, 3.05, 0], parent: root });+ createPart('HeadlampBox', boxGeo(0.4, 0.5, 0.4), black, { position: [3.9, 3.45, 0], parent: root });+ createPart('HeadlampLens', boxGeo(0.06, 0.34, 0.3), lampLens, { position: [4.12, 3.45, 0], parent: root });+ createPart('HeadlampTop', coneGeo(0.28, 0.2, 4), black, { position: [3.9, 3.8, 0], rotation: [0, 45, 0], parent: root });+ for (const s of [1, -1]) {+ createPart('MarkerLamp_' + s, boxGeo(0.16, 0.22, 0.16), brass, { position: [4.5, 1.6, s * 1.0], parent: root });+ }+ createPart('NumberPlate', cylinderXGeo(0.16, 0.16, 0.04, 16), brass, { position: [4.32, 2.5, 0], parent: root });+ createPart('RoofVent', cylinderGeo(0.09, 0.12, 0.16, 10), black, { position: [-3.0, 4.06, 0], parent: root });+ createPart('RoofVentCap', cylinderGeo(0.14, 0.14, 0.05, 10), black, { position: [-3.0, 4.16, 0], parent: root });+ for (const lz of [-0.7, -0.3, 0.3, 0.7]) {+ createPart('LampIron_' + lz, boxGeo(0.04, 0.25, 0.04), darkSteel, { position: [4.63, 1.45, lz], parent: root });+ }++ // ---------- steps with hangers (attached) ----------+ for (const s of [1, -1]) {+ createPart('CabStep1_' + s, boxGeo(0.5, 0.06, 0.4), darkSteel, { position: [-3.2, 1.2, s * 1.05], parent: root });+ createPart('CabStep2_' + s, boxGeo(0.5, 0.06, 0.4), darkSteel, { position: [-3.2, 0.75, s * 1.05], parent: root });+ createPart('StepHangerF_' + s, boxGeo(0.06, 0.36, 0.06), darkSteel, { position: [-3.0, 1.38, s * 1.05], parent: root });+ createPart('StepHangerR_' + s, boxGeo(0.06, 0.36, 0.06), darkSteel, { position: [-3.4, 1.38, s * 1.05], parent: root });+ createPart('StepHangerLow_' + s, boxGeo(0.06, 0.45, 0.06), darkSteel, { position: [-3.2, 0.97, s * 1.05], parent: root });+ createPart('FrontStep_' + s, boxGeo(0.5, 0.06, 0.35), darkSteel, { position: [4.32, 1.0, s * 1.1], parent: root });+ }++ // smokebox rivet ring+ for (let k = 0; k < 16; k++) {+ const a = k * 22.5 * Math.PI / 180;+ createPart('Rivet_' + k, sphereGeo(0.03, 6, 4), darkSteel,+ { position: [4.06, 2.15 + Math.sin(a) * 0.88, Math.cos(a) * 0.88], parent: root });+ }++ return root;+}++function animate() {+ const dur = 1.2, N = 12;+ const crankR = 0.38, Yd = 0.82;+ const Xd1 = 0.6, Xc0 = 1.45, Yc = 0.95, Lrod = 1.9;+ function circleKeys(cx, cy, phase) {+ const ks = [];+ for (let i = 0; i <= N; i++) {+ const t = dur * i / N;+ const phi = -2 * Math.PI * i / N + phase;+ ks.push({ time: t, position: [cx + crankR * Math.cos(phi), cy + crankR * Math.sin(phi), 0] });+ }+ return ks;+ }+ function crossKeys(phase) {+ const ks = [];+ for (let i = 0; i <= N; i++) {+ const t = dur * i / N;+ const phi = -2 * Math.PI * i / N + phase;+ const yc = Yd + crankR * Math.sin(phi);+ const xc = Xd1 + crankR * Math.cos(phi);+ const dy = yc - Yc;+ const xcross = xc + Math.sqrt(Lrod * Lrod - dy * dy) - (Lrod - (Xc0 - Xd1));+ ks.push({ time: t, position: [xcross, 0, 0] });+ }+ return ks;+ }+ function mainRodKeys(phase) {+ const pk = [], rk = [];+ for (let i = 0; i <= N; i++) {+ const t = dur * i / N;+ const phi = -2 * Math.PI * i / N + phase;+ const yc = Yd + crankR * Math.sin(phi);+ const xc = Xd1 + crankR * Math.cos(phi);+ const dy = yc - Yc;+ const xcross = xc + Math.sqrt(Lrod * Lrod - dy * dy) - (Lrod - (Xc0 - Xd1));+ const mx = (xc + xcross) / 2, my = (yc + Yc) / 2;+ pk.push({ time: t, position: [mx - 1.0, my - 0.9, 0] });+ const ang = Math.atan2(yc - Yc, xcross - xc) * 180 / Math.PI;+ rk.push({ time: t, rotation: [0, 0, ang] });+ }+ return { pk, rk };+ }+ const tracks = [];+ for (const n of ['Joint_Driver1L', 'Joint_Driver2L', 'Joint_Driver3L'])+ tracks.push(rotationTrack(n, [{ time: 0, rotation: [0, 0, 0] }, { time: dur, rotation: [0, 0, -360] }]));+ for (const n of ['Joint_Driver1R', 'Joint_Driver2R', 'Joint_Driver3R'])+ tracks.push(rotationTrack(n, [{ time: 0, rotation: [0, 0, -90] }, { time: dur, rotation: [0, 0, -450] }]));+ for (let i = 1; i <= 4; i++)+ tracks.push(rotationTrack('Joint_Pony' + i, [{ time: 0, rotation: [0, 0, 0] }, { time: dur, rotation: [0, 0, -720] }]));+ for (let i = 1; i <= 2; i++)+ tracks.push(rotationTrack('Joint_Trail' + i, [{ time: 0, rotation: [0, 0, 0] }, { time: dur, rotation: [0, 0, -720] }]));+ tracks.push(positionTrack('Joint_CoupleL', circleKeys(-0.75, Yd, 0)));+ tracks.push(positionTrack('Joint_CoupleR', circleKeys(-0.75, Yd, -Math.PI / 2)));+ tracks.push(positionTrack('Joint_CrossheadL', crossKeys(0)));+ tracks.push(positionTrack('Joint_CrossheadR', crossKeys(-Math.PI / 2)));+ const mL = mainRodKeys(0), mR = mainRodKeys(-Math.PI / 2);+ tracks.push(positionTrack('Joint_MainRodL', mL.pk));+ tracks.push(rotationTrack('Joint_MainRodL', mL.rk));+ tracks.push(positionTrack('Joint_MainRodR', mR.pk));+ tracks.push(rotationTrack('Joint_MainRodR', mR.rk));+ function valveKeys(phase) {+ const ks = [];+ for (let i = 0; i <= N; i++) {+ const t = dur * i / N;+ const phi = -2 * Math.PI * i / N + phase;+ ks.push({ time: t, position: [0.12 * Math.cos(phi + 1.2), 0, 0] });+ }+ return ks;+ }+ tracks.push(positionTrack('Joint_ValveL', valveKeys(0)));+ tracks.push(positionTrack('Joint_ValveR', valveKeys(-Math.PI / 2)));+ return [createClip('Drive', dur, tracks)];+}diff --git a/examples/tram.kiln.js b/examples/tram.kiln.jsnew file mode 100644index 00000000..49d59579--- /dev/null+++ b/examples/tram.kiln.js@@ -0,0 +1,529 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored, with one exception recorded+// below.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.+//+// The exception: review found the four canted cab corners rotated the wrong+// way, which left the panels crossing the line they should have lain on and a+// slot open into the cabin at each end of every one. The sign of `cornerAngle`+// was negated by hand at its three sites. Nothing else was touched, and the+// contact sheet the model was working from does not show the defect at the+// scale it was reviewed -- which is the honest reason it survived: the+// structural gates pass this asset either way, because a mirrored chamfer is+// well-formed geometry in the wrong place.++const meta = { name: 'Tram', category: 'vehicle' };++async function build() {+ const root = createRoot('Tram');++ // --- 1. Materials ---+ const matSteelDark = gameMaterial(0x202328, { metalness: 0.7, roughness: 0.45 });+ const matRailSteel = gameMaterial(0x6e747e, { metalness: 0.85, roughness: 0.35 });+ const matWoodTie = gameMaterial(0x35261b, { roughness: 0.9 });+ const matWoodInterior = gameMaterial(0x694627, { roughness: 0.75 });+ const matBodyGreen = gameMaterial(0x1a3c2c, { roughness: 0.5 });+ const matBodyGreenDark = gameMaterial(0x10261c, { roughness: 0.55 });+ const matBodyCream = gameMaterial(0xf5eedc, { roughness: 0.45 });+ const matRoofCanvas = gameMaterial(0x3e4248, { roughness: 0.85 });+ const matBrass = gameMaterial(0xd8aa44, { metalness: 0.85, roughness: 0.25 });+ const matCopper = gameMaterial(0xb96e3c, { metalness: 0.8, roughness: 0.3 });+ const matGlass = glassMaterial(0xa0d2ea, { opacity: 0.35, roughness: 0.1 });+ const matLampGlow = gameMaterial(0xfff5d6, { emissive: 0xffe28a, emissiveIntensity: 1.3 });+ const matSignDark = gameMaterial(0x14171b, { roughness: 0.85 });+ const matMarkerRed = gameMaterial(0xcc2222, { roughness: 0.4, emissive: 0x880000, emissiveIntensity: 0.6 });++ // Shared Geometries for instancing and clean draw call count+ const tieGeo = boxGeo(0.24, 0.09, 2.3);+ const tiePlateGeo = boxGeo(0.26, 0.015, 0.16);+ const wheelRadius = 0.33;+ const wheelTreadGeo = cylinderZGeo(wheelRadius, wheelRadius, 0.065, 14);+ const wheelFlangeGeo = cylinderZGeo(wheelRadius + 0.035, wheelRadius + 0.035, 0.025, 14);+ const wheelHubGeo = cylinderZGeo(0.09, 0.09, 0.09, 10);+ const journalBoxGeo = boxGeo(0.16, 0.18, 0.12);+ const coilSpringGeo = cylinderYGeo(0.045, 0.045, 0.12, 8);+ const brakeShoeGeo = boxGeo(0.06, 0.14, 0.06);+ const rivetGeo = sphereGeo(0.014, 6, 4);++ // --- 2. Track & Ground (Y=0) ---+ for (let x = -5.6; x <= 5.6; x += 0.7) {+ const xPos = Math.round(x * 10) / 10;+ createPart('Tie_' + xPos, tieGeo, matWoodTie, { position: [xPos, 0.045, 0], parent: root });+ createPart('TiePlate_L_' + xPos, tiePlateGeo, matSteelDark, { position: [xPos, 0.095, -0.72], parent: root });+ createPart('TiePlate_R_' + xPos, tiePlateGeo, matSteelDark, { position: [xPos, 0.095, 0.72], parent: root });+ }++ const railLength = 12.0;+ const railBaseGeo = boxGeo(railLength, 0.02, 0.12);+ const railWebGeo = boxGeo(railLength, 0.08, 0.03);+ const railHeadGeo = boxGeo(railLength, 0.04, 0.065);+ [-0.72, 0.72].forEach((z, i) => {+ const side = i === 0 ? 'L' : 'R';+ createPart('RailBase_' + side, railBaseGeo, matRailSteel, { position: [0, 0.10, z], parent: root });+ createPart('RailWeb_' + side, railWebGeo, matRailSteel, { position: [0, 0.15, z], parent: root });+ createPart('RailHead_' + side, railHeadGeo, matRailSteel, { position: [0, 0.21, z], parent: root });+ });++ const railTopY = 0.23;+ const axleY = railTopY + wheelRadius; // 0.56m+ const floorY = 0.88;++ // --- 3. Two 4-Wheel Bogie Trucks ---+ const bogieCenters = [-2.6, 2.6];+ const axleShaftGeo = cylinderZGeo(0.045, 0.045, 1.6, 10);+ const motorGeo = boxGeo(0.35, 0.28, 0.5);+ const sideFrameTopGeo = boxGeo(1.8, 0.08, 0.06);+ const sideFrameBotGeo = boxGeo(1.5, 0.06, 0.06);+ const sideDiagGeo = boxGeo(0.65, 0.05, 0.05);+ const springPackGeo = boxGeo(0.32, 0.12, 0.09);+ const truckBolsterGeo = boxGeo(0.40, 0.36, 1.85);++ bogieCenters.forEach((bX, bIdx) => {+ const bogie = createPivot('Truck_' + bIdx, [bX, 0, 0], root);++ createPart('TruckBolster_' + bIdx, truckBolsterGeo, matSteelDark, {+ position: [0, 0.74, 0],+ parent: bogie+ });++ [-0.88, 0.88].forEach((zSide, sIdx) => {+ const sName = (sIdx === 0 ? 'L' : 'R') + '_' + bIdx;+ createPart('SideFrameTop_' + sName, sideFrameTopGeo, matSteelDark, { position: [0, axleY + 0.08, zSide], parent: bogie });+ createPart('SideFrameBot_' + sName, sideFrameBotGeo, matSteelDark, { position: [0, axleY - 0.10, zSide], parent: bogie });+ createPart('SideFrameDiagA_' + sName, sideDiagGeo, matSteelDark, { position: [-0.4, axleY, zSide], rotation: [0, 0, 25], parent: bogie });+ createPart('SideFrameDiagB_' + sName, sideDiagGeo, matSteelDark, { position: [0.4, axleY, zSide], rotation: [0, 0, -25], parent: bogie });+ createPart('SpringPack_' + sName, springPackGeo, matSteelDark, { position: [0, axleY - 0.02, zSide], parent: bogie });+ });++ [-0.7, 0.7].forEach((dx, aIdx) => {+ const axleName = bIdx + '_' + aIdx;+ createPart('AxleShaft_' + axleName, axleShaftGeo, matSteelDark, { position: [dx, axleY, 0], parent: bogie });+ createPart('TractionMotor_' + axleName, motorGeo, matSteelDark, { position: [dx > 0 ? dx - 0.22 : dx + 0.22, axleY, 0], parent: bogie });++ [-0.72, 0.72].forEach((wZ, wIdx) => {+ const wName = (wIdx === 0 ? 'L' : 'R') + '_' + axleName;+ const flangeZ = wIdx === 0 ? wZ + 0.035 : wZ - 0.035;++ createPart('WheelTread_' + wName, wheelTreadGeo, matRailSteel, { position: [dx, axleY, wZ], parent: bogie });+ createPart('WheelFlange_' + wName, wheelFlangeGeo, matRailSteel, { position: [dx, axleY, flangeZ], parent: bogie });+ createPart('WheelHub_' + wName, wheelHubGeo, matSteelDark, { position: [dx, axleY, wIdx === 0 ? wZ - 0.03 : wZ + 0.03], parent: bogie });++ const brakeX = dx > 0 ? dx + wheelRadius * 0.95 : dx - wheelRadius * 0.95;+ createPart('BrakeShoe_' + wName, brakeShoeGeo, matSteelDark, { position: [brakeX, axleY, wZ], parent: bogie });+ });++ [-0.88, 0.88].forEach((jZ, jIdx) => {+ const jName = (jIdx === 0 ? 'L' : 'R') + '_' + axleName;+ createPart('JournalBox_' + jName, journalBoxGeo, matSteelDark, { position: [dx, axleY, jZ], parent: bogie });+ createPart('CoilSpring_' + jName, coilSpringGeo, matSteelDark, { position: [dx, axleY + 0.12, jZ], parent: bogie });+ });+ });++ [-0.7, 0.7].forEach((dx, aIdx) => {+ const bXPos = dx > 0 ? dx + 0.32 : dx - 0.32;+ createPart('BrakeBeam_' + bIdx + '_' + aIdx, cylinderZGeo(0.03, 0.03, 1.5, 8), matSteelDark, {+ position: [bXPos, axleY, 0],+ parent: bogie+ });+ });+ });++ // --- 4. Underframe & Chassis Equipment ---+ const sideSillGeo = boxGeo(8.6, 0.14, 0.08);+ [-1.12, 1.12].forEach((zSill, sIdx) => {+ createPart('SideSill_' + (sIdx === 0 ? 'L' : 'R'), sideSillGeo, matSteelDark, { position: [0, floorY - 0.07, zSill], parent: root });+ });+ createPart('ChassisSubFloor', boxGeo(8.6, 0.10, 2.22), matSteelDark, { position: [0, floorY - 0.05, 0], parent: root });+ createPart('InteriorFloor', boxGeo(8.4, 0.02, 2.16), matWoodInterior, { position: [0, floorY + 0.01, 0], parent: root });++ createPart('AirReservoir', cylinderXGeo(0.18, 0.18, 1.4, 12), matSteelDark, { position: [-0.6, floorY - 0.22, -0.45], parent: root });+ createPart('CompressorBox', boxGeo(0.6, 0.32, 0.5), matSteelDark, { position: [0.7, floorY - 0.20, -0.4], parent: root });+ createPart('ResistanceGridBox', boxGeo(1.2, 0.26, 0.55), matSteelDark, { position: [0, floorY - 0.18, 0.42], parent: root });+ const resistFinGeo = boxGeo(0.02, 0.24, 0.57);+ for (let gx = -0.5; gx <= 0.5; gx += 0.2) {+ createPart('ResistFin_' + gx.toFixed(1), resistFinGeo, matSteelDark, { position: [gx, floorY - 0.18, 0.42], parent: root });+ }++ // --- 5. Tram Lower Panelled Skirt & Belt Rail ---+ const bodyCenterLength = 6.0;+ const skirtY = floorY + 0.44;+ const lowerSkirtGeo = boxGeo(bodyCenterLength, 0.86, 0.04);+ const rockerTrimGeo = boxGeo(bodyCenterLength + 0.1, 0.06, 0.06);+ const beltRailGeo = boxGeo(bodyCenterLength + 0.1, 0.07, 0.065);+ const skirtBattenGeo = boxGeo(0.04, 0.84, 0.02);++ [-1.13, 1.13].forEach((zSide, sIdx) => {+ const sLabel = sIdx === 0 ? 'L' : 'R';+ createPart('LowerSkirt_' + sLabel, lowerSkirtGeo, matBodyGreen, { position: [0, skirtY, zSide], parent: root });+ createPart('RockerSill_' + sLabel, rockerTrimGeo, matBodyGreenDark, { position: [0, floorY + 0.03, zSide + (sIdx === 0 ? -0.015 : 0.015)], parent: root });+ createPart('BeltRail_' + sLabel, beltRailGeo, matBrass, { position: [0, floorY + 0.86, zSide + (sIdx === 0 ? -0.015 : 0.015)], parent: root });++ for (let bx = -2.7; bx <= 2.7; bx += 0.6) {+ const bxPos = Math.round(bx * 10) / 10;+ createPart('Batten_' + sLabel + '_' + bxPos, skirtBattenGeo, matBodyGreenDark, { position: [bxPos, skirtY, zSide + (sIdx === 0 ? -0.02 : 0.02)], parent: root });+ createPart('RivetTop_' + sLabel + '_' + bxPos, rivetGeo, matBrass, { position: [bxPos, floorY + 0.86, zSide + (sIdx === 0 ? -0.045 : 0.045)], parent: root });+ createPart('RivetBot_' + sLabel + '_' + bxPos, rivetGeo, matBrass, { position: [bxPos, floorY + 0.04, zSide + (sIdx === 0 ? -0.045 : 0.045)], parent: root });+ }+ });++ // Vestibule section+ [-3.35, 3.35].forEach((vx, vIdx) => {+ const vName = vIdx === 0 ? 'Rear' : 'Front';+ createPart('VestibuleSkirt_L_' + vName, boxGeo(0.7, 0.86, 0.04), matBodyGreen, { position: [vx, skirtY, -1.13], parent: root });+ createPart('VestibuleBelt_L_' + vName, boxGeo(0.7, 0.07, 0.065), matBrass, { position: [vx, floorY + 0.86, -1.145], parent: root });+ createPart('VestibuleRocker_L_' + vName, boxGeo(0.7, 0.06, 0.06), matBodyGreenDark, { position: [vx, floorY + 0.03, -1.145], parent: root });++ createPart('DoorStepWell_' + vName, boxGeo(0.72, 0.12, 0.20), matWoodInterior, { position: [vx, floorY - 0.02, 1.10], parent: root });+ createPart('DoorLeafA_' + vName, boxGeo(0.32, 1.74, 0.03), matBodyGreenDark, { position: [vx - 0.17, floorY + 0.90, 1.13], parent: root });+ createPart('DoorLeafB_' + vName, boxGeo(0.32, 1.74, 0.03), matBodyGreenDark, { position: [vx + 0.17, floorY + 0.90, 1.13], parent: root });+ createPart('DoorGlassA_' + vName, boxGeo(0.22, 0.65, 0.015), matGlass, { position: [vx - 0.17, floorY + 1.25, 1.13], parent: root });+ createPart('DoorGlassB_' + vName, boxGeo(0.22, 0.65, 0.015), matGlass, { position: [vx + 0.17, floorY + 1.25, 1.13], parent: root });+ beamBetween('DoorGrab_' + vName, [vx - 0.32, floorY + 0.15, 1.15], [vx - 0.32, floorY + 1.20, 1.15], 0.016, matBrass, { parent: root });+ });++ // --- 6. Rounded Cab Ends (Front +X, Rear -X) ---+ const cabExtents = [+ { dir: 1, name: 'Front' },+ { dir: -1, name: 'Rear' }+ ];++ const dashCenterGeo = boxGeo(0.06, 0.86, 1.22);+ const beltCenterGeo = boxGeo(0.08, 0.07, 1.24);+ const rockerCenterGeo = boxGeo(0.08, 0.06, 1.24);+ const dashCornerGeo = boxGeo(0.06, 0.86, 0.76);+ const beltCornerGeo = boxGeo(0.08, 0.07, 0.78);+ const rockerCornerGeo = boxGeo(0.08, 0.06, 0.78);+ const bumperCenterGeo = boxGeo(0.12, 0.18, 1.6);+ const bumperWingGeo = boxGeo(0.10, 0.18, 0.68);++ cabExtents.forEach(cab => {+ const d = cab.dir;+ const cName = cab.name;++ createPart('CabDashCenter_' + cName, dashCenterGeo, matBodyGreen, { position: [d * 4.35, skirtY, 0], parent: root });+ createPart('CabBeltCenter_' + cName, beltCenterGeo, matBrass, { position: [d * 4.37, floorY + 0.86, 0], parent: root });+ createPart('CabRockerCenter_' + cName, rockerCenterGeo, matBodyGreenDark, { position: [d * 4.37, floorY + 0.03, 0], parent: root });++ [-1, 1].forEach(sideDir => {+ const sideName = sideDir === -1 ? 'L' : 'R';+ const cornerAngle = -d * sideDir * 40;+ const cornerX = d * 3.98;+ const cornerZ = sideDir * 0.85;++ createPart('CabDashCorner_' + cName + '_' + sideName, dashCornerGeo, matBodyGreen, {+ position: [cornerX, skirtY, cornerZ],+ rotation: [0, cornerAngle, 0],+ parent: root+ });+ createPart('CabBeltCorner_' + cName + '_' + sideName, beltCornerGeo, matBrass, {+ position: [cornerX + d * 0.015, floorY + 0.86, cornerZ + sideDir * 0.015],+ rotation: [0, cornerAngle, 0],+ parent: root+ });+ createPart('CabRockerCorner_' + cName + '_' + sideName, rockerCornerGeo, matBodyGreenDark, {+ position: [cornerX + d * 0.015, floorY + 0.03, cornerZ + sideDir * 0.015],+ rotation: [0, cornerAngle, 0],+ parent: root+ });+ });++ const bumperX = d * 4.56;+ createPart('BumperCenter_' + cName, bumperCenterGeo, matSteelDark, { position: [bumperX, floorY - 0.05, 0], parent: root });+ for (let ry = -0.05; ry <= 0.05; ry += 0.05) {+ createPart('BumperRib_' + cName + '_' + ry.toFixed(2), boxGeo(0.03, 0.02, 1.58), matRailSteel, {+ position: [bumperX + d * 0.065, floorY - 0.05 + ry, 0],+ parent: root+ });+ }+ [-1, 1].forEach(sideDir => {+ const bWingName = (sideDir === -1 ? 'L' : 'R') + '_' + cName;+ createPart('BumperWing_' + bWingName, bumperWingGeo, matSteelDark, {+ position: [d * 4.36, floorY - 0.05, sideDir * 0.98],+ rotation: [0, d * sideDir * 35, 0],+ parent: root+ });+ });++ createPart('BumperBracket_L_' + cName, boxGeo(0.55, 0.10, 0.08), matSteelDark, { position: [d * 4.25, floorY - 0.05, -0.6], parent: root });+ createPart('BumperBracket_R_' + cName, boxGeo(0.55, 0.10, 0.08), matSteelDark, { position: [d * 4.25, floorY - 0.05, 0.6], parent: root });+ });++ // --- 7. Front Life-Guard Fender / Cowcatcher ---+ createPart('FenderMount_L', boxGeo(0.55, 0.08, 0.08), matSteelDark, { position: [4.40, 0.42, -0.65], parent: root });+ createPart('FenderMount_R', boxGeo(0.55, 0.08, 0.08), matSteelDark, { position: [4.40, 0.42, 0.65], parent: root });+ beamBetween('FenderArm_L', [4.35, floorY - 0.06, -0.65], [4.68, 0.36, -0.65], 0.035, matSteelDark, { parent: root });+ beamBetween('FenderArm_R', [4.35, floorY - 0.06, 0.65], [4.68, 0.36, 0.65], 0.035, matSteelDark, { parent: root });++ createPart('FenderTransverseBeam', cylinderZGeo(0.04, 0.04, 1.8, 10), matSteelDark, { position: [4.68, 0.36, 0], parent: root });+ createPart('FenderLowerBeam', cylinderZGeo(0.03, 0.03, 1.7, 10), matSteelDark, { position: [4.90, 0.27, 0], parent: root });+ for (let fz = -0.75; fz <= 0.75; fz += 0.15) {+ const fzPos = Math.round(fz * 100) / 100;+ beamBetween('FenderSlat_' + fzPos, [4.68, 0.36, fzPos], [4.90, 0.27, fzPos], 0.015, matWoodInterior, { parent: root });+ }++ // --- 8. Window Band (Drop Windows & Transoms) ---+ const windowBaseY = floorY + 0.88;+ const windowMidY = windowBaseY + 0.45;+ const windowTopY = windowBaseY + 0.90;++ const eaveHeaderGeo = boxGeo(bodyCenterLength + 0.8, 0.07, 0.07);+ [-1.13, 1.13].forEach((zSide, sIdx) => {+ const sLabel = sIdx === 0 ? 'L' : 'R';+ createPart('WindowEaveHeader_' + sLabel, eaveHeaderGeo, matBodyCream, {+ position: [0, windowTopY + 0.035, zSide + (sIdx === 0 ? -0.01 : 0.01)],+ parent: root+ });+ });++ const windowSpacing = 0.60;+ const postWidth = 0.08;+ const glassWidth = windowSpacing - postWidth;+ const postGeo = boxGeo(postWidth, 0.90, 0.06);+ const windowSillGeo = boxGeo(glassWidth + 0.04, 0.035, 0.08);+ const dropGlassGeo = boxGeo(glassWidth, 0.52, 0.015);+ const transomGlassGeo = boxGeo(glassWidth, 0.28, 0.015);+ const transomBarGeo = boxGeo(glassWidth + 0.02, 0.025, 0.04);++ for (let wx = -2.7; wx <= 2.7; wx += windowSpacing) {+ const wxPos = Math.round(wx * 100) / 100;+ [-1.13, 1.13].forEach((zSide, sIdx) => {+ const sLabel = sIdx === 0 ? 'L' : 'R';+ createPart('WindowPost_' + sLabel + '_' + wxPos, postGeo, matBodyCream, { position: [wxPos, windowMidY, zSide], parent: root });+ createPart('WindowSill_' + sLabel + '_' + wxPos, windowSillGeo, matBodyCream, { position: [wxPos + windowSpacing / 2, windowBaseY + 0.02, zSide], parent: root });+ createPart('DropGlass_' + sLabel + '_' + wxPos, dropGlassGeo, matGlass, { position: [wxPos + windowSpacing / 2, windowBaseY + 0.30, zSide], parent: root });+ createPart('TransomGlass_' + sLabel + '_' + wxPos, transomGlassGeo, matGlass, { position: [wxPos + windowSpacing / 2, windowBaseY + 0.72, zSide], parent: root });+ createPart('TransomBar_' + sLabel + '_' + wxPos, transomBarGeo, matBodyCream, { position: [wxPos + windowSpacing / 2, windowBaseY + 0.57, zSide], parent: root });+ });+ }++ [-3.35, 3.35].forEach((vx, vIdx) => {+ const vName = vIdx === 0 ? 'Rear' : 'Front';+ createPart('VestibuleGlass_L_' + vName, boxGeo(0.55, 0.75, 0.015), matGlass, { position: [vx, windowMidY, -1.13], parent: root });+ createPart('VestibuleFrame_L_' + vName, boxGeo(0.59, 0.85, 0.05), matBodyCream, { position: [vx, windowMidY, -1.13], parent: root });+ });++ const windshieldCenterGeo = boxGeo(0.02, 0.75, 1.12);+ const windshieldFrameBotGeo = boxGeo(0.06, 0.04, 1.16);+ const windshieldFrameTopGeo = boxGeo(0.06, 0.05, 1.16);+ const windshieldCornerGeo = boxGeo(0.02, 0.75, 0.68);+ const cornerFrameBotGeo = boxGeo(0.06, 0.04, 0.72);+ const cornerFrameTopGeo = boxGeo(0.06, 0.05, 0.72);+ const cornerPillarGeo = boxGeo(0.08, 0.90, 0.08);++ cabExtents.forEach(cab => {+ const d = cab.dir;+ const cName = cab.name;++ createPart('WindshieldCenter_' + cName, windshieldCenterGeo, matGlass, { position: [d * 4.34, windowMidY, 0], parent: root });+ createPart('WindshieldFrameBot_' + cName, windshieldFrameBotGeo, matBodyCream, { position: [d * 4.35, windowBaseY + 0.04, 0], parent: root });+ createPart('WindshieldFrameTop_' + cName, windshieldFrameTopGeo, matBodyCream, { position: [d * 4.35, windowTopY - 0.04, 0], parent: root });++ if (d > 0) {+ createPart('WiperMotor', cylinderXGeo(0.03, 0.03, 0.06, 8), matSteelDark, { position: [4.38, windowTopY - 0.02, 0.25], parent: root });+ beamBetween('WiperBlade', [4.38, windowTopY - 0.04, 0.25], [4.37, windowMidY - 0.1, 0.12], 0.012, matSteelDark, { parent: root });+ }++ [-1, 1].forEach(sideDir => {+ const sideName = sideDir === -1 ? 'L' : 'R';+ const cornerAngle = -d * sideDir * 40;+ const cornerX = d * 3.98;+ const cornerZ = sideDir * 0.85;++ createPart('WindshieldCorner_' + cName + '_' + sideName, windshieldCornerGeo, matGlass, {+ position: [cornerX, windowMidY, cornerZ],+ rotation: [0, cornerAngle, 0],+ parent: root+ });+ createPart('CornerFrameBot_' + cName + '_' + sideName, cornerFrameBotGeo, matBodyCream, {+ position: [cornerX + d * 0.01, windowBaseY + 0.04, cornerZ + sideDir * 0.01],+ rotation: [0, cornerAngle, 0],+ parent: root+ });+ createPart('CornerFrameTop_' + cName + '_' + sideName, cornerFrameTopGeo, matBodyCream, {+ position: [cornerX + d * 0.01, windowTopY - 0.04, cornerZ + sideDir * 0.01],+ rotation: [0, cornerAngle, 0],+ parent: root+ });+ createPart('CornerPillar_' + cName + '_' + sideName, cornerPillarGeo, matBodyCream, {+ position: [d * 4.28, windowMidY, sideDir * 0.58],+ parent: root+ });+ });+ });++ // --- 9. Interior Fixtures ---+ const seatCushionGeo = boxGeo(0.42, 0.08, 0.65);+ const seatBackGeo = boxGeo(0.06, 0.42, 0.65);+ const seatPedestalGeo = cylinderYGeo(0.03, 0.03, 0.34, 8);+ const aisleGripGeo = cylinderYGeo(0.015, 0.015, 0.12, 6);++ for (let sx = -2.2; sx <= 2.2; sx += 0.8) {+ const sxPos = Math.round(sx * 10) / 10;+ [-0.68, 0.68].forEach((sz, sIdx) => {+ const sSide = sIdx === 0 ? 'L' : 'R';+ createPart('SeatCushion_' + sSide + '_' + sxPos, seatCushionGeo, matWoodInterior, { position: [sxPos, floorY + 0.38, sz], parent: root });+ createPart('SeatBack_' + sSide + '_' + sxPos, seatBackGeo, matWoodInterior, { position: [sxPos - 0.18, floorY + 0.58, sz], parent: root });+ createPart('SeatPedestal_' + sSide + '_' + sxPos, seatPedestalGeo, matSteelDark, { position: [sxPos, floorY + 0.17, sz], parent: root });+ createPart('AisleGrip_' + sSide + '_' + sxPos, aisleGripGeo, matBrass, { position: [sxPos - 0.18, floorY + 0.82, sIdx === 0 ? -0.36 : 0.36], parent: root });+ });+ }++ cabExtents.forEach(cab => {+ const d = cab.dir;+ const cName = cab.name;+ createPart('Controller_' + cName, boxGeo(0.28, 0.72, 0.28), matSteelDark, { position: [d * 3.95, floorY + 0.36, -0.25], parent: root });+ createPart('ThrottleHandle_' + cName, cylinderYGeo(0.02, 0.02, 0.12, 8), matBrass, { position: [d * 3.95, floorY + 0.78, -0.25], parent: root });+ createPart('BrakeStaff_' + cName, cylinderYGeo(0.02, 0.02, 0.85, 8), matSteelDark, { position: [d * 3.95, floorY + 0.42, 0.25], parent: root });+ createPart('BrakeWheel_' + cName, torusGeo(0.12, 0.018, 8, 12), matBrass, { position: [d * 3.95, floorY + 0.86, 0.25], rotation: [90, 0, 0], parent: root });+ });++ for (let hx = -2.0; hx <= 2.0; hx += 0.8) {+ createPart('CeilingLamp_' + hx.toFixed(1), sphereGeo(0.06, 8, 6), matLampGlow, { position: [hx, windowTopY + 0.18, 0], parent: root });+ }++ // --- 10. Continuous Roof & Raised Clerestory Monitor Roof ---+ const roofY = windowTopY + 0.06;++ createPart('RoofLowerDeck', boxGeo(7.6, 0.10, 2.42), matRoofCanvas, { position: [0, roofY + 0.05, 0], parent: root });++ cabExtents.forEach(cab => {+ const d = cab.dir;+ const cName = cab.name;+ createPart('CabHoodCenter_' + cName, boxGeo(0.65, 0.10, 1.35), matRoofCanvas, { position: [d * 4.15, roofY + 0.05, 0], parent: root });+ [-1, 1].forEach(sideDir => {+ const cornerAngle = -d * sideDir * 40;+ createPart('CabHoodCorner_' + cName + '_' + (sideDir === -1 ? 'L' : 'R'), boxGeo(0.55, 0.10, 0.85), matRoofCanvas, {+ position: [d * 3.92, roofY + 0.05, sideDir * 0.90],+ rotation: [0, cornerAngle, 0],+ parent: root+ });+ });+ });++ const clerestoryBaseY = roofY + 0.10;+ const clerestoryHeight = 0.28;+ const clerestoryMidY = clerestoryBaseY + 0.14;+ const clerestoryTopY = clerestoryBaseY + 0.28;++ createPart('ClerestoryUpperDeck', boxGeo(6.2, 0.08, 1.38), matRoofCanvas, { position: [0, clerestoryTopY + 0.04, 0], parent: root });+ createPart('ClerestoryArchCrown', boxGeo(6.0, 0.06, 1.15), matRoofCanvas, { position: [0, clerestoryTopY + 0.09, 0], parent: root });++ const clerestoryEndCapGeo = cylinderYGeo(0.68, 0.68, 0.28, 12);+ [-3.1, 3.1].forEach((cx, cIdx) => {+ const capName = cIdx === 0 ? 'Rear' : 'Front';+ createPart('ClerestoryEndCap_' + capName, clerestoryEndCapGeo, matRoofCanvas, { position: [cx, clerestoryMidY, 0], parent: root });+ });++ const clerestoryWallGeo = boxGeo(6.0, 0.26, 0.04);+ const louverFrameGeo = boxGeo(0.32, 0.16, 0.025);+ const louverSlatGeo = boxGeo(0.28, 0.025, 0.035);++ [-0.67, 0.67].forEach((cz, sIdx) => {+ const sLabel = sIdx === 0 ? 'L' : 'R';+ createPart('ClerestoryWall_' + sLabel, clerestoryWallGeo, matBodyCream, { position: [0, clerestoryMidY, cz], parent: root });++ for (let lx = -2.5; lx <= 2.5; lx += 0.55) {+ const lxPos = Math.round(lx * 100) / 100;+ createPart('LouverFrame_' + sLabel + '_' + lxPos, louverFrameGeo, matBodyGreenDark, {+ position: [lxPos, clerestoryMidY, cz + (sIdx === 0 ? -0.022 : 0.022)],+ parent: root+ });+ createPart('LouverSlatA_' + sLabel + '_' + lxPos, louverSlatGeo, matBrass, {+ position: [lxPos, clerestoryMidY + 0.03, cz + (sIdx === 0 ? -0.025 : 0.025)],+ parent: root+ });+ createPart('LouverSlatB_' + sLabel + '_' + lxPos, louverSlatGeo, matBrass, {+ position: [lxPos, clerestoryMidY - 0.03, cz + (sIdx === 0 ? -0.025 : 0.025)],+ parent: root+ });+ }+ });++ const ventStemGeo = cylinderYGeo(0.045, 0.045, 0.08, 8);+ const ventCapGeo = cylinderYGeo(0.14, 0.08, 0.05, 10);+ for (let vx = -2.2; vx <= 2.2; vx += 0.88) {+ const vxPos = Math.round(vx * 100) / 100;+ createPart('VentStem_' + vxPos, ventStemGeo, matSteelDark, { position: [vxPos, clerestoryTopY + 0.14, 0], parent: root });+ createPart('VentCap_' + vxPos, ventCapGeo, matCopper, { position: [vxPos, clerestoryTopY + 0.19, 0], parent: root });+ }++ const catwalkGeo = boxGeo(5.8, 0.025, 0.22);+ [-0.92, 0.92].forEach((boardZ, bIdx) => {+ createPart('RoofCatwalk_' + (bIdx === 0 ? 'L' : 'R'), catwalkGeo, matWoodInterior, { position: [0, roofY + 0.11, boardZ], parent: root });+ });++ // --- 11. Trolley Pole Reaching to Wire ---+ const baseCenterY = clerestoryTopY + 0.13;+ createPart('TrolleyMountPlate', boxGeo(0.65, 0.04, 0.55), matSteelDark, { position: [0.5, baseCenterY, 0], parent: root });+ createPart('TrolleyTurret', cylinderYGeo(0.14, 0.16, 0.12, 10), matSteelDark, { position: [0.5, baseCenterY + 0.08, 0], parent: root });+ const trolleySpringGeo = cylinderXGeo(0.04, 0.04, 0.38, 8);+ [-0.10, 0.10].forEach((sz, sIdx) => {+ createPart('TrolleySpring_' + (sIdx === 0 ? 'L' : 'R'), trolleySpringGeo, matSteelDark, { position: [0.45, baseCenterY + 0.12, sz], parent: root });+ });++ const poleTip = [-2.2, 4.75, 0];+ beamBetween('TrolleyPoleLower', [0.45, baseCenterY + 0.15, 0], [-0.8, 3.90, 0], 0.032, matBrass, { parent: root });+ beamBetween('TrolleyPoleUpper', [-0.8, 3.90, 0], poleTip, 0.022, matBrass, { parent: root });++ createPart('TrolleyHarp', boxGeo(0.12, 0.08, 0.06), matBrass, { position: [poleTip[0], poleTip[1], poleTip[2]], parent: root });+ createPart('TrolleyWheel', cylinderZGeo(0.065, 0.065, 0.045, 10), matBrass, { position: [poleTip[0] - 0.04, poleTip[1] + 0.05, 0], parent: root });++ createPart('OverheadWire', cylinderXGeo(0.012, 0.012, 11.8, 8), matCopper, { position: [0, 4.80, 0], parent: root });++ beamBetween('TrolleyRope', poleTip, [-4.36, floorY + 0.55, 0], 0.007, matSteelDark, { parent: root });+ createPart('TrolleyCatcherDrum', cylinderXGeo(0.07, 0.07, 0.08, 10), matBrass, { position: [-4.40, floorY + 0.55, 0], parent: root });++ // --- 12. Headlamps, Destination Blinds & Dash Fittings ---+ const hlHousingGeo = cylinderXGeo(0.18, 0.17, 0.18, 14);+ const hlBezelGeo = cylinderXGeo(0.19, 0.19, 0.03, 14);+ const hlLensGeo = cylinderXGeo(0.16, 0.16, 0.02, 12);+ const destHousingGeo = boxGeo(0.16, 0.24, 0.88);+ const destFaceGeo = boxGeo(0.02, 0.18, 0.80);+ const destTextGeo = boxGeo(0.01, 0.10, 0.65);+ const markerBracketGeo = cylinderXGeo(0.018, 0.018, 0.08, 6);+ const markerLanternGeo = cylinderYGeo(0.045, 0.045, 0.10, 8);+ const markerLensGeo = sphereGeo(0.035, 8, 6);+ const footGongGeo = cylinderYGeo(0.12, 0.06, 0.08, 10);+ const gongStemGeo = cylinderYGeo(0.02, 0.02, 0.10, 6);++ cabExtents.forEach(cab => {+ const d = cab.dir;+ const cName = cab.name;++ const hlX = d * 4.42;+ const hlY = floorY + 0.55;+ createPart('HeadlampBracket_' + cName, boxGeo(0.14, 0.08, 0.08), matSteelDark, { position: [hlX - d * 0.04, hlY, 0], parent: root });+ createPart('HeadlampHousing_' + cName, hlHousingGeo, matBrass, { position: [hlX + d * 0.07, hlY, 0], parent: root });+ createPart('HeadlampBezel_' + cName, hlBezelGeo, matBrass, { position: [hlX + d * 0.16, hlY, 0], parent: root });+ createPart('HeadlampLens_' + cName, hlLensGeo, matLampGlow, { position: [hlX + d * 0.175, hlY, 0], parent: root });++ const destX = d * 4.36;+ const destY = roofY + 0.02;+ createPart('DestBoxHousing_' + cName, destHousingGeo, matBodyCream, { position: [destX, destY, 0], parent: root });+ createPart('DestBlindFace_' + cName, destFaceGeo, matSignDark, { position: [destX + d * 0.08, destY, 0], parent: root });+ createPart('DestTextPlate_' + cName, destTextGeo, matLampGlow, { position: [destX + d * 0.09, destY, 0], parent: root });++ [-0.55, 0.55].forEach((mz, mIdx) => {+ const mName = (mIdx === 0 ? 'L' : 'R') + '_' + cName;+ const markerColor = (d > 0 && mIdx === 1) ? matMarkerRed : matLampGlow;+ createPart('MarkerBracket_' + mName, markerBracketGeo, matBrass, { position: [d * 4.30, windowTopY - 0.05, mz], parent: root });+ createPart('MarkerLantern_' + mName, markerLanternGeo, matBrass, { position: [d * 4.34, windowTopY - 0.05, mz], parent: root });+ createPart('MarkerLens_' + mName, markerLensGeo, markerColor, { position: [d * 4.36, windowTopY - 0.05, mz], parent: root });+ });++ [-0.60, 0.60].forEach((gz, gIdx) => {+ const gName = (gIdx === 0 ? 'L' : 'R') + '_' + cName;+ beamBetween('GrabIron_' + gName, [d * 4.34, floorY + 0.10, gz], [d * 4.34, floorY + 0.86, gz], 0.018, matBrass, { parent: root });+ });++ createPart('FootGongStem_' + cName, gongStemGeo, matSteelDark, { position: [d * 4.15, floorY - 0.08, 0], parent: root });+ createPart('FootGong_' + cName, footGongGeo, matBrass, { position: [d * 4.15, floorY - 0.14, 0], parent: root });+ });++ return root;+}diff --git a/examples/trebuchet.kiln.js b/examples/trebuchet.kiln.jsnew file mode 100644index 00000000..60cfde1b--- /dev/null+++ b/examples/trebuchet.kiln.js@@ -0,0 +1,276 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools, and cut off+// mid-run rather than finished -- by a provider limit, or by the+// dispatch deadline. The program below is what was on disk when the+// session ended; how many times it had looked at its own contact sheet+// by then is not recorded, so this one does not make the claim the+// others do.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'Trebuchet', category: 'prop' };++function build() {+ const root = createRoot('Trebuchet');++ // Materials+ const woodDark = gameMaterial(0x4a3525, { roughness: 0.85, metalness: 0.05 });+ const woodBeam = gameMaterial(0x5c432d, { roughness: 0.8, metalness: 0.05 });+ const woodLight = gameMaterial(0x705338, { roughness: 0.85, metalness: 0.05 });+ const ironMat = gameMaterial(0x242628, { roughness: 0.45, metalness: 0.85 });+ const ropeMat = gameMaterial(0x998365, { roughness: 0.95, metalness: 0.0 });+ const stoneMat = gameMaterial(0x7a7975, { roughness: 0.9, metalness: 0.05 });+ const leatherMat = gameMaterial(0x5a341a, { roughness: 0.85, metalness: 0.1 });++ // Geometry dimensions+ // Base: length 8.0 along X (-4.8 to 3.2), width 2.4 along Z (-1.2 to 1.2), sits on Y=0+ const baseRunnerGeo = boxGeo(8.0, 0.3, 0.25);+ const runnerY = 0.15;+ const zLeft = -1.1;+ const zRight = 1.1;++ // Runners+ createPart('Runner_Left', baseRunnerGeo, woodDark, { position: [-0.8, runnerY, zLeft], parent: root });+ createPart('Runner_Right', baseRunnerGeo, woodDark, { position: [-0.8, runnerY, zRight], parent: root });++ // Ladder cross rungs (7 rungs)+ const rungGeo = boxGeo(0.25, 0.22, 2.2);+ const rungXs = [-4.6, -3.2, -1.8, -0.4, 1.0, 2.2, 3.0];+ for (let i = 0; i < rungXs.length; i++) {+ createPart(`Rung_${i}`, rungGeo, woodDark, { position: [rungXs[i], runnerY + 0.02, 0], parent: root });+ }++ // Launch trough along center of ladder frame+ const troughBaseGeo = boxGeo(5.0, 0.06, 0.6);+ createPart('Trough_Base', troughBaseGeo, woodLight, { position: [-1.2, runnerY + 0.12, 0], parent: root });+ const troughSideGeo = boxGeo(5.0, 0.14, 0.06);+ createPart('Trough_SideL', troughSideGeo, woodLight, { position: [-1.2, runnerY + 0.18, -0.3], parent: root });+ createPart('Trough_SideR', troughSideGeo, woodLight, { position: [-1.2, runnerY + 0.18, 0.3], parent: root });++ // Outriggers / stabilizers on base+ const outriggerGeo = boxGeo(0.22, 0.25, 3.4);+ createPart('Outrigger_Front', outriggerGeo, woodDark, { position: [1.8, runnerY, 0], parent: root });+ createPart('Outrigger_Rear', outriggerGeo, woodDark, { position: [-3.8, runnerY, 0], parent: root });++ // A-Frame Apex position+ const apexX = 0.2;+ const apexY = 4.6;++ // A-Frame uprights on Left and Right+ const legRadius = 0.14;+ [zLeft, zRight].forEach((z, idx) => {+ const side = idx === 0 ? 'L' : 'R';++ // Front leg: from (1.8, 0.3, z) to (apexX, apexY, z)+ beamBetween(`Leg_Front_${side}`, [1.8, 0.3, z], [apexX, apexY, z], legRadius, woodDark, { parent: root });++ // Rear leg: from (-3.0, 0.3, z) to (apexX, apexY, z)+ beamBetween(`Leg_Rear_${side}`, [-3.0, 0.3, z], [apexX, apexY, z], legRadius, woodDark, { parent: root });++ // Vertical kingpost: from (apexX, 0.3, z) to (apexX, apexY, z)+ beamBetween(`Kingpost_${side}`, [apexX, 0.3, z], [apexX, apexY, z], legRadius * 0.9, woodDark, { parent: root });++ // Horizontal tie beam at Y = 2.2+ beamBetween(`Tie_Horiz_${side}`, [-1.5, 2.2, z], [1.1, 2.2, z], legRadius * 0.85, woodDark, { parent: root });++ // Diagonal braces+ beamBetween(`Brace_Front_${side}`, [0.2, 2.2, z], [1.5, 0.3, z], legRadius * 0.7, woodDark, { parent: root });+ beamBetween(`Brace_Rear_${side}`, [0.2, 2.2, z], [-2.2, 0.3, z], legRadius * 0.7, woodDark, { parent: root });++ // Apex bearing block+ const capGeo = boxGeo(0.5, 0.4, 0.32);+ createPart(`BearingBlock_${side}`, capGeo, woodBeam, { position: [apexX, apexY, z], parent: root });+ const strapGeo = boxGeo(0.52, 0.42, 0.08);+ createPart(`BearingStrap_${side}`, strapGeo, ironMat, { position: [apexX, apexY, z + (idx === 0 ? -0.16 : 0.16)], parent: root });+ });++ // Cross-bracing between trusses (Left & Right)+ beamBetween('Cross_Apex_Front', [apexX + 0.2, apexY - 0.4, zLeft], [apexX + 0.2, apexY - 0.4, zRight], 0.1, woodDark, { parent: root });+ beamBetween('Cross_Apex_Rear', [apexX - 0.2, apexY - 0.4, zLeft], [apexX - 0.2, apexY - 0.4, zRight], 0.1, woodDark, { parent: root });+ beamBetween('Cross_Tie_Mid', [apexX, 2.2, zLeft], [apexX, 2.2, zRight], 0.11, woodDark, { parent: root });+ beamBetween('Cross_Tie_Front', [1.1, 2.2, zLeft], [1.1, 2.2, zRight], 0.1, woodDark, { parent: root });+ beamBetween('Cross_Tie_Rear', [-1.5, 2.2, zLeft], [-1.5, 2.2, zRight], 0.1, woodDark, { parent: root });++ // X-bracing between rear legs+ beamBetween('X_Rear_1', [-1.5, 2.2, zLeft], [-3.0, 0.3, zRight], 0.06, woodDark, { parent: root });+ beamBetween('X_Rear_2', [-1.5, 2.2, zRight], [-3.0, 0.3, zLeft], 0.06, woodDark, { parent: root });++ // Main Axle at apex+ const axleGeo = cylinderZGeo(0.1, 0.1, 2.8, 12);+ createPart('Main_Axle', axleGeo, ironMat, { position: [apexX, apexY, 0], parent: root });++ // Throwing Beam+ // Rotated in cocked position: beam tilted down to rear (-X), short end up to front (+X).+ // Tilt angle around Z: e.g. -38 degrees.+ const beamPivot = createPivot('BeamPivot', [apexX, apexY, 0], root);+ beamPivot.rotation.z = -38 * Math.PI / 180;++ // The beam geometry centered at pivot or offset.+ // Total beam length: 7.2m. Short arm = 1.6m (+X), Long arm = 5.6m (-X).+ // Beam center offset: (1.6 - 5.6) / 2 = -2.0m.+ const beamGeo = boxGeo(7.2, 0.35, 0.28);+ createPart('Throwing_Beam', beamGeo, woodBeam, { position: [-2.0, 0, 0], parent: beamPivot });++ // Beam iron reinforcement bands around pivot+ const ironCollarGeo = boxGeo(0.8, 0.42, 0.34);+ createPart('Beam_Collar', ironCollarGeo, ironMat, { position: [0, 0, 0], parent: beamPivot });++ // Beam taper / reinforcement cheeks+ const cheekGeo = boxGeo(2.4, 0.12, 0.32);+ createPart('Beam_CheekTop', cheekGeo, woodDark, { position: [-0.5, 0.22, 0], parent: beamPivot });+ createPart('Beam_CheekBottom', cheekGeo, woodDark, { position: [-0.5, -0.22, 0], parent: beamPivot });++ // Release finger at long beam tip+ // Beam tip is at local X = -5.6+ const fingerGeo = cylinderXGeo(0.025, 0.015, 0.5, 8);+ createPart('Release_Finger', fingerGeo, ironMat, { position: [-5.7, 0.1, 0], rotation: [0, 0, 25], parent: beamPivot });+ const fingerRingGeo = torusGeo(0.06, 0.015, 8, 16);+ createPart('Finger_BaseRing', fingerRingGeo, ironMat, { position: [-5.55, 0.05, 0], rotation: [0, 90, 0], parent: beamPivot });++ // Trunnion axle on short end of beam (local X = 1.5)+ const trunnionAxleGeo = cylinderZGeo(0.06, 0.06, 1.4, 10);+ createPart('Trunnion_Axle', trunnionAxleGeo, ironMat, { position: [1.5, 0, 0], parent: beamPivot });++ // Counterweight:+ // Must hang vertically free! So create counterweight pivot attached to root at trunnion world position.+ // Let's find trunnion world position:+ // Apex = (apexX, apexY, 0). Short arm is at angle -38 deg.+ // dx = 1.5 * cos(-38 deg) = 1.5 * 0.788 = 1.182+ // dy = 1.5 * sin(-38 deg) = 1.5 * (-0.615) = -0.923 (wait, rotation around Z: +38 tilts short arm UP if +X goes to +Y!)+ // In Three.js: rotation around Z: x' = x*cos(theta) - y*sin(theta); y' = x*sin(theta) + y*cos(theta)+ // With theta = +38 deg: x' = 1.5*cos(38) = 1.18, y' = 1.5*sin(38) = 0.92.+ // If we want short arm UP and long arm DOWN: theta should be positive (+35 deg)!+ // Let's adjust beamPivot rotation:+ // theta = 38 deg.+ // Short arm (+X) goes to X = apexX + 1.5*cos(38°) = 0.2 + 1.18 = 1.38, Y = apexY + 1.5*sin(38°) = 4.6 + 0.92 = 5.52.+ // Long arm (-X) goes to X = apexX - 5.6*cos(38°) = 0.2 - 4.41 = -4.21, Y = apexY - 5.6*sin(38°) = 4.6 - 3.45 = 1.15.+ // Perfect!+ beamPivot.rotation.z = 38 * Math.PI / 180;++ const trunnionX = apexX + 1.5 * Math.cos(38 * Math.PI / 180);+ const trunnionY = apexY + 1.5 * Math.sin(38 * Math.PI / 180);++ // Counterweight hangs straight down from (trunnionX, trunnionY, 0)+ const cwPivot = createPivot('CounterweightPivot', [trunnionX, trunnionY, 0], root);++ // Counterweight suspension arms (iron hangers on left and right)+ const hangerArmGeo = boxGeo(0.08, 1.4, 0.05);+ createPart('Hanger_L', hangerArmGeo, ironMat, { position: [0, -0.65, -0.6], parent: cwPivot });+ createPart('Hanger_R', hangerArmGeo, ironMat, { position: [0, -0.65, 0.6], parent: cwPivot });++ // Counterweight box: wooden crate with iron straps+ const boxW = 1.1;+ const boxH = 1.2;+ const boxD = 1.1;+ const cwBoxGeo = boxGeo(boxW, boxH, boxD);+ createPart('CW_Box', cwBoxGeo, woodDark, { position: [0, -1.6, 0], parent: cwPivot });++ // Iron straps around counterweight box+ const strapHGeo = boxGeo(boxW + 0.04, 0.08, boxD + 0.04);+ createPart('CW_Strap_H1', strapHGeo, ironMat, { position: [0, -1.2, 0], parent: cwPivot });+ createPart('CW_Strap_H2', strapHGeo, ironMat, { position: [0, -1.9, 0], parent: cwPivot });+ const strapVGeo = boxGeo(0.08, boxH + 0.04, boxD + 0.04);+ createPart('CW_Strap_V1', strapVGeo, ironMat, { position: [-0.4, -1.6, 0], parent: cwPivot });+ createPart('CW_Strap_V2', strapVGeo, ironMat, { position: [0.4, -1.6, 0], parent: cwPivot });++ // Ballast rocks visible on top of counterweight box+ for (let i = 0; i < 6; i++) {+ const rockGeo = sphereGeo(0.18 + (i % 3) * 0.03, 6, 6);+ const rx = ((i % 3) - 1) * 0.3;+ const rz = (Math.floor(i / 3) - 0.5) * 0.4;+ createPart(`CW_Rock_${i}`, rockGeo, stoneMat, { position: [rx, -0.95, rz], parent: cwPivot });+ }++ // Beam tip world position:+ const tipX = apexX - 5.6 * Math.cos(38 * Math.PI / 180);+ const tipY = apexY - 5.6 * Math.sin(38 * Math.PI / 180);++ // Windlass assembly at rear (-X)+ const windlassX = -4.3;+ const windlassY = 0.55;++ // Upright support posts for windlass+ const winPostGeo = boxGeo(0.18, 0.8, 0.18);+ createPart('WinPost_L', winPostGeo, woodDark, { position: [windlassX, windlassY, -0.65], parent: root });+ createPart('WinPost_R', winPostGeo, woodDark, { position: [windlassX, windlassY, 0.65], parent: root });++ // Windlass drum axle+ const drumAxleGeo = cylinderZGeo(0.04, 0.04, 1.6, 10);+ createPart('Windlass_Axle', drumAxleGeo, ironMat, { position: [windlassX, windlassY + 0.25, 0], parent: root });++ // Wooden winding drum in center+ const drumGeo = cylinderZGeo(0.16, 0.16, 0.8, 12);+ createPart('Windlass_Drum', drumGeo, woodLight, { position: [windlassX, windlassY + 0.25, 0], parent: root });++ // Ratchet wheel and pawl+ const ratchetDiscGeo = cylinderZGeo(0.24, 0.24, 0.05, 16);+ createPart('Ratchet_Disc', ratchetDiscGeo, ironMat, {+ position: [windlassX, windlassY + 0.25, 0.45],+ parent: root+ });+ const toothGeo = boxGeo(0.08, 0.04, 0.05);+ for (let i = 0; i < 12; i++) {+ const angle = (i / 12) * Math.PI * 2;+ createPart(`Ratchet_Tooth_${i}`, toothGeo, ironMat, {+ position: [windlassX + Math.cos(angle) * 0.24, windlassY + 0.25 + Math.sin(angle) * 0.24, 0.45],+ rotation: [0, 0, (angle * 180 / Math.PI) + 30],+ parent: root+ });+ }+ const pawlGeo = boxGeo(0.22, 0.05, 0.04);+ createPart('Ratchet_Pawl', pawlGeo, ironMat, {+ position: [windlassX - 0.15, windlassY + 0.45, 0.45],+ rotation: [0, 0, -30],+ parent: root+ });++ // Windlass spokes / hand wheel on outer right side+ for (let a = 0; a < 4; a++) {+ const spokeGeo = cylinderGeo(0.025, 0.025, 1.1, 8);+ createPart(`WinSpoke_${a}`, spokeGeo, woodDark, {+ position: [windlassX, windlassY + 0.25, 0.82],+ rotation: [0, 0, a * 45],+ parent: root+ });+ }++ // Cocking rope from windlass drum to beam tip hook+ beamBetween('Cocking_Rope', [windlassX, windlassY + 0.35, 0], [tipX, tipY, 0], 0.025, ropeMat, { parent: root });++ // Stone Ball and Leather Pouch in trough+ // Stone ball sits in trough at X = -1.2, Y = 0.45, Z = 0+ const stoneRadius = 0.22;+ const stoneX = -1.2;+ const stoneY = runnerY + 0.12 + 0.03 + stoneRadius;+ const stoneGeo = sphereGeo(stoneRadius, 12, 10);+ createPart('Stone_Shot', stoneGeo, stoneMat, { position: [stoneX, stoneY, 0], parent: root });++ // Leather pouch under and around stone+ const pouchGeo = boxGeo(0.55, 0.08, 0.48);+ createPart('Leather_Pouch', pouchGeo, leatherMat, { position: [stoneX, stoneY - stoneRadius + 0.03, 0], parent: root });++ // Sling ropes running from beam tip to leather pouch+ beamBetween('Sling_Rope_L', [tipX, tipY + 0.05, -0.06], [stoneX - 0.25, stoneY - 0.05, -0.2], 0.015, ropeMat, { parent: root });+ beamBetween('Sling_Rope_R', [tipX, tipY + 0.05, 0.06], [stoneX - 0.25, stoneY - 0.05, 0.2], 0.015, ropeMat, { parent: root });++ // Rope lashings and iron brackets at critical joints+ // Base corners iron straps+ [-4.6, 3.0].forEach(bx => {+ [zLeft, zRight].forEach((bz, bidx) => {+ const cornerStrap = boxGeo(0.35, 0.32, 0.3);+ createPart(`Strap_Base_${bx > 0 ? 'F' : 'R'}_${bidx === 0 ? 'L' : 'R'}`, cornerStrap, ironMat, { position: [bx, runnerY, bz], parent: root });+ });+ });++ // Lashings around A-frame leg bases+ [zLeft, zRight].forEach((z, idx) => {+ const s = idx === 0 ? 'L' : 'R';+ const lashingGeo = cylinderGeo(0.2, 0.2, 0.25, 8);+ createPart(`Lash_Front_${s}`, lashingGeo, ropeMat, { position: [1.8, 0.35, z], parent: root });+ createPart(`Lash_Rear_${s}`, lashingGeo, ropeMat, { position: [-3.0, 0.35, z], parent: root });+ });++ return root;+}diff --git a/examples/tugboat.kiln.js b/examples/tugboat.kiln.jsnew file mode 100644index 00000000..db6422ff--- /dev/null+++ b/examples/tugboat.kiln.js@@ -0,0 +1,735 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Its hull, deckhouse, mast and fittings are its own.+//+// Two things were repaired afterwards. The whip antennas started 50 mm above+// the masthead, which is two numbers. And the bilge keels were straight boxes+// parked at a fixed z: the half-beam runs from 2.40 m amidships to 0.06 m at+// the cutwater, so a 5 m bar leaves the plating long before either end and+// reads as a red stick hanging in the water beside the boat. Moving it inboard+// only moves where it detaches, so the fins are now swept along the hull --+// they sample the model's own getStationProfile at each station and stand off+// the surface normal, which puts them on the plating by construction. Nothing+// else in the program was touched.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'Tugboat', category: 'vehicle', role: 'vehicle' };++async function build() {+ const root = createRoot('Tugboat');++ // ==========================================+ // MATERIALS (Consistent, game-ready PBR)+ // ==========================================+ const hullLowerMat = gameMaterial(0x8b2010, { roughness: 0.65, metalness: 0.15 }); // Red oxide antifouling+ const hullUpperMat = gameMaterial(0x182026, { roughness: 0.55, metalness: 0.25 }); // Dark navy/black steel topsides+ const bootTopMat = gameMaterial(0xf0f0f0, { roughness: 0.6, metalness: 0.1 }); // White waterline stripe / band+ const deckMat = gameMaterial(0x3a4048, { roughness: 0.85, metalness: 0.2 }); // Non-skid steel deck+ const deckhouseMat = gameMaterial(0xf4f6f8, { roughness: 0.45, metalness: 0.15 }); // Crisp white superstructure+ const trimDarkMat = gameMaterial(0x222a35, { roughness: 0.6, metalness: 0.3 }); // Bulwarks capping & trims+ const glassMat = glassMaterial(0x4080aa, { opacity: 0.5, roughness: 0.1, metalness: 0.4 }); // Glazing+ const fenderMat = gameMaterial(0x3e3226, { roughness: 0.95, metalness: 0.0 }); // Coir rope fender belt+ const puddingMat = gameMaterial(0x2e241a, { roughness: 0.98, metalness: 0.0 }); // Bow pudding fender+ const rubberMat = gameMaterial(0x1a1a1a, { roughness: 0.9, metalness: 0.05 }); // Tyre drop fenders+ const funnelMat = gameMaterial(0xd35400, { roughness: 0.5, metalness: 0.2 }); // Maritime orange funnel+ const funnelCapMat = gameMaterial(0x151515, { roughness: 0.7, metalness: 0.3 }); // Black funnel cap+ const steelMat = gameMaterial(0x71797e, { roughness: 0.4, metalness: 0.75 }); // Machinery & rails+ const darkIronMat = gameMaterial(0x282c34, { roughness: 0.65, metalness: 0.7 }); // Bitts, towing hook, windlass+ const brassMat = gameMaterial(0xd4af37, { roughness: 0.3, metalness: 0.85 }); // Propeller, horn, portholes+ const mastMat = gameMaterial(0xdde2e6, { roughness: 0.4, metalness: 0.3 }); // Radar mast+ const lanternRed = gameMaterial(0xdd2222, { roughness: 0.2, metalness: 0.1, emissive: 0xaa0000, emissiveIntensity: 0.9 });+ const lanternGreen = gameMaterial(0x22dd44, { roughness: 0.2, metalness: 0.1, emissive: 0x00aa22, emissiveIntensity: 0.9 });+ const lanternWhite = gameMaterial(0xffffff, { roughness: 0.2, metalness: 0.1, emissive: 0xffffff, emissiveIntensity: 0.9 });+ const lanternAmber = gameMaterial(0xffaa11, { roughness: 0.2, metalness: 0.1, emissive: 0xee8800, emissiveIntensity: 0.9 });+ const lifeRingMat = gameMaterial(0xe65100, { roughness: 0.6, metalness: 0.05 }); // Orange lifebuoy++ // ==========================================+ // 1. PARAMETRIC HULL GEOMETRY+ // ==========================================+ // Tuned station and girth count to fit solidly in 4,000-12,000 triangle budget (~7,500 tris)+ const numStations = 16;+ const numGirthLower = 5;+ const numGirthUpper = 4;+ const wlY = 1.65; // Waterline height++ function getStationProfile(u) {+ const xBase = -6.6 + 15.0 * u;++ // Keel profile: flat at Y=0 amidships, rises at deadwood (stern) and forefoot (bow)+ let yKeel = 0.0;+ if (u < 0.15) {+ const tf = (0.15 - u) / 0.15;+ yKeel = 0.85 * tf * tf;+ } else if (u > 0.84) {+ const tf = (u - 0.84) / 0.16;+ yKeel = 0.75 * tf * tf;+ }++ // Sheerline profile: classic sweep, lowest amidships, rising to bow flare+ let ySheer = 2.45;+ if (u <= 0.45) {+ const tf = (0.45 - u) / 0.45;+ ySheer = 2.45 + 0.35 * tf * tf;+ } else {+ const tf = (u - 0.45) / 0.55;+ ySheer = 2.45 + 1.05 * tf * tf;+ }++ // Half beam: max amidships (u=0.48), rounded counter at stern, sharp cutwater at stem+ let b = 2.4;+ if (u < 0.48) {+ const tf = (0.48 - u) / 0.48;+ b = 2.4 * (1.0 - 0.38 * tf * tf);+ } else {+ const tf = (u - 0.48) / 0.52;+ b = 0.06 + (2.4 - 0.06) * (1.0 - Math.pow(tf, 1.45));+ }++ // Stem rake forward & stern counter overhang aft+ let rakeX = 0;+ if (u > 0.84) {+ rakeX = 0.65 * Math.pow((u - 0.84) / 0.16, 1.5);+ } else if (u < 0.12) {+ rakeX = -0.45 * Math.pow((0.12 - u) / 0.12, 1.5);+ }++ return { xBase, rakeX, yKeel, ySheer, b };+ }++ // Generate Lower Hull (Keel to Waterline)+ const lowerPos = [];+ const lowerIndices = [];+ for (let i = 0; i <= numStations; i++) {+ const u = i / numStations;+ const st = getStationProfile(u);+ const yTop = Math.min(wlY, st.ySheer - 0.05);++ // Starboard (+z)+ for (let j = 0; j <= numGirthLower; j++) {+ const v = j / numGirthLower;+ const y = st.yKeel + v * (yTop - st.yKeel);+ const x = st.xBase + st.rakeX * (y / st.ySheer);+ const angle = v * (Math.PI / 2);+ const zFrac = Math.pow(Math.sin(angle), 0.55);+ const zHalf = 0.12 + (st.b * (yTop / st.ySheer) - 0.12) * zFrac;+ lowerPos.push(x, y, zHalf);+ }+ // Port (-z)+ for (let j = 0; j <= numGirthLower; j++) {+ const v = j / numGirthLower;+ const y = st.yKeel + v * (yTop - st.yKeel);+ const x = st.xBase + st.rakeX * (y / st.ySheer);+ const angle = v * (Math.PI / 2);+ const zFrac = Math.pow(Math.sin(angle), 0.55);+ const zHalf = 0.12 + (st.b * (yTop / st.ySheer) - 0.12) * zFrac;+ lowerPos.push(x, y, -zHalf);+ }+ }++ const ptsPerStLower = (numGirthLower + 1) * 2;+ for (let i = 0; i < numStations; i++) {+ for (let j = 0; j < numGirthLower; j++) {+ // Starboard side+ const a = i * ptsPerStLower + j;+ const b = a + 1;+ const c = (i + 1) * ptsPerStLower + j;+ const d = c + 1;+ lowerIndices.push(a, b, d, a, d, c);++ // Port side+ const pa = i * ptsPerStLower + (numGirthLower + 1) + j;+ const pb = pa + 1;+ const pc = (i + 1) * ptsPerStLower + (numGirthLower + 1) + j;+ const pd = pc + 1;+ lowerIndices.push(pa, pc, pd, pa, pd, pb);+ }+ }++ const lowerHullGeo = new THREE.BufferGeometry();+ lowerHullGeo.setAttribute('position', new THREE.Float32BufferAttribute(lowerPos, 3));+ lowerHullGeo.setIndex(lowerIndices);+ lowerHullGeo.computeVertexNormals();+ createPart('HullLower', lowerHullGeo, hullLowerMat, { parent: root });++ // Generate Upper Hull (Waterline to Sheerline)+ const upperPos = [];+ const upperIndices = [];+ const sheerlinePoints = [];+ const sheerlinePort = [];++ for (let i = 0; i <= numStations; i++) {+ const u = i / numStations;+ const st = getStationProfile(u);+ const yBot = Math.min(wlY, st.ySheer - 0.05);++ for (let j = 0; j <= numGirthUpper; j++) {+ const v = j / numGirthUpper;+ const y = yBot + v * (st.ySheer - yBot);+ const x = st.xBase + st.rakeX * (y / st.ySheer);+ const zBot = 0.12 + (st.b * (yBot / st.ySheer) - 0.12);+ const zTop = st.b;+ const zHalf = zBot + v * (zTop - zBot);+ upperPos.push(x, y, zHalf);++ if (j === numGirthUpper) {+ sheerlinePoints.push([x, y, zHalf]);+ sheerlinePort.push([x, y, -zHalf]);+ }+ }+ for (let j = 0; j <= numGirthUpper; j++) {+ const v = j / numGirthUpper;+ const y = yBot + v * (st.ySheer - yBot);+ const x = st.xBase + st.rakeX * (y / st.ySheer);+ const zBot = 0.12 + (st.b * (yBot / st.ySheer) - 0.12);+ const zTop = st.b;+ const zHalf = zBot + v * (zTop - zBot);+ upperPos.push(x, y, -zHalf);+ }+ }++ const ptsPerStUpper = (numGirthUpper + 1) * 2;+ for (let i = 0; i < numStations; i++) {+ for (let j = 0; j < numGirthUpper; j++) {+ const a = i * ptsPerStUpper + j;+ const b = a + 1;+ const c = (i + 1) * ptsPerStUpper + j;+ const d = c + 1;+ upperIndices.push(a, b, d, a, d, c);++ const pa = i * ptsPerStUpper + (numGirthUpper + 1) + j;+ const pb = pa + 1;+ const pc = (i + 1) * ptsPerStUpper + (numGirthUpper + 1) + j;+ const pd = pc + 1;+ upperIndices.push(pa, pc, pd, pa, pd, pb);+ }+ }++ const upperHullGeo = new THREE.BufferGeometry();+ upperHullGeo.setAttribute('position', new THREE.Float32BufferAttribute(upperPos, 3));+ upperHullGeo.setIndex(upperIndices);+ upperHullGeo.computeVertexNormals();+ createPart('HullUpper', upperHullGeo, hullUpperMat, { parent: root });++ // Stern counter cap+ createPart('SternCounterCap', cylinderGeo(1.48, 1.45, 1.1, 12, 1, false, Math.PI / 2, Math.PI), hullUpperMat, {+ position: [-6.6, 2.05, 0],+ rotation: [0, 90, 0],+ scale: [1, 1, 0.45],+ parent: root+ });++ // Main Deck Surface+ const deckPos = [];+ const deckIndices = [];+ for (let i = 0; i <= numStations; i++) {+ const u = i / numStations;+ const st = getStationProfile(u);+ const x = st.xBase + st.rakeX;+ const y = st.ySheer;+ const b = st.b - 0.08;+ deckPos.push(x, y, b);+ deckPos.push(x, y, -b);+ }+ for (let i = 0; i < numStations; i++) {+ const a = i * 2;+ const b = a + 1;+ const c = (i + 1) * 2;+ const d = c + 1;+ deckIndices.push(a, d, b, a, c, d);+ }+ const deckGeo = new THREE.BufferGeometry();+ deckGeo.setAttribute('position', new THREE.Float32BufferAttribute(deckPos, 3));+ deckGeo.setIndex(deckIndices);+ deckGeo.computeVertexNormals();+ createPart('MainDeck', deckGeo, deckMat, { parent: root });++ // Bulwarks+ const bulwarkPos = [];+ const bulwarkIndices = [];+ const bulwarkHeight = 0.65;+ for (let i = 0; i <= numStations; i++) {+ const u = i / numStations;+ const st = getStationProfile(u);+ const x = st.xBase + st.rakeX;+ const yBase = st.ySheer;+ const yTop = yBase + bulwarkHeight;+ const b = st.b;+ bulwarkPos.push(x, yBase, b);+ bulwarkPos.push(x, yTop, b);+ bulwarkPos.push(x, yBase, -b);+ bulwarkPos.push(x, yTop, -b);+ }+ for (let i = 0; i < numStations; i++) {+ const a = i * 4;+ const b = a + 1;+ const c = (i + 1) * 4;+ const d = c + 1;+ bulwarkIndices.push(a, b, d, a, d, c);++ const pa = i * 4 + 2;+ const pb = pa + 1;+ const pc = (i + 1) * 4 + 2;+ const pd = pc + 1;+ bulwarkIndices.push(pa, pd, pb, pa, pc, pd);+ }+ const bulwarkGeo = new THREE.BufferGeometry();+ bulwarkGeo.setAttribute('position', new THREE.Float32BufferAttribute(bulwarkPos, 3));+ bulwarkGeo.setIndex(bulwarkIndices);+ bulwarkGeo.computeVertexNormals();+ createPart('Bulwarks', bulwarkGeo, hullUpperMat, { parent: root });++ // Bulwark Capping Rails+ const stbdCapPath = [];+ const portCapPath = [];+ for (let i = 0; i <= numStations; i++) {+ const u = i / numStations;+ const st = getStationProfile(u);+ stbdCapPath.push([st.xBase + st.rakeX, st.ySheer + bulwarkHeight, st.b]);+ portCapPath.push([st.xBase + st.rakeX, st.ySheer + bulwarkHeight, -st.b]);+ }+ const stbdCapGeo = pipeAlongPath(stbdCapPath, 0.055, { bendRadius: 0.15, tubularSegments: 16, radialSegments: 6 });+ createPart('CapRailStbd', stbdCapGeo, trimDarkMat, { parent: root });++ const portCapGeo = pipeAlongPath(portCapPath, 0.055, { bendRadius: 0.15, tubularSegments: 16, radialSegments: 6 });+ createPart('CapRailPort', portCapGeo, trimDarkMat, { parent: root });++ createPart('CapStern', torusGeo(1.48, 0.055, 6, 12), trimDarkMat, {+ position: [-6.6, 2.75 + bulwarkHeight, 0],+ rotation: [90, 0, 0],+ scale: [0.6, 1, 1],+ parent: root+ });++ // Freeing ports / scuppers+ const scupperX = [-4.0, -2.0, 0.2, 2.4];+ scupperX.forEach((sx, idx) => {+ createPart(`ScupperStbd_${idx}`, decalBox(0.35, 0.14, 0.03), trimDarkMat, { position: [sx, 2.58, 2.38], parent: root });+ createPart(`ScupperPort_${idx}`, decalBox(0.35, 0.14, 0.03), trimDarkMat, { position: [sx, 2.58, -2.38], parent: root });+ });++ // ==========================================+ // 2. KEEL BAR, SKEG & BILGE KEELS (Grounding firmly at Y=0)+ // ==========================================+ // Continuous bar keel touching Y=0 (Y center = 0.11, height = 0.22 -> min Y = 0.000)+ createPart('KeelBarMain', boxGeo(10.5, 0.22, 0.28), hullLowerMat, { position: [1.2, 0.11, 0], parent: root });+ // Stern skeg / sole piece extending under propeller to rudder heel (min Y = 0.000)+ createPart('SkegSolePiece', boxGeo(3.2, 0.22, 0.22), hullLowerMat, { position: [-5.4, 0.11, 0], parent: root });+ // Deadwood fairing connecting keel to hull stern+ createPart('Deadwood', boxGeo(2.4, 0.75, 0.24), hullLowerMat, { position: [-4.6, 0.55, 0], parent: root });++ // Bilge keels (roll damping fins), swept along the hull rather than laid+ // beside it.+ //+ // A bilge keel is welded to the turn of the bilge and follows it, so a+ // straight box cannot be one: the half-beam here runs from 2.40 m amidships+ // to 0.06 m at the cutwater, and a 5 m bar parked at a fixed z leaves the+ // plating long before it reaches either end. That is what it looked like --+ // a red stick hanging in the water alongside the boat.+ //+ // The hull is parametric, so the fin can simply ask it where the plating is.+ // At each station it samples getStationProfile at a fixed girth fraction,+ // takes the surface tangent there analytically, and sweeps a thin rectangle+ // outward along the surface normal. The fin is then on the hull by+ // construction, at every station, whatever the sections do.+ const BK_V = 0.42; // girth fraction: the turn of the bilge+ const BK_DEPTH = 0.30; // how far the fin stands off the plating+ const BK_THICK = 0.06;+ const BK_U0 = 0.28;+ const BK_U1 = 0.72;+ const BK_STATIONS = 12;++ // The plating point and its outward normal at girth fraction v, in the+ // station's own y-z plane. dz/dv is the derivative of the girth curve the+ // hull loops use, so the fin sits flush instead of approximately flush.+ function bilgeFrame(u) {+ const st = getStationProfile(u);+ const yTop = Math.min(wlY, st.ySheer - 0.05);+ const zSpan = st.b * (yTop / st.ySheer) - 0.12;+ const ang = BK_V * (Math.PI / 2);+ const y = st.yKeel + BK_V * (yTop - st.yKeel);+ const z = 0.12 + zSpan * Math.pow(Math.sin(ang), 0.55);+ const dy = yTop - st.yKeel;+ const dz = zSpan * 0.55 * Math.pow(Math.sin(ang), -0.45) * Math.cos(ang) * (Math.PI / 2);+ const len = Math.hypot(dy, dz) || 1;+ return { st, y, z, ny: -dz / len, nz: dy / len, ty: dy / len, tz: dz / len };+ }++ function bilgeKeelGeo(side) {+ const pos = [];+ const idx = [];+ for (let i = 0; i <= BK_STATIONS; i++) {+ const u = BK_U0 + (i / BK_STATIONS) * (BK_U1 - BK_U0);+ const f = bilgeFrame(u);+ // Four section corners: inner and outer edge, each given the fin's+ // thickness along the girth tangent.+ for (const d of [0, BK_DEPTH]) {+ for (const t of [-BK_THICK / 2, BK_THICK / 2]) {+ const y = f.y + f.ny * d + f.ty * t;+ const z = f.z + f.nz * d + f.tz * t;+ const x = f.st.xBase + f.st.rakeX * (y / f.st.ySheer);+ pos.push(x, y, side * z);+ }+ }+ }+ const quad = (a, b, c, d) =>+ side > 0 ? idx.push(a, b, d, a, d, c) : idx.push(a, d, b, a, c, d);+ for (let i = 0; i < BK_STATIONS; i++) {+ const a = i * 4;+ const b = a + 4;+ quad(a + 0, a + 1, b + 0, b + 1); // inner face+ quad(a + 2, a + 3, b + 2, b + 3); // outer face+ quad(a + 0, a + 2, b + 0, b + 2); // one side+ quad(a + 1, a + 3, b + 1, b + 3); // the other+ }+ // Caps, so the fin reads as a plate with ends and not an open trough.+ const last = BK_STATIONS * 4;+ quad(0, 1, 2, 3);+ quad(last + 2, last + 3, last + 0, last + 1);+ const geo = new THREE.BufferGeometry();+ geo.setAttribute('position', new THREE.Float32BufferAttribute(pos, 3));+ geo.setIndex(idx);+ geo.computeVertexNormals();+ return geo;+ }++ createPart('BilgeKeelStbd', bilgeKeelGeo(1), hullLowerMat, { parent: root });+ createPart('BilgeKeelPort', bilgeKeelGeo(-1), hullLowerMat, { parent: root });++ // ==========================================+ // 3. HEAVY ROPE FENDER BELTING & BOW PUDDING FENDER+ // ==========================================+ const fullFenderPath = [];+ for (let i = numStations; i >= 0; i--) {+ fullFenderPath.push([sheerlinePoints[i][0], sheerlinePoints[i][1] - 0.05, sheerlinePoints[i][2] + 0.12]);+ }+ const sternR = 1.58;+ for (let a = 0; a <= 6; a++) {+ const theta = (a / 6) * Math.PI;+ const sx = -6.6 - Math.sin(theta) * 0.42;+ const sz = Math.cos(theta) * sternR;+ fullFenderPath.push([sx, 2.75, sz]);+ }+ for (let i = 0; i <= numStations; i++) {+ fullFenderPath.push([sheerlinePort[i][0], sheerlinePort[i][1] - 0.05, sheerlinePort[i][2] - 0.12]);+ }++ const fenderBeltGeo = pipeAlongPath(fullFenderPath, 0.24, { bendRadius: 0.25, closed: true, tubularSegments: 36, radialSegments: 6 });+ createPart('RopeFenderBelt', fenderBeltGeo, fenderMat, { parent: root });++ // Bow Pudding Fender (Tight to the raked cutwater stem)+ const puddingGroup = createPivot('BowPuddingAssembly', [0, 0, 0], root);+ const pMainPoints = [+ [7.9, 3.1, -0.6],+ [8.5, 3.0, -0.3],+ [8.95, 2.9, 0.0],+ [8.5, 3.0, 0.3],+ [7.9, 3.1, 0.6],+ ];+ const pMainGeo = pipeAlongPath(pMainPoints, 0.38, { bendRadius: 0.2, tubularSegments: 12, radialSegments: 6 });+ createPart('PuddingCenter', pMainGeo, puddingMat, { parent: puddingGroup });++ const pUpperPoints = [+ [8.2, 3.65, -0.5],+ [8.7, 3.55, -0.25],+ [9.15, 3.45, 0.0],+ [8.7, 3.55, 0.25],+ [8.2, 3.65, 0.5],+ ];+ const pUpperGeo = pipeAlongPath(pUpperPoints, 0.32, { bendRadius: 0.18, tubularSegments: 12, radialSegments: 6 });+ createPart('PuddingUpper', pUpperGeo, puddingMat, { parent: puddingGroup });++ const pLowerPoints = [+ [7.7, 2.55, -0.6],+ [8.2, 2.45, -0.3],+ [8.65, 2.35, 0.0],+ [8.2, 2.45, 0.3],+ [7.7, 2.55, 0.6],+ ];+ const pLowerGeo = pipeAlongPath(pLowerPoints, 0.36, { bendRadius: 0.18, tubularSegments: 12, radialSegments: 6 });+ createPart('PuddingLower', pLowerGeo, puddingMat, { parent: puddingGroup });++ beamBetween('PuddingChainTopL', [8.2, 3.75, -0.5], [8.0, 3.6, -0.85], 0.035, darkIronMat, { parent: puddingGroup });+ beamBetween('PuddingChainTopR', [8.2, 3.75, 0.5], [8.0, 3.6, 0.85], 0.035, darkIronMat, { parent: puddingGroup });+ beamBetween('PuddingChainBotL', [7.7, 2.4, -0.55], [7.5, 2.25, -0.9], 0.035, darkIronMat, { parent: puddingGroup });+ beamBetween('PuddingChainBotR', [7.7, 2.4, 0.55], [7.5, 2.25, 0.9], 0.035, darkIronMat, { parent: puddingGroup });++ // Side tyre drop fenders+ const dropFenderX = [-2.5, -0.8, 0.8];+ dropFenderX.forEach((dx, i) => {+ createPart(`TyreStbd_${i}`, torusGeo(0.32, 0.1, 6, 10), rubberMat, { position: [dx, 2.2, 2.48], rotation: [0, 90, 0], parent: root });+ beamBetween(`TyreChainS_${i}`, [dx, 3.05, 2.42], [dx, 2.5, 2.48], 0.02, steelMat, { parent: root });+ createPart(`TyrePort_${i}`, torusGeo(0.32, 0.1, 6, 10), rubberMat, { position: [dx, 2.2, -2.48], rotation: [0, 90, 0], parent: root });+ beamBetween(`TyreChainP_${i}`, [dx, 3.05, -2.42], [dx, 2.5, -2.48], 0.02, steelMat, { parent: root });+ });++ // ==========================================+ // 4. LOW FORECASTLE, ANCHOR WINCH & HAWSE PIPES+ // ==========================================+ createPart('ForecastleDeck', boxGeo(3.6, 0.18, 3.6), deckMat, { position: [6.0, 3.22, 0], parent: root });+ createPart('Breakwater', boxGeo(0.12, 0.35, 3.4), trimDarkMat, { position: [4.2, 3.4, 0], parent: root });++ // Anchor Winch+ createPart('WinchBed', boxGeo(1.5, 0.35, 1.9), darkIronMat, { position: [5.6, 3.45, 0], parent: root });+ createPart('WinchGearCase', boxGeo(0.8, 0.7, 0.6), darkIronMat, { position: [5.6, 3.85, 0], parent: root });+ createPart('WinchDriveMotor', cylinderXGeo(0.24, 0.24, 0.85, 8), steelMat, { position: [5.1, 3.75, 0], parent: root });+ createPart('WildcatPort', cylinderZGeo(0.38, 0.38, 0.32, 10), darkIronMat, { position: [5.6, 3.85, -0.55], parent: root });+ createPart('WildcatStbd', cylinderZGeo(0.38, 0.38, 0.32, 10), darkIronMat, { position: [5.6, 3.85, 0.55], parent: root });+ createPart('WarpingHeadPort', cylinderZGeo(0.26, 0.32, 0.38, 8), steelMat, { position: [5.6, 3.85, -1.0], parent: root });+ createPart('WarpingHeadStbd', cylinderZGeo(0.26, 0.32, 0.38, 8), steelMat, { position: [5.6, 3.85, 1.0], parent: root });+ createPart('BrakeWheelPort', torusGeo(0.22, 0.03, 6, 10), darkIronMat, { position: [5.1, 4.15, -0.55], rotation: [0, 90, 0], parent: root });+ createPart('BrakeWheelStbd', torusGeo(0.22, 0.03, 6, 10), darkIronMat, { position: [5.1, 4.15, 0.55], rotation: [0, 90, 0], parent: root });++ createPart('HawseLipPort', torusGeo(0.25, 0.06, 6, 8), darkIronMat, { position: [7.2, 2.7, -1.25], rotation: [25, 30, 0], parent: root });+ createPart('HawseLipStbd', torusGeo(0.25, 0.06, 6, 8), darkIronMat, { position: [7.2, 2.7, 1.25], rotation: [-25, 30, 0], parent: root });+ beamBetween('ChainRunPort', [5.6, 3.75, -0.55], [6.8, 3.32, -0.85], 0.055, darkIronMat, { parent: root });+ beamBetween('ChainRunStbd', [5.6, 3.75, 0.55], [6.8, 3.32, 0.85], 0.055, darkIronMat, { parent: root });++ beamBetween('AnchorShankPort', [7.2, 2.7, -1.25], [7.7, 2.1, -1.55], 0.07, darkIronMat, { parent: root });+ createPart('AnchorCrownPort', boxGeo(0.3, 0.35, 0.5), darkIronMat, { position: [7.7, 2.05, -1.6], rotation: [20, -35, 10], parent: root });+ createPart('AnchorFlukePort', boxGeo(0.55, 0.5, 0.12), darkIronMat, { position: [7.85, 2.15, -1.62], rotation: [20, -35, 10], parent: root });++ beamBetween('AnchorShankStbd', [7.2, 2.7, 1.25], [7.7, 2.1, 1.55], 0.07, darkIronMat, { parent: root });+ createPart('AnchorCrownStbd', boxGeo(0.3, 0.35, 0.5), darkIronMat, { position: [7.7, 2.05, 1.6], rotation: [-20, 35, 10], parent: root });+ createPart('AnchorFlukeStbd', boxGeo(0.55, 0.5, 0.12), darkIronMat, { position: [7.85, 2.15, 1.62], rotation: [-20, 35, 10], parent: root });++ createPart('BowCenterChock', boxGeo(0.4, 0.25, 0.5), darkIronMat, { position: [8.2, 3.85, 0], parent: root });+ createPart('BowChockHole', cylinderXGeo(0.12, 0.12, 0.5, 8), trimDarkMat, { position: [8.2, 3.88, 0], parent: root });++ // ==========================================+ // 5. WHITE DECKHOUSE & GLAZED WHEELHOUSE WITH WALKAROUND BRIDGE+ // ==========================================+ createPart('DeckhouseMain', boxGeo(4.8, 1.55, 3.1), deckhouseMat, { position: [1.8, 3.5, 0], parent: root });+ createPart('EngineCasing', boxGeo(2.2, 1.35, 2.4), deckhouseMat, { position: [-0.9, 3.4, 0], parent: root });++ createPart('DoorStbd', boxGeo(0.1, 1.3, 0.7), trimDarkMat, { position: [0.8, 3.4, 1.57], parent: root });+ createPart('DoorPort', boxGeo(0.1, 1.3, 0.7), trimDarkMat, { position: [0.8, 3.4, -1.57], parent: root });++ const portholeOffsets = [-0.4, 1.8, 3.0];+ portholeOffsets.forEach((px, i) => {+ createPart(`PortholeStbd_${i}`, torusGeo(0.15, 0.03, 6, 8), brassMat, { position: [px, 3.65, 1.57], rotation: [0, 90, 0], parent: root });+ createPart(`PortholePort_${i}`, torusGeo(0.15, 0.03, 6, 8), brassMat, { position: [px, 3.65, -1.57], rotation: [0, 90, 0], parent: root });+ });++ createPart('LouverStbd', boxGeo(0.8, 0.4, 0.08), trimDarkMat, { position: [-1.2, 3.65, 1.23], parent: root });+ createPart('LouverPort', boxGeo(0.8, 0.4, 0.08), trimDarkMat, { position: [-1.2, 3.65, -1.23], parent: root });+ createPart('MushroomVent1', cylinderYGeo(0.18, 0.12, 0.4, 8), steelMat, { position: [-1.6, 4.3, 0.7], parent: root });+ createPart('MushroomVent2', cylinderYGeo(0.18, 0.12, 0.4, 8), steelMat, { position: [-1.6, 4.3, -0.7], parent: root });++ createLadder('BridgeLadderPort', { bottom: [0.0, 2.65, -1.75], top: [0.0, 4.25, -1.75], width: 0.48, rungCount: 5, material: steelMat, parent: root });+ createLadder('BridgeLadderStbd', { bottom: [0.0, 2.65, 1.75], top: [0.0, 4.25, 1.75], width: 0.48, rungCount: 5, material: steelMat, parent: root });++ createPart('LifebuoyStbd', torusGeo(0.3, 0.08, 6, 10), lifeRingMat, { position: [2.5, 3.6, 1.6], rotation: [0, 90, 0], parent: root });+ createPart('LifebuoyPort', torusGeo(0.3, 0.08, 6, 10), lifeRingMat, { position: [2.5, 3.6, -1.6], rotation: [0, 90, 0], parent: root });++ createPart('BridgeDeckFloor', boxGeo(5.2, 0.16, 3.7), deckMat, { position: [1.8, 4.28, 0], parent: root });+ createPart('BridgeWingStbd', boxGeo(1.6, 0.16, 0.45), deckMat, { position: [2.2, 4.28, 2.05], parent: root });+ createPart('BridgeWingPort', boxGeo(1.6, 0.16, 0.45), deckMat, { position: [2.2, 4.28, -2.05], parent: root });++ const bridgeRailGroup = createPivot('BridgeRailings', [0, 0, 0], root);+ const railH = 0.92;+ const bY = 4.36;+ const bPerimeter = [+ [-0.7, 1.85], [1.4, 1.85], [1.4, 2.25], [3.0, 2.25], [3.0, 1.85], [4.3, 1.85],+ [4.3, -1.85], [3.0, -1.85], [3.0, -2.25], [1.4, -2.25], [1.4, -1.85], [-0.7, -1.85]+ ];+ const topRailPts = bPerimeter.map(p => [p[0], bY + railH, p[1]]);+ const midRailPts = bPerimeter.map(p => [p[0], bY + railH * 0.5, p[1]]);+ const topRailGeo = pipeAlongPath(topRailPts, 0.028, { bendRadius: 0.1, closed: true, tubularSegments: 24, radialSegments: 5 });+ createPart('BridgeTopRail', topRailGeo, steelMat, { parent: bridgeRailGroup });++ const midRailGeo = pipeAlongPath(midRailPts, 0.02, { bendRadius: 0.1, closed: true, tubularSegments: 24, radialSegments: 5 });+ createPart('BridgeMidRail', midRailGeo, steelMat, { parent: bridgeRailGroup });++ bPerimeter.forEach((p, idx) => {+ beamBetween(`Stanchion_${idx}`, [p[0], bY, p[1]], [p[0], bY + railH, p[1]], 0.026, steelMat, { parent: bridgeRailGroup });+ });++ // Glazed Wheelhouse+ createPart('WheelhouseLower', boxGeo(3.0, 0.6, 2.6), deckhouseMat, { position: [2.2, 4.66, 0], parent: root });+ createPart('WheelhouseRoof', boxGeo(3.4, 0.16, 3.0), deckhouseMat, { position: [2.2, 5.92, 0], parent: root });+ createPart('SunVisor', boxGeo(0.5, 0.08, 3.1), trimDarkMat, { position: [3.8, 5.9, 0], rotation: [0, 0, -15], parent: root });++ createPart('FrontWinGlass', boxGeo(0.06, 0.75, 2.3), glassMat, { position: [3.71, 5.35, 0], parent: root });+ createPart('ClearViewScreen', torusGeo(0.24, 0.025, 6, 10), brassMat, { position: [3.73, 5.35, 0], rotation: [0, 90, 0], parent: root });+ beamBetween('MullionF1', [3.72, 4.96, -0.6], [3.72, 5.76, -0.6], 0.035, trimDarkMat, { parent: root });+ beamBetween('MullionF2', [3.72, 4.96, 0.6], [3.72, 5.76, 0.6], 0.035, trimDarkMat, { parent: root });++ createPart('StbdWinGlass', boxGeo(2.4, 0.75, 0.06), glassMat, { position: [2.2, 5.35, 1.31], parent: root });+ beamBetween('MullionS1', [1.6, 4.96, 1.32], [1.6, 5.76, 1.32], 0.035, trimDarkMat, { parent: root });+ beamBetween('MullionS2', [2.8, 4.96, 1.32], [2.8, 5.76, 1.32], 0.035, trimDarkMat, { parent: root });++ createPart('PortWinGlass', boxGeo(2.4, 0.75, 0.06), glassMat, { position: [2.2, 5.35, -1.31], parent: root });+ beamBetween('MullionP1', [1.6, 4.96, -1.32], [1.6, 5.76, -1.32], 0.035, trimDarkMat, { parent: root });+ beamBetween('MullionP2', [2.8, 4.96, -1.32], [2.8, 5.76, -1.32], 0.035, trimDarkMat, { parent: root });++ createPart('AftWinGlass', boxGeo(0.06, 0.75, 1.8), glassMat, { position: [0.69, 5.35, 0], parent: root });++ // Interior+ createPart('HelmConsole', boxGeo(0.6, 0.5, 1.4), darkIronMat, { position: [3.3, 5.15, 0], parent: root });+ createPart('ShipWheel', torusGeo(0.24, 0.03, 6, 10), brassMat, { position: [3.1, 5.35, 0], rotation: [0, 90, 0], parent: root });+ createPart('TelegraphStbd', cylinderYGeo(0.08, 0.1, 0.5, 8), brassMat, { position: [3.2, 5.25, 0.55], parent: root });+ createPart('TelegraphPort', cylinderYGeo(0.08, 0.1, 0.5, 8), brassMat, { position: [3.2, 5.25, -0.55], parent: root });+ createPart('HelmChair', boxGeo(0.45, 0.45, 0.45), darkIronMat, { position: [2.3, 5.2, 0], parent: root });++ // Searchlight & horns+ createPart('SearchlightBase', cylinderYGeo(0.12, 0.15, 0.25, 8), steelMat, { position: [3.2, 6.12, 0], parent: root });+ createPart('SearchlightBarrel', cylinderXGeo(0.2, 0.24, 0.35, 8), brassMat, { position: [3.25, 6.35, 0], parent: root });+ createPart('SearchlightLens', sphereGeo(0.18, 6, 6), lanternWhite, { position: [3.42, 6.35, 0], scale: [0.3, 1, 1], parent: root });+ createPart('AirHornLong', coneXGeo(0.12, 0.65, 8), brassMat, { position: [2.5, 6.18, 0.55], parent: root });+ createPart('AirHornShort', coneXGeo(0.11, 0.45, 8), brassMat, { position: [2.5, 6.18, 0.75], parent: root });++ // Funnel+ const funnelPivot = createPivot('FunnelAssembly', [-0.5, 4.2, 0], root);+ funnelPivot.rotation.z = -0.14;+ createPart('FunnelBody', cylinderYGeo(0.72, 0.82, 1.9, 14), funnelMat, {+ position: [0, 0.95, 0],+ scale: [1.35, 1.0, 0.9],+ parent: funnelPivot+ });+ createPart('FunnelWhiteBand', cylinderYGeo(0.73, 0.76, 0.45, 14), bootTopMat, {+ position: [0, 1.15, 0],+ scale: [1.36, 1.0, 0.91],+ parent: funnelPivot+ });+ createPart('FunnelBlackCap', cylinderYGeo(0.74, 0.72, 0.5, 14), funnelCapMat, {+ position: [0, 2.05, 0],+ scale: [1.38, 1.0, 0.92],+ parent: funnelPivot+ });+ createPart('ExhaustPipeMain', cylinderYGeo(0.18, 0.18, 0.7, 8), funnelCapMat, { position: [0.2, 2.4, 0], parent: funnelPivot });+ createPart('ExhaustPipeAux', cylinderYGeo(0.11, 0.11, 0.6, 6), funnelCapMat, { position: [-0.25, 2.35, 0.15], parent: funnelPivot });+ beamBetween('WhistlePipe', [0.85, 0.1, 0], [0.75, 2.3, 0], 0.035, brassMat, { parent: funnelPivot });++ // Mast+ const mastPivot = createPivot('MastAssembly', [1.8, 5.95, 0], root);+ mastPivot.rotation.z = -0.05;+ createPart('MastLowerPole', cylinderYGeo(0.1, 0.15, 1.8, 8), mastMat, { position: [0, 0.9, 0], parent: mastPivot });+ createPart('MastUpperPole', cylinderYGeo(0.05, 0.1, 1.8, 8), mastMat, { position: [0, 2.7, 0], parent: mastPivot });+ beamBetween('MastStayFwd', [0, 2.0, 0], [1.3, 0.05, 0], 0.02, steelMat, { parent: mastPivot });+ beamBetween('MastStayPort', [0, 2.0, 0], [-0.4, 0.05, -1.3], 0.02, steelMat, { parent: mastPivot });+ beamBetween('MastStayStbd', [0, 2.0, 0], [-0.4, 0.05, 1.3], 0.02, steelMat, { parent: mastPivot });++ createPart('RadarPlatform', boxGeo(0.7, 0.1, 0.7), mastMat, { position: [0.15, 1.35, 0], parent: mastPivot });+ createPart('RadarMotorBox', cylinderYGeo(0.18, 0.22, 0.25, 8), mastMat, { position: [0.15, 1.52, 0], parent: mastPivot });+ createPart('RadarScannerBar', boxGeo(0.14, 0.12, 1.25), deckhouseMat, { position: [0.15, 1.72, 0], parent: mastPivot });+ createPart('RadarScannerFace', decalBox(0.03, 0.09, 1.2), trimDarkMat, { position: [0.23, 1.72, 0], parent: mastPivot });++ beamBetween('CrossYard', [0, 2.4, -1.1], [0, 2.4, 1.1], 0.045, mastMat, { parent: mastPivot });++ // Navigation lights with screens+ createPart('NavScreenStbd', boxGeo(0.24, 0.3, 0.04), trimDarkMat, { position: [0, 2.4, 1.05], parent: mastPivot });+ createPart('NavLanternStbd', boxGeo(0.14, 0.2, 0.14), lanternGreen, { position: [0.08, 2.4, 1.15], parent: mastPivot });+ createPart('NavScreenPort', boxGeo(0.24, 0.3, 0.04), trimDarkMat, { position: [0, 2.4, -1.05], parent: mastPivot });+ createPart('NavLanternPort', boxGeo(0.14, 0.2, 0.14), lanternRed, { position: [0.08, 2.4, -1.15], parent: mastPivot });+ createPart('MastheadLantern', boxGeo(0.14, 0.2, 0.14), lanternWhite, { position: [0.12, 3.1, 0], parent: mastPivot });++ createPart('TowingLightUpper', boxGeo(0.12, 0.15, 0.12), lanternAmber, { position: [-0.1, 2.8, 0], parent: mastPivot });+ createPart('TowingLightLower', boxGeo(0.12, 0.15, 0.12), lanternAmber, { position: [-0.1, 2.5, 0], parent: mastPivot });++ createPart('MastTruck', cylinderYGeo(0.08, 0.08, 0.08, 6), brassMat, { position: [0, 3.65, 0], parent: mastPivot });+ beamBetween('AntennaPort', [0, 3.45, -0.04], [0, 5.0, -0.35], 0.015, steelMat, { parent: mastPivot });+ beamBetween('AntennaStbd', [0, 3.45, 0.04], [0, 5.0, 0.35], 0.015, steelMat, { parent: mastPivot });++ // ==========================================+ // 8. TOWING HOOK, TOWING ARCHES & BITTS ON OPEN AFTER DECK+ // ==========================================+ const arch1Points = [];+ for (let a = 0; a <= 10; a++) {+ const theta = (a / 10) * Math.PI;+ const ay = 2.65 + Math.sin(theta) * 1.35;+ const az = -Math.cos(theta) * 2.2;+ arch1Points.push([-3.4, ay, az]);+ }+ const arch1Geo = pipeAlongPath(arch1Points, 0.065, { bendRadius: 0.15, tubularSegments: 12, radialSegments: 6 });+ createPart('TowingArchForward', arch1Geo, steelMat, { parent: root });++ const arch2Points = [];+ for (let a = 0; a <= 10; a++) {+ const theta = (a / 10) * Math.PI;+ const ay = 2.7 + Math.sin(theta) * 1.15;+ const az = -Math.cos(theta) * 1.85;+ arch2Points.push([-5.0, ay, az]);+ }+ const arch2Geo = pipeAlongPath(arch2Points, 0.065, { bendRadius: 0.15, tubularSegments: 12, radialSegments: 6 });+ createPart('TowingArchAft', arch2Geo, steelMat, { parent: root });++ const towPostGroup = createPivot('TowingHookAssembly', [-1.6, 2.65, 0], root);+ createPart('TowingPostMain', boxGeo(0.55, 1.25, 0.55), darkIronMat, { position: [0, 0.62, 0], parent: towPostGroup });+ createPart('TowingPostCrossPin', cylinderZGeo(0.14, 0.14, 1.6, 8), darkIronMat, { position: [0, 0.95, 0], parent: towPostGroup });+ createPart('RadialTrack', torusGeo(1.2, 0.06, 6, 10), steelMat, {+ position: [0, 0.7, 0],+ rotation: [90, 0, 0],+ scale: [0.6, 1, 1],+ parent: towPostGroup+ });+ createPart('SpringCylinder', cylinderXGeo(0.18, 0.18, 0.8, 8), darkIronMat, { position: [-0.45, 0.7, 0], parent: towPostGroup });+ createPart('TowingHookJaw', torusGeo(0.24, 0.07, 6, 10), darkIronMat, {+ position: [-0.95, 0.7, 0],+ rotation: [90, 0, 0],+ parent: towPostGroup+ });+ beamBetween('TripLever', [-0.9, 0.7, 0], [-0.9, 1.15, 0], 0.03, lanternRed, { parent: towPostGroup });++ createPart('HawserReelStandL', boxGeo(0.1, 0.75, 0.12), darkIronMat, { position: [-2.5, 3.0, -0.65], parent: root });+ createPart('HawserReelStandR', boxGeo(0.1, 0.75, 0.12), darkIronMat, { position: [-2.5, 3.0, 0.65], parent: root });+ createPart('HawserDrum', cylinderZGeo(0.35, 0.35, 1.1, 8), darkIronMat, { position: [-2.5, 3.1, 0], parent: root });+ createPart('HawserCoil', cylinderZGeo(0.32, 0.32, 0.9, 8), fenderMat, { position: [-2.5, 3.1, 0], parent: root });+ createPart('AftHatchCoaming', boxGeo(0.9, 0.18, 0.9), darkIronMat, { position: [-4.2, 2.75, 0], parent: root });+ createPart('AftHatchCover', boxGeo(0.82, 0.08, 0.82), trimDarkMat, { position: [-4.2, 2.86, 0], parent: root });+ createPart('SternRollerChock', boxGeo(0.45, 0.3, 0.6), darkIronMat, { position: [-6.45, 3.2, 0], parent: root });+ createPart('SternRollerPin', cylinderZGeo(0.09, 0.09, 0.45, 8), steelMat, { position: [-6.45, 3.25, 0], parent: root });++ const bittLayout = [+ { name: 'BittForePort', pos: [6.4, 3.28, -1.25] },+ { name: 'BittForeStbd', pos: [6.4, 3.28, 1.25] },+ { name: 'BittWaistFwdPort', pos: [3.4, 2.82, -1.95] },+ { name: 'BittWaistFwdStbd', pos: [3.4, 2.82, 1.95] },+ { name: 'BittWaistAftPort', pos: [-3.8, 2.7, -1.95] },+ { name: 'BittWaistAftStbd', pos: [-3.8, 2.7, 1.95] },+ { name: 'BittQuarterPort', pos: [-5.6, 2.78, -1.35] },+ { name: 'BittQuarterStbd', pos: [-5.6, 2.78, 1.35] },+ ];+ bittLayout.forEach(b => {+ const bp = createPivot(b.name, b.pos, root);+ createPart(`${b.name}_Base`, boxGeo(0.35, 0.08, 0.65), darkIronMat, { position: [0, 0.04, 0], parent: bp });+ createPart(`${b.name}_Post1`, cylinderYGeo(0.09, 0.09, 0.45, 8), darkIronMat, { position: [0, 0.28, -0.16], parent: bp });+ createPart(`${b.name}_Post2`, cylinderYGeo(0.09, 0.09, 0.45, 8), darkIronMat, { position: [0, 0.28, 0.16], parent: bp });+ createPart(`${b.name}_Bar`, cylinderZGeo(0.04, 0.04, 0.58, 6), darkIronMat, { position: [0, 0.4, 0], parent: bp });+ });++ // ==========================================+ // 9. SINGLE PROPELLER & RUDDER UNDER COUNTER+ // ==========================================+ createPart('ShaftBossing', cylinderXGeo(0.28, 0.32, 1.4, 10), hullLowerMat, { position: [-4.6, 0.85, 0], parent: root });+ createPart('PropellerShaft', cylinderXGeo(0.09, 0.09, 1.0, 8), steelMat, { position: [-5.2, 0.85, 0], parent: root });++ // Propeller Hub (raised to Y = 0.85m to ensure ample clearance above skeg shoe)+ createPart('PropellerHub', cylinderXGeo(0.24, 0.16, 0.5, 10), brassMat, { position: [-5.65, 0.85, 0], parent: root });+ // 4 Propeller blades: tips stay well above skeg (lowest blade reaches Y = 0.22m)+ for (let b = 0; b < 4; b++) {+ const bladeAngleDeg = b * 90;+ const rad = bladeAngleDeg * Math.PI / 180;+ const bladeDist = 0.40;+ const by = Math.sin(rad) * bladeDist;+ const bz = Math.cos(rad) * bladeDist;+ createPart(`PropBlade_${b}`, boxGeo(0.12, 0.46, 0.28), brassMat, {+ position: [-5.65, 0.85 + by, bz],+ rotation: [bladeAngleDeg + 28, 0, 0],+ scale: [1, 1, 0.7],+ parent: root+ });+ }++ // Rudder Assembly+ const rudderGroup = createPivot('RudderAssembly', [-6.35, 0, 0], root);+ createPart('RudderStock', cylinderYGeo(0.12, 0.12, 1.4, 8), steelMat, { position: [0, 1.35, 0], parent: rudderGroup });+ createPart('RudderBladeMain', boxGeo(1.05, 1.35, 0.14), hullLowerMat, { position: [-0.35, 0.78, 0], parent: rudderGroup });+ createPart('RudderLeadingEdge', cylinderYGeo(0.08, 0.08, 1.35, 8), hullLowerMat, { position: [0.15, 0.78, 0], parent: rudderGroup });+ createPart('RudderHeelBearing', cylinderYGeo(0.12, 0.12, 0.22, 8), darkIronMat, { position: [0, 0.11, 0], parent: rudderGroup });++ return root;+}diff --git a/examples/typewriter.kiln.js b/examples/typewriter.kiln.jsnew file mode 100644index 00000000..f88943a8--- /dev/null+++ b/examples/typewriter.kiln.js@@ -0,0 +1,267 @@+// Authored by: opencode-go/muse-spark-1.3-contributor, via opencode.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.+//+// Refined later, in this repository, with `kiln_edit`: the type-bar segment+// was rebuilt as a slotted arc that clears the keys, the back of the frame was+// closed with a panel, and the finish was made crinkle enamel.+// The attribution above is for the authoring run, which had none of this in+// scope. Both passes went through the same tools; only the second one could+// see the gallery it was going into.++const meta = { name: 'Typewriter', category: 'prop' };++async function build() {+ const root = createRoot('Typewriter');++ // Wrinkle enamel.+ //+ // The frame was 0x17181c and 0x232429 -- two flat near-blacks -- and the+ // whole machine came back as a silhouette with white keys floating on it.+ // A black subject still has to return light somewhere or there is nothing+ // for the eye to read the form from, and on this machine the light comes+ // from the finish itself: interwar office typewriters were sprayed in+ // crinkle enamel, a paint that dries into a fine pebbled crust and breaks+ // every highlight into hundreds of small ones. So the value goes up to a+ // charcoal that can actually shade, and the crust is a height map -- which+ // is the part that makes the panels look sprayed rather than filled.+ const enamelAlbedo = proceduralTexture({+ schemaVersion: 2, size: 512, usage: 'albedo', name: 'WrinkleEnamel',+ layers: [+ { op: 'solid', color: 0x2f3034 },+ { op: 'noise', colorA: 0x1c1d21, colorB: 0x43454a, scale: 48, octaves: 5, seed: 3, blend: 'overlay', opacity: 0.7 },+ { op: 'noise', colorA: 0x232429, colorB: 0x35373c, scale: 9, octaves: 3, seed: 23, blend: 'multiply', opacity: 0.2 },+ ],+ });+ const enamelNormal = normalMapFromHeight(enamelAlbedo, { strength: 4 });+ const castIron = pbrMaterial({+ albedo: enamelAlbedo, normal: enamelNormal, roughness: 0.5, metalness: 0.25,+ });+ const castIron2 = gameMaterial(0x33353a, { roughness: 0.55, metalness: 0.35 });+ const steel = gameMaterial(0x9aa0a6, { roughness: 0.32, metalness: 0.85 });+ const darkSteel = gameMaterial(0x4a4d52, { roughness: 0.45, metalness: 0.8 });+ const brass = gameMaterial(0x5e4d26, { roughness: 0.45, metalness: 0.75 });+ const rubber = gameMaterial(0x101012, { roughness: 0.95, metalness: 0.0 });+ const ivory = gameMaterial(0xe9e2cd, { roughness: 0.35, metalness: 0.0 });+ // Nickel key rings, not black ones -- the ring is what separates one key+ // cap from the next when the whole deck is dark.+ const keyRim = gameMaterial(0x6e7278, { roughness: 0.3, metalness: 0.85 });+ const paperMat = gameMaterial(0xf2ecda, { roughness: 0.9, metalness: 0.0 });+ const glassTop = glassMaterial(0xdfe8ea, { opacity: 0.35, roughness: 0.1, metalness: 0.1 });++ const footGeo = cylinderGeo(0.032, 0.038, 0.03, 16);+ const footPos = [[0.28, 0.015, 0.30], [0.28, 0.015, -0.30], [-0.28, 0.015, 0.30], [-0.28, 0.015, -0.30]];+ for (let i = 0; i < 4; i++) {+ createPart('Foot_' + i, footGeo, rubber, { position: footPos[i], parent: root });+ }++ // Unwrapped because it is CSG output: roundedBoxGeo hulls eight spheres+ // through Manifold and hands back geometry with no UV attribute, which the+ // enamel's albedo and normal maps both need.+ const baseGeo = await autoUnwrap(await roundedBoxGeo(0.72, 0.10, 0.70, 0.02, { segments: 4 }));+ createPart('Base', baseGeo, castIron, { position: [0.0, 0.08, 0.0], parent: root });++ const lipGeo = await roundedBoxGeo(0.06, 0.04, 0.66, 0.012, { segments: 3 });+ createPart('FrontLip', lipGeo, castIron2, { position: [0.36, 0.09, 0.0], parent: root });+ // maker plate on front lip+ createPart('MakerPlate', decalBox(0.012, 0.018, 0.20), brass, { position: [0.392, 0.09, 0.0], rotation: [0, 0, 0], parent: root });++ const deckGeo = await autoUnwrap(await roundedBoxGeo(0.42, 0.06, 0.64, 0.015, { segments: 3 }));+ createPart('KeyDeck', deckGeo, castIron, { position: [0.12, 0.185, 0.0], rotation: [0, 0, -12], parent: root });++ const coverGeo = await roundedBoxGeo(0.16, 0.04, 0.60, 0.012, { segments: 3 });+ createPart('TopCover', coverGeo, castIron2, { position: [-0.10, 0.245, 0.0], parent: root });++ const cheekGeo = await autoUnwrap(await roundedBoxGeo(0.45, 0.15, 0.045, 0.012, { segments: 2 }));+ createPart('CheekR', cheekGeo, castIron, { position: [-0.03, 0.205, 0.335], parent: root });+ createPart('CheekL', cheekGeo, castIron, { position: [-0.03, 0.205, -0.335], parent: root });++ const capGeo = boxGeo(0.42, 0.014, 0.05);+ createPart('TrimR', capGeo, brass, { position: [-0.03, 0.287, 0.335], parent: root });+ createPart('TrimL', capGeo, brass, { position: [-0.03, 0.287, -0.335], parent: root });++ // Back plate. The frame had two cheeks and a top cover and nothing at all+ // closing the rear, so from behind you looked straight through the machine+ // and out at the underside of the keys. Every enclosed typewriter has this+ // panel: it butts against the rear face of both cheeks (x = -0.255), spans+ // the gap between their inner faces (z = +/-0.3125), and runs from the top of+ // the base up to the trim line. Its own trim strip carries the brass around+ // the back so the three sides read as one band.+ const backPlateGeo = await autoUnwrap(await roundedBoxGeo(0.030, 0.158, 0.625, 0.008, { segments: 3 }));+ createPart('BackPlate', backPlateGeo, castIron, { position: [-0.270, 0.209, 0.0], parent: root });+ createPart('TrimB', boxGeo(0.05, 0.014, 0.625), brass, { position: [-0.2725, 0.287, 0.0], parent: root });++ // carriage support standards (ground the carriage to the frame)+ const stdGeo = boxGeo(0.10, 0.12, 0.04);+ createPart('CarriageStdR', stdGeo, castIron, { position: [-0.23, 0.32, 0.40], parent: root });+ createPart('CarriageStdL', stdGeo, castIron, { position: [-0.23, 0.32, -0.40], parent: root });++ const stalkGeo = cylinderGeo(0.006, 0.006, 0.10, 10);+ const rimGeo = cylinderGeo(0.027, 0.025, 0.015, 20);+ const faceGeo = cylinderGeo(0.021, 0.021, 0.004, 20);+ const glassGeo = cylinderGeo(0.020, 0.020, 0.003, 20);++ const rows = [+ { x: 0.29, y: 0.195, n: 9, z0: -0.224 },+ { x: 0.19, y: 0.235, n: 10, z0: -0.252 },+ { x: 0.09, y: 0.275, n: 9, z0: -0.224 }+ ];+ let ki = 0;+ for (let r = 0; r < rows.length; r++) {+ const row = rows[r];+ for (let k = 0; k < row.n; k++) {+ const z = row.z0 + k * 0.056;+ createPart('KeyStalk_' + ki, stalkGeo, darkSteel, { position: [row.x - 0.01, row.y - 0.045, z], rotation: [0, 0, 12], parent: root });+ createPart('KeyRim_' + ki, rimGeo, keyRim, { position: [row.x, row.y, z], rotation: [0, 0, -12], parent: root });+ createPart('KeyFace_' + ki, faceGeo, ivory, { position: [row.x + 0.0025, row.y + 0.0075, z], rotation: [0, 0, -12], parent: root });+ createPart('KeyGlass_' + ki, glassGeo, glassTop, { position: [row.x + 0.004, row.y + 0.010, z], rotation: [0, 0, -12], parent: root });+ ki++;+ }+ }++ const spaceGeo = await roundedBoxGeo(0.045, 0.018, 0.34, 0.008, { segments: 3 });+ createPart('Spacebar', spaceGeo, keyRim, { position: [0.345, 0.165, 0.0], rotation: [0, 0, -8], parent: root });+ const spaceArmGeo = boxGeo(0.08, 0.01, 0.015);+ createPart('SpaceArmR', spaceArmGeo, darkSteel, { position: [0.31, 0.14, 0.14], parent: root });+ createPart('SpaceArmL', spaceArmGeo, darkSteel, { position: [0.31, 0.14, -0.14], parent: root });++ const shiftGeo = await roundedBoxGeo(0.05, 0.02, 0.05, 0.006, { segments: 2 });+ createPart('ShiftR', shiftGeo, keyRim, { position: [0.09, 0.24, 0.29], rotation: [0, 0, -12], parent: root });+ createPart('ShiftL', shiftGeo, keyRim, { position: [0.09, 0.24, -0.29], rotation: [0, 0, -12], parent: root });++ // The type-bar segment.+ //+ // This was a filled disc -- cylinderGeo(0.16, 0.18, 0.05) centred at+ // x = -0.06 -- with a full torus ring above it. Both are circles, and a+ // circle of that radius reaches forward to x = +0.12, which is exactly where+ // the back row of keys sits (x = 0.09, rim radius 0.027). From above the+ // machine looked like it had a lid closed over its own keyboard.+ //+ // The real part is not a disc. It is the segment: a slotted arc standing+ // behind the print point with one slot per type bar, holding the bars in+ // register as they swing. It is open at the front, and it stops well short of+ // the keys -- that gap is where the operator's fingers go. Built from blocks+ // on an arc because torusGeo takes no arc argument; the slots are the gaps+ // between the teeth, which is how the part reads on the real machine too.+ const segTeeth = 27;+ const segToothGeo = boxGeo(0.030, 0.026, 0.0055);+ const segBackGeo = boxGeo(0.014, 0.030, 0.016);+ for (let i = 0; i < segTeeth; i++) {+ const t = i / (segTeeth - 1) - 0.5;+ const ang = t * 150;+ const c = Math.cos((ang * Math.PI) / 180);+ const s = Math.sin((ang * Math.PI) / 180);+ // A Y rotation of a carries +X to (cos a, 0, -sin a), so -ang is what+ // points each tooth outward along its own radius.+ createPart('SegTooth_' + i, segToothGeo, darkSteel, {+ position: [-0.115 + c * 0.088, 0.288, s * 0.208],+ rotation: [0, -ang, 0],+ parent: root,+ });+ createPart('SegBack_' + i, segBackGeo, castIron2, {+ position: [-0.115 + c * 0.070, 0.283, s * 0.166],+ rotation: [0, -ang, 0],+ parent: root,+ });+ }++ const printPt = [-0.10, 0.40, 0.0];+ const nBars = 26;+ for (let i = 0; i < nBars; i++) {+ const t = (i / (nBars - 1) - 0.5);+ const ang = t * 140;+ const rad = 0.15;+ const bx = -0.06 - Math.abs(t) * 0.025;+ const bz = Math.sin(ang * Math.PI / 180) * rad * 1.4;+ const by = 0.30;+ const midX = (bx + printPt[0]) / 2 + 0.02;+ const midY = (by + printPt[1]) / 2;+ const midZ = bz * 0.55;+ beamBetween('TypeBar_' + i, [bx, by, bz], [midX, midY, midZ], 0.0042, darkSteel, { parent: root });+ beamBetween('TypeBarTop_' + i, [midX, midY, midZ], printPt, 0.003, steel, { parent: root });+ createPart('TypeSlug_' + i, boxGeo(0.018, 0.012, 0.010), steel, { position: [printPt[0] - 0.005 - (i % 3) * 0.004, printPt[1] + 0.005, (i - nBars / 2) * 0.0012], rotation: [0, 0, 20], parent: root });+ }+ createPart('TypeGuide', boxGeo(0.03, 0.06, 0.02), darkSteel, { position: [-0.105, 0.375, 0.0], parent: root });++ const spoolCoreGeo = cylinderGeo(0.028, 0.028, 0.022, 20);+ const spoolFlangeGeo = cylinderGeo(0.048, 0.048, 0.005, 24);+ const spoolPos = [[-0.02, 0.285, 0.20], [-0.02, 0.285, -0.20]];+ for (let s = 0; s < 2; s++) {+ const sp = spoolPos[s];+ createPart('SpoolCore_' + s, spoolCoreGeo, rubber, { position: sp, parent: root });+ createPart('SpoolFlangeB_' + s, spoolFlangeGeo, darkSteel, { position: [sp[0], sp[1] - 0.013, sp[2]], parent: root });+ createPart('SpoolFlangeT_' + s, spoolFlangeGeo, darkSteel, { position: [sp[0], sp[1] + 0.013, sp[2]], parent: root });+ createPart('SpoolPin_' + s, cylinderGeo(0.005, 0.005, 0.03, 10), steel, { position: [sp[0], sp[1] + 0.025, sp[2]], parent: root });+ }+ const ribbonGeo = boxGeo(0.10, 0.004, 0.36);+ createPart('Ribbon', ribbonGeo, rubber, { position: [-0.06, 0.30, 0.0], parent: root });+ beamBetween('RibbonArmR', [-0.02, 0.29, 0.20], [-0.10, 0.36, 0.03], 0.004, darkSteel, { parent: root });+ beamBetween('RibbonArmL', [-0.02, 0.29, -0.20], [-0.10, 0.36, -0.03], 0.004, darkSteel, { parent: root });++ const railGeo = cylinderZGeo(0.012, 0.012, 0.92, 14);+ createPart('CarriageRailF', railGeo, steel, { position: [-0.16, 0.36, 0.0], parent: root });+ createPart('CarriageRailB', railGeo, steel, { position: [-0.30, 0.36, 0.0], parent: root });++ const endGeo = await autoUnwrap(await roundedBoxGeo(0.20, 0.10, 0.03, 0.01, { segments: 2 }));+ createPart('CarriageEndR', endGeo, castIron, { position: [-0.23, 0.42, 0.46], parent: root });+ createPart('CarriageEndL', endGeo, castIron, { position: [-0.23, 0.42, -0.46], parent: root });++ const platenGeo = cylinderZGeo(0.062, 0.062, 0.82, 28);+ createPart('Platen', platenGeo, rubber, { position: [-0.24, 0.475, 0.0], parent: root });+ const capPGeo = cylinderZGeo(0.045, 0.045, 0.03, 20);+ createPart('PlatenCapR', capPGeo, darkSteel, { position: [-0.24, 0.475, 0.425], parent: root });+ createPart('PlatenCapL', capPGeo, darkSteel, { position: [-0.24, 0.475, -0.425], parent: root });++ const knobBodyGeo = cylinderZGeo(0.048, 0.048, 0.045, 24);+ const knobEndGeo = cylinderZGeo(0.030, 0.048, 0.02, 24);+ const knobAxGeo = cylinderZGeo(0.010, 0.010, 0.06, 12);+ const ribGeo = boxGeo(0.008, 0.008, 0.05);+ for (const side of [1, -1]) {+ const zc = side * 0.48;+ const tag = side > 0 ? 'R' : 'L';+ createPart('KnobBody_' + tag, knobBodyGeo, castIron2, { position: [-0.24, 0.475, zc], parent: root });+ createPart('KnobEnd_' + tag, knobEndGeo, castIron2, { position: [-0.24, 0.475, zc + side * 0.032], parent: root });+ createPart('KnobAx_' + tag, knobAxGeo, steel, { position: [-0.24, 0.475, side * 0.445], parent: root });+ for (let r = 0; r < 8; r++) {+ const a = r * 22.5;+ createPart('KnobRib_' + tag + r, ribGeo, castIron2, { position: [-0.24, 0.475, zc], rotation: [0, 0, a], parent: root });+ }+ }++ // paper seated against platen back, table directly behind paper+ const tableGeo = boxGeo(0.015, 0.20, 0.78);+ createPart('PaperTable', tableGeo, castIron2, { position: [-0.325, 0.52, 0.0], rotation: [0, 0, -12], parent: root });+ const paperGeo = boxGeo(0.006, 0.26, 0.60);+ createPart('Paper', paperGeo, paperMat, { position: [-0.308, 0.585, 0.0], rotation: [0, 0, -12], parent: root });++ const bailGeo = cylinderZGeo(0.008, 0.008, 0.80, 12);+ createPart('BailBar', bailGeo, steel, { position: [-0.185, 0.53, 0.0], parent: root });+ const rollerGeo = cylinderZGeo(0.016, 0.016, 0.03, 14);+ createPart('BailRollerR', rollerGeo, rubber, { position: [-0.185, 0.53, 0.18], parent: root });+ createPart('BailRollerC', rollerGeo, rubber, { position: [-0.185, 0.53, 0.0], parent: root });+ createPart('BailRollerL', rollerGeo, rubber, { position: [-0.185, 0.53, -0.15], parent: root });+ beamBetween('BailArmR', [-0.23, 0.44, 0.44], [-0.185, 0.53, 0.40], 0.006, darkSteel, { parent: root });+ beamBetween('BailArmL', [-0.23, 0.44, -0.44], [-0.185, 0.53, -0.40], 0.006, darkSteel, { parent: root });++ const rulerGeo = boxGeo(0.03, 0.015, 0.80);+ createPart('PaperRuler', rulerGeo, steel, { position: [-0.145, 0.40, 0.0], parent: root });++ beamBetween('ReturnLever', [-0.23, 0.47, -0.47], [-0.04, 0.54, -0.60], 0.009, darkSteel, { parent: root });+ createPart('ReturnGrip', cylinderGeo(0.015, 0.015, 0.10, 14), castIron2, { position: [0.005, 0.55, -0.615], rotation: [0, 0, 78], parent: root });++ createPart('LineLever', boxGeo(0.02, 0.02, 0.06), darkSteel, { position: [-0.23, 0.50, -0.47], parent: root });+ const smallKnobGeo = sphereGeo(0.016, 14, 10);+ createPart('MarginKnobR', smallKnobGeo, brass, { position: [-0.16, 0.385, 0.38], parent: root });+ createPart('MarginKnobL', smallKnobGeo, brass, { position: [-0.16, 0.385, -0.38], parent: root });++ const screwGeo = cylinderGeo(0.008, 0.008, 0.008, 12);+ createPart('ScrewFR', screwGeo, steel, { position: [0.30, 0.135, 0.28], parent: root });+ createPart('ScrewFL', screwGeo, steel, { position: [0.30, 0.135, -0.28], parent: root });++ return root;+}diff --git a/examples/vending-machine.kiln.js b/examples/vending-machine.kiln.jsnew file mode 100644index 00000000..1abe6d70--- /dev/null+++ b/examples/vending-machine.kiln.js@@ -0,0 +1,532 @@+// A Japanese street vending machine, at night.+//+// Authored by: Claude Opus 5, via Claude Code. Every part below was written by+// the model itself, looking at its own renders through the Kiln tools and+// revising. Not a line of it is hand-authored.+//+// This is the EMISSIVE example, and the thing it exists to demonstrate is the+// rule that keeps catching people out:+//+// EMISSIVE AREA IS THE ENEMY OF SHAPE.+//+// There is no global illumination here. An emissive surface does not light the+// room, it only makes its own pixels bright -- so a large panel at a high+// intensity does not read as "a glowing sign", it reads as a white rectangle+// with nothing in it, and anything standing in front of it is a black+// silhouette against a blown-out ground. The first pass of this file ran the+// display backlight at intensity 2.4 across 0.76 x 0.62 m and every bottle in+// the machine disappeared into it.+//+// So the emissive here is allocated the other way round:+//+// large area, LOW intensity the display backlight, which only has to be+// brighter than the cabinet around it+// small area, HIGH intensity the price tags, the button LEDs, the two neon+// tubes -- narrow enough that clipping to white+// is what you want, because that is what a real+// tube does to a camera+//+// and the contrast that sells all of it comes from the DARK: near-black bezel,+// near-black mullions between the columns, a black delivery port. Put a bright+// thing next to a black thing and the bright thing glows. Put it next to+// another bright thing and you have a lightbox.+//+// The second rule this asset is built on is that the machine is a FACE. Every+// element is on a declared plane measured forward from the cabinet front, and+// the ones a customer touches -- buttons, coin slot, the flap -- stand proud of+// the ones they only look at. A vending machine modelled flat looks like a+// poster of a vending machine.+//+// Known limit: no text anywhere. proceduralTexture has no text op, so the+// price tags are colour fields, the brand banner is a stripe, and the hot/cold+// labels are the red and blue bands they sit on rather than the words. At asset+// scale that reads correctly -- Japanese machines really do code hot and cold+// by colour first -- but it would not survive a close-up.+const meta = { name: 'VendingMachine', category: 'prop', role: 'poi' };++async function build() {+ const root = createRoot('VendingMachine');+ const uv = (g) => autoUnwrap(g, { resolution: 1024 });++ // ---------- Plan ----------+ const HZ = 0.55; // half width, across Z+ const CAB_Y0 = 0.10; // top of the plinth+ const CAB_Y1 = 1.76; // top of the cabinet+ const CROWN_Y = 1.94; // top of the illuminated banner++ // Depth planes, forward from the machine's back. Every part states which one+ // it lives on, so nothing is coplanar by accident and the fascia has real+ // relief instead of decals.+ const P = {+ NEON: 0.400,+ BUTTON: 0.386,+ BEZEL: 0.374,+ FASCIA: 0.360, // the cabinet's own front face+ TAG: 0.350,+ GLASS: 0.344,+ SHELF: 0.260,+ CANS: 0.245,+ BACKLIGHT: 0.172,+ WELL_BACK: 0.160, // front face of the carcass = back wall of the display+ BACK: -0.360,+ };++ // The well is 0.20 m deep, and that number is load-bearing. Cutting the+ // opening at the previous 0.32 m turned the display into a cave: the mullions+ // and shelves stood far enough forward to occlude the lit panel from any+ // angle but dead-on, so the machine went straight from a white lightbox to a+ // black hole without ever passing through "shop window". A real display is a+ // shallow diorama -- the dummy products sit about 10 cm behind the glass and+ // about 6 cm in front of the light, and that is the whole trick.++ // The display: four columns, three shelves, and all four of them stocked.+ // Column 2 was an unlit sold-out column for a while, on the theory that one+ // dead cell stops a 4 x 3 grid reading as a texture. It does, but not the way+ // it was supposed to: everything in that column -- the dim panel, the bezel+ // shelves, the rails -- is near-black, so instead of an empty rack behind a+ // switched-off light it came out as a solid black rectangle with no shape in+ // it at all, and against three lit columns that reads as a hole in the model+ // rather than as a sold-out slot. The asymmetry that actually works is the one+ // that is still here: cans in column 1, bottles in the other three.+ const COL_Z = [-0.400, -0.212, -0.024, 0.164];+ const COL_W = 0.176;+ const SHELF_Y = [0.885, 1.148, 1.411];+ const DISP_Z0 = -0.500;+ const DISP_Z1 = 0.256;+ const DISP_Y0 = 0.860;+ const DISP_Y1 = 1.650;++ // ---------- Materials ----------+ // Cabinet enamel. Painted sheet steel: dielectric, and slightly off-white,+ // because a pure white body under a warm sign turns grey in the shadows and+ // reads as plastic.+ const shellAlbedo = proceduralTexture({+ schemaVersion: 2, size: 1024, usage: 'albedo', name: 'Shell',+ layers: [+ { op: 'solid', color: 0xd8d5cd },+ { op: 'gradient', from: 0xe6e3db, to: 0x9d9a94, angleDeg: 90, blend: 'overlay', opacity: 0.50 },+ // Vertical brushing plus grime that only reaches up the lower panels --+ // a machine on a street is filthy at ankle height and clean at eye level.+ { op: 'stripes', colorA: 0xd8d5cd, colorB: 0xcbc8c0, count: 90, angleDeg: 90, blend: 'overlay', opacity: 0.22 },+ { op: 'noise', colorA: 0x8e8b83, colorB: 0xd8d5cd, scale: 22, octaves: 4, seed: 5, blend: 'multiply', opacity: 0.16 },+ ],+ });+ const shell = pbrMaterial({+ albedo: shellAlbedo,+ normal: normalMapFromHeight(shellAlbedo, { strength: 0.55 }),+ roughness: 0.44, metalness: 0.18,+ });++ // The red band. Same paint, different colour, and still dielectric.+ const bandAlbedo = proceduralTexture({+ schemaVersion: 2, size: 512, usage: 'albedo', name: 'Band',+ layers: [+ { op: 'solid', color: 0xb01f26 },+ { op: 'gradient', from: 0xd0272f, to: 0x87161c, angleDeg: 90, blend: 'overlay', opacity: 0.55 },+ { op: 'noise', colorA: 0x9a1a20, colorB: 0xc0232b, scale: 60, octaves: 3, seed: 23, blend: 'overlay', opacity: 0.18 },+ ],+ });+ const band = pbrMaterial({+ albedo: bandAlbedo,+ normal: normalMapFromHeight(bandAlbedo, { strength: 0.4 }),+ roughness: 0.38, metalness: 0.10,+ });++ // The dark. This material is doing more work than any of the emissives: it is+ // the ground everything bright is measured against.+ const bezel = gameMaterial(0x18191c, { roughness: 0.52, metalness: 0.30 });+ const black = gameMaterial(0x0d0e10, { roughness: 0.70, metalness: 0.05 });+ const steel = gameMaterial(0x767b82, { roughness: 0.36, metalness: 0.92 });+ const rubber = gameMaterial(0x232527, { roughness: 0.90, metalness: 0.0 });++ const glass = glassMaterial(0x0e1a22, { opacity: 0.22, roughness: 0.03, metalness: 0.0 });++ // Large area, LOW intensity. This panel is 0.76 x 0.68 m; at anything above+ // about 1.0 it stops being a backlight and becomes a hole in the machine.+ // Note the albedo: a near-WHITE albedo under an emissive is what actually+ // clips. Lit surface plus emitted light both land in the same pixel, so a+ // panel painted 0xfff3dc is already most of the way to 1.0 before the+ // emissive is added. Paint it mid-grey and let the emission do the work.+ // ...and then measured, which moved it the other way again. Once the shelves+ // are stocked, the panel is not a 0.76 x 0.68 m emitter at all: the products+ // cover most of it and what actually reaches the camera is a set of slivers+ // between bottles. Small visible area, so it wants a HIGH intensity, by the+ // same rule that keeps the neon at 3.6. The area that matters is the area you+ // can see, not the area you built.+ const backlight = gameMaterial(0x9a9284, {+ emissive: 0xffe6b4, emissiveIntensity: 2.30, roughness: 0.60,+ });+ // Small area, HIGH intensity. These are allowed to clip -- a fluorescent tube+ // photographed at night is clipped, and refusing to let it clip is what makes+ // CG neon look like painted plastic.+ const neonPink = gameMaterial(0xff9ecb, {+ emissive: 0xff2f8e, emissiveIntensity: 3.6, roughness: 0.25,+ });+ const neonCyan = gameMaterial(0xa8f0ff, {+ emissive: 0x1fd4ff, emissiveIntensity: 3.2, roughness: 0.25,+ });+ const hotTag = gameMaterial(0xff8a80, {+ emissive: 0xe8231a, emissiveIntensity: 2.4, roughness: 0.35,+ });+ const coldTag = gameMaterial(0x8ec5ff, {+ emissive: 0x1f6fe0, emissiveIntensity: 2.4, roughness: 0.35,+ });+ const signFace = gameMaterial(0xfff6e4, {+ emissive: 0xffe6b0, emissiveIntensity: 1.15, roughness: 0.55,+ });+ const signGround = gameMaterial(0x1a1430, {+ emissive: 0x241c46, emissiveIntensity: 0.55, roughness: 0.55,+ });+ const binLabel = gameMaterial(0xe8e4dc, { roughness: 0.70 });+ const readout = gameMaterial(0x143c22, {+ emissive: 0x35ff86, emissiveIntensity: 2.0, roughness: 0.30,+ });++ // Drinks. Four columns, four different products, and the labels are stripes+ // and gradients rather than artwork -- see the known limit in the header.+ //+ // All four are DIELECTRIC, the printed can included. A can is aluminium, but+ // what a customer sees is the printing on it, and print is a coating over the+ // metal -- only the bare lid is exposed aluminium, and that is what capMat is+ // for. Modelling the whole can as metal at 0.78 is what made it disappear:+ // a metal has no diffuse term, so its entire appearance is a specular+ // reflection tinted by its albedo, and a near-black albedo under a neutral+ // studio dome returns almost nothing. The cans rendered as black rectangles+ // and their column read as empty stock.+ //+ // They still must not be PALE. Everything in the display stands in front of a+ // lit panel, and a pale product against a backlight is the one thing+ // guaranteed to vanish. Mid-tone and saturated is the window that works.+ const drink = (base, top, metal, rough = 0.34) => pbrMaterial({+ albedo: proceduralTexture({+ schemaVersion: 2, size: 256, usage: 'albedo', name: `Drink${base.toString(16)}`,+ layers: [+ { op: 'solid', color: base },+ { op: 'stripes', colorA: base, colorB: top, count: 3, angleDeg: 0, blend: 'normal', opacity: 0.55 },+ ],+ }),+ roughness: rough, metalness: metal,+ });+ const drinks = [+ drink(0x1c6b39, 0xcfc7a4, 0.0), // PET, deep green+ drink(0x8f2733, 0xe4d9c6, 0.12, 0.27), // printed can, cola red over foil+ drink(0xa8541c, 0xf0dcae, 0.0), // PET, amber+ drink(0x123566, 0xb9cee8, 0.0), // PET, deep blue+ ];+ const capMat = gameMaterial(0xd9d4c8, { roughness: 0.35, metalness: 0.15 });++ const concrete = pbrMaterial({+ albedo: proceduralTexture({+ schemaVersion: 2, size: 512, usage: 'albedo', name: 'Concrete',+ layers: [+ { op: 'solid', color: 0x4c4b48 },+ { op: 'noise', colorA: 0x3a3937, colorB: 0x5e5d59, scale: 40, octaves: 5, seed: 31, blend: 'overlay', opacity: 0.7 },+ ],+ }),+ roughness: 0.92, metalness: 0.0,+ });++ const box = async (name, w, h, d, position, mat, opts = {}) =>+ createPart(name, await uv(await roundedBoxGeo(w, h, d, opts.r ?? 0.006), opts.res ?? 512), mat, {+ position, rotation: opts.rotation, parent: opts.parent ?? root,+ });+ const slab = (name, w, h, d, position, mat, rotation) =>+ createPart(name, boxGeo(w, h, d), mat, { position, rotation, parent: root });++ // ---------- Ground ----------+ // A machine with nothing under it floats. The pad also gives the neon+ // something to sit against in the bottom of the frame.+ await box('Pad', 1.30, 0.030, 1.90, [0.10, 0.015, 0], concrete, { r: 0.006, res: 512 });++ // ---------- Cabinet ----------+ await box('Plinth', 0.66, CAB_Y0, 1.06, [0, CAB_Y0 / 2, 0], black, { r: 0.010 });+ // The cabinet is a CARCASS plus a fascia with a hole in it, not one solid+ // box. The first pass built it as one box from x = -0.36 to +0.36 and then+ // placed the backlight, the shelves, the mullions and every bottle at x+ // between 0.05 and 0.25 -- which is to say, sealed inside it. The render+ // showed a clean white rectangle where the display should be and it took a+ // zoom to work out that the white rectangle was the cabinet's own front+ // panel, with the entire display standing behind it. Nothing was wrong with+ // the emissive at all.+ //+ // A machine with a window in it needs the window to be an absence.+ const CARCASS_X = P.WELL_BACK;+ await box('Carcass', 0.36 + CARCASS_X, CAB_Y1 - CAB_Y0, 1.10,+ [(CARCASS_X - 0.36) / 2, (CAB_Y0 + CAB_Y1) / 2, 0], shell, { r: 0.018, res: 1024 });+ {+ // Fascia, in four pieces around the opening. Depth runs from the carcass+ // face to the machine's front, so the display well is a genuine 0.32 m deep+ // recess and the products sit inside it rather than on it.+ const fx = (CARCASS_X + P.FASCIA) / 2;+ const fd = P.FASCIA - CARCASS_X;+ await box('FasciaTop', fd, CAB_Y1 - DISP_Y1, 1.10,+ [fx, (DISP_Y1 + CAB_Y1) / 2, 0], shell, { r: 0.014, res: 1024 });+ await box('FasciaBottom', fd, DISP_Y0 - CAB_Y0, 1.10,+ [fx, (CAB_Y0 + DISP_Y0) / 2, 0], shell, { r: 0.014, res: 1024 });+ await box('FasciaLeft', fd, DISP_Y1 - DISP_Y0, DISP_Z0 + HZ,+ [fx, (DISP_Y0 + DISP_Y1) / 2, (-HZ + DISP_Z0) / 2], shell, { r: 0.012, res: 512 });+ await box('FasciaRight', fd, DISP_Y1 - DISP_Y0, HZ - DISP_Z1,+ [fx, (DISP_Y0 + DISP_Y1) / 2, (DISP_Z1 + HZ) / 2], shell, { r: 0.012, res: 512 });+ }+ // Levelling feet, visible under the plinth's inset.+ for (const sx of [-1, 1]) {+ for (const sz of [-1, 1]) {+ createPart(`Foot_${sx}${sz}`, cylinderGeo(0.026, 0.026, 0.034, 10), steel,+ { position: [sx * 0.28, 0.020, sz * 0.46], parent: root });+ }+ }+ // Side vents and the compressor grille, on the machine's left flank.+ for (let i = 0; i < 9; i++) {+ slab(`Vent_${i}`, 0.30, 0.010, 0.006, [-0.10, 0.34 + i * 0.026, -HZ - 0.001], bezel);+ }+ // Panel seams on the flanks. A 1.9 m sheet-steel side with no joint in it+ // reads as a solid block of plastic.+ for (const sz of [-1, 1]) {+ slab(`FlankSeam_${sz > 0 ? 'R' : 'L'}`, 0.006, 1.44, 0.008, [0.058, 1.00, sz * (HZ + 0.002)], bezel);+ slab(`FlankSeamH_${sz > 0 ? 'R' : 'L'}`, 0.40, 0.008, 0.008, [-0.12, 0.300, sz * (HZ + 0.002)], bezel);+ }+ slab('BackPanel', 0.008, CAB_Y1 - CAB_Y0 - 0.10, 1.02, [P.BACK - 0.004, 0.94, 0], bezel);+ // The back is where the refrigeration lives, and it was one black rectangle.+ // A sixth view that is a solid field of one colour reads as an unfinished+ // model even when nothing is actually missing.+ {+ const bx = P.BACK - 0.012;+ createPart('CondenserRing', torusGeo(0.150, 0.016, 8, 28), steel,+ { position: [bx, 0.520, -0.230], rotation: [0, 90, 0], parent: root });+ createPart('CondenserHub', cylinderXGeo(0.048, 0.048, 0.030, 16), bezel,+ { position: [bx - 0.008, 0.520, -0.230], parent: root });+ for (let i = 0; i < 4; i++) {+ slab(`CondenserGuard_${i}`, 0.006, 0.290, 0.010,+ [bx - 0.014, 0.520, -0.230 + (i - 1.5) * 0.075], steel);+ }+ for (let i = 0; i < 11; i++) {+ slab(`Louvre_${i}`, 0.012, 0.014, 0.420,+ [bx - 0.004, 0.320 + i * 0.030, 0.190], bezel);+ }+ slab('DataPlate', 0.006, 0.130, 0.180, [bx - 0.006, 1.320, 0.140], steel);+ slab('CompressorBox', 0.070, 0.240, 0.300, [P.BACK + 0.040, 0.230, 0.150], bezel);+ createPart('SuctionLine', cylinderGeo(0.014, 0.014, 0.330, 10), steel,+ { position: [P.BACK + 0.020, 0.480, 0.150], parent: root });+ }++ // ---------- Crown ----------+ // The illuminated banner. Bright, but only 0.18 m tall: the whole point of+ // putting the biggest emissive at the TOP of a tall object is that it lights+ // the frame rather than competing with the product display.+ await box('CrownBody', 0.62, CROWN_Y - CAB_Y1, 1.12,+ [0.02, (CAB_Y1 + CROWN_Y) / 2, 0], bezel, { r: 0.012 });+ // 0.336, not 0.318: the crown body's front face is at 0.330, so the first+ // placement put the entire illuminated banner INSIDE the box it lights.+ {+ // The sign is the machine's face and it was a blank white plank. A lit sign+ // is a DARK ground with a small bright mark on it -- that is what makes it+ // read as illuminated rather than as a sheet of paper, and it is the same+ // trade as the neon: contrast comes from the surround, not the intensity.+ const cy = (CAB_Y1 + CROWN_Y) / 2;+ slab('CrownFace', 0.014, 0.136, 1.04, [0.336, cy, 0], signGround);+ createPart('CrownMark', cylinderXGeo(0.046, 0.046, 0.008, 24), neonCyan,+ { position: [0.347, cy, 0.330], parent: root });+ createPart('CrownMarkCore', cylinderXGeo(0.022, 0.022, 0.010, 20), signGround,+ { position: [0.349, cy, 0.330], parent: root });+ const bar = [0.084, 0.060, 0.104];+ for (let i = 0; i < bar.length; i++) {+ slab(`CrownBar_${i}`, 0.008, 0.018, bar[i],+ [0.345, cy + 0.030 - i * 0.030, 0.196 - bar[i] / 2], i === 1 ? neonPink : signFace);+ }+ }+ slab('CrownStripe', 0.016, 0.030, 1.04, [0.340, CAB_Y1 + 0.038, 0], band);+ // Two tubes framing the banner. Narrow and hot, which is the whole recipe.+ for (const ny of [CAB_Y1 + 0.012, CROWN_Y - 0.012]) {+ createPart(`NeonTop_${ny.toFixed(3)}`, cylinderZGeo(0.013, 0.013, 1.10, 12), neonPink,+ { position: [0.330, ny, 0], parent: root });+ }+ // Vertical tubes down both edges of the fascia. Cyan against the pink reads+ // as two separate light sources rather than one wash.+ for (const sz of [-1, 1]) {+ createPart(`NeonSide_${sz > 0 ? 'R' : 'L'}`, cylinderGeo(0.011, 0.011, 1.26, 12), neonCyan,+ { position: [P.NEON - 0.026, 1.06, sz * (HZ - 0.018)], parent: root });+ }++ // ---------- Display ----------+ const dispW = DISP_Z1 - DISP_Z0;+ const dispH = DISP_Y1 - DISP_Y0;+ const dispCz = (DISP_Z0 + DISP_Z1) / 2;+ const dispCy = (DISP_Y0 + DISP_Y1) / 2;+ // Recessed well. The interior is lined black so the only bright things inside+ // are the backlight panel and the products it is behind.+ const wellD = P.FASCIA - P.WELL_BACK;+ const wellX = (P.WELL_BACK + P.FASCIA) / 2;+ slab('WellTop', wellD, 0.012, dispW, [wellX, DISP_Y1 - 0.006, dispCz], black);+ slab('WellBot', wellD, 0.012, dispW, [wellX, DISP_Y0 + 0.006, dispCz], black);+ for (const sz of [-1, 1]) {+ slab(`WellSide_${sz > 0 ? 'R' : 'L'}`, wellD, dispH, 0.012,+ [wellX, dispCy, dispCz + sz * (dispW / 2 - 0.006)], black);+ }+ slab('Backlight', 0.010, dispH - 0.02, dispW - 0.02, [P.BACKLIGHT, dispCy, dispCz], backlight);++ // Shelves and mullions. The mullions matter more than they look: without a+ // dark divider between columns the four products merge into one bright band.+ // Shelves 65 mm deep with a lit front rail, not 150 mm deep plain plates.+ // Depth was the whole problem: at the hero elevation a 150 mm shelf hides+ // 73 mm of the cell below it, and the gap above a 204 mm bottle in a 263 mm+ // cell is 59 mm -- so the backlight was occluded by the shelf, not by the+ // products, and no amount of emissive intensity was going to reach the+ // camera. The rail is the second half of the fix and the more honest one:+ // a chiller lights its shelf fronts, and a light at the front of the well+ // cannot be occluded by anything in the well.+ for (const sy of SHELF_Y) {+ const k = sy.toFixed(3);+ slab(`Shelf_${k}`, 0.065, 0.010, dispW - 0.03, [0.328, sy, dispCz], bezel);+ slab(`ShelfRail_${k}`, 0.014, 0.026, dispW - 0.03, [0.353, sy - 0.017, dispCz], bezel);+ slab(`ShelfLed_${k}`, 0.010, 0.009, dispW - 0.06, [0.350, sy - 0.006, dispCz], backlight);+ }+ slab('CanopyLed', 0.010, 0.009, dispW - 0.06, [0.350, DISP_Y1 - 0.022, dispCz], backlight);+ for (let i = 0; i <= COL_Z.length; i++) {+ const z = i < COL_Z.length+ ? COL_Z[i] - COL_W / 2 - 0.006+ : COL_Z[COL_Z.length - 1] + COL_W / 2 + 0.006;+ // 60 mm deep, at the glass. The previous 160 mm ran the full depth of the+ // well, and at a 3/4 view a divider that deep occludes 112 mm of a 176 mm+ // cell -- so the lit panel behind was geometrically unreachable from any+ // angle a hero shot is taken at. A divider only has to divide at the front.+ slab(`Mullion_${i}`, 0.060, dispH - 0.02, 0.012, [0.310, dispCy, z], black);+ }++ // Product columns. 0.186 m to the neck, 0.204 to the top of the cap, in a+ // 0.222 m cell. The+ // first sizing ran 0.236 and every bottle grew through the shelf above it.+ const bottleGeo = await uv(await revolveProfile([+ [0.000, 0.000], [0.037, 0.000], [0.039, 0.014], [0.038, 0.104],+ [0.037, 0.134], [0.031, 0.152], [0.016, 0.170], [0.014, 0.186], [0.000, 0.186],+ ], { segments: 20, axis: 'y', smooth: true }));+ for (let c = 0; c < COL_Z.length; c++) {+ const z = COL_Z[c];+ const mat = drinks[c];+ for (let s = 0; s < SHELF_Y.length; s++) {+ const y = SHELF_Y[s] + 0.005;+ for (const dz of [-0.044, 0.044]) {+ const nm = `Prod_${c}_${s}_${dz > 0 ? 'a' : 'b'}`;+ if (c === 1) {+ // Cans in column 1, bottles elsewhere. Two silhouettes rather than+ // one is most of what keeps the display from reading as wallpaper.+ createPart(nm, cylinderGeo(0.037, 0.037, 0.136, 18), mat,+ { position: [P.CANS, y + 0.068, z + dz], parent: root });+ createPart(`${nm}_Lid`, cylinderGeo(0.033, 0.033, 0.009, 18), capMat,+ { position: [P.CANS, y + 0.139, z + dz], parent: root });+ } else {+ createPart(nm, bottleGeo, mat, { position: [P.CANS, y, z + dz], parent: root });+ createPart(`${nm}_Cap`, cylinderGeo(0.016, 0.016, 0.018, 12), capMat,+ { position: [P.CANS, y + 0.194, z + dz], parent: root });+ }+ }+ }+ }++ // Glazing, then the bezel that frames it. The frame is proud of the glass by+ // 30 mm, which is what puts the display INTO the machine.+ slab('Glass', 0.008, dispH - 0.006, dispW - 0.006, [P.GLASS, dispCy, dispCz], glass);+ const frameT = 0.052;+ slab('BezelTop', 0.030, frameT, dispW + frameT * 2, [P.BEZEL, DISP_Y1 + frameT / 2, dispCz], bezel);+ slab('BezelBot', 0.030, frameT, dispW + frameT * 2, [P.BEZEL, DISP_Y0 - frameT / 2, dispCz], bezel);+ for (const sz of [-1, 1]) {+ slab(`BezelSide_${sz > 0 ? 'R' : 'L'}`, 0.030, dispH, frameT,+ [P.BEZEL, dispCy, dispCz + sz * (dispW / 2 + frameT / 2)], bezel);+ }++ // ---------- Selection row ----------+ // Under each column: a price tag on its hot/cold band, and the button. The+ // tags are the second-brightest thing on the machine and they are 20 mm tall,+ // which is exactly the trade the header describes.+ const TAG_Y = 0.792;+ const BTN_Y = 0.700;+ slab('SelectionPanel', 0.020, 0.180, DISP_Z1 - DISP_Z0 + 0.104,+ [P.FASCIA - 0.004, 0.738, dispCz], bezel);+ for (let c = 0; c < COL_Z.length; c++) {+ const z = COL_Z[c];+ const tag = c === 1 ? hotTag : coldTag;+ slab(`Tag_${c}`, 0.008, 0.022, COL_W - 0.020, [P.TAG + 0.036, TAG_Y, z], tag);+ slab(`TagWell_${c}`, 0.010, 0.034, COL_W - 0.006, [P.TAG + 0.030, TAG_Y, z], black);+ await box(`Button_${c}`, 0.024, 0.050, 0.104, [P.BUTTON - 0.006, BTN_Y, z],+ steel, { r: 0.008, res: 256 });+ createPart(`ButtonLamp_${c}`, cylinderXGeo(0.010, 0.010, 0.014, 12), tag,+ { position: [P.BUTTON + 0.008, BTN_Y + 0.012, z], parent: root });+ }++ // ---------- Money column ----------+ const MZ = 0.386;+ slab('MoneyPanel', 0.018, 1.06, 0.180, [P.FASCIA - 0.002, 1.06, MZ], bezel);+ slab('Readout', 0.008, 0.052, 0.126, [P.FASCIA + 0.010, 1.500, MZ], readout);+ slab('ReadoutWell', 0.012, 0.076, 0.150, [P.FASCIA + 0.004, 1.500, MZ], black);+ // Note acceptor: a slot with a lit throat, which is the detail that makes it+ // read as a mechanism rather than a printed rectangle.+ await box('NoteBezel', 0.026, 0.120, 0.150, [P.FASCIA + 0.008, 1.330, MZ], steel, { r: 0.006, res: 256 });+ slab('NoteSlot', 0.010, 0.014, 0.098, [P.FASCIA + 0.022, 1.330, MZ], black);+ slab('NoteLamp', 0.006, 0.006, 0.090, [P.FASCIA + 0.024, 1.330, MZ], readout);+ // Coin slot, angled the way a real one is so a coin can fall into it.+ await box('CoinBezel', 0.024, 0.090, 0.090, [P.FASCIA + 0.008, 1.180, MZ], steel, { r: 0.006, res: 256 });+ slab('CoinSlot', 0.014, 0.044, 0.014, [P.FASCIA + 0.018, 1.180, MZ], black, [0, 0, 18]);+ // Coin return and its cup.+ createPart('ReturnLever', cylinderXGeo(0.014, 0.014, 0.030, 12), steel,+ { position: [P.FASCIA + 0.018, 1.062, MZ + 0.052], parent: root });+ await box('CoinCup', 0.034, 0.056, 0.098, [P.FASCIA + 0.002, 0.968, MZ], black, { r: 0.008, res: 256 });++ // ---------- Delivery port ----------+ // The bottom-left flap. It is black, deep, and hinged slightly open, because+ // a closed flush flap on a flat panel is invisible and this is the one part of+ // the machine a person actually reaches into.+ const PORT_Z = -0.246;+ slab('PortSurround', 0.020, 0.280, 0.470, [P.FASCIA - 0.004, 0.400, PORT_Z], bezel);+ slab('PortVoid', 0.070, 0.226, 0.412, [P.FASCIA - 0.030, 0.396, PORT_Z], black);+ // Hinged a few degrees open. A flush flap on a flat panel is invisible, and+ // this is the one part of the machine a person actually puts a hand into.+ await box('PortFlap', 0.016, 0.212, 0.400, [P.FASCIA + 0.016, 0.436, PORT_Z], rubber,+ { r: 0.006, rotation: [0, 0, 11], res: 512 });+ slab('PortLip', 0.030, 0.018, 0.420, [P.FASCIA + 0.010, 0.292, PORT_Z], steel);+ // Lower fascia, and the red band that carries the machine's colour down to+ // the ground so the bottom half is not a blank white slab.+ slab('LowerBand', 0.012, 0.088, 1.08, [P.FASCIA + 0.006, 0.196, 0], band);+ slab('KickPlate', 0.014, 0.084, 1.06, [P.FASCIA + 0.004, 0.128, 0], bezel);++ // ---------- Recycling bin ----------+ // Every one of these machines on every street in Japan has a bin bolted to+ // its flank. It is here for scale as much as for company: a 1.9 m cabinet+ // photographed alone could be any size at all.+ const binZ = HZ + 0.29;+ createPart('Bin', await uv(await revolveProfile([+ [0.000, 0.000], [0.185, 0.000], [0.190, 0.030], [0.196, 0.560],+ [0.204, 0.640], [0.204, 0.690], [0.176, 0.690], [0.000, 0.690],+ ], { segments: 26, axis: 'y', smooth: true })), band, { position: [0.02, 0.03, binZ], parent: root });+ createPart('BinRim', torusGeo(0.196, 0.018, 8, 26), bezel,+ { position: [0.02, 0.722, binZ], rotation: [90, 0, 0], parent: root });+ createPart('BinHole', cylinderGeo(0.116, 0.116, 0.030, 20), black,+ { position: [0.02, 0.706, binZ], parent: root });+ // The sorting label, and it cannot be a slab. A flat plate 0.24 m across a+ // 0.39 m drum only touches it along one line: the middle sinks in and the two+ // ends stand 40 mm proud of the curve, which from the front reads as a white+ // wing sticking out of the bin. A label on a round bin is a curved plate, so+ // this is an annular sector -- the same wedge trick the well's curb stones+ // use -- swept up through the label's height and sitting 6 mm proud all the+ // way round.+ const labelArc = (r, t) => [r * Math.cos(t), r * Math.sin(t)];+ const LABEL_HALF = 0.44;+ const labelProfile = [];+ for (let i = 0; i <= 6; i++) {+ labelProfile.push(labelArc(0.1925, -LABEL_HALF + (i / 6) * 2 * LABEL_HALF));+ }+ for (let i = 6; i >= 0; i--) {+ labelProfile.push(labelArc(0.2005, -LABEL_HALF + (i / 6) * 2 * LABEL_HALF));+ }+ createPart(+ 'BinLabel',+ await extrudeProfile(labelProfile, { depth: 0.110, axis: 'y' }),+ binLabel,+ { position: [0.02, 0.375, binZ], parent: root },+ );+ // The bracket that actually holds it to the machine. Short, dark and tucked+ // behind the bin's shoulder -- the first version was a pale slab long enough+ // to pass straight through the bin and out the far side.+ slab('BinBracket', 0.050, 0.026, 0.130, [-0.10, 0.585, HZ + 0.10], bezel);+ slab('BinBracketPad', 0.016, 0.070, 0.020, [-0.10, 0.585, HZ + 0.028], bezel);++ return root;+}diff --git a/examples/victorian-greenhouse.kiln.js b/examples/victorian-greenhouse.kiln.jsnew file mode 100644index 00000000..185a37fd--- /dev/null+++ b/examples/victorian-greenhouse.kiln.js@@ -0,0 +1,1054 @@+// Authored by: gemini-3.8-flash-high, via agy.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.++const meta = { name: 'VictorianGreenhouse', category: 'architecture' };++function build() {+ const root = createRoot('VictorianGreenhouse');++ // ==========================================+ // MATERIALS+ // ==========================================+ const brickMat = gameMaterial(0x8f3c2c, { roughness: 0.88, metalness: 0.04 });+ const plinthBrickMat = gameMaterial(0x4e2c24, { roughness: 0.84, metalness: 0.06 });+ const stoneMat = gameMaterial(0xc6bead, { roughness: 0.78, metalness: 0.05 });+ const ironMat = gameMaterial(0xf4f6f3, { roughness: 0.35, metalness: 0.25 });+ const darkIronMat = gameMaterial(0x2a2e2b, { roughness: 0.55, metalness: 0.55 });+ const brassMat = gameMaterial(0xcba845, { roughness: 0.28, metalness: 0.85 });+ const woodMat = gameMaterial(0x563820, { roughness: 0.82, metalness: 0.05 });+ const glassMat = glassMaterial(0xaad8e6, { opacity: 0.30, roughness: 0.08, metalness: 0.1 });+ const potMat = gameMaterial(0xba582d, { roughness: 0.86, metalness: 0.04 });+ const compostMat = gameMaterial(0x2b1e16, { roughness: 0.95, metalness: 0.02 });+ const plantMat = gameMaterial(0x2e6926, { roughness: 0.72, metalness: 0.04 });+ const darkLeafMat = gameMaterial(0x1d4d18, { roughness: 0.75, metalness: 0.04 });+ const flowerRedMat = gameMaterial(0xd42424, { roughness: 0.55, metalness: 0.05 });+ const flowerWhiteMat = gameMaterial(0xf5f3ee, { roughness: 0.60, metalness: 0.05 });++ // ==========================================+ // CORE GEOMETRY & ARCHITECTURAL GRID+ // ==========================================+ const length = 6.0; // along X: -3.0 to +3.0+ const width = 3.6; // along Z: -1.8 to +1.8+ const halfL = length / 2;+ const halfW = width / 2;+ const numBays = 6;+ const baySize = length / numBays; // 1.0m per bay++ // Heights+ const plinthH = 0.14; // dark brick base+ const wallH = 0.74; // top of red brick+ const copingH = 0.08; // stone coping+ const sillY = wallH + copingH; // 0.82m+ const eaveH = 2.22; // underside of eave beam+ const vaultRise = 1.12; // barrel vault rise+ const ridgeVaultCrown = eaveH + vaultRise; // 3.34m++ const wallThick = 0.18;+ const archHalfW = halfW - wallThick / 2; // 1.71m++ // Lantern dimensions+ const lanternW = 0.82; // width along Z+ const lanternHalfW = lanternW / 2; // 0.41m+ const lanternH = 0.58; // vertical height of lantern side walls+ const lanternEaveH = 3.26 + lanternH; // 3.84m+ const lanternPitchH = 0.28; // lantern ridge cap rise+ const lanternRidgeY = lanternEaveH + lanternPitchH; // 4.12m++ // Door opening+ const doorW = 1.30;+ const doorLeafW = doorW / 2 - 0.03;+ const doorTransomH = 2.06;++ // 1. Foundation & Floor+ createPart('FoundSlab', boxGeo(length + 0.36, 0.08, width + 0.36), stoneMat, {+ position: [0, 0.04, 0],+ parent: root,+ });+ createPart('InteriorFloor', boxGeo(length - 0.04, 0.03, width - 0.04), stoneMat, {+ position: [0, 0.085, 0],+ parent: root,+ });+ createPart('WalkwayBorderL', boxGeo(length - 0.1, 0.02, 0.06), stoneMat, {+ position: [0, 0.10, -0.48],+ parent: root,+ });+ createPart('WalkwayBorderR', boxGeo(length - 0.1, 0.02, 0.06), stoneMat, {+ position: [0, 0.10, 0.48],+ parent: root,+ });+ createPart('DoorStep_Exterior', boxGeo(0.36, 0.06, doorW + 0.16), stoneMat, {+ position: [halfL + 0.14, 0.03, 0],+ parent: root,+ });++ // 2. Brick Dwarf Wall with Plinth & Coping+ const wallBodyH = wallH - plinthH;+ const wallMidY = plinthH + wallBodyH / 2;++ // Left Long Wall+ const zLeft = -halfW + wallThick / 2;+ createPart('Plinth_Left', boxGeo(length, plinthH, wallThick + 0.04), plinthBrickMat, {+ position: [0, plinthH / 2, zLeft],+ parent: root,+ });+ createPart('Wall_Left', boxGeo(length, wallBodyH, wallThick), brickMat, {+ position: [0, wallMidY, zLeft],+ parent: root,+ });+ createPart('Coping_Left', boxGeo(length + 0.08, copingH, wallThick + 0.06), stoneMat, {+ position: [0, wallH + copingH / 2, zLeft],+ parent: root,+ });++ // Right Long Wall+ const zRight = halfW - wallThick / 2;+ createPart('Plinth_Right', boxGeo(length, plinthH, wallThick + 0.04), plinthBrickMat, {+ position: [0, plinthH / 2, zRight],+ parent: root,+ });+ createPart('Wall_Right', boxGeo(length, wallBodyH, wallThick), brickMat, {+ position: [0, wallMidY, zRight],+ parent: root,+ });+ createPart('Coping_Right', boxGeo(length + 0.08, copingH, wallThick + 0.06), stoneMat, {+ position: [0, wallH + copingH / 2, zRight],+ parent: root,+ });++ // Brick Piers under each post on Left and Right+ const pierGeo = boxGeo(0.20, wallBodyH, 0.03);+ const pierCapGeo = boxGeo(0.22, copingH + 0.01, 0.04);+ for (let b = 0; b <= numBays; b++) {+ const x = -halfL + b * baySize;+ createPart(`Pier_L_${b}`, pierGeo, brickMat, {+ position: [x, wallMidY, zLeft - wallThick / 2 - 0.015],+ parent: root,+ });+ createPart(`PierCap_L_${b}`, pierCapGeo, stoneMat, {+ position: [x, wallH + copingH / 2, zLeft - wallThick / 2 - 0.02],+ parent: root,+ });+ createPart(`Pier_R_${b}`, pierGeo, brickMat, {+ position: [x, wallMidY, zRight + wallThick / 2 + 0.015],+ parent: root,+ });+ createPart(`PierCap_R_${b}`, pierCapGeo, stoneMat, {+ position: [x, wallH + copingH / 2, zRight + wallThick / 2 + 0.02],+ parent: root,+ });+ }++ // Back Wall (Continuous)+ const backX = -halfL + wallThick / 2;+ createPart('Plinth_Back', boxGeo(wallThick + 0.04, plinthH, width - 2 * wallThick), plinthBrickMat, {+ position: [backX, plinthH / 2, 0],+ parent: root,+ });+ createPart('Wall_Back', boxGeo(wallThick, wallBodyH, width - 2 * wallThick), brickMat, {+ position: [backX, wallMidY, 0],+ parent: root,+ });+ createPart('Coping_Back', boxGeo(wallThick + 0.06, copingH, width), stoneMat, {+ position: [backX, wallH + copingH / 2, 0],+ parent: root,+ });++ // Front Wall (with door opening)+ const frontX = halfL - wallThick / 2;+ const frontSideW = (width - doorW) / 2 - wallThick;+ const frontZ_L = -doorW / 2 - frontSideW / 2;+ const frontZ_R = doorW / 2 + frontSideW / 2;++ createPart('Plinth_Front_L', boxGeo(wallThick + 0.04, plinthH, frontSideW), plinthBrickMat, {+ position: [frontX, plinthH / 2, frontZ_L],+ parent: root,+ });+ createPart('Wall_Front_L', boxGeo(wallThick, wallBodyH, frontSideW), brickMat, {+ position: [frontX, wallMidY, frontZ_L],+ parent: root,+ });+ createPart('Coping_Front_L', boxGeo(wallThick + 0.06, copingH, frontSideW + 0.03), stoneMat, {+ position: [frontX, wallH + copingH / 2, frontZ_L],+ parent: root,+ });++ createPart('Plinth_Front_R', boxGeo(wallThick + 0.04, plinthH, frontSideW), plinthBrickMat, {+ position: [frontX, plinthH / 2, frontZ_R],+ parent: root,+ });+ createPart('Wall_Front_R', boxGeo(wallThick, wallBodyH, frontSideW), brickMat, {+ position: [frontX, wallMidY, frontZ_R],+ parent: root,+ });+ createPart('Coping_Front_R', boxGeo(wallThick + 0.06, copingH, frontSideW + 0.03), stoneMat, {+ position: [frontX, wallH + copingH / 2, frontZ_R],+ parent: root,+ });++ // 3. White-Painted Cast-Iron Side Walls+ const sideWindowH = eaveH - sillY;+ const sideWindowMidY = sillY + sideWindowH / 2;++ createPart('SillBeam_L', boxGeo(length, 0.04, 0.06), ironMat, {+ position: [0, sillY + 0.02, zLeft],+ parent: root,+ });+ createPart('SillBeam_R', boxGeo(length, 0.04, 0.06), ironMat, {+ position: [0, sillY + 0.02, zRight],+ parent: root,+ });+ createPart('EavesBeam_L', boxGeo(length + 0.08, 0.07, 0.08), ironMat, {+ position: [0, eaveH + 0.035, zLeft],+ parent: root,+ });+ createPart('EavesBeam_R', boxGeo(length + 0.08, 0.07, 0.08), ironMat, {+ position: [0, eaveH + 0.035, zRight],+ parent: root,+ });++ const transomY = sillY + sideWindowH * 0.52;+ createPart('TransomRail_L', boxGeo(length, 0.03, 0.04), ironMat, {+ position: [0, transomY, zLeft],+ parent: root,+ });+ createPart('TransomRail_R', boxGeo(length, 0.03, 0.04), ironMat, {+ position: [0, transomY, zRight],+ parent: root,+ });++ // Vertical Posts & Spandrel Brackets+ const postGeo = cylinderGeo(0.032, 0.036, sideWindowH, 5);+ const shoeGeo = boxGeo(0.10, 0.04, 0.10);+ const capGeo = boxGeo(0.10, 0.05, 0.10);+ const spandrelGeo = torusGeo(0.08, 0.012, 3, 6);++ for (let b = 0; b <= numBays; b++) {+ const x = -halfL + b * baySize;+ createPart(`Post_L_${b}`, postGeo, ironMat, {+ position: [x, sideWindowMidY, zLeft],+ parent: root,+ });+ createPart(`Post_R_${b}`, postGeo, ironMat, {+ position: [x, sideWindowMidY, zRight],+ parent: root,+ });+ createPart(`PostShoe_L_${b}`, shoeGeo, ironMat, {+ position: [x, sillY + 0.02, zLeft],+ parent: root,+ });+ createPart(`PostShoe_R_${b}`, shoeGeo, ironMat, {+ position: [x, sillY + 0.02, zRight],+ parent: root,+ });+ createPart(`PostCap_L_${b}`, capGeo, ironMat, {+ position: [x, eaveH - 0.025, zLeft],+ parent: root,+ });+ createPart(`PostCap_R_${b}`, capGeo, ironMat, {+ position: [x, eaveH - 0.025, zRight],+ parent: root,+ });+ createPart(`Spandrel_L_${b}`, spandrelGeo, ironMat, {+ position: [x, eaveH + 0.06, zLeft + 0.08],+ rotation: [0, 90, 0],+ parent: root,+ });+ createPart(`Spandrel_R_${b}`, spandrelGeo, ironMat, {+ position: [x, eaveH + 0.06, zRight - 0.08],+ rotation: [0, 90, 0],+ parent: root,+ });+ }++ // Side glazing+ const lowerH = transomY - sillY - 0.04;+ const upperH = eaveH - transomY - 0.04;+ const lowerMidY = sillY + 0.02 + lowerH / 2;+ const upperMidY = transomY + 0.02 + upperH / 2;+ const paneW = baySize / 2 - 0.025;+ const muntinGeo = boxGeo(0.02, sideWindowH, 0.025);+ const glassLowGeo = boxGeo(paneW, lowerH, 0.008);+ const glassUpGeo = boxGeo(paneW, upperH, 0.008);++ for (let b = 0; b < numBays; b++) {+ const xMid = -halfL + (b + 0.5) * baySize;+ createPart(`SideMuntin_L_${b}`, muntinGeo, ironMat, {+ position: [xMid, sideWindowMidY, zLeft],+ parent: root,+ });+ createPart(`SideMuntin_R_${b}`, muntinGeo, ironMat, {+ position: [xMid, sideWindowMidY, zRight],+ parent: root,+ });++ for (let sub = 0; sub < 2; sub++) {+ const subX = -halfL + b * baySize + (sub + 0.5) * (baySize / 2);+ createPart(`Glass_L_Low_${b}_${sub}`, glassLowGeo, glassMat, {+ position: [subX, lowerMidY, zLeft],+ parent: root,+ });+ createPart(`Glass_L_Up_${b}_${sub}`, glassUpGeo, glassMat, {+ position: [subX, upperMidY, zLeft],+ parent: root,+ });+ createPart(`Glass_R_Low_${b}_${sub}`, glassLowGeo, glassMat, {+ position: [subX, lowerMidY, zRight],+ parent: root,+ });+ createPart(`Glass_R_Up_${b}_${sub}`, glassUpGeo, glassMat, {+ position: [subX, upperMidY, zRight],+ parent: root,+ });+ }+ }++ // ==========================================+ // 4. BARREL-VAULTED ROOF STRUCTURE+ // ==========================================+ const roof = createRoot('Roof');+ root.add(roof);++ function archY(z) {+ const ratio = Math.min(1.0, Math.max(-1.0, z / archHalfW));+ return eaveH + vaultRise * Math.sqrt(Math.max(0, 1 - ratio * ratio));+ }++ // Continuous Curved Iron Ribs across the vault at each bay+ const ribSegs = 14;+ const ribPts = [];+ for (let s = 0; s <= ribSegs; s++) {+ const theta = (s / ribSegs) * Math.PI;+ const z = -archHalfW * Math.cos(theta);+ const y = eaveH + vaultRise * Math.sin(theta);+ ribPts.push([0, y, z]);+ }+ const ribGeo = curveToMesh(ribPts, 0.028, 12, 4);++ for (let b = 0; b <= numBays; b++) {+ const x = -halfL + b * baySize;+ createPart(`Rib_${b}`, ribGeo, ironMat, {+ position: [x, 0, 0],+ parent: roof,+ });+ beamBetween(`TieRod_${b}`, [x, eaveH + 0.12, -archHalfW + 0.15], [x, eaveH + 0.12, archHalfW - 0.15], 0.012, ironMat, { segments: 4, parent: roof });+ beamBetween(`KingRod_${b}`, [x, eaveH + 0.12, 0], [x, ridgeVaultCrown - 0.04, 0], 0.010, ironMat, { segments: 4, parent: roof });+ }++ // Longitudinal purlins+ const purlinAngles = [0.44, 0.90, Math.PI - 0.90, Math.PI - 0.44];+ const purlinGeo = cylinderXGeo(0.02, 0.02, length + 0.04, 5);+ for (let p = 0; p < purlinAngles.length; p++) {+ const theta = purlinAngles[p];+ const pz = -archHalfW * Math.cos(theta);+ const py = eaveH + vaultRise * Math.sin(theta);+ createPart(`Purlin_${p}`, purlinGeo, ironMat, {+ position: [0, py, pz],+ parent: roof,+ });+ }++ // Roof Glazing Facets+ const thetaLantern = Math.acos(lanternHalfW / archHalfW);+ const roofSlopeSegs = 6;++ for (let b = 0; b < numBays; b++) {+ const xMid = -halfL + (b + 0.5) * baySize;++ // Left slope+ for (let s = 0; s < roofSlopeSegs; s++) {+ const t0 = (s / roofSlopeSegs) * thetaLantern;+ const t1 = ((s + 1) / roofSlopeSegs) * thetaLantern;+ const z0 = -archHalfW * Math.cos(t0);+ const z1 = -archHalfW * Math.cos(t1);+ const y0 = eaveH + vaultRise * Math.sin(t0);+ const y1 = eaveH + vaultRise * Math.sin(t1);++ const midZ = (z0 + z1) / 2;+ const midY = (y0 + y1) / 2;+ const dz = z1 - z0;+ const dy = y1 - y0;+ const chord = Math.sqrt(dz * dz + dy * dy);+ const angleDeg = -Math.atan2(dy, dz) * (180 / Math.PI);++ createPart(`RoofGlass_L_${b}_${s}`, boxGeo(baySize - 0.025, chord - 0.006, 0.008), glassMat, {+ position: [xMid, midY, midZ],+ rotation: [angleDeg, 0, 0],+ parent: roof,+ });+ }++ // Right slope+ for (let s = 0; s < roofSlopeSegs; s++) {+ const t0 = Math.PI - thetaLantern + (s / roofSlopeSegs) * thetaLantern;+ const t1 = Math.PI - thetaLantern + ((s + 1) / roofSlopeSegs) * thetaLantern;+ const z0 = -archHalfW * Math.cos(t0);+ const z1 = -archHalfW * Math.cos(t1);+ const y0 = eaveH + vaultRise * Math.sin(t0);+ const y1 = eaveH + vaultRise * Math.sin(t1);++ const midZ = (z0 + z1) / 2;+ const midY = (y0 + y1) / 2;+ const dz = z1 - z0;+ const dy = y1 - y0;+ const chord = Math.sqrt(dz * dz + dy * dy);+ const angleDeg = -Math.atan2(dy, dz) * (180 / Math.PI);++ createPart(`RoofGlass_R_${b}_${s}`, boxGeo(baySize - 0.025, chord - 0.006, 0.008), glassMat, {+ position: [xMid, midY, midZ],+ rotation: [angleDeg, 0, 0],+ parent: roof,+ });+ }+ }++ // ==========================================+ // 5. RIDGE LANTERN WITH PROPPED OPEN VENTS+ // ==========================================+ const lanternSillY = archY(lanternHalfW); // ~3.27m+ const lanternEaveY = lanternSillY + lanternH; // ~3.85m+ const lanternRidgeCapY = lanternEaveY + lanternPitchH; // ~4.13m++ createPart('LanternSill_L', boxGeo(length + 0.06, 0.06, 0.06), ironMat, {+ position: [0, lanternSillY + 0.03, -lanternHalfW],+ parent: roof,+ });+ createPart('LanternSill_R', boxGeo(length + 0.06, 0.06, 0.06), ironMat, {+ position: [0, lanternSillY + 0.03, lanternHalfW],+ parent: roof,+ });+ createPart('LanternEave_L', boxGeo(length + 0.06, 0.05, 0.06), ironMat, {+ position: [0, lanternEaveY - 0.025, -lanternHalfW],+ parent: roof,+ });+ createPart('LanternEave_R', boxGeo(length + 0.06, 0.05, 0.06), ironMat, {+ position: [0, lanternEaveY - 0.025, lanternHalfW],+ parent: roof,+ });+ createPart('LanternRidgeBeam', boxGeo(length + 0.08, 0.06, 0.05), ironMat, {+ position: [0, lanternRidgeCapY, 0],+ parent: roof,+ });++ const lantPostGeo = cylinderGeo(0.022, 0.022, lanternH, 4);+ for (let b = 0; b <= numBays; b++) {+ const x = -halfL + b * baySize;+ createPart(`LanternPost_L_${b}`, lantPostGeo, ironMat, {+ position: [x, lanternSillY + lanternH / 2, -lanternHalfW],+ parent: roof,+ });+ createPart(`LanternPost_R_${b}`, lantPostGeo, ironMat, {+ position: [x, lanternSillY + lanternH / 2, lanternHalfW],+ parent: roof,+ });+ beamBetween(`LanternRafter_L_${b}`, [x, lanternRidgeCapY, 0], [x, lanternEaveY, -lanternHalfW - 0.03], 0.018, ironMat, { segments: 4, parent: roof });+ beamBetween(`LanternRafter_R_${b}`, [x, lanternRidgeCapY, 0], [x, lanternEaveY, lanternHalfW + 0.03], 0.018, ironMat, { segments: 4, parent: roof });+ }++ const capChord = Math.sqrt(lanternHalfW * lanternHalfW + lanternPitchH * lanternPitchH);+ const capPitchDeg = Math.atan2(lanternPitchH, lanternHalfW) * (180 / Math.PI);+ const capGlassGeo = boxGeo(baySize - 0.025, capChord, 0.008);+ for (let b = 0; b < numBays; b++) {+ const xMid = -halfL + (b + 0.5) * baySize;+ createPart(`LanternCapGlass_L_${b}`, capGlassGeo, glassMat, {+ position: [xMid, (lanternEaveY + lanternRidgeCapY) / 2, -lanternHalfW / 2],+ rotation: [capPitchDeg, 0, 0],+ parent: roof,+ });+ createPart(`LanternCapGlass_R_${b}`, capGlassGeo, glassMat, {+ position: [xMid, (lanternEaveY + lanternRidgeCapY) / 2, lanternHalfW / 2],+ rotation: [-capPitchDeg, 0, 0],+ parent: roof,+ });+ }++ // Hinged Side Vents Propped Open (Bays 1, 3, 5)+ const ventW = baySize - 0.05;+ const ventH = lanternH - 0.07;+ const ventFrameGeo = boxGeo(ventW, ventH, 0.025);+ const ventGlassGeo = boxGeo(ventW - 0.06, ventH - 0.06, 0.008);+ const closedFrameGeo = boxGeo(ventW, ventH, 0.02);++ for (let b = 0; b < numBays; b++) {+ const xMid = -halfL + (b + 0.5) * baySize;+ const isOpen = (b % 2 === 1);++ if (isOpen) {+ const tiltDeg = -24;+ const pivotY = lanternEaveY - 0.03;+ const pivotZ = -lanternHalfW;+ const rad = tiltDeg * (Math.PI / 180);++ const vcY = pivotY - (ventH / 2) * Math.cos(rad);+ const vcZ = pivotZ + (ventH / 2) * Math.sin(rad);++ createPart(`VentFrame_L_${b}`, ventFrameGeo, ironMat, {+ position: [xMid, vcY, vcZ],+ rotation: [tiltDeg, 0, 0],+ parent: roof,+ });+ createPart(`VentGlass_L_${b}`, ventGlassGeo, glassMat, {+ position: [xMid, vcY, vcZ],+ rotation: [tiltDeg, 0, 0],+ parent: roof,+ });++ const bottomY = pivotY - ventH * Math.cos(rad);+ const bottomZ = pivotZ + ventH * Math.sin(rad);+ beamBetween(`VentStay_L1_${b}`, [xMid - 0.22, lanternSillY + 0.05, -lanternHalfW], [xMid - 0.22, bottomY, bottomZ], 0.007, brassMat, { segments: 4, parent: roof });+ beamBetween(`VentStay_L2_${b}`, [xMid + 0.22, lanternSillY + 0.05, -lanternHalfW], [xMid + 0.22, bottomY, bottomZ], 0.007, brassMat, { segments: 4, parent: roof });++ const tiltDegR = 24;+ const radR = tiltDegR * (Math.PI / 180);+ const vcYR = pivotY - (ventH / 2) * Math.cos(radR);+ const vcZR = lanternHalfW + (ventH / 2) * Math.sin(radR);++ createPart(`VentFrame_R_${b}`, ventFrameGeo, ironMat, {+ position: [xMid, vcYR, vcZR],+ rotation: [tiltDegR, 0, 0],+ parent: roof,+ });+ createPart(`VentGlass_R_${b}`, ventGlassGeo, glassMat, {+ position: [xMid, vcYR, vcZR],+ rotation: [tiltDegR, 0, 0],+ parent: roof,+ });++ const bottomYR = pivotY - ventH * Math.cos(radR);+ const bottomZR = lanternHalfW + ventH * Math.sin(radR);+ beamBetween(`VentStay_R1_${b}`, [xMid - 0.22, lanternSillY + 0.05, lanternHalfW], [xMid - 0.22, bottomYR, bottomZR], 0.007, brassMat, { segments: 4, parent: roof });+ beamBetween(`VentStay_R2_${b}`, [xMid + 0.22, lanternSillY + 0.05, lanternHalfW], [xMid + 0.22, bottomYR, bottomZR], 0.007, brassMat, { segments: 4, parent: roof });++ } else {+ const vcY = lanternSillY + lanternH / 2;+ createPart(`VentFrame_L_${b}`, closedFrameGeo, ironMat, {+ position: [xMid, vcY, -lanternHalfW],+ parent: roof,+ });+ createPart(`VentGlass_L_${b}`, ventGlassGeo, glassMat, {+ position: [xMid, vcY, -lanternHalfW],+ parent: roof,+ });+ createPart(`VentFrame_R_${b}`, closedFrameGeo, ironMat, {+ position: [xMid, vcY, lanternHalfW],+ parent: roof,+ });+ createPart(`VentGlass_R_${b}`, ventGlassGeo, glassMat, {+ position: [xMid, vcY, lanternHalfW],+ parent: roof,+ });+ }+ }++ // Lantern End Gables+ createPart('LanternEndGlass_Front', boxGeo(0.008, lanternH + lanternPitchH * 0.7, lanternW - 0.04), glassMat, {+ position: [halfL, lanternSillY + lanternH / 2 + lanternPitchH * 0.2, 0],+ parent: roof,+ });+ createPart('LanternEndGlass_Back', boxGeo(0.008, lanternH + lanternPitchH * 0.7, lanternW - 0.04), glassMat, {+ position: [-halfL, lanternSillY + lanternH / 2 + lanternPitchH * 0.2, 0],+ parent: roof,+ });+ createPart('LanternEndPost_F', boxGeo(0.03, lanternH + lanternPitchH, 0.03), ironMat, {+ position: [halfL, lanternSillY + (lanternH + lanternPitchH) / 2, 0],+ parent: roof,+ });+ createPart('LanternEndPost_B', boxGeo(0.03, lanternH + lanternPitchH, 0.03), ironMat, {+ position: [-halfL, lanternSillY + (lanternH + lanternPitchH) / 2, 0],+ parent: roof,+ });++ // ==========================================+ // 6. CAST-IRON CRESTING & FINIALS ALONG RIDGE+ // ==========================================+ const crestBaseY = lanternRidgeCapY + 0.03;+ createPart('CrestingBaseBar', boxGeo(length + 0.10, 0.02, 0.015), ironMat, {+ position: [0, crestBaseY, 0],+ parent: roof,+ });+ createPart('CrestingMidBar', boxGeo(length + 0.10, 0.015, 0.012), ironMat, {+ position: [0, crestBaseY + 0.09, 0],+ parent: roof,+ });++ // 17 ornate cresting modules (0.35m spacing)+ const crestPitch = 0.35;+ const crestNum = Math.floor(length / crestPitch);+ const crestRingGeo = torusGeo(0.035, 0.005, 3, 5);+ const crestSpikeGeo = coneGeo(0.015, 0.11, 4);+ const crestBeadGeo = sphereGeo(0.009, 3, 3);++ for (let c = 0; c <= crestNum; c++) {+ const x = -halfL + c * crestPitch;+ createPart(`CrestRing_${c}`, crestRingGeo, ironMat, {+ position: [x, crestBaseY + 0.045, 0],+ rotation: [0, 90, 0],+ parent: roof,+ });+ createPart(`CrestSpike_${c}`, crestSpikeGeo, ironMat, {+ position: [x, crestBaseY + 0.14, 0],+ rotation: [0, 45, 0],+ parent: roof,+ });+ createPart(`CrestBead_${c}`, crestBeadGeo, ironMat, {+ position: [x, crestBaseY + 0.09, 0],+ parent: roof,+ });+ }++ // Turned Victorian End Finials+ function makeRidgeFinial(name, xPos) {+ createPart(`${name}_BaseUrn`, cylinderGeo(0.032, 0.020, 0.08, 5), darkIronMat, {+ position: [xPos, crestBaseY + 0.04, 0],+ parent: roof,+ });+ createPart(`${name}_Orb`, sphereGeo(0.052, 5, 5), darkIronMat, {+ position: [xPos, crestBaseY + 0.12, 0],+ parent: roof,+ });+ createPart(`${name}_Girdle`, torusGeo(0.058, 0.010, 3, 6), darkIronMat, {+ position: [xPos, crestBaseY + 0.12, 0],+ rotation: [90, 0, 0],+ parent: roof,+ });+ createPart(`${name}_Spire`, coneGeo(0.022, 0.36, 4), darkIronMat, {+ position: [xPos, crestBaseY + 0.30, 0],+ parent: roof,+ });+ }+ makeRidgeFinial('Finial_Front', halfL);+ makeRidgeFinial('Finial_Back', -halfL);++ // ==========================================+ // 6. GLAZED GABLE SCREENS (BACK & FRONT)+ // ==========================================+ // Back Gable: Horizontal transom and mullions fitting elliptical vault+ createPart('GableTransom_Back', boxGeo(0.05, 0.05, archHalfW * 2), ironMat, {+ position: [-halfL, eaveH, 0],+ parent: root,+ });++ const backMullionsZ = [-1.20, -0.80, -0.40, 0.0, 0.40, 0.80, 1.20];+ for (let i = 0; i < backMullionsZ.length; i++) {+ const gz = backMullionsZ[i];+ createPart(`BackMullion_${i}`, boxGeo(0.035, eaveH - sillY, 0.035), ironMat, {+ position: [-halfL, sillY + (eaveH - sillY) / 2, gz],+ parent: root,+ });+ }++ // Back gable lower & upper glazing in 8 fitted bays+ const backBayCount = 8;+ const backBayW = (archHalfW * 2) / backBayCount; // ~0.427m+ for (let i = 0; i < backBayCount; i++) {+ const zPane = -archHalfW + (i + 0.5) * backBayW;+ createPart(`BackGlass_Low_${i}`, boxGeo(0.008, eaveH - sillY - 0.04, backBayW - 0.03), glassMat, {+ position: [-halfL, sillY + (eaveH - sillY) / 2, zPane],+ parent: root,+ });+ // Upper tympanum glass fitting smoothly under curved vault rib+ const zEdge = Math.abs(zPane) + backBayW * 0.45;+ const topY = archY(zEdge) - 0.03;+ const hTymp = Math.max(0.08, topY - eaveH);+ createPart(`BackGlass_Tymp_${i}`, boxGeo(0.008, hTymp, backBayW - 0.03), glassMat, {+ position: [-halfL, eaveH + hTymp / 2, zPane],+ parent: root,+ });+ }++ // Front Gable: Door Portal, Side Flanks, Transoms & Tympanum+ createPart('FrontTransom_L', boxGeo(0.05, 0.05, frontSideW), ironMat, {+ position: [halfL, eaveH, frontZ_L],+ parent: root,+ });+ createPart('FrontTransom_R', boxGeo(0.05, 0.05, frontSideW), ironMat, {+ position: [halfL, eaveH, frontZ_R],+ parent: root,+ });++ const flankPanes = [+ { name: 'L0', z: -1.45, w: 0.44 },+ { name: 'L1', z: -0.95, w: 0.44 },+ { name: 'R1', z: 0.95, w: 0.44 },+ { name: 'R0', z: 1.45, w: 0.44 },+ ];+ for (let i = 0; i < flankPanes.length; i++) {+ const fp = flankPanes[i];+ createPart(`FrontGlass_Low_${fp.name}`, boxGeo(0.008, eaveH - sillY - 0.04, fp.w - 0.03), glassMat, {+ position: [halfL, sillY + (eaveH - sillY) / 2, fp.z],+ parent: root,+ });+ const zEdge = Math.abs(fp.z) + fp.w * 0.45;+ const topY = archY(zEdge) - 0.03;+ const hTymp = Math.max(0.08, topY - eaveH);+ createPart(`FrontGlass_Tymp_${fp.name}`, boxGeo(0.008, hTymp, fp.w - 0.03), glassMat, {+ position: [halfL, eaveH + hTymp / 2, fp.z],+ parent: root,+ });+ }+ createPart('FrontMullion_L', boxGeo(0.04, eaveH - sillY, 0.04), ironMat, {+ position: [halfL, sillY + (eaveH - sillY) / 2, frontZ_L],+ parent: root,+ });+ createPart('FrontMullion_R', boxGeo(0.04, eaveH - sillY, 0.04), ironMat, {+ position: [halfL, sillY + (eaveH - sillY) / 2, frontZ_R],+ parent: root,+ });++ // Entrance Portal Jambs & Lintel+ const doorJambH = doorTransomH - 0.06;+ createPart('DoorJamb_L', boxGeo(0.06, doorJambH, 0.06), ironMat, {+ position: [halfL, 0.06 + doorJambH / 2, -doorW / 2],+ parent: root,+ });+ createPart('DoorJamb_R', boxGeo(0.06, doorJambH, 0.06), ironMat, {+ position: [halfL, 0.06 + doorJambH / 2, doorW / 2],+ parent: root,+ });+ createPart('DoorTransomBeam', boxGeo(0.06, 0.06, doorW + 0.06), ironMat, {+ position: [halfL, doorTransomH, 0],+ parent: root,+ });++ // Stone Threshold / Doorstep+ createPart('DoorThreshold', boxGeo(0.24, 0.06, doorW + 0.12), stoneMat, {+ position: [halfL + 0.08, 0.03, 0],+ parent: root,+ });++ // ==========================================+ // 7. ARCHED DOUBLE DOORS & FANLIGHT+ // ==========================================+ const leafW = doorLeafW;+ const leafMidH = doorJambH;+ const leafZ_L = -leafW / 2 - 0.015;+ const leafZ_R = leafW / 2 + 0.015;++ function makeDoorLeaf(side, zPos, handleZ) {+ createPart(`Door_Kick_${side}`, boxGeo(0.028, 0.74, leafW - 0.06), woodMat, {+ position: [halfL - 0.01, 0.06 + 0.37, zPos],+ parent: root,+ });+ createPart(`Door_Glass_${side}`, boxGeo(0.008, 1.04, leafW - 0.06), glassMat, {+ position: [halfL - 0.01, 0.94 + 0.52, zPos],+ parent: root,+ });+ createPart(`Door_Stile_O_${side}`, boxGeo(0.038, leafMidH, 0.038), woodMat, {+ position: [halfL - 0.01, 0.06 + leafMidH / 2, zPos + (side === 'L' ? -leafW / 2 + 0.02 : leafW / 2 - 0.02)],+ parent: root,+ });+ createPart(`Door_Stile_I_${side}`, boxGeo(0.038, leafMidH, 0.038), woodMat, {+ position: [halfL - 0.01, 0.06 + leafMidH / 2, zPos + (side === 'L' ? leafW / 2 - 0.02 : -leafW / 2 + 0.02)],+ parent: root,+ });+ createPart(`Door_Rail_Top_${side}`, boxGeo(0.038, 0.05, leafW - 0.04), woodMat, {+ position: [halfL - 0.01, 0.06 + leafMidH - 0.025, zPos],+ parent: root,+ });+ createPart(`Door_Rail_Mid_${side}`, boxGeo(0.038, 0.06, leafW - 0.04), woodMat, {+ position: [halfL - 0.01, 0.93, zPos],+ parent: root,+ });+ createPart(`Door_Rail_Bot_${side}`, boxGeo(0.038, 0.08, leafW - 0.04), woodMat, {+ position: [halfL - 0.01, 0.10, zPos],+ parent: root,+ });++ createPart(`Door_Handle_${side}`, sphereGeo(0.022, 5, 5), brassMat, {+ position: [halfL + 0.022, 0.96, handleZ],+ parent: root,+ });+ createPart(`Door_Plate_${side}`, boxGeo(0.008, 0.09, 0.024), brassMat, {+ position: [halfL + 0.012, 0.96, handleZ],+ parent: root,+ });+ }+ makeDoorLeaf('L', leafZ_L, -0.06);+ makeDoorLeaf('R', leafZ_R, 0.06);++ // Semicircular Fanlight Arch & Sunburst Tracery+ const fanRadius = doorW / 2;+ const fanPts = [];+ for (let i = 0; i <= 8; i++) {+ const th = (i / 8) * Math.PI;+ fanPts.push([halfL, doorTransomH + fanRadius * Math.sin(th), -fanRadius * Math.cos(th)]);+ }+ createPart('FanlightArchRing', curveToMesh(fanPts, 0.020, 8, 4), ironMat, { parent: root });++ const sunRayAngles = [30, 60, 90, 120, 150];+ for (let i = 0; i < sunRayAngles.length; i++) {+ const rad = sunRayAngles[i] * (Math.PI / 180);+ const endP = [halfL, doorTransomH + (fanRadius - 0.02) * Math.sin(rad), -(fanRadius - 0.02) * Math.cos(rad)];+ beamBetween(`FanRay_${i}`, [halfL, doorTransomH, 0], endP, 0.009, ironMat, { segments: 4, parent: root });+ }+ createPart('FanlightGlass', boxGeo(0.008, fanRadius, doorW - 0.04), glassMat, {+ position: [halfL, doorTransomH + fanRadius / 2, 0],+ parent: root,+ });++ // Central Tympanum above Fanlight Arch divided into 4 vertical fitted panes+ const fanTopY = doorTransomH + fanRadius;+ const centralTympW = doorW / 4; // ~0.325m+ for (let i = 0; i < 4; i++) {+ const cpZ = -doorW / 2 + (i + 0.5) * centralTympW;+ const zEdge = Math.abs(cpZ) + centralTympW * 0.45;+ const topY = archY(zEdge) - 0.03;+ const hCentral = Math.max(0.10, topY - fanTopY);+ createPart(`DoorTympGlass_${i}`, boxGeo(0.008, hCentral, centralTympW - 0.03), glassMat, {+ position: [halfL, fanTopY + hCentral / 2, cpZ],+ parent: root,+ });+ }+ // Central tympanum mullions+ for (let m = 1; m < 4; m++) {+ const mz = -doorW / 2 + m * centralTympW;+ const topY = archY(mz) - 0.03;+ const hm = topY - fanTopY;+ createPart(`DoorTympMullion_${m}`, boxGeo(0.03, hm, 0.03), ironMat, {+ position: [halfL, fanTopY + hm / 2, mz],+ parent: root,+ });+ }++ // ==========================================+ // 8. STAGING BENCHES & HOT-WATER HEATING PIPES+ // ==========================================+ const benchL = 4.8;+ const benchW = 0.72;+ const benchH = 0.85;+ const legXPositions = [-2.1, -0.7, 0.7, 2.1];+ const floorTopY = 0.10; // floor surface+ const legH = benchH - floorTopY; // 0.75m++ function makeBench(side, benchZ) {+ for (let i = 0; i < legXPositions.length; i++) {+ const lx = legXPositions[i];+ // Legs sit firmly atop the interior floor (overlapping floor by 0.01m)+ createPart(`BenchLeg_O_${side}_${i}`, boxGeo(0.035, legH + 0.01, 0.035), darkIronMat, {+ position: [lx, floorTopY + legH / 2 - 0.005, benchZ + (side === 'L' ? -benchW / 2 + 0.03 : benchW / 2 - 0.03)],+ parent: root,+ });+ createPart(`BenchLeg_I_${side}_${i}`, boxGeo(0.035, legH + 0.01, 0.035), darkIronMat, {+ position: [lx, floorTopY + legH / 2 - 0.005, benchZ + (side === 'L' ? benchW / 2 - 0.03 : -benchW / 2 + 0.03)],+ parent: root,+ });+ // Lower crossbar supporting lower shelf slats+ createPart(`BenchTie_Low_${side}_${i}`, boxGeo(0.035, 0.025, benchW - 0.02), darkIronMat, {+ position: [lx, 0.27, benchZ],+ parent: root,+ });+ // Upper crossbar supporting tabletop slats+ createPart(`BenchTie_Top_${side}_${i}`, boxGeo(0.035, 0.025, benchW - 0.02), darkIronMat, {+ position: [lx, benchH - 0.02, benchZ],+ parent: root,+ });+ }++ // Top slats resting on upper crossbars+ for (let s = 0; s < 4; s++) {+ const sz = benchZ - 0.27 + s * 0.18;+ createPart(`BenchSlat_${side}_${s}`, boxGeo(benchL, 0.024, 0.15), woodMat, {+ position: [0, benchH, sz],+ parent: root,+ });+ }++ // Lower shelf slats resting on lower crossbars+ for (let s = 0; s < 3; s++) {+ const sz = benchZ - 0.22 + s * 0.22;+ createPart(`BenchLowSlat_${side}_${s}`, boxGeo(benchL, 0.018, 0.18), woodMat, {+ position: [0, 0.29, sz],+ parent: root,+ });+ }++ // Retaining lips around bench perimeter+ createPart(`BenchLip_${side}`, boxGeo(benchL + 0.02, 0.04, 0.02), woodMat, {+ position: [0, benchH + 0.02, benchZ + (side === 'L' ? benchW / 2 : -benchW / 2)],+ parent: root,+ });+ }++ makeBench('L', -1.22);+ makeBench('R', 1.22);++ // Hot-water cast iron heating pipes along plinth perimeter+ createPart('HeatPipe_L_Low', cylinderXGeo(0.038, 0.038, 5.2, 5), darkIronMat, {+ position: [0, 0.20, -1.55],+ parent: root,+ });+ createPart('HeatPipe_L_High', cylinderXGeo(0.038, 0.038, 5.2, 5), darkIronMat, {+ position: [0, 0.35, -1.55],+ parent: root,+ });+ createPart('HeatPipe_R_Low', cylinderXGeo(0.038, 0.038, 5.2, 5), darkIronMat, {+ position: [0, 0.20, 1.55],+ parent: root,+ });+ createPart('HeatPipe_R_High', cylinderXGeo(0.038, 0.038, 5.2, 5), darkIronMat, {+ position: [0, 0.35, 1.55],+ parent: root,+ });++ // ==========================================+ // 9. POTTED SPECIMEN PLANTS ON BENCHES+ // ==========================================+ const potBaseGeo = cylinderGeo(0.075, 0.05, 0.13, 5);+ const potRimGeo = cylinderGeo(0.082, 0.082, 0.024, 5);+ const potSoilGeo = cylinderGeo(0.072, 0.072, 0.012, 5);++ const plantPositions = [+ { x: -2.0, z: -1.26, type: 'fern' },+ { x: -1.35, z: -1.18, type: 'geranium' },+ { x: -0.7, z: -1.26, type: 'palm' },+ { x: 0.0, z: -1.18, type: 'lily' },+ { x: 0.7, z: -1.26, type: 'fern' },+ { x: 1.35, z: -1.18, type: 'geranium' },+ { x: 2.0, z: -1.26, type: 'palm' },+ { x: -2.0, z: 1.26, type: 'palm' },+ { x: -1.35, z: 1.18, type: 'lily' },+ { x: -0.7, z: 1.26, type: 'fern' },+ { x: 0.0, z: 1.18, type: 'geranium' },+ { x: 0.7, z: 1.26, type: 'palm' },+ { x: 1.35, z: 1.18, type: 'lily' },+ { x: 2.0, z: 1.26, type: 'fern' },+ ];++ for (let i = 0; i < plantPositions.length; i++) {+ const p = plantPositions[i];+ const potY = benchH + 0.012;+ createPart(`Pot_Base_${i}`, potBaseGeo, potMat, {+ position: [p.x, potY + 0.065, p.z],+ parent: root,+ });+ createPart(`Pot_Rim_${i}`, potRimGeo, potMat, {+ position: [p.x, potY + 0.125, p.z],+ parent: root,+ });+ createPart(`Pot_Soil_${i}`, potSoilGeo, compostMat, {+ position: [p.x, potY + 0.12, p.z],+ parent: root,+ });++ const plantBaseY = potY + 0.13;+ if (p.type === 'fern') {+ for (let f = 0; f < 5; f++) {+ const fa = (f / 5) * 360;+ createPart(`Fern_${i}_${f}`, boxGeo(0.04, 0.005, 0.22), plantMat, {+ position: [p.x, plantBaseY + 0.05, p.z],+ rotation: [22, fa, 0],+ parent: root,+ });+ }+ } else if (p.type === 'palm') {+ createPart(`Palm_Stem_${i}`, cylinderGeo(0.012, 0.016, 0.20, 4), plantMat, {+ position: [p.x, plantBaseY + 0.10, p.z],+ parent: root,+ });+ for (let l = 0; l < 4; l++) {+ const la = l * 90 + 45;+ createPart(`Palm_Leaf_${i}_${l}`, boxGeo(0.10, 0.005, 0.16), darkLeafMat, {+ position: [p.x, plantBaseY + 0.20, p.z],+ rotation: [30, la, 0],+ parent: root,+ });+ }+ } else if (p.type === 'geranium') {+ createPart(`Geran_Dome_${i}`, sphereGeo(0.075, 4, 3), plantMat, {+ position: [p.x, plantBaseY + 0.06, p.z],+ parent: root,+ });+ for (let g = 0; g < 3; g++) {+ const ga = (g / 3) * Math.PI * 2;+ createPart(`Geran_Bloom_${i}_${g}`, sphereGeo(0.028, 3, 3), flowerRedMat, {+ position: [p.x + 0.05 * Math.cos(ga), plantBaseY + 0.12, p.z + 0.05 * Math.sin(ga)],+ parent: root,+ });+ }+ } else if (p.type === 'lily') {+ for (let l = 0; l < 4; l++) {+ const la = l * 90;+ createPart(`Lily_Leaf_${i}_${l}`, boxGeo(0.045, 0.005, 0.18), plantMat, {+ position: [p.x, plantBaseY + 0.04, p.z],+ rotation: [25, la, 0],+ parent: root,+ });+ }+ createPart(`Lily_Stem_${i}`, cylinderGeo(0.006, 0.008, 0.12, 4), plantMat, {+ position: [p.x, plantBaseY + 0.06, p.z],+ parent: root,+ });+ createPart(`Lily_Flower_${i}`, coneGeo(0.022, 0.07, 4), flowerWhiteMat, {+ position: [p.x, plantBaseY + 0.13, p.z],+ parent: root,+ });+ }+ }++ // ==========================================+ // 10. HANGING BASKETS (CONNECTED TO TIE RODS)+ // ==========================================+ const basketXs = [-1.0, 0.0, 1.0];+ const tieRodY = eaveH + 0.12; // exactly 2.34m+ const basketY = 1.82;++ for (let b = 0; b < basketXs.length; b++) {+ const bx = basketXs[b];+ // Vertical suspension chain directly connecting to TieRod at tieRodY+ beamBetween(`BasketChain_${b}`, [bx, basketY, 0], [bx, tieRodY, 0], 0.006, darkIronMat, { segments: 4, parent: root });++ createPart(`BasketBody_${b}`, coneGeo(0.15, 0.12, 5), darkIronMat, {+ position: [bx, basketY - 0.06, 0],+ rotation: [180, 0, 0],+ parent: root,+ });+ createPart(`BasketRim_${b}`, torusGeo(0.15, 0.008, 3, 6), darkIronMat, {+ position: [bx, basketY, 0],+ rotation: [90, 0, 0],+ parent: root,+ });+ createPart(`BasketMoss_${b}`, sphereGeo(0.13, 4, 3), compostMat, {+ position: [bx, basketY - 0.01, 0],+ parent: root,+ });++ // Trailing ivy tendrils+ for (let t = 0; t < 4; t++) {+ const ta = (t / 4) * Math.PI * 2;+ createPart(`BasketIvy_${b}_${t}`, boxGeo(0.022, 0.16, 0.008), plantMat, {+ position: [bx + 0.13 * Math.cos(ta), basketY - 0.10, 0.13 * Math.sin(ta)],+ rotation: [15 * Math.sin(ta), (t * 90), 15 * Math.cos(ta)],+ parent: root,+ });+ }+ }++ // ==========================================+ // 11. GARDENER'S ACCESSORIES+ // ==========================================+ // Vintage brass watering can in aisle+ const canX = 2.1;+ const canZ = 0.38;+ createPart('WateringCan_Body', cylinderGeo(0.08, 0.08, 0.16, 5), brassMat, {+ position: [canX, 0.08, canZ],+ parent: root,+ });+ beamBetween('WateringCan_Spout', [canX, 0.04, canZ], [canX + 0.16, 0.18, canZ], 0.010, brassMat, { segments: 4, parent: root });+ createPart('WateringCan_Rose', cylinderGeo(0.024, 0.012, 0.020, 4), brassMat, {+ position: [canX + 0.17, 0.19, canZ],+ rotation: [0, 0, -45],+ parent: root,+ });+ createPart('WateringCan_Handle', torusGeo(0.065, 0.007, 3, 6), brassMat, {+ position: [canX, 0.16, canZ],+ rotation: [0, 90, 0],+ parent: root,+ });++ return root;+}diff --git a/examples/well.kiln.js b/examples/well.kiln.jsindex 574b6df4..ee0f8f76 100644--- a/examples/well.kiln.js+++ b/examples/well.kiln.js@@ -39,31 +39,162 @@ async function build() {metalness: 0.9,});- // Curb: a ring of blocks, so the brick texture wraps a real surface.- const R = 0.72;+ // Curb: two courses of masonry, laid the way masonry is actually laid.+ //+ // The obvious way to ring a circle with stones is a box per segment, rotated+ // to face outward. It does not work, and the reason is worth keeping: a box+ // has parallel sides, so on a circle its two neighbours meet it at an angle+ // and the joint opens into a V that widens toward the outside face. Sixteen+ // of those read as a cog wheel with a dark slot at every tooth. A real curb+ // stone is a wedge -- its side faces lie on radial planes through the axis,+ // so a neighbour meets it flat, and its inner and outer faces follow the+ // curve instead of cutting across it.+ const R_IN = 0.57;+ const R_OUT = 0.87;+ const R_MID = (R_IN + R_OUT) / 2;const SEGMENTS = 16;- for (let i = 0; i < SEGMENTS; i++) {- const a = (i / SEGMENTS) * Math.PI * 2;- const block = createPart(`Curb_${i}`, boxGeo(0.30, 0.46, 0.30), stone, {- position: [Math.cos(a) * R, 0.23, Math.sin(a) * R],- parent: root,+ const COURSE_H = 0.23;+ const step = (Math.PI * 2) / SEGMENTS;+ // A joint you can see. Radial faces that meet exactly would be coincident and+ // z-fight, and dry masonry has a mortar line anyway; 3 mm at the outer face.+ const half = step / 2 - 0.003 / R_OUT;++ // The footprint of one stone, in plan: u is world X, v is world Z, and the+ // extrusion runs up Y. The arcs carry an extra sample each so the faces bend+ // with the ring rather than chording across it.+ const arc = (r, t) => [r * Math.cos(t), r * Math.sin(t)];+ const stoneProfile = [+ arc(R_IN, -half),+ arc(R_OUT, -half),+ arc(R_OUT, -half / 2),+ arc(R_OUT, 0),+ arc(R_OUT, half / 2),+ arc(R_OUT, half),+ arc(R_IN, half),+ arc(R_IN, half / 2),+ arc(R_IN, 0),+ arc(R_IN, -half / 2),+ ];+ // One geometry, thirty-two meshes. Every stone in a course is the same stone+ // turned to its own angle, which is both what a mason would cut and what+ // keeps this under a thousand triangles.+ // extrudeProfile returns bare geometry with no UVs, and a texture-backed+ // material on unwrapped geometry is a QA blocker, not a silent miss. Use the+ // unwrap that matches the shape: cylinderUnwrap runs u around the Y axis and+ // v up the height, so the brick courses wrap the curve. boxUnwrap's flat+ // projection would smear them into horizontal bands on the outer face. Both+ // helpers CLONE, so the return value is the one to keep.+ const curbGeo = cylinderUnwrap(await extrudeProfile(stoneProfile, { depth: COURSE_H, axis: 'y' }));++ // Where the posts go, and why the curb has to know about it before it is laid.+ //+ // A post that stops on the curb's top face is resting on the wall, not built+ // into it: from any angle where the wall curves away the timber reads as+ // overhanging the stone, because a square post on a round wall always will.+ // Masonry solves this by leaving a socket -- the post runs past the courses to+ // the plinth and the stones on its line are cut around it. So the sockets are+ // modelled first, as ordinary solids, and subtracted from the few stones that+ // meet them.+ const POST = R_MID;+ const POST_W = 0.13;+ const POST_TOP = 1.76;+ const BASE_TOP = 0.10;+ const sockets = [-1, 1].map((sz) =>+ createPart(`Socket_${sz > 0 ? 'R' : 'L'}`, boxGeo(POST_W + 0.008, 0.62, POST_W + 0.008), iron, {+ position: [0, BASE_TOP + 0.31, sz * POST],+ }),+ );++ // Which stones are on that line. A stone spans `half` either side of its own+ // angle; the post reaches `postReach` either side of its post's. Overlap is+ // the sum, and the answer is one stone per post in the un-skewed course and+ // two in the skewed one, where the post straddles a joint. Everything else is+ // laid as a plain instance, which is the point of doing the test at all.+ const postReach = Math.atan2(POST_W / 2 + 0.02, POST - POST_W / 2);+ const meetsPost = (a) =>+ [Math.PI / 2, -Math.PI / 2].some((p) => {+ const d = Math.abs((((a - p + Math.PI) % (Math.PI * 2)) + Math.PI * 2) % (Math.PI * 2) - Math.PI);+ return d < half + postReach;});- block.rotation.y = -a;- boxUnwrap(block.geometry);++ for (let course = 0; course < 2; course++) {+ // Break the joints. Both courses use the same sixteen positions offset by+ // half a step, so no joint runs the full height of the curb -- which is the+ // whole reason masonry is coursed and the thing the eye reads as "built".+ const skew = course * (step / 2);+ for (let i = 0; i < SEGMENTS; i++) {+ const angle = i * step + skew;+ const block = createPart(`Curb_${course}_${i}`, curbGeo, stone, {+ position: [0, course * COURSE_H, 0],+ });+ block.rotation.y = -angle;+ if (!meetsPost(angle)) {+ root.add(block);+ continue;+ }+ // CSG bakes the world transform into the result and drops the UVs, so the+ // unwrap has to run a second time. It lands correctly because the baked+ // stone now sits around the ring's own axis, which is what the cylindrical+ // unwrap measures from.+ const notched = await boolDiff(`Curb_${course}_${i}`, block, ...sockets);+ notched.geometry = cylinderUnwrap(notched.geometry);+ root.add(notched);+ }}+ // The shaft lining: a pipe, not a cylinder. cylinderGeo is a solid, and a+ // solid here fills the well -- the hole is the whole point of a well. An+ // extruded ring with a hole in its profile is the shape that was wanted, and+ // it sits 5 mm behind the stones so the mortar joints show lining rather than+ // daylight without the two surfaces fighting over the same pixels.+ const circle = (r) =>+ Array.from({ length: 32 }, (_, i) => arc(r, (i / 32) * Math.PI * 2));+ // Same tile treatment as the base: the unwrap maps a whole turn to u 0..1+ // because it cannot know how big the ring is in metres, so the caller says.+ const linerR = R_IN - 0.005;+ const linerGeo = panelRemapV(+ cylinderUnwrap(+ await extrudeProfile(circle(linerR), {+ depth: 2 * COURSE_H,+ axis: 'y',+ holes: [circle(R_IN - 0.045)],+ }),+ ),+ (2 * COURSE_H) / 0.58,+ 0,+ (2 * Math.PI * linerR) / 0.58,+ );+ createPart('Shaft', linerGeo, stone, { position: [0, 0, 0], parent: root });++ // Water, and the reason it is here is not decoration. The base disc runs the+ // full radius, so without it you look down the shaft at the base's top face --+ // a cap whose UVs the tile remap above stretched into radial streaks. A well+ // that reads as a well has something dark at the bottom anyway.+ createPart('Water', cylinderGeo(R_IN - 0.05, R_IN - 0.05, 0.02, 32), gameMaterial(0x101a1e, {+ roughness: 0.12,+ metalness: 0.2,+ }), { position: [0, 0.11, 0], parent: root });+// Base course, slightly proud, so the curb reads as sitting on something.- const base = createPart('Base', cylinderGeo(R + 0.20, R + 0.20, 0.10, 24), stone, {- position: [0, 0.05, 0],- parent: root,- });- cylinderUnwrap(base.geometry);+ const baseR = R_OUT + 0.05;+ // cylinderGeo ships its own UVs, so no unwrap runs and the brick texture gets+ // one full tile stretched around 5.8 m of circumference and squeezed into+ // 100 mm of height -- which is why it read as wood grain. panelRemapV rescales+ // the existing UVs to a real-world tile: ten repeats around, and a v range+ // matching the course height it actually is.+ const base = createPart(+ 'Base',+ panelRemapV(cylinderGeo(baseR, baseR, 0.10, 24), 0.1, 0, (2 * Math.PI * baseR) / 0.58),+ stone,+ { position: [0, 0.05, 0], parent: root },+ );- // Posts and crossbeam.- const POST = R + 0.02;+ // Posts and crossbeam. Each post drops through its socket and bears on the+ // plinth, so the load path is timber to stone to ground rather than timber+ // balanced on a curved ledge.for (const sz of [-1, 1]) {- createPart(`Post_${sz > 0 ? 'R' : 'L'}`, boxGeo(0.13, 1.30, 0.13), wood, {- position: [0, 1.11, sz * POST],+ createPart(`Post_${sz > 0 ? 'R' : 'L'}`, boxGeo(POST_W, POST_TOP - BASE_TOP, POST_W), wood, {+ position: [0, (BASE_TOP + POST_TOP) / 2, sz * POST],parent: root,});}diff --git a/examples/windmill.kiln.js b/examples/windmill.kiln.jsnew file mode 100644index 00000000..825de8f7--- /dev/null+++ b/examples/windmill.kiln.js@@ -0,0 +1,245 @@+// Authored by: opencode-go/deepseek-v4-flash-vision-exp, via opencode.+//+// Written by the model itself through the Kiln MCP tools: it wrote the+// program, rendered it, looked at its own six-view contact sheet, and+// revised. Not a line of it is hand-authored.+//+// Dispatched into a clean directory containing only the brief and the Kiln+// skills, with no access to this repository or to any finished example.+//+// Refined later, in this repository, with `kiln_edit`: three materials that+// looked right in source and wrong in the render. The comments at each one say+// what the render showed. The attribution above is for the authoring run; both+// passes went through the same tools, and only the second one was looking at+// the asset next to a gallery.++const meta = { name: 'Windmill', category: 'prop', role: 'poi' };++async function build() {+ const root = createRoot('Windmill');+ const D2R = Math.PI / 180;++ // ---------- materials ----------+ // The tower was a solid terracotta with an OVERLAY noise laid over it, and+ // overlay is a contrast operator: a base already past mid on red and under it+ // on green and blue comes back out of it as fire-engine red. The windmill+ // rendered as a painted silo. Real coursing instead, from the `bricks` op the+ // texture DSL already has, with the noise dropped to a light multiply so it+ // soils the brick rather than recolouring it, and a height-derived normal so+ // the courses catch the light from the side the way brick does.+ const brickTex = proceduralTexture({ schemaVersion: 2, size: 512, usage: 'albedo', name: 'Brick',+ layers: [ { op: 'solid', color: 0x7d5346 },+ { op: 'bricks', brick: 0x8a5f4e, mortar: 0x9c948a, rows: 56, cols: 22, mortarWidth: 0.08, stagger: 0.5 },+ { op: 'noise', colorA: 0x6d4c40, colorB: 0xa07a6b, scale: 7, octaves: 4, seed: 3, blend: 'multiply', opacity: 0.32 } ] });+ const brick = pbrMaterial({ albedo: brickTex, normal: normalMapFromHeight(brickTex, { strength: 3 }), roughness: 0.95 });++ // Same overlay problem, and the cap had a second one: nothing in the texture+ // said shingle, so a shingled cap rendered as a smooth brown dome. Courses of+ // staggered tiles, and the normal map is what turns them into overlapping+ // boards rather than a printed pattern.+ const shingleTex = proceduralTexture({ schemaVersion: 2, size: 512, usage: 'albedo', name: 'Shingle',+ layers: [ { op: 'solid', color: 0x6b5c48 },+ { op: 'bricks', brick: 0x6f6049, mortar: 0x4a3f31, rows: 26, cols: 14, mortarWidth: 0.06, stagger: 0.5 },+ { op: 'noise', colorA: 0x5a4d3c, colorB: 0x8d7c62, scale: 9, octaves: 4, seed: 8, blend: 'multiply', opacity: 0.4 } ] });+ const shingle = pbrMaterial({ albedo: shingleTex, normal: normalMapFromHeight(shingleTex, { strength: 4 }), roughness: 0.72 });++ const wood = gameMaterial(0x8a5c33, { roughness: 0.85 });+ const woodDark = gameMaterial(0x5a3a20, { roughness: 0.9 });+ const green = gameMaterial(0x35503a, { roughness: 0.7 });+ const iron = gameMaterial(0x2f2f33, { metalness: 0.9, roughness: 0.32 });+ // 0xdcd2b6 is already within a few percent of white, and under the neutral+ // studio dome a rough near-white surface clips: the sail bays came back as+ // blank white rectangles with no weave and no fold. Unbleached rather than+ // bleached, which leaves headroom for the highlight to land somewhere.+ const canvas = gameMaterial(0x9c8f74, { roughness: 0.96 });+ const trim = gameMaterial(0xd6d0bd, { roughness: 0.8 });+ const dark = gameMaterial(0x1a1a1a, { roughness: 0.9 });+ // Dressed stone, not chalk. The belt courses at 0x8f8a82 came back within a+ // few percent of white and read as icing piped round the tower: a rough+ // diffuse surface under the neutral studio dome returns nearly all of what it+ // is given, so a light base colour has nowhere left to go.+ const stone = gameMaterial(0x6f6a63, { roughness: 0.95 });++ // ---------- tower ----------+ const baseR = 4.5, topR = 3.0, topY = 14.0;+ const towR = (y) => baseR + (topR - baseR) * (y / topY);++ const towerGeo = cylinderUnwrap(cylinderGeo(topR, baseR, topY, 32));+ createPart('Tower', towerGeo, brick, { position: [0, 7, 0], parent: root });++ // The eleven course rings that used to be here were a stand-in for coursing+ // the texture could not draw. It can now, and eleven proud hoops down a+ // tapering tower read as a stack of tyres, not as brick.++ // stone belt-courses (structural accent bands)+ [1.0, 7.2, 13.0].forEach((y, i) => {+ const r = towR(y) + 0.05;+ createPart('Belt' + i, torusGeo(r, 0.16, 6, 32), stone, { position: [0, y, 0], rotation: [90, 0, 0], parent: root });+ });++ // stepped foundation plinth+ createPart('Plinth', cylinderGeo(baseR + 0.3, baseR + 0.5, 0.62, 32), brick, { position: [0, 0.31, 0], parent: root });+ createPart('Plinth2', cylinderGeo(baseR + 0.5, baseR + 0.62, 0.4, 32), brick, { position: [0, 0.7, 0], parent: root });++ // iron hoops at the tower head+ const hoopY = 13.15;+ const hoopR = towR(hoopY) + 0.1;+ createPart('HoopTop', torusGeo(hoopR, 0.13, 8, 32), iron, { position: [0, hoopY, 0], rotation: [90, 0, 0], parent: root });+ createPart('HoopTop2', torusGeo(hoopR * 0.98, 0.09, 8, 32), iron, { position: [0, 13.45, 0], rotation: [90, 0, 0], parent: root });++ // ---------- plank door (front, +X) ----------+ const doorG = createPivot('Door', [0, 0, 0], root);+ {+ const dx = towR(1.3) + 0.02;+ for (let i = 0; i < 7; i++) {+ const z = (i - 3) * 0.21;+ const h = 2.3 - Math.abs(z) * 0.25;+ createPart('DoorPlank' + i, boxGeo(0.09, h, 0.2), green, { position: [dx, 0.1 + h / 2, z], parent: doorG });+ }+ createPart('DFrameL', boxGeo(0.12, 2.4, 0.12), woodDark, { position: [dx + 0.02, 1.35, -0.75], parent: doorG });+ createPart('DFrameR', boxGeo(0.12, 2.4, 0.12), woodDark, { position: [dx + 0.02, 1.35, 0.75], parent: doorG });+ createPart('DFrameT', boxGeo(0.12, 0.14, 1.6), woodDark, { position: [dx + 0.02, 2.5, 0], parent: doorG });+ createPart('DoorStep', boxGeo(0.6, 0.18, 1.7), stone, { position: [dx + 0.35, 0.09, 0], parent: doorG });+ }++ // ---------- shuttered windows at three levels ----------+ function shutterWindow(n, azDeg, y) {+ const piv = createPivot('Win' + n, [0, y, 0], root);+ piv.rotation.y = azDeg * D2R;+ const rx = towR(y) + 0.04;+ createPart('Win' + n + 'Dark', decalBox(0.06, 0.95, 0.62), dark, { position: [rx, 0, 0], parent: piv });+ createPart('Win' + n + 'T', decalBox(0.06, 0.09, 0.72), trim, { position: [rx + 0.01, 0.52, 0], parent: piv });+ createPart('Win' + n + 'B', decalBox(0.08, 0.1, 0.72), trim, { position: [rx + 0.02, -0.52, 0], parent: piv });+ createPart('Win' + n + 'L', decalBox(0.06, 1.05, 0.09), trim, { position: [rx + 0.01, 0, -0.36], parent: piv });+ createPart('Win' + n + 'R', decalBox(0.06, 1.05, 0.09), trim, { position: [rx + 0.01, 0, 0.36], parent: piv });+ createPart('Win' + n + 'SL', boxGeo(0.05, 1.0, 0.34), green, { position: [rx + 0.12, 0, -0.54], rotation: [0, -24, 0], parent: piv });+ createPart('Win' + n + 'SR', boxGeo(0.05, 1.0, 0.34), green, { position: [rx + 0.12, 0, 0.54], rotation: [0, 24, 0], parent: piv });+ return piv;+ }+ shutterWindow(0, 0, 4.8);+ shutterWindow(1, 62, 8.0);+ shutterWindow(2, -62, 10.6);+ shutterWindow(3, 0, 9.2);+ shutterWindow(4, 180, 5.4);+ shutterWindow(5, 118, 10.9);++ // ---------- timber stage gallery (2/3 up) ----------+ const galleryY = 12.0;+ const galOuter = 3.9;+ createPart('StageFloor', cylinderGeo(galOuter, galOuter, 0.22, 28), woodDark, { position: [0, galleryY - 0.11, 0], parent: root });+ createPart('StageRim', torusGeo(galOuter, 0.09, 6, 28), wood, { position: [0, galleryY - 0.05, 0], rotation: [90, 0, 0], parent: root });++ const plank = createPart('Plank0', boxGeo(1.0, 0.07, 0.42), wood, { position: [3.42, galleryY + 0.02, 0], parent: root });+ arrayRadial('Plank', plank, 34, 'y', root);++ const post = createPart('Post0', boxGeo(0.09, 1.25, 0.09), wood, { position: [galOuter - 0.05, galleryY + 0.72, 0], parent: root });+ arrayRadial('Post', post, 32, 'y', root);++ const baluster = createPart('Baluster0', cylinderYGeo(0.035, 0.035, 0.5, 6), woodDark, { position: [galOuter - 0.05, galleryY + 0.62, 0], parent: root });+ arrayRadial('Baluster', baluster, 64, 'y', root);+ createPart('RailTop', torusGeo(galOuter - 0.05, 0.075, 6, 32), wood, { position: [0, galleryY + 1.34, 0], rotation: [90, 0, 0], parent: root });+ createPart('RailMid', torusGeo(galOuter - 0.05, 0.05, 6, 32), wood, { position: [0, galleryY + 0.9, 0], rotation: [90, 0, 0], parent: root });+ createPart('RailBottom', torusGeo(galOuter - 0.05, 0.05, 6, 32), wood, { position: [0, galleryY + 0.25, 0], rotation: [90, 0, 0], parent: root });++ const bracket = createPart('Bracket0', boxGeo(0.95, 0.09, 0.09), wood, { position: [3.45, galleryY - 0.45, 0], rotation: [0, 0, 49], parent: root });+ arrayRadial('Bracket', bracket, 28, 'y', root);++ // access ladder leaning on the tower up to the gallery+ {+ const az = 55 * D2R;+ const c = Math.cos(az), s = Math.sin(az);+ createLadder('Ladder', { bottom: [(towR(0.2) + 0.35) * c, 0.05, (towR(0.2) + 0.35) * s], top: [(towR(11.9) + 0.35) * c, galleryY - 0.1, (towR(11.9) + 0.35) * s], material: wood, width: 0.55, rungCount: 15, railRadius: 0.055, rungRadius: 0.05, parent: root });+ }++ // ---------- boat-shaped shingled cap ----------+ const capProfile = [+ [3.9, 14.0], [3.9, 14.9], [3.2, 16.1], [1.6, 17.0], [0.0, 17.4], [-1.9, 17.0],+ [-3.2, 16.0], [-4.2, 14.7], [-4.4, 14.0], [-2.2, 14.0], [0.0, 14.0], [2.2, 14.0]+ ];+ let capGeo = await extrudeProfile(capProfile, { depth: 6.6, bevel: 0.28, bevelStyle: 'round', segments: 7, axis: 'z', center: true, smooth: false });+ capGeo = await autoUnwrap(capGeo);+ createPart('Cap', capGeo, shingle, { position: [0, 0, 0], parent: root });++ const ridge = curveToMesh([[3.7, 14.9, 0], [3.2, 16.1, 0], [1.6, 17.0, 0], [0, 17.4, 0], [-1.9, 17.0, 0], [-3.2, 16.0, 0], [-4.1, 14.7, 0]], 0.09, 16, 6);+ createPart('Ridge', ridge, woodDark, { parent: root });++ createPart('Gable', boxGeo(0.12, 1.0, 3.4), woodDark, { position: [3.95, 15.3, 0], parent: root });++ // finial weathervane on the crown of the cap+ createPart('VaneMast', cylinderYGeo(0.035, 0.035, 1.3, 8), iron, { position: [0, 18.0, 0], parent: root });+ createPart('VaneArrow', boxGeo(0.9, 0.06, 0.02), iron, { position: [0.3, 18.4, 0], parent: root });+ createPart('VaneArrowTip', boxGeo(0.02, 0.24, 0.02), iron, { position: [0.72, 18.4, 0], parent: root });+ createPart('VaneTail', boxGeo(0.3, 0.24, 0.02), iron, { position: [-0.2, 18.4, 0], parent: root });++ // ---------- canted windshaft ----------+ const cant = 12 * D2R;+ const dd = [Math.cos(cant), Math.sin(cant), 0];+ const hubPos = [5.2, 16.1, 0];+ const shaftStart = [1.0, 14.6, 0];++ const shaftLen = Math.hypot(hubPos[0] - shaftStart[0], hubPos[1] - shaftStart[1]);+ const shaftCenter = [(shaftStart[0] + hubPos[0]) / 2, (shaftStart[1] + hubPos[1]) / 2, 0];+ createPart('Shaft', cylinderOnAxis(shaftCenter, dd, 0.2, shaftLen + 0.4), wood, { parent: root });++ // stuffing-box collar where the shaft exits the cap front lip+ createPart('ShaftCollar', cylinderOnAxis([3.6, 15.15, 0], dd, 0.34, 0.5), iron, { parent: root });++ // ---------- four lattice sails (spin around the canted shaft) ----------+ const shaftPivot = createPivot('ShaftBase', hubPos, root);+ shaftPivot.rotation.z = -(Math.PI / 2 - cant);++ const spinPivot = createPivot('Sails', [0, 0, 0], shaftPivot);++ function buildSail(sp, tag) {+ // main stock (spar)+ createPart('Stock' + tag, boxGeo(7.8, 0.14, 0.4), wood, { position: [4.2, 0, 0], parent: sp });+ // hub-side leading sailboard+ createPart('Board' + tag, boxGeo(1.4, 0.1, 1.1), woodDark, { position: [1.1, 0, -0.4], parent: sp });+ // sailcloth panel behind the lattice+ createPart('Cloth' + tag, boxGeo(5.5, 0.03, 1.8), canvas, { position: [5.1, -0.09, 0], parent: sp });+ // cloth-bay lattice frame+ createPart('L' + tag + 'A1', boxGeo(0.07, 0.07, 1.9), woodDark, { position: [2.3, 0, 0], parent: sp });+ createPart('L' + tag + 'A2', boxGeo(0.07, 0.07, 1.9), woodDark, { position: [7.9, 0, 0], parent: sp });+ createPart('L' + tag + 'R1', boxGeo(5.6, 0.07, 0.07), woodDark, { position: [5.1, 0, 0.95], parent: sp });+ createPart('L' + tag + 'R2', boxGeo(5.6, 0.07, 0.07), woodDark, { position: [5.1, 0, -0.95], parent: sp });+ for (let i = 0; i < 11; i++) {+ createPart('L' + tag + 'V' + i, boxGeo(0.05, 0.05, 1.9), woodDark, { position: [2.55 + i * 0.52, 0, 0], parent: sp });+ }+ createPart('L' + tag + 'H1', boxGeo(5.6, 0.05, 0.05), woodDark, { position: [5.1, 0, 0.33], parent: sp });+ createPart('L' + tag + 'H2', boxGeo(5.6, 0.05, 0.05), woodDark, { position: [5.1, 0, -0.33], parent: sp });+ // tip board at the far end of the sail+ createPart('Tip' + tag, boxGeo(0.5, 0.12, 1.4), woodDark, { position: [8.15, 0, 0], parent: sp });+ }++ for (let k = 0; k < 4; k++) {+ const sp = createPivot('SailPivot' + k, [0, 0, 0], spinPivot);+ sp.rotation.y = k * (Math.PI / 2);+ buildSail(sp, k);+ }++ // hub block+ createPart('Hub', cylinderOnAxis(hubPos, dd, 0.45, 0.7), iron, { parent: root });++ // ---------- fantail on a small tower behind the cap ----------+ const fant = createPivot('Fantail', [0, 0, 0], root);+ {+ const fx = -4.2, fy = 13.2;+ createPart('FantTower', cylinderGeo(0.32, 0.5, 2.6, 10), wood, { position: [fx, fy, 0], parent: fant });+ const fp = createPart('FantPost0', cylinderYGeo(0.045, 0.045, 2.8, 6), woodDark, { position: [fx + 0.42, fy, 0], parent: fant });+ arrayRadial('FantPost', fp, 4, 'y', fant);+ createPart('FantRing1', torusGeo(0.42, 0.04, 5, 12), woodDark, { position: [fx, fy - 1.0, 0], rotation: [90, 0, 0], parent: fant });+ createPart('FantRing2', torusGeo(0.42, 0.04, 5, 12), woodDark, { position: [fx, fy + 1.0, 0], rotation: [90, 0, 0], parent: fant });++ // fan blades (8) around a horizontal -X-facing wheel+ const fan = createPivot('FanHub', [fx - 0.7, fy, 0], fant);+ const blade = createPart('Blade0', boxGeo(0.07, 1.4, 0.32), woodDark, { position: [0, 0.78, 0], parent: fan });+ arrayRadial('Blade', blade, 8, 'x', fan);+ createPart('FanCenter', cylinderXGeo(0.14, 0.14, 0.5, 10), iron, { position: [0, 0, 0], parent: fan });+ }++ return root;+}++function animate() {+ return [spinAnimation('Joint_Sails', 12, 'y')];+}diff --git a/scripts/anim-gifs.ts b/scripts/anim-gifs.tsnew file mode 100644index 00000000..0749ef91--- /dev/null+++ b/scripts/anim-gifs.ts@@ -0,0 +1,278 @@+/**+ * Render one looping GIF per animated example into `examples/renders/`.+ *+ * A still cannot show that Kiln's animation path works, and the claim that a+ * model can write `animate()` and then watch its own motion deserves better+ * evidence than a sentence. This produces the loop itself.+ *+ * bun scripts/anim-gifs.ts # every entry in GIFS+ * bun scripts/anim-gifs.ts robot-arm+ * bun scripts/anim-gifs.ts --frames 30 --fps 15 --display 460+ *+ * Two details matter more than they look like they should.+ *+ * The frames are sampled across [0, duration) rather than [0, duration]. A clip+ * loops, so its last keyframe is its first; sampling inclusively duplicates a+ * frame and puts a visible hitch at the seam of every repeat.+ *+ * And the framing is pinned by hand. The render port fits the camera to the+ * bounding box it is handed, which is right for a still and wrong for a+ * sequence: a robot arm's posed extent varies 63% across its cycle, so the+ * camera would zoom in and out as the arm reached, and the asset would appear+ * to breathe. Rather than skip those assets or change the port's contract, each+ * frame is corrected back onto one shared frame afterwards. That correction is+ * exact rather than approximate — see `refit` below.+ */+import { mkdir, readFile, writeFile } from 'node:fs/promises';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';++import sharp from 'sharp';++import { orthoHalfExtent, viewBasis } from '../render-service/src/framing.mjs';+import { captureViewPngsViaPort } from '../src/agent/generate';+import { buildRenderPort } from '../src/cli-render-mode';+import { resolveEvaluatorPortV1 } from '../src/evaluator/protocol';+import { renderSceneToGLB } from '../src/render';+import { loadGlbReviewScene } from '../src/views';+import { poseSceneAtTime, prepareClip } from '../src/views/pose';+import { measureBounds } from '../src/views/raster';++const HERE = dirname(fileURLToPath(import.meta.url));+const REPO = resolve(HERE, '..');+const EXAMPLES = join(REPO, 'examples');+const OUT_DIR = join(EXAMPLES, 'renders');++/**+ * Animated examples, with the clip each one is shown in.+ *+ * The longcase clock is deliberately absent. It animates — a two-second+ * pendulum swing — but the bob travels a few pixels in a frame sized for a+ * two-metre case, so the GIF reads as a still that occasionally flickers. It+ * stays in the gallery as a still, where it is one of the better ones.+ */+const GIFS: readonly { name: string; clip: string }[] = [+ { name: 'robot-arm', clip: 'PickAndPlace' },+ { name: 'carousel', clip: 'ride' },+ { name: 'orrery', clip: 'OrreryMotion' },+ { name: 'radio-telescope', clip: 'Scan' },+];++/** Matches the hero stills, so a GIF sits beside them without a jump in angle. */+const HERO_DIR: [number, number, number] = [0.82, 0.44, 0.58];++type Vec3 = [number, number, number];++interface Args {+ names: string[];+ frames: number;+ fps: number;+ size: number;+ display: number;+ cpu: boolean;+}++function parseArgs(argv: string[]): Args {+ const names: string[] = [];+ let frames = 24;+ let fps = 12;+ let size = 640;+ let display = 440;+ let cpu = false;+ for (let i = 0; i < argv.length; i++) {+ const flag = argv[i]!;+ if (flag === '--frames') frames = Number(argv[++i]);+ else if (flag === '--fps') fps = Number(argv[++i]);+ else if (flag === '--size') size = Number(argv[++i]);+ else if (flag === '--display') display = Number(argv[++i]);+ else if (flag === '--cpu') cpu = true;+ else if (flag.startsWith('-')) throw new Error(`unknown flag ${flag}`);+ else names.push(flag.replace(/\.kiln\.js$/, ''));+ }+ if (!Number.isFinite(frames) || frames < 2 || frames > 120) {+ throw new Error(`--frames must be between 2 and 120, got ${frames}`);+ }+ if (!Number.isFinite(fps) || fps < 1 || fps > 50) {+ throw new Error(`--fps must be between 1 and 50, got ${fps}`);+ }+ return { names, frames, fps, size, display, cpu };+}++/** Even samples across [0, duration) — the endpoint is the start of the loop. */+function loopTimes(duration: number, count: number): number[] {+ return Array.from({ length: count }, (_, i) => (i / count) * duration);+}++const centreOf = (min: readonly number[], max: readonly number[]): Vec3 => [+ (min[0]! + max[0]!) / 2,+ (min[1]! + max[1]!) / 2,+ (min[2]! + max[2]!) / 2,+];++/**+ * Put one frame back on the sequence's shared camera.+ *+ * The port renders a square covering ±`half` around that frame's own bounding+ * centre. The sequence wants a square covering ±`unionHalf` around the union+ * centre. Because the projection is orthographic and the fit is exact, the two+ * differ by exactly a uniform scale and a translation, both of which are known+ * here: the frame occupies `half / unionHalf` of the target, and its centre+ * belongs wherever the union centre projects it. Scaling and compositing is+ * therefore not an approximation of a fixed camera — it is the fixed camera.+ */+async function refit(+ png: Uint8Array,+ opts: {+ size: number;+ half: number;+ unionHalf: number;+ centre: Vec3;+ unionCentre: Vec3;+ dir: Vec3;+ background: { r: number; g: number; b: number };+ },+): Promise<Buffer> {+ const scale = opts.half / opts.unionHalf;+ const inner = Math.max(1, Math.round(opts.size * scale));++ const { right, up } = viewBasis(opts.dir) as { right: Vec3; up: Vec3 };+ const delta: Vec3 = [+ opts.centre[0] - opts.unionCentre[0],+ opts.centre[1] - opts.unionCentre[1],+ opts.centre[2] - opts.unionCentre[2],+ ];+ const pxPerUnit = opts.size / (2 * opts.unionHalf);+ const dx = (delta[0] * right[0] + delta[1] * right[1] + delta[2] * right[2]) * pxPerUnit;+ const dy = (delta[0] * up[0] + delta[1] * up[1] + delta[2] * up[2]) * pxPerUnit;++ // Screen y grows downward; the up axis grows upward.+ const left = Math.round(opts.size / 2 + dx - inner / 2);+ const top = Math.round(opts.size / 2 - dy - inner / 2);++ const scaled = await sharp(Buffer.from(png)).resize(inner, inner, { fit: 'fill' }).toBuffer();+ return sharp({+ create: { width: opts.size, height: opts.size, channels: 3, background: opts.background },+ })+ .composite([{ input: scaled, left, top }])+ .removeAlpha()+ .raw()+ .toBuffer();+}++async function main(): Promise<void> {+ const args = parseArgs(process.argv.slice(2));+ await mkdir(OUT_DIR, { recursive: true });++ const chosen = args.names.length+ ? args.names.map((n) => GIFS.find((g) => g.name === n) ?? { name: n, clip: '' })+ : [...GIFS];++ const context = await buildRenderPort(args.cpu ? 'cpu' : 'auto', undefined);+ if (!context.viewRenderPort) {+ throw new Error('no GPU render port — a geometry-flat GIF is not worth publishing');+ }+ const evaluator = resolveEvaluatorPortV1(undefined, 'trusted-local');++ for (const { name, clip: wanted } of chosen) {+ const code = await readFile(join(EXAMPLES, `${name}.kiln.js`), 'utf8');+ const rendered = await evaluator.render(code);+ const { root, clips } = await loadGlbReviewScene(rendered.glb);+ const all = clips as unknown as { name: string }[];+ const clip = wanted+ ? (all.find((c) => c.name.toLowerCase().includes(wanted.toLowerCase())) ?? all[0])+ : all[0];+ if (!clip) {+ console.warn(` ${name}: no animation clips, skipped`);+ continue;+ }++ const prepared = prepareClip(root as never, clip as never);+ const times = loopTimes(prepared.duration, args.frames);++ // Pass one: every frame's bounds, and their union.+ const perFrame: { min: Vec3; max: Vec3 }[] = [];+ const uMin: Vec3 = [Infinity, Infinity, Infinity];+ const uMax: Vec3 = [-Infinity, -Infinity, -Infinity];+ for (const t of times) {+ poseSceneAtTime(root as never, prepared, t);+ const b = measureBounds(root);+ const min = [b.min[0]!, b.min[1]!, b.min[2]!] as Vec3;+ const max = [b.max[0]!, b.max[1]!, b.max[2]!] as Vec3;+ perFrame.push({ min, max });+ for (let a = 0; a < 3; a++) {+ if (min[a]! < uMin[a]!) uMin[a] = min[a]!;+ if (max[a]! > uMax[a]!) uMax[a] = max[a]!;+ }+ }+ const unionHalf = orthoHalfExtent(uMin, uMax, HERO_DIR) as number;+ const unionCentre = centreOf(uMin, uMax);+ const tightest = Math.min(+ ...perFrame.map((f) => orthoHalfExtent(f.min, f.max, HERO_DIR) as number),+ );++ // Pass two: render each pose, then put it back on the shared camera.+ const stacked: Buffer[] = [];+ let background = { r: 0, g: 0, b: 0 };+ for (let i = 0; i < times.length; i++) {+ poseSceneAtTime(root as never, prepared, times[i]!);+ // Same re-serialization the review tools do, and the same reason it is+ // not a fresh asset submission: these bytes came out of this engine.+ const posed = await renderSceneToGLB(root as never, { derivative: true });+ const shot = await captureViewPngsViaPort(+ context.viewRenderPort,+ Uint8Array.from(posed.bytes),+ context.viewRenderTimeoutMs ?? 120_000,+ [HERO_DIR],+ args.size,+ );+ if (!shot.ok) throw new Error(`${name}: render port declined (${shot.reason})`);+ const png = shot.pngs[0]!;+ if (i === 0) {+ // The port paints a flat ground colour; sampling it keeps the padding+ // added below invisible rather than a guessed near-match.+ const corner = await sharp(Buffer.from(png))+ .extract({ left: 0, top: 0, width: 1, height: 1 })+ .removeAlpha()+ .raw()+ .toBuffer();+ background = { r: corner[0]!, g: corner[1]!, b: corner[2]! };+ }+ const frame = await refit(png, {+ size: args.size,+ half: orthoHalfExtent(perFrame[i]!.min, perFrame[i]!.max, HERO_DIR) as number,+ unionHalf,+ centre: centreOf(perFrame[i]!.min, perFrame[i]!.max),+ unionCentre,+ dir: HERO_DIR,+ background,+ });+ stacked.push(+ await sharp(frame, { raw: { width: args.size, height: args.size, channels: 3 } })+ .resize(args.display, args.display, { fit: 'fill' })+ .raw()+ .toBuffer(),+ );+ }++ const gif = await sharp(Buffer.concat(stacked), {+ raw: {+ width: args.display,+ height: args.display * times.length,+ channels: 3,+ pageHeight: args.display,+ },+ })+ .gif({ loop: 0, delay: Math.round(1000 / args.fps) })+ .toBuffer();++ const out = join(OUT_DIR, `${name}.gif`);+ await writeFile(out, gif);+ console.log(+ ` ${name}.gif ${args.display}px ${times.length} frames @ ${args.fps}fps ` ++ `${(gif.byteLength / 1024).toFixed(0)} KB ` ++ `(refit ${((1 - tightest / unionHalf) * 100).toFixed(0)}% at the tightest pose)`,+ );+ }+}++await main();diff --git a/scripts/authorship.ts b/scripts/authorship.tsnew file mode 100644index 00000000..4f60166a--- /dev/null+++ b/scripts/authorship.ts@@ -0,0 +1,120 @@+/**+ * Who wrote a given program, read off the program itself.+ *+ * Every dispatched example carries an `// Authored by: <model>, via <harness>.`+ * header, and three separate things now depend on parsing it the same way: the+ * README test that checks the authorship paragraph against reality, the site+ * build that puts a model name on every card, and anything that comes after. A+ * second copy of this parser is a second chance to miscount the gallery, which+ * has already happened twice -- once when the header turned out not to always be+ * on line one, and once when a hand-written harness spelling did not match the+ * dispatcher's. So it lives here, once.+ *+ * This is repository tooling and not part of the published engine, which is why+ * it sits under `scripts/` rather than `src/`.+ */++/**+ * Display names, because a person writing prose calls a model `Muse Spark 1.3`+ * and never `opencode-go/muse-spark-1.3-contributor`. A model that arrives+ * without a name here resolves to `null` rather than being quietly renamed to+ * something plausible, so the caller can decide whether an unnamed model is a+ * gap to fill or a test to fail.+ */+export const MODEL_DISPLAY: ReadonlyArray<readonly [RegExp, string]> = [+ // Both spellings: the dispatcher stamps the model id `gemini-3.8-flash-high`,+ // and a header written by hand says `Gemini 3.8 Flash`.+ [/^gemini[- ]3\.8/i, 'Gemini 3.8 Flash'],+ [/^gemini[- ]3\.1/i, 'Gemini 3.1 Pro'],+ [/muse-spark/, 'Muse Spark 1.3'],+ [/deepseek/, 'DeepSeek V4 Flash'],+ [/glm-5\.3-flash/, 'GLM 5.3 Flash'],+ [/omen-alpha/, 'Omen Alpha'],+ [/minimax-m3/, 'MiniMax M3'],+ [/longcat/, 'LongCat 2.0'],+ [/kimi-k3/, 'Kimi K3'],+ [/qwen/, 'Qwen 3.8 Max'],+ [/grok/, 'Grok 4.6'],+ [/gpt-6-astra/, 'GPT-6 Astra'],+];++/** A dispatched Claude run stamps whichever alias it was invoked with. */+const CLAUDE = /^(opus|sonnet|haiku|claude)/i;++/**+ * Harness names as a reader would say them. The dispatcher writes the short id+ * it was given on the command line; a hand-stamped header sometimes spells the+ * product out and puts the id in brackets after it.+ */+export const HARNESS_DISPLAY: Readonly<Record<string, string>> = {+ claude: 'Claude Code',+ agy: 'Antigravity CLI',+ opencode: 'OpenCode',+ hermes: 'Hermes',+ codex: 'Codex',+};++export interface Authorship {+ /** The raw model id from the header, or `null` when there is no header. */+ model: string | null;+ /** The model as prose names it, or `null` for a model with no display name. */+ display: string | null;+ /** True for Claude in any of its spellings, including an absent header. */+ claude: boolean;+ harness: string;+ /**+ * The program was written in a directory holding nothing but a brief and the+ * Kiln skills, with no access to this repository and no finished example to+ * copy. It is the strongest claim any of these headers makes, so it is read+ * from the sentence that makes it rather than inferred from the header's shape.+ */+ cleanRoom: boolean;+}++/**+ * `m`, and not an anchor to the first line, because the header is not always at+ * the top: ten of these programs open with a paragraph about the asset and carry+ * the attribution below it, and the arcade cabinet -- which Gemini wrote -- has+ * it on line 41. Reading only line one filed every one of those as unattributed.+ *+ * Three spellings of the harness are in circulation and all three are here: the+ * bare id the dispatcher stamps (`via codex.`), a product name with the id in+ * brackets after it (`via Antigravity CLI (agy).`), and a product name on its own+ * (`via Claude Code.`) running straight into the prose of the next sentence.+ */+const HEADER = /^\/\/ Authored by: ([^,]+), via (?:([^(.]+?)\s*\((\w+)\)|([^.]+?))\./m;++const CLEAN_ROOM = /Dispatched into a clean directory/;++export function readAuthorship(source: string): Authorship {+ const cleanRoom = CLEAN_ROOM.test(source);+ const m = HEADER.exec(source);+ // No header means the program was written against this repository rather than+ // dispatched into a clean directory, which so far has always meant Claude.+ if (!m) {+ return { model: null, display: 'Claude Opus 5', claude: true, harness: 'Claude Code', cleanRoom };+ }+ const model = m[1]!.trim();+ // The bracketed id when there is one, otherwise whatever stands after `via`.+ // Anything the table does not know is already a product name spelled the way a+ // reader would say it, so it passes through untouched.+ const id = (m[3] ?? m[4]!).trim();+ const harness = HARNESS_DISPLAY[id.toLowerCase()] ?? m[2]?.trim() ?? id;+ if (CLAUDE.test(model)) return { model, display: 'Claude Opus 5', claude: true, harness, cleanRoom };+ return {+ model,+ display: MODEL_DISPLAY.find(([re]) => re.test(model))?.[1] ?? null,+ claude: false,+ harness,+ cleanRoom,+ };+}++/**+ * The category the program declares for itself, which is not the same field as+ * the category on a render result: that one carries whatever the *request* asked+ * for, and these programs are rendered without asking for anything.+ */+export function readCategory(source: string): string {+ return /\bcategory:\s*'([a-z]+)'/.exec(source)?.[1] ?? 'prop';+}diff --git a/scripts/check-vision.mjs b/scripts/check-vision.mjsnew file mode 100644index 00000000..a4199324--- /dev/null+++ b/scripts/check-vision.mjs@@ -0,0 +1,90 @@+#!/usr/bin/env node+// Refuse to dispatch a model that cannot see.+//+// Kiln's loop is the model rendering its own program and looking at the result,+// so a model without image input is not doing the thing this repository claims+// its assets demonstrate. It will still produce a file -- it just produces it+// blind, from the API docs alone, and the attribution header promote-asset.mjs+// writes ("looked at its own six-view contact sheet") would be a lie.+//+// This came out of a nine-model batch in which four of the nine turned out to+// be text-only. Nothing failed loudly; they simply built worse assets for+// reasons that looked like model quality and were actually a missing modality.+//+// node scripts/check-vision.mjs opencode-go/kimi-k3 opencode-go/glm-5.3+//+// Exits non-zero and names the offenders. OpenCode answers from a local cache,+// so the whole check costs about two seconds however many models you pass.+import { spawnSync } from 'node:child_process';++/** Pull top-level JSON objects out of `opencode models --verbose` output. */+function jsonBlocks(text) {+ const out = [];+ let depth = 0;+ let start = -1;+ for (let i = 0; i < text.length; i++) {+ const c = text[i];+ if (c === '{') {+ if (depth === 0) start = i;+ depth++;+ } else if (c === '}') {+ depth--;+ if (depth === 0 && start >= 0) {+ try {+ out.push(JSON.parse(text.slice(start, i + 1)));+ } catch {+ // A model whose metadata does not parse is not this script's problem.+ }+ start = -1;+ }+ }+ }+ return out;+}++function capabilities(provider) {+ const r = spawnSync('opencode', ['models', provider, '--verbose'], {+ encoding: 'utf8',+ shell: process.platform === 'win32',+ });+ const map = new Map();+ for (const o of jsonBlocks(r.stdout ?? '')) {+ if (o.id) map.set(o.id, o.capabilities ?? {});+ }+ return map;+}++const models = process.argv.slice(2);+if (!models.length) {+ console.error('usage: check-vision.mjs <provider/model> [<provider/model> ...]');+ process.exit(2);+}++const byProvider = new Map();+for (const m of models) {+ const slash = m.indexOf('/');+ const provider = slash > 0 ? m.slice(0, slash) : 'opencode';+ const id = slash > 0 ? m.slice(slash + 1) : m;+ if (!byProvider.has(provider)) byProvider.set(provider, capabilities(provider));+}++const blind = [];+const unknown = [];+for (const m of models) {+ const slash = m.indexOf('/');+ const provider = slash > 0 ? m.slice(0, slash) : 'opencode';+ const id = slash > 0 ? m.slice(slash + 1) : m;+ const caps = byProvider.get(provider)?.get(id);+ if (!caps) unknown.push(m);+ else if (caps.attachment !== true) blind.push(m);+ const state = !caps ? 'not listed by this provider' : caps.attachment === true ? 'sees images' : 'TEXT ONLY';+ console.log(` ${m.padEnd(44)} ${state}`);+}++if (blind.length || unknown.length) {+ console.error('');+ if (blind.length) console.error(`refusing to dispatch ${blind.length} text-only model(s): ${blind.join(', ')}`);+ if (unknown.length) console.error(`could not verify: ${unknown.join(', ')}`);+ process.exit(1);+}+console.log(`all ${models.length} models accept image input`);diff --git a/scripts/curate-texture-library.mjs b/scripts/curate-texture-library.mjsindex 9420f15e..4ea74fc3 100644--- a/scripts/curate-texture-library.mjs+++ b/scripts/curate-texture-library.mjs@@ -26,6 +26,14 @@ const FAMILIES = [{ slug: 'rock-face', asset: 'rock_face_03', label: 'Layered rock face', recipes: ['kiln.material.stone.v1'] },{ slug: 'dry-soil', asset: 'brown_mud_dry', label: 'Dry compacted soil', recipes: ['kiln.material.stone.v1'] },{ slug: 'brick-wall', asset: 'brick_wall_005', label: 'Weathered brick wall', recipes: ['kiln.material.stone.v1'] },+ { slug: 'brown-leather', asset: 'brown_leather', label: 'Brown grained leather', recipes: ['kiln.material.skin.v1', 'kiln.material.cloth.v1'] },+ { slug: 'forest-leaves', asset: 'forest_leaves_03', label: 'Forest leaf litter', recipes: ['kiln.material.leaf.v1'] },+ { slug: 'rubber-tiles', asset: 'rubber_tiles', label: 'Studded rubber tiles', recipes: ['kiln.material.rubber.v1'] },+ { slug: 'metal-plate', asset: 'metal_plate', label: 'Riveted steel plate', recipes: ['kiln.material.painted-metal.v1'] },+ { slug: 'clay-roof-tiles', asset: 'clay_roof_tiles', label: 'Clay roof tiles', recipes: ['kiln.material.stone.v1'] },+ { slug: 'cobblestone-floor', asset: 'cobblestone_floor_01', label: 'Cobblestone paving', recipes: ['kiln.material.stone.v1'] },+ { slug: 'oak-veneer', asset: 'oak_veneer_01', label: 'Finished oak veneer', recipes: ['kiln.material.wood.v1'] },+ { slug: 'polished-marble', asset: 'marble_01', label: 'Polished marble', recipes: ['kiln.material.stone.v1'] },];const MAPS = [@@ -118,7 +126,7 @@ const total = records.reduce((sum, record) => sum + record.bytes.byteLength, 0);const generated = `/*** GENERATED by scripts/curate-texture-library.mjs.*- * Eight Poly Haven CC0 families, each with albedo, OpenGL normal, and packed+ * ${FAMILIES.length} Poly Haven CC0 families, each with albedo, OpenGL normal, and packed* ambient-occlusion/roughness/metalness (ARM) maps. Source download identity is* retained below; runtime output is self-contained and never calls Poly Haven.* Embedded payload: ${total} bytes.diff --git a/scripts/dispatch-asset.mjs b/scripts/dispatch-asset.mjsnew file mode 100644index 00000000..4664d502--- /dev/null+++ b/scripts/dispatch-asset.mjs@@ -0,0 +1,405 @@+#!/usr/bin/env node+// Dispatch a headless CLI agent to author one Kiln asset, then verify the+// result with the engine itself.+//+// This is the "agent spawns an agent" path. The parent process here is dumb on+// purpose: it composes a prompt, shells out to whichever coding CLI you have+// installed, and then runs `kiln render` on whatever file came back. The child+// agent does the actual work through the Kiln MCP tools -- it writes the+// program, renders it, looks at its own six-view contact sheet, and revises.+//+// node scripts/dispatch-asset.mjs --name espresso-machine \+// "a commercial three-group lever espresso machine"+//+// node scripts/dispatch-asset.mjs --harness claude --model sonnet \+// --name anglerfish "a deep-sea anglerfish with a lit lure"+//+// The harness must already have Kiln attached. See docs/install.md; the whole+// point of this script is that once the MCP server and the skills are wired up,+// dispatching is the same three lines for every harness.+import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';+import { join, resolve } from 'node:path';++// The harness table, the Windows-safe spawn, the deadline that kills a process+// tree, and the clean-room sandbox all live next door: `harness-smoke.mjs`+// needs every one of them to prove a harness is wired up, and this script needs+// them to send that same harness after an asset.+import { HARNESSES, REPO, makeSandbox, parseDuration, run } from './harness.mjs';++/**+ * Mirrored from `ASSET_CATEGORIES` in src/contracts/asset.ts, because this+ * script runs before anything is built and cannot import the TypeScript source.+ * `src/__tests__/dispatch-categories.test.ts` fails if the two ever drift.+ */+const ASSET_CATEGORIES = ['prop', 'character', 'vfx', 'environment', 'architecture', 'vegetation', 'vehicle'];++/**+ * Extra guidance appended to the brief, and EXPERIMENTAL -- read the entry for+ * `prop` before using any of the others.+ *+ * `prop` is the default and its entry is deliberately empty. That is not an+ * omission: almost anything can be built as a prop, the base skill already+ * describes how, and an empty entry is the least constrained brief this script+ * can send. The six below each narrow the model's attention to what tends to go+ * wrong for that kind of subject, which is a bet. It pays when the subject+ * really is one of those things and the failure mode is the named one. It costs+ * when it is not: telling a model to worry about storey rhythm and eaves is+ * actively unhelpful for a bandstand, and pushing branching rules at something+ * that is a plant in name only will make it worse than saying nothing.+ *+ * So the honest default is `prop`, and reaching for another category is a+ * deliberate choice to trade freedom for a hint. If a run comes back worse than+ * the same brief as a prop, the hint was wrong and the category is the thing to+ * drop first.+ */+const CATEGORY_BRIEF = {+ architecture: 'This is ARCHITECTURE. Get the mass and the storey rhythm right before any ornament: floor heights consistent, openings on a grid, a roof that meets its walls with a real eave rather than hovering. Repeated elements (bays, columns, windows) should be generated in a loop from one set of numbers so they stay aligned.',+ character: 'This is a CHARACTER. Proportion beats detail: block the silhouette to a believable height first, then subdivide. Build it symmetric about the +X forward axis, standing on Y=0, in a neutral stance with limbs slightly away from the body so nothing interpenetrates.',+ vegetation: 'This is VEGETATION. Nothing on a plant is straight or evenly spaced. Drive branching from a small recursive rule with varied angle and length rather than placing limbs by hand, taper every stem toward its tip, and let the crown be an irregular volume rather than a sphere.',+ vehicle: 'This is a VEHICLE. It has to look like it works: wheels or tracks touching Y=0 and equally spaced, a cabin sized for whoever drives it, and a clear front. Build it along +X forward so it points the way the frame says it points.',+ environment: 'This is an ENVIRONMENT piece. It will be placed among others, so keep the footprint honest and the origin sensible, and make the parts that meet the ground actually meet it.',+ vfx: 'This is a VFX asset. It reads as motion and light rather than as an object: build it from layered, mostly emissive or transparent shells, keep the triangle count low, and make sure it looks right from every angle because a viewer will orbit it.',+ prop: '',+};+++function parseArgs(argv) {+ const opts = {+ harness: 'agy',+ model: null,+ name: null,+ outDir: join(REPO, '.dogfood'),+ timeout: '25m',+ tris: '4,000-12,000',+ // Antigravity's Gemini quota exhausts account-wide for a window rather than+ // per model, so a fallback ladder alone is not enough for a batch: --wait+ // rides it out instead of failing ten assets in forty seconds.+ waitMinutes: 0,+ // Motion is not a decoration on some subjects, it is the subject: a+ // locomotive without its rods moving is a shed on wheels. --animate adds+ // the rig requirements to the brief and makes the child prove the loop.+ animate: false,+ // Every asset dispatched before this flag existed came back a prop, because+ // the brief hardcoded `category: 'prop'`. The problem was not that they were+ // props -- most of them are, correctly -- but that nobody could say+ // otherwise, so the field carried no information and the engine's own+ // per-category guidance was unreachable. `prop` stays the default because it+ // is the right answer most of the time; see CATEGORY_BRIEF below for what+ // choosing another one actually buys and costs.+ category: 'prop',+ subject: null,+ };+ const rest = [];+ for (let i = 0; i < argv.length; i++) {+ const a = argv[i];+ if (a === '--harness') opts.harness = argv[++i];+ else if (a === '--model') opts.model = argv[++i];+ else if (a === '--name') opts.name = argv[++i];+ else if (a === '--out') opts.outDir = resolve(argv[++i]);+ else if (a === '--timeout') opts.timeout = argv[++i];+ else if (a === '--tris') opts.tris = argv[++i];+ else if (a === '--wait') opts.waitMinutes = Number(argv[++i]);+ else if (a === '--animate') opts.animate = true;+ else if (a === '--category') opts.category = argv[++i];+ else rest.push(a);+ }+ opts.subject = rest.join(' ').trim();+ if (!ASSET_CATEGORIES.includes(opts.category)) {+ throw new Error(+ `--category ${opts.category} is not a Kiln category. Pick one of: ${ASSET_CATEGORIES.join(', ')}.`,+ );+ }+ return opts;+}++/**+ * The prompt. Three things in here are load-bearing and are the difference+ * between a usable asset and a pile of boxes:+ *+ * 1. ABSOLUTE paths. Every CLI resolves relative paths against something --+ * `agy` against the installed plugin copy, not your working tree -- so a+ * prompt that says `examples/foo.js` writes to a file you will never find.+ * 2. list_primitives FIRST. Without it the model writes the API it remembers+ * from some other engine and every call fails.+ * 3. An explicit instruction to LOOK at the render and revise. A model that+ * is not told to look will write one pass, declare success, and stop --+ * and the whole argument for this tool is the loop, not the codegen.+ */+function composePrompt({ name, subject, file, tris, animate, category }) {+ const motion = animate+ ? [+ '- THIS ASSET MUST MOVE. Hang every moving part off a pivot: pass',+ " `pivot: [x, y, z]` to createPart and name the part `Joint_<Thing>`, then",+ ' parent the geometry that turns with it to that joint.',+ '- Export `function animate()` returning',+ " [createClip(name, duration, [rotationTrack('Joint_X', keys), ...])].",+ ' Keyframes are `{ time, rotation: [x, y, z] }` in DEGREES, or',+ ' `{ time, position: [x, y, z] }` for a track that slides.',+ '- The clip must LOOP: the pose at t = duration must equal the pose at t = 0,',+ ' or the asset visibly jumps every cycle.',+ '- Call kiln_screenshot_animation, LOOK at the frames, and fix the motion you',+ ' actually see. A column of angles cannot tell you whether a linkage binds.',+ ]+ : [];+ return [+ `Author a Kiln 3D asset: ${subject}.`,+ '',+ 'You have the Kiln MCP tools (kiln_list_primitives, kiln_render, kiln_inspect,',+ 'kiln_validate, kiln_view_interior, kiln_screenshot_animation) and the',+ 'kiln-author-asset skill. Use them.',+ '',+ 'Rules:',+ `- Write the program to the ABSOLUTE path ${file.replaceAll('\\', '/')}`,+ '- Call kiln_list_primitives FIRST, so you use the real API rather than one',+ ' you remember from another engine.',+ `- Start the file with: const meta = { name: '${toPascal(name)}', category: '${category}' };`,+ '- Coordinates are +X forward, +Y up, +Z right, and the asset sits on Y=0.',+ '- Write a ROUGH version of the file EARLY, before you have the details',+ ' worked out, then improve it. Do NOT solve the geometry analytically',+ ' first: models have spent their entire output budget hand-computing pin',+ ' positions in prose, been cut off mid-calculation, and left no file at all.',+ '- Render with kiln_render, LOOK at the six-view contact sheet it returns,',+ ' and fix what you actually see wrong. Do at least two revision passes.',+ `- Target ${tris} triangles.`,+ ...motion,+ '- Finish by reporting the triangle count and the bounds.',+ ...(CATEGORY_BRIEF[category] ? ['', CATEGORY_BRIEF[category]] : []),+ ].join('\n');+}++const toPascal = (s) => s.split(/[-_\s]+/).map((w) => w[0].toUpperCase() + w.slice(1)).join('');++/**+ * Record the author in the file itself.+ *+ * The `.result.json` manifest beside it already carries this, but manifests do+ * not survive being copied into `examples/`, and the gallery makes a claim+ * about provenance that has to travel with the program it describes.+ */+function stampAuthor(file, model, harness, { cleanRoom = true, interrupted = false } = {}) {+ let body = readFileSync(file, 'utf8');+ if (body.charCodeAt(0) === 0xfeff) body = body.slice(1); // strip BOM before prepending+ if (/^\/\/ Authored by:/m.test(body)) return;+ // The clean-room sentence is a factual claim about how the run was set up, so+ // it is only written when the run actually had one. Assets authored before+ // sandboxing existed get the same attribution without it rather than a+ // provenance claim nobody can support.+ const header = [+ `// Authored by: ${model}, via ${harness}.`,+ '//',+ ...(interrupted+ ? [+ '// Written by the model itself through the Kiln MCP tools, and cut off',+ '// mid-run rather than finished -- by a provider limit, or by the',+ '// dispatch deadline. The program below is what was on disk when the',+ '// session ended; how many times it had looked at its own contact sheet',+ '// by then is not recorded, so this one does not make the claim the',+ '// others do.',+ ]+ : [+ '// Written by the model itself through the Kiln MCP tools: it wrote the',+ '// program, rendered it, looked at its own six-view contact sheet, and',+ '// revised. Not a line of it is hand-authored.',+ ]),+ ...(cleanRoom+ ? [+ '//',+ '// Dispatched into a clean directory containing only the brief and the Kiln',+ '// skills, with no access to this repository or to any finished example.',+ ]+ : []),+ '',+ ].join('\n');+ writeFileSync(file, `${header}\n${body}`);+}++// `session limit` is Claude Code's wording and matches none of the others, so a+// batch that hit one used to report three flat failures in a row and give up+// instead of falling back or waiting out the window.+const RATE_LIMITED =+ /RESOURCE_EXHAUSTED|429|rate.?limit|quota|exhausted|(session|usage) limit/i;+const sleep = (ms) => new Promise((r) => setTimeout(r, ms));++/**+ * Ask the harness for one word before committing to a twenty-minute run.+ * Returns 'ok', 'limited', or 'error'. A probe costs a few tokens; discovering+ * a quota wall after the child has been building for ten minutes does not.+ */+async function probeQuota(harness, model, logFile) {+ if (!harness.probe) return 'ok';+ const r = await run(harness.bin, harness.probe(model), { logFile, timeoutMs: 120_000 });+ if (r.code === 0 && r.out.toUpperCase().includes('OK')) return 'ok';+ return RATE_LIMITED.test(r.out) ? 'limited' : 'error';+}++/**+ * Who actually wrote this, as opposed to who was asked to.+ *+ * A harness may quietly run a different model than the one requested -- OpenCode+ * substitutes when a model is busy, with no error and no note. Everywhere else+ * that would be a curiosity; here it is the difference between a gallery that+ * documents its provenance and one that misattributes it, so the requested id is+ * treated as a request and the harness's own report as the fact.+ *+ * Harnesses print the bare model name where the request carried a provider+ * prefix (`omen-alpha` for `opencode-go/omen-alpha`), so the comparison is on the+ * last segment and the prefix is carried back onto a substitute.+ */+function reconcileModel(requested, actual, name) {+ if (!actual) return requested;+ const bare = String(requested).split('/').pop();+ if (actual === bare) return requested;+ const prefix = String(requested).includes('/')+ ? `${String(requested).slice(0, String(requested).lastIndexOf('/'))}/`+ : '';+ const ran = `${prefix}${actual}`;+ console.log(`[${name}] asked for ${requested} but the harness ran ${ran}; recording ${ran}`);+ return ran;+}++async function main() {+ const opts = parseArgs(process.argv.slice(2));+ const harness = HARNESSES[opts.harness];+ if (!harness) {+ console.error(`unknown harness "${opts.harness}" (have: ${Object.keys(HARNESSES).join(', ')})`);+ process.exit(2);+ }+ if (!opts.subject) {+ // Built from the table rather than typed out: the list drifted once+ // already, and omitted the harness that had written six of the gallery.+ const names = Object.keys(HARNESSES).join('|');+ console.error(`usage: dispatch-asset.mjs [--harness ${names}] [--model M] [--category ${ASSET_CATEGORIES.join('|')}] --name <slug> "<subject>"`);+ process.exit(2);+ }+ opts.name ??= opts.subject.toLowerCase().replaceAll(/[^a-z0-9]+/g, '-').slice(0, 40);++ const models = [opts.model ?? harness.defaultModel, ...(opts.model ? [] : harness.fallbackModels)];+ // Checked before anything is created on disk. A harness with no default model+ // (Codex, whose entitlements this repository cannot know) must be told one:+ // this path stamps the author into the program and writes it into the+ // gallery's provenance note, and an asset whose author cannot be named is one+ // that already shipped once reading "Authored by: null".+ if (models[0] == null) {+ console.error(`--model is required for the ${opts.harness} harness: it has no default, and the author has to be recorded`);+ process.exit(2);+ }++ mkdirSync(opts.outDir, { recursive: true });+ // The child works in a clean room and writes there; the result is copied out+ // afterwards. Nothing the agent produces lands in the repository directly.+ const sandbox = makeSandbox(opts.name);+ const sandboxFile = join(sandbox, `${opts.name}.kiln.js`);+ const file = join(opts.outDir, `${opts.name}.kiln.js`);+ const briefPath = join(sandbox, `${opts.name}.prompt.txt`);+ writeFileSync(briefPath, composePrompt({ ...opts, file: sandboxFile }));+ // The brief goes in a file and the command line carries a pointer to it.+ // Every CLI here quotes its arguments differently and two of them mangle a+ // multi-line one; a one-line prompt is the only shape that survives all of+ // them, and it leaves the exact brief on disk next to the result.+ const prompt = `Read ${briefPath.replaceAll('\\', '/')} and carry out the instructions in it exactly.`;++ const logFile = harness.needsLogFile ? join(opts.outDir, `${opts.name}.harness.log`) : null;+ const deadline = Date.now() + opts.waitMinutes * 60_000;+ let result = null;+ let authoredBy = null;+ let interrupted = false;++ outer: for (;;) {+ for (const model of models) {+ if ((await probeQuota(harness, model, logFile)) === 'limited') {+ console.log(`[${opts.name}] ${model}: rate limited`);+ continue;+ }+ process.stdout.write(`[${opts.name}] ${opts.harness} / ${model} ... `);+ const started = Date.now();+ result = await run(harness.bin, harness.argv({ model, prompt, timeout: opts.timeout, logFile, sandbox }), {+ logFile,+ cwd: sandbox,+ timeoutMs: parseDuration(opts.timeout),+ env: harness.env?.({ model }) ?? null,+ });+ const secs = ((Date.now() - started) / 1000).toFixed(0);+ if (result.code === 0 && existsSync(sandboxFile)) {+ console.log(`wrote ${opts.name}.kiln.js in ${secs}s`);+ authoredBy = reconcileModel(model, harness.actualModel?.(result.out), opts.name);+ break outer;+ }+ // A bad ending with a program already on disk is not the same event as a+ // bad ending with nothing. The run is over either way, but the work+ // survives and the model that did it is known -- so this is checked before+ // the failure is classified, and it covers every way a run can be cut+ // short rather than only the one that was noticed first. Both of the ways+ // seen so far fire long after the program is written: a provider session+ // limit, and the dispatcher's own 25 minute deadline. Discarding the+ // attribution in either case is how a finished asset ends up stamped+ // `Authored by: null`, which is worse than an interrupted claim because it+ // is not a claim at all.+ if (existsSync(sandboxFile)) {+ console.log(`cut off after ${secs}s (exit ${result.code}), keeping its program`);+ authoredBy = reconcileModel(model, harness.actualModel?.(result.out), opts.name);+ interrupted = true;+ break outer;+ }+ if (RATE_LIMITED.test(result.out)) {+ console.log(`rate limited after ${secs}s, falling back`);+ continue;+ }+ // Exit 0 with nothing on disk is its own diagnosis and deserves its own+ // sentence: the CLI ran, the model answered, and it simply never wrote the+ // file. Reporting that as "failed (exit 0)" reads like a contradiction and+ // sends you looking at the harness, which is the one thing that did work.+ if (result.code === 0) {+ console.log(`ran ${secs}s and answered without writing a program`);+ } else {+ console.log(`failed (exit ${result.code}) after ${secs}s`);+ }+ break outer;+ }+ if (Date.now() >= deadline) break;+ console.log(`[${opts.name}] all models rate limited; waiting 10 min (giving up at ${new Date(deadline).toLocaleTimeString()})`);+ await sleep(10 * 60_000);+ }+ writeFileSync(join(opts.outDir, `${opts.name}.log`), result?.out ?? '');++ if (!existsSync(sandboxFile)) {+ console.error(`[${opts.name}] no program produced; see ${opts.name}.log`);+ process.exit(1);+ }+ // Out of the clean room, stamped with who wrote it.+ copyFileSync(sandboxFile, file);+ stampAuthor(file, authoredBy, opts.harness, { interrupted });++ // Verify with the engine, not with the agent's own claim about it. This is+ // the only part of the pipeline that is allowed to say the asset is fine.+ const glb = join(opts.outDir, `${opts.name}.glb`);+ const sheet = join(opts.outDir, `${opts.name}.png`);+ const check = await run('bun', ['src/cli.ts', 'render', file, '--out', glb, '--views', sheet]);+ console.log(check.out.trim());+ // A manifest per asset. With a fallback ladder in play, "which model made+ // this" is not something you can reconstruct later from the file itself.+ writeFileSync(+ join(opts.outDir, `${opts.name}.result.json`),+ `${JSON.stringify({+ name: opts.name,+ subject: opts.subject,+ harness: opts.harness,+ model: authoredBy,+ // Recorded rather than assumed: the gallery's provenance note is written+ // from this field, and assets predating the sandbox must not inherit a+ // claim about isolation they never had.+ cleanRoom: true,+ // Set when a provider limit ended the session with a program already+ // written. `promote-asset.mjs` reads it, because an asset whose authoring+ // loop was cut short must not carry a header claiming the loop ran.+ interrupted,+ at: new Date().toISOString(),+ tris: /(\d+) tris/.exec(check.out)?.[1] ?? null,+ bounds: /bounds\s+(.+)/.exec(check.out)?.[1]?.trim() ?? null,+ rendered: check.code === 0,+ }, null, 2)}+`,+ );+ process.exit(check.code === 0 ? 0 : 1);+}++main();diff --git a/scripts/harness-smoke.mjs b/scripts/harness-smoke.mjsnew file mode 100644index 00000000..eb8dad81--- /dev/null+++ b/scripts/harness-smoke.mjs@@ -0,0 +1,163 @@+#!/usr/bin/env node+// Prove that a harness can actually reach Kiln's tools, before trusting it with+// real work.+//+// node scripts/harness-smoke.mjs # every CLI on PATH+// node scripts/harness-smoke.mjs --harness agy # just one+//+// This exists because every wiring failure so far has been silent. A harness+// that cannot see the MCP server does not say so: `agy plugin validate` reports+// the server as processed while `agy mcp list` shows none, and the agent simply+// answers as if the tools were never mentioned. A harness that can see the+// tools but will not grant them behaves the same way -- three runs in one batch+// came back exit 0, having written a polite note about permissions instead of a+// program. Both look exactly like a model that was not up to the task.+//+// So this asks for the cheapest thing that cannot be faked: call one tool that+// only the server can answer, then write a four-line program and validate it.+// The parent then runs the engine over what came back, because the child's own+// report of success is the one piece of evidence that proves nothing.+//+// It costs one short model turn per harness. It is not part of `bun run test`+// and never should be -- it spends provider quota and needs CLIs that CI does+// not have.+import { spawnSync } from 'node:child_process';+import { existsSync, readFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';++import { HARNESSES, REPO, makeSandbox, parseDuration, run } from './harness.mjs';++// One line, because a shell-shimmed CLI on Windows carries the whole prompt as+// a single command-line string and a newline in it ends the command.+const BRIEF = (file) =>+ [+ 'You have the Kiln MCP tools. Do exactly this, in order, and nothing else.',+ '1) Call kiln_list_primitives and note one geometry helper it lists.',+ `2) Write ${file} containing a Kiln program: a bare "const meta = { name: 'Smoke', category: 'prop' };"`,+ 'then "function build() {" which calls createRoot(), makes one 1m box part with boxGeo and gameMaterial(0x808080),',+ 'and returns the root. No imports and no exports.',+ `3) Call kiln_validate on ${file}.`,+ 'Then reply with the validator verdict in one line.',+ ].join(' ');++function parseArgs(argv) {+ const opts = { harness: null, model: null, timeout: '5m' };+ for (let i = 0; i < argv.length; i++) {+ if (argv[i] === '--harness') opts.harness = argv[++i];+ else if (argv[i] === '--model') opts.model = argv[++i];+ else if (argv[i] === '--timeout') opts.timeout = argv[++i];+ }+ return opts;+}++/**+ * Is this CLI installed at all? A missing binary is a skip, not a failure --+ * nobody has all four, and a report that fails you for not having Codex is a+ * report you stop reading.+ */+function installed(bin) {+ const probe = process.platform === 'win32' ? 'where' : 'which';+ // No shell: both probes are real executables, and asking for one only buys+ // a deprecation warning printed across the progress line.+ return spawnSync(probe, [bin], { stdio: 'ignore', shell: false }).status === 0;+}++async function smoke(name, harness, opts) {+ // May be null: a harness with no default uses whatever its own config says.+ const model = opts.model ?? harness.defaultModel;+ const sandbox = makeSandbox(`smoke-${name}`);+ const file = join(sandbox, 'smoke.kiln.js');+ const logFile = join(sandbox, 'agent.log');+ const prompt = BRIEF(file);++ const started = Date.now();+ const r = await run(+ harness.bin,+ harness.argv({ model, prompt, timeout: opts.timeout, logFile, sandbox }),+ {+ cwd: sandbox,+ logFile: harness.needsLogFile ? logFile : null,+ timeoutMs: parseDuration(opts.timeout),+ env: harness.env?.({ model }) ?? null,+ },+ );+ const secs = ((Date.now() - started) / 1000).toFixed(0);+ // What ran, not what was asked for. The two have agreed on every run measured,+ // but a report that names the model you requested is telling you your own+ // input back, and this script exists to stop doing that.+ const ran = harness.actualModel?.(r.out) ?? null;+ const used = ran && ran !== String(model ?? '').split('/').pop() ? `${ran} (asked for ${model})` : model;++ if (!existsSync(file)) {+ // The distinction that matters for a wiring bug: a child that never saw the+ // tools usually says so in as many words, and that reads very differently+ // from a model that tried and produced nothing.+ const said = /no such tool|not available|don't have|do not have|unable to|no tools/i.test(r.out);+ return {+ name,+ model: used,+ secs,+ ok: false,+ why: said ? 'agent reported the Kiln tools were unavailable' : `no program written (exit ${r.code})`,+ out: r.out,+ };+ }++ // The engine has the final word. `kiln render` runs the build, the QA gates+ // and the rasterizer, so a file that satisfies it is a file the harness+ // really did produce through a working tool surface.+ const glb = join(sandbox, 'smoke.glb');+ const check = await run('bun', ['src/cli.ts', 'render', file, '--out', glb], { cwd: REPO });+ const tris = /(\d+) tris/.exec(check.out)?.[1] ?? null;+ return {+ name,+ model: used,+ secs,+ ok: check.code === 0,+ why: check.code === 0 ? `built ${tris} tris` : 'program written but the engine rejected it',+ out: check.out,+ program: readFileSync(file, 'utf8'),+ };+}++async function main() {+ const opts = parseArgs(process.argv.slice(2));+ const wanted = opts.harness ? [opts.harness] : Object.keys(HARNESSES);+ for (const name of wanted) {+ if (!HARNESSES[name]) {+ console.error(`unknown harness "${name}" -- have ${Object.keys(HARNESSES).join(', ')}`);+ process.exit(2);+ }+ }++ const results = [];+ for (const name of wanted) {+ const harness = HARNESSES[name];+ if (!installed(harness.bin)) {+ console.log(`${name.padEnd(9)} skipped -- ${harness.bin} is not on PATH`);+ continue;+ }+ process.stdout.write(`${name.padEnd(9)} running...`);+ const r = await smoke(name, harness, opts);+ results.push(r);+ console.log(`\r${name.padEnd(9)} ${r.ok ? 'ok ' : 'FAIL'} ${`${r.secs}s`.padStart(5)} ${r.model ?? '(configured default)'} ${r.why}`);+ // On a failure the sandbox is the only copy of the evidence -- the brief the+ // child was given, its log, and whatever it did or did not write. It stays+ // on disk; `makeSandbox` clears it at the start of the next run anyway.+ if (!r.ok) {+ console.log(r.out.trim().split('\n').slice(-12).map((l) => ` ${l}`).join('\n'));+ console.log(` sandbox: ${join(tmpdir(), 'kiln-dispatch', `smoke-${name}`)}`);+ }+ }++ const failed = results.filter((r) => !r.ok);+ if (results.length === 0) {+ console.log('\nno harness CLIs installed; nothing was verified');+ process.exit(2);+ }+ console.log(`\n${results.length - failed.length}/${results.length} harnesses reached the Kiln tools`);+ process.exit(failed.length === 0 ? 0 : 1);+}++main();diff --git a/scripts/harness.mjs b/scripts/harness.mjsnew file mode 100644index 00000000..9b0fb042--- /dev/null+++ b/scripts/harness.mjs@@ -0,0 +1,443 @@+// The parts of a headless dispatch that are not about authoring an asset.+//+// Two callers need the same machinery for different reasons:+// `dispatch-asset.mjs` sends an agent to write a program, and+// `harness-smoke.mjs` sends one to prove the tools are reachable at all. What+// they share is everything below -- the harness table, spawning a CLI on+// Windows without losing the prompt to a shell, enforcing a deadline on a+// process tree, and building the clean room the child runs in.+//+// It lives in its own file because the alternative was a second copy, and the+// comments here are the record of failures that took hours to diagnose. A+// duplicate of that record is a duplicate that goes stale, and the half that+// goes stale is the half nobody was reading when it mattered.+import { spawn, spawnSync } from 'node:child_process';+import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { homedir, tmpdir } from 'node:os';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';++export const REPO = resolve(dirname(fileURLToPath(import.meta.url)), '..');++/** `--model X`, or nothing at all when the harness should use its own default. */+const modelFlag = (model) => (model ? ['--model', model] : []);++/**+ * A model's published output-token limit, from OpenCode's own catalog.+ *+ * Read from the cache it already maintains rather than hardcoded, so a new model+ * gets its real ceiling the day it appears and a lowered one is respected.+ * Returns null when the catalog is missing or says nothing, which leaves the+ * harness default alone.+ */+function declaredOutputLimit(model) {+ const id = String(model ?? '');+ const slash = id.indexOf('/');+ if (slash < 0) return null;+ try {+ const cache = join(homedir(), '.cache', 'opencode', 'models.json');+ if (!existsSync(cache)) return null;+ const catalog = JSON.parse(readFileSync(cache, 'utf8'));+ const entry = catalog?.[id.slice(0, slash)]?.models?.[id.slice(slash + 1)];+ const out = entry?.limit?.output;+ return Number.isInteger(out) && out > 0 ? out : null;+ } catch {+ return null;+ }+}++/** Colour codes are noise when you are trying to read a model name out of a log. */+const stripAnsi = (s) => String(s).replaceAll(/\[[0-9;]*m|\[0m/g, '');++// One entry per harness. `argv` is a function so a harness that needs the+// prompt attached to a flag (agy) and one that takes it positionally (claude,+// codex) can share the same call site.+export const HARNESSES = {+ agy: {+ bin: 'agy',+ defaultModel: 'gemini-3.8-flash-high',+ // --print takes its prompt ATTACHED. Passed separately, Go's flag package+ // reads the next flag as the prompt and silently ignores what you typed.+ argv: ({ model, prompt, timeout, logFile, sandbox }) => [+ '--model', model,+ '--print-timeout', timeout,+ '--add-dir', sandbox,+ '--log-file', logFile,+ `--print=${prompt}`,+ ],+ // agy prints "Agent execution terminated due to error." to stdout and puts+ // the actual cause only in --log-file. Without reading that file back a+ // quota failure is indistinguishable from a bad prompt, and the fallback+ // ladder below never fires -- which is exactly how a ten-asset batch came+ // back empty in forty seconds with no usable diagnosis.+ needsLogFile: true,+ probe: (model) => ['--model', model, '--print=reply with the single word OK'],+ // Antigravity rate-limits per model id, and a 429 on one variant does not+ // mean the account is out of quota -- so fall back down the ladder rather+ // than failing the batch.+ fallbackModels: ['gemini-3.8-flash-medium', 'gemini-3.8-flash-low', 'gemini-3.1-pro-low'],+ },+ claude: {+ bin: 'claude',+ probe: (model) => ['-p', 'reply with the single word OK', '--model', model],+ defaultModel: 'sonnet',+ // `--allowedTools` and not only the sandbox's settings file: project+ // settings are applied once a directory is trusted, and a dispatch sandbox+ // is a directory the CLI has never seen. In a non-interactive run there is+ // nobody to trust it, so the allow-list written into `.claude/settings.json`+ // was honoured on some runs and silently ignored on others -- the same batch+ // produced a finished 22,000-triangle ship and two runs that could not call+ // `kiln_list_primitives` at all. A CLI flag is not subject to that, so the+ // grant is passed on the invocation and the settings file stays as the+ // belt-and-braces copy other harnesses can read. Both server names appear+ // because the tool prefix depends on how Kiln was installed.+ argv: ({ model, prompt, sandbox }) => [+ '-p', prompt,+ '--model', model,+ '--permission-mode', 'acceptEdits',+ '--allowedTools', 'mcp__plugin_kiln_kiln mcp__kiln Read Write Edit Glob Grep',+ '--add-dir', sandbox,+ ],+ fallbackModels: [],+ },+ // Three things here were wrong for as long as this table existed, and every+ // one of them failed before the model saw the brief -- which is why nothing in+ // the gallery came from Codex. `--full-auto` is deprecated in favour of an+ // explicit `--sandbox`. A clean room is a bare temp directory, so Codex+ // refuses it as "not inside a trusted directory" unless the git check is+ // waived. And the sandbox was never passed at all: without `--cd` the child+ // ran in this repository with every finished example in reach, which is the+ // exact contamination `makeSandbox` exists to prevent.+ codex: {+ bin: 'codex',+ probe: (model) => ['exec', ...modelFlag(model), '--skip-git-repo-check', 'reply with the single word OK'],+ // No default model, deliberately. Codex rejects a model its account is not+ // entitled to -- `gpt-5.1-codex` came back "not supported when using Codex+ // with a ChatGPT account" -- and which ids an account can reach is not+ // something this repository can know. Omitting the flag uses whatever the+ // operator configured in `~/.codex/config.toml`, which is right by+ // construction. `--model` still overrides it.+ defaultModel: null,+ // `--approve-for-me` and not `--sandbox workspace-write`, which is what this+ // used to pass. `codex exec` runs with the approval policy pinned to+ // `never`, and under that policy an MCP tool call is not asked about, it is+ // refused: four dispatches came back inside a minute having written nothing+ // but a note that `kiln_list_primitives` was blocked. The two flags are+ // mutually exclusive on the command line, and `--approve-for-me` is the one+ // that does both jobs -- it selects the same workspace-write sandbox and+ // moves approval to `on-request`, routed through automatic review, which is+ // what an unattended run needs. It is the Codex spelling of OpenCode's+ // `--auto` and of the Claude allow-list above, and like both of those it+ // governs one throwaway temp directory holding a brief and a copy of the+ // skills.+ argv: ({ model, prompt, sandbox }) => [+ 'exec',+ ...modelFlag(model),+ '--approve-for-me',+ '--skip-git-repo-check',+ '--cd', sandbox,+ prompt,+ ],+ fallbackModels: [],+ },+ // OpenCode is the widest model surface of the four: one subscription reaches+ // a dozen vendors' models behind `provider/model` ids, which is what makes a+ // gallery with more than one author's handwriting in it possible at all.+ // `--auto` is what lets it run unattended; without it the child stops at the+ // first tool-permission prompt and the run times out having written nothing.+ opencode: {+ bin: 'opencode',+ probe: (model) => ['run', '--auto', '-m', model, 'reply with the single word OK'],+ // The -flash variant and not plain glm-5.3, which is text only. A default+ // that cannot see images is the worst kind of wrong here: the run succeeds,+ // the program builds, and the asset is quietly worse because the model wrote+ // it blind and nothing in the output says so. scripts/check-vision.mjs is how+ // this pair was found and is worth running before trusting any new id.+ defaultModel: 'opencode-go/glm-5.3-flash',+ argv: ({ model, prompt, sandbox }) => ['run', '--auto', '--dir', sandbox, '-m', model, prompt],+ // The model that answered, read back rather than assumed. `-m` has been+ // honoured on every run measured so far, but the gallery's whole claim is+ // that a named model wrote a particular program, and "we asked for it" is a+ // weaker thing to be able to say than "it said so". OpenCode announces its+ // choice as `> <agent> · <model>`, so the dispatcher takes it from there and+ // reports any disagreement instead of quietly preferring its own request.+ // OpenCode caps a single assistant step at 32,000 output tokens regardless of+ // what the model can actually do. Measured across every step in its session+ // store, nothing ever exceeded that number -- not once, not by one token --+ // while the models involved declare limits of 80,000 to 943,718. Runs died+ // there mid-sentence with no file written and no error.+ //+ // `OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX` is the knob for it. This raises it+ // to the model's OWN published limit rather than to a number picked here, so+ // the ceiling is the one the provider set and never higher.+ env: ({ model }) => {+ const out = declaredOutputLimit(model);+ return out ? { OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX: String(out) } : {};+ },+ actualModel: (out) => /^>\s*\S+\s+·\s+(\S+)\s*$/m.exec(stripAnsi(out))?.[1] ?? null,+ // Model ids here name one vendor's model each, so there is no ladder of+ // variants to walk: a 429 on `glm-5.3` says nothing about `kimi-k3`. The+ // batch script picks the next model instead.+ fallbackModels: [],+ },+ // Hermes is the odd one out, and the reason this table earns its keep: a+ // Python agent with its own skill store, its own config file and its own+ // provider routing, nothing like the four JavaScript CLIs above. It takes the+ // same MCP server and the same brief anyway, which is the portability claim+ // this repository actually makes -- Kiln is not a Claude Code plugin that+ // happens to run elsewhere.+ //+ // `-z` is its headless mode: one prompt in, the final response text out, no+ // banner and no approval prompts. It has no working-directory flag, so the+ // sandbox is simply the CWD `run()` spawns it in -- which is also where it+ // reads AGENTS.md from, so the clean room holds.+ hermes: {+ bin: 'hermes',+ // No default model: Hermes routes through whichever provider the operator+ // configured, and a model id hardcoded here would override a working setup+ // with a guess. Same reasoning as Codex.+ defaultModel: null,+ // `-z` is the whole harness contract here: Hermes documents it as the mode+ // for scripts and pipes, and it already resolves tool prompts on its own,+ // so no additional flag is needed to make a dispatch run unattended.+ probe: (model) => [...modelFlag(model), '-z', 'reply with the single word OK'],+ argv: ({ model, prompt }) => [...modelFlag(model), '-z', prompt],+ fallbackModels: [],+ },+};+++// Windows: resolve the executable ourselves rather than asking for a shell.+// `shell: true` concatenates argv into one command line, and the prompt is+// multi-line -- so with a shell the child sees a mangled command and exits 2+// before it has read anything. Resolving the .exe lets us pass a real argv+// array, which CreateProcess hands through untouched.+const binCache = new Map();++/**+ * Find the real executable behind a CLI name on Windows.+ *+ * `where` returns every match, and the extension decides how the thing can be+ * launched. A `.exe` takes a real argv array through CreateProcess untouched. A+ * `.cmd` shim -- which is what npm-installed CLIs are, `opencode.cmd` among them+ * -- cannot be spawned without a shell at all.+ *+ * The previous version accepted only `.exe` and silently fell through to the+ * bare name for everything else, which is how a dispatch to OpenCode hung for+ * thirty-five minutes having never created a session: with `shell: true` Node+ * concatenates argv into one command line and quotes nothing, so a prompt with+ * spaces in it arrived as a dozen separate arguments.+ */+export function resolveBin(bin) {+ if (process.platform !== 'win32') return { cmd: bin, shell: false };+ if (!binCache.has(bin)) {+ const r = spawnSync('where', [bin], { encoding: 'utf8', shell: true });+ const lines = (r.stdout ?? '').split('\n').map((l) => l.trim()).filter(Boolean);+ const exe = lines.find((l) => l.toLowerCase().endsWith('.exe'));+ const shim = lines.find((l) => /\.(cmd|bat)$/i.test(l));+ binCache.set(bin, exe ? { cmd: exe, shell: false } : { cmd: shim ?? bin, shell: true });+ }+ return binCache.get(bin);+}++/**+ * Quote one argument for cmd.exe.+ *+ * Only needed on the shim path: `shell: true` hands the joined string to+ * cmd.exe, and Node does no quoting of its own. Without this every argument+ * containing a space -- a prompt, a Windows path under `Program Files` -- is+ * split at the space by the shell.+ */+export const quoteArg = (a) => (/[\s"^&|<>]/.test(a) ? `"${String(a).replaceAll('"', '""')}"` : String(a));++/** '25m' / '90s' / '3600' -> milliseconds. */+export function parseDuration(v) {+ const m = /^(\d+)\s*([smh]?)$/.exec(String(v).trim());+ if (!m) return null;+ const n = Number(m[1]);+ return n * ({ s: 1000, m: 60_000, h: 3_600_000 }[m[2]] ?? 1000);+}++/**+ * End a spawned CLI and everything it started.+ *+ * `child.kill()` signals the direct child and nothing below it. That is enough+ * on the no-shell path and useless on the one that matters: an npm-installed+ * CLI on Windows is a `.cmd` shim, so the direct child is `cmd.exe` and the+ * agent itself is a grandchild. Killing the shim leaves the agent running and+ * holding the stdout pipe open, which means `close` never fires and a job that+ * has already been declared timed out goes on running until someone kills it by+ * hand. Measured: three jobs sat between 14 and 38 minutes past a 24m deadline.+ *+ * So kill the tree. `taskkill /T` walks the child list on Windows; elsewhere the+ * child leads its own process group and the group takes the signal.+ */+export function killTree(child) {+ if (!child.pid) return;+ if (process.platform === 'win32') {+ try {+ spawnSync('taskkill', ['/pid', String(child.pid), '/t', '/f'], { stdio: 'ignore' });+ return;+ } catch {+ // fall through to the plain kill below+ }+ }+ try {+ process.kill(-child.pid, 'SIGKILL');+ } catch {+ try {+ child.kill('SIGKILL');+ } catch {}+ }+}++/**+ * `agy` enforces the deadline itself via --print-timeout. `claude`, `codex` and+ * `opencode` have no such flag, so a child that wedges -- waiting on a tool that+ * never returns, or a model that will not stop -- hangs the whole batch with no+ * output and no error. This kills it and reports the timeout as a normal failure+ * so the caller can move to the next model.+ */+export function run(bin, args, { cwd = REPO, capture = true, logFile = null, timeoutMs = null, env = null } = {}) {+ if (logFile) rmSync(logFile, { force: true });+ return new Promise((res) => {+ const resolved = resolveBin(bin);+ // A .cmd shim (npm-installed CLIs on Windows) cannot be spawned without a+ // shell, and a shell carries one flat string -- so on that path every+ // argument is quoted here, and the prompt stays one line long so no shell+ // has to carry a newline.+ // stdin is closed, not piped. A dispatched agent is given its whole brief+ // on the command line and has nothing to read, but OpenCode keeps its+ // process alive as long as stdin is an open pipe: it answers the prompt,+ // writes its files, and then sits there. Measured against the same command+ // four ways, the only variable that mattered was this one -- an open pipe+ // ran until the 75s kill, a closed one exited in 6s. The other CLIs never+ // read stdin either, so closing it costs nothing and removes a hang that+ // looks exactly like a slow model.+ const stdio = ['ignore', 'pipe', 'pipe'];+ // Off Windows the child is made its own process-group leader, which is what+ // lets `killTree` signal the group rather than just the shell in front of it.+ // Windows has no process groups to lead; `taskkill /T` covers it there.+ const detached = process.platform !== 'win32';+ const childEnv = env ? { ...process.env, ...env } : process.env;+ const child = resolved.shell+ ? spawn(quoteArg(resolved.cmd), args.map(quoteArg), { cwd, shell: true, stdio, detached, env: childEnv })+ : spawn(resolved.cmd, args, { cwd, shell: false, stdio, detached, env: childEnv });+ let out = '';+ if (capture) {+ child.stdout.on('data', (d) => { out += d; });+ child.stderr.on('data', (d) => { out += d; });+ }+ let settled = false;+ let grace = null;+ const finish = (code) => {+ if (settled) return;+ settled = true;+ if (timer) clearTimeout(timer);+ if (grace) clearTimeout(grace);+ // Fold the harness's own log into the captured output, so the caller+ // sees the real cause rather than the one-line summary on stdout.+ if (logFile && existsSync(logFile)) {+ try { out += readFileSync(logFile, 'utf8'); } catch {}+ }+ res({ code, out });+ };++ const timer = timeoutMs+ ? setTimeout(() => {+ out += `\ntimed out after ${(timeoutMs / 60_000).toFixed(0)}m; killed`;+ killTree(child);+ // Killing the tree should end the pipes and fire `close` on its own.+ // If it does not -- a descendant that ignores the signal, or a handle+ // held open somewhere unreachable -- the batch still has to advance,+ // so the deadline is enforced here rather than merely requested.+ grace = setTimeout(() => finish(-1), 15_000);+ }, timeoutMs)+ : null;+ child.on('error', (e) => {+ out += `\nspawn failed: ${e.message}`;+ finish(-1);+ });+ child.on('close', (code) => {+ finish(code);+ });+ });+}++/**+ * A clean room for one dispatch.+ *+ * Dispatches used to run with the harness pointed at this repository, which+ * quietly invalidated the thing they were supposed to be evidence for: a child+ * agent sitting in the repo can open `examples/cathedral.kiln.js` and copy an+ * API it never had to learn. "The tools teach the API" is not demonstrated by+ * an agent that read thirteen finished programs first.+ *+ * So each run gets its own directory containing exactly two things: the brief+ * and the Kiln skills, and nothing else. The harness's write grant is+ * scoped to it, and its working directory is it. The model arrives knowing only+ * what the skills say and what the MCP tools answer.+ *+ * The skills go in `.claude/skills/`, which is the one location every harness+ * here agrees on -- Claude Code natively, and OpenCode which reads+ * `.claude/skills/<name>/SKILL.md` alongside its own `.opencode/skills`.+ * Antigravity loads them from its installed plugin copy instead, so for `agy`+ * this directory is belt and braces rather than the delivery mechanism.+ *+ * What this does NOT isolate, and it is worth being exact: skills and MCP+ * servers the operator has installed at USER scope are still in scope, because+ * no harness here exposes a per-run flag to suppress them. What it removes is+ * the repository -- the examples, the engine source, and `AGENTS.md`.+ */+// The sandbox lives outside the repository, in the OS temp directory.+//+// The first version of this put it under `.dogfood/`, which looked isolated and+// was not: every coding CLI finds the project it is working in by walking up+// from the working directory to the nearest `.git`, so a sandbox nested inside+// the repo resolved back to the repo. The child could still reach every+// finished example, which is the exact contamination the sandbox exists to+// prevent. OpenCode additionally hung during bootstrap on such a directory --+// three concurrent runs reached `init` and never started -- so the honest fix+// and the working fix turned out to be the same one.+export function makeSandbox(name) {+ const sandbox = join(tmpdir(), 'kiln-dispatch', name);+ rmSync(sandbox, { recursive: true, force: true });+ mkdirSync(sandbox, { recursive: true });+ const skillsSrc = join(REPO, 'skills');+ if (existsSync(skillsSrc)) cpSync(skillsSrc, join(sandbox, '.claude', 'skills'), { recursive: true });++ // Pre-approve the tools the brief asks the child to use.+ //+ // `--permission-mode acceptEdits` covers writes and nothing else, so a child+ // that reached for `kiln_render` stopped and asked -- with no terminal+ // attached to ask. Three of four runs in one batch came back after a minute+ // having written nothing but a polite explanation of which permissions they+ // would need, which is the worst possible failure for an unattended path:+ // exit 0, no program, no error. The MCP server name depends on how Kiln was+ // installed (as a plugin it is `plugin_kiln_kiln`), so allow both spellings.+ //+ // Scoped deliberately rather than reached for with+ // `--dangerously-skip-permissions`: this settings file governs one throwaway+ // temp directory that contains a brief and a copy of the skills, and the+ // allow-list names the Kiln tools plus the file tools the child needs to+ // write its program. Nothing here grants the child the shell.+ const settings = {+ permissions: {+ allow: [+ 'mcp__kiln',+ 'mcp__plugin_kiln_kiln',+ 'Read',+ 'Write',+ 'Edit',+ 'Glob',+ 'Grep',+ ],+ },+ };+ mkdirSync(join(sandbox, '.claude'), { recursive: true });+ writeFileSync(+ join(sandbox, '.claude', 'settings.json'),+ `${JSON.stringify(settings, null, 2)}\n`,+ );+ return sandbox;+}diff --git a/scripts/hero-shots.ts b/scripts/hero-shots.tsindex 2bf73e34..b428675d 100644--- a/scripts/hero-shots.ts+++ b/scripts/hero-shots.ts@@ -11,7 +11,7 @@* output is a picture of the asset rather than a diagnostic sheet.** bun scripts/hero-shots.ts # every hero- * bun scripts/hero-shots.ts mech lunar-lander+ * bun scripts/hero-shots.ts mech cathedral* bun scripts/hero-shots.ts --size 1400 --cpu** Renders come off the port as raw RGB PNGs -- 8 MB each at 1200 px, which is@@ -43,15 +43,55 @@ const OUT_DIR = join(EXAMPLES, 'renders');*/const HEROES = ['field-gun',+ 'cathedral',+ 'mech','diving-helmet',+ 'cafe-racer','penny-farthing',+ 'sushi-store','street-lamp',- 'mech','arcade-cabinet',- 'sushi-store',- 'cafe-racer',- 'beam-engine',- 'lunar-lander',+ 'robot-arm',+ 'carousel',+ 'ferris-wheel',+ 'orrery',+ 'longcase-clock',+ 'radio-telescope',+ 'anglerfish',+ 'hot-air-balloon',+ 'vending-machine',+ 'gramophone',+ 'typewriter',+ 'lighthouse',+ 'steam-locomotive',+ 'windmill',+ 'aircraft-carrier',+ 'air-defense-radar',+ 'fighter-jet',+ 'comms-satellite',+ 'victorian-greenhouse',+ 'gothic-gatehouse',+ 'cable-stayed-bridge',+ 'fire-lookout-tower',+ 'tram',+ 'tugboat',+ 'deep-sea-diver',+ 'pumpjack',+ 'drilling-rig',+ 'harbour-crane',+ 'crawler-crane',+ 'excavator',+ 'printing-press',+ 'pipe-organ',+ 'planetarium-projector',+ 'astronomical-clock',+ 'espresso-machine',+ 'pinball-machine',+ 'trebuchet',+ 'orbital-station',+ 'rigid-airship',+ 'blast-furnace',+ 'clock-tower',] as const;/**@@ -66,6 +106,37 @@ const HEROES = [const HERO_DIR: [number, number, number] = [0.82, 0.44, 0.58];const HERO_ZOOM = 1.06;+/**+ * Per-asset camera, for the few subjects the shared angle does not suit.+ *+ * The default looks mostly down the +X axis, which is the right three-quarter+ * for almost everything because +X is the contract's forward. It is wrong for a+ * subject whose most important feature also points at +X: the gramophone's horn+ * is a 0.32 m bell on the +X axis, so from the shared angle it faces the lens+ * squarely and hides the turntable, the tonearm and the whole crane behind it.+ * Swinging round toward +Z puts the horn in profile, where its flare reads and+ * the deck is visible past it.+ *+ * This is a camera choice, not a retouch -- the render is still the program,+ * straight through the same port.+ */+const HERO_OVERRIDES: Record<string, { dir?: [number, number, number]; zoom?: number }> = {+ gramophone: { dir: [0.3, 0.4, 0.87], zoom: 1.02 },+ // Same problem, different subject: the fish is modelled nose-at-+X, so the+ // shared angle looks it straight in the mouth and a deep-sea anglerfish+ // becomes a dark oval with a light in front of it. Almost side-on is the only+ // view where the profile, the jaw line, the arched illicium and the fin rays+ // all read at once, which is why every plate ever drawn of one is in profile.+ anglerfish: { dir: [0.24, 0.3, 0.92], zoom: 1.04 },+ // A 332 m hull is four times as long as it is wide, so the shared angle leaves+ // it as a thin diagonal with the flight deck nearly edge-on. Swinging toward+ // the beam opens the deck out; dropping the elevation to 27 degrees is what+ // puts the ship back under it. From higher up the entire flank falls into the+ // shadow of its own overhang and a carrier reads as a black lozenge with+ // markings on it.+ 'aircraft-carrier': { dir: [0.6, 0.42, 0.55], zoom: 1.0 },+};+/** Width the shot is published at. Render size stays higher, for the downsample. */const DISPLAY_PX = 1000;@@ -91,11 +162,23 @@ async function main(): Promise<void> {await mkdir(OUT_DIR, { recursive: true });const context = await buildRenderPort(cpu ? 'cpu' : 'auto', undefined);- if (!context.viewRenderPort) {- // The CPU rasterizer is geometry-flat: it draws shape, not materials. That+ if (!context.viewRenderPort && !cpu) {+ // The CPU rasterizer is geometry-flat: it draws shape, not materials, which// is the right fallback for an in-loop diagnostic and the wrong one for a- // gallery image, so say so rather than quietly shipping grey renders.- console.warn('no GPU render port — shots will be geometry-flat, not material-faithful');+ // gallery image. Warning and carrying on was worse than useless: the+ // detection probe is a health GET that times out whenever the service is+ // busy -- which it is whenever a dispatch batch is rendering through it --+ // so a transient miss silently replaced finished PBR heroes with grey ones,+ // and the only evidence was a line of scrollback. Refuse instead. `--cpu`+ // still says so deliberately, and KILN_RENDER_PORT_URL skips the probe.+ console.error(+ 'no GPU render port reachable at http://127.0.0.1:8000.\n' ++ 'Gallery shots must be material-faithful, and overwriting them with flat\n' ++ 'CPU renders loses work that cannot be recovered from the tree.\n' ++ 'Start the render service, or set KILN_RENDER_PORT_URL to skip the probe\n' ++ '(it is taken on trust), or pass --cpu if you really do want flat shots.',+ );+ process.exit(1);}const evaluator = resolveEvaluatorPortV1(undefined, 'trusted-local');@@ -110,7 +193,7 @@ async function main(): Promise<void> {context.viewRenderPort,rendered.glb,context.viewRenderTimeoutMs ?? 120_000,- [HERO_DIR],+ [HERO_OVERRIDES[name]?.dir ?? HERO_DIR],size,);if (ported.ok) png = ported.pngs[0];diff --git a/scripts/promote-asset.mjs b/scripts/promote-asset.mjsnew file mode 100644index 00000000..48b8306a--- /dev/null+++ b/scripts/promote-asset.mjs@@ -0,0 +1,126 @@+#!/usr/bin/env node+// Promote a dispatched asset from `.dogfood/` into `examples/`.+//+// Curation is a judgement call made by looking at the render, and nothing here+// tries to automate that part. What it does automate is everything that has to+// be true once the judgement is made, because each of these was got wrong by+// hand at least once: the program is copied, the authoring model is recorded in+// the file itself, and the triangle count the README will quote comes from+// re-running the program rather than from whatever the dispatch log said.+//+// node scripts/promote-asset.mjs radio-telescope+// node scripts/promote-asset.mjs --all-listed+//+// The provenance claim is written from the asset's own `.result.json`, and the+// clean-room sentence is only added when that manifest says the run had one.+// Assets authored before sandboxing existed are attributed without it; the+// alternative is a header making a claim about isolation that was not true.+import { spawnSync } from 'node:child_process';+import { copyFileSync, existsSync, readFileSync, writeFileSync } from 'node:fs';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';++const REPO = resolve(dirname(fileURLToPath(import.meta.url)), '..');+const DOGFOOD = join(REPO, '.dogfood');+const EXAMPLES = join(REPO, 'examples');++function manifestFor(name) {+ const p = join(DOGFOOD, `${name}.result.json`);+ if (!existsSync(p)) return null;+ try {+ return JSON.parse(readFileSync(p, 'utf8'));+ } catch {+ return null;+ }+}++function stamp(file, { model, harness, cleanRoom, interrupted }) {+ let body = readFileSync(file, 'utf8');+ if (body.charCodeAt(0) === 0xfeff) body = body.slice(1);+ if (/^\/\/ Authored by:/m.test(body)) return false;+ const header = [+ `// Authored by: ${model}, via ${harness}.`,+ '//',+ ...(interrupted+ ? [+ '// Written by the model itself through the Kiln MCP tools, and cut off',+ '// mid-run rather than finished -- by a provider limit, or by the',+ '// dispatch deadline. The program below is what was on disk when the',+ '// session ended; how many times it had looked at its own contact sheet',+ '// by then is not recorded, so this one does not make the claim the',+ '// others do.',+ ]+ : [+ '// Written by the model itself through the Kiln MCP tools: it wrote the',+ '// program, rendered it, looked at its own six-view contact sheet, and',+ '// revised. Not a line of it is hand-authored.',+ ]),+ ...(cleanRoom+ ? [+ '//',+ '// Dispatched into a clean directory containing only the brief and the Kiln',+ '// skills, with no access to this repository or to any finished example.',+ ]+ : []),+ '',+ ].join('\n');+ writeFileSync(file, `${header}\n${body}`);+ return true;+}++function promote(name) {+ const src = join(DOGFOOD, `${name}.kiln.js`);+ if (!existsSync(src)) return { name, ok: false, why: 'no program in .dogfood' };++ const manifest = manifestFor(name);+ if (!manifest?.model) return { name, ok: false, why: 'no model attribution in .result.json' };++ const dest = join(EXAMPLES, `${name}.kiln.js`);+ copyFileSync(src, dest);+ // `cleanRoom` is absent on manifests written before sandboxing, and absent+ // means "not known to have had one", which is the honest reading.+ stamp(dest, {+ model: manifest.model,+ harness: manifest.harness ?? 'unknown harness',+ cleanRoom: manifest.cleanRoom === true,+ interrupted: manifest.interrupted === true,+ });++ // Re-run the program to get the number the README will quote. The dispatch+ // log's count came off a different copy of the file, before this header.+ const glb = join(DOGFOOD, `${name}.promote.glb`);+ const r = spawnSync('bun', ['src/cli.ts', 'render', dest, '--out', glb, '--render', 'cpu'], {+ cwd: REPO,+ encoding: 'utf8',+ shell: process.platform === 'win32',+ });+ const out = `${r.stdout ?? ''}${r.stderr ?? ''}`;+ const tris = /(\d+) tris/.exec(out)?.[1];+ if (r.status !== 0 || !tris) return { name, ok: false, why: `render failed: ${out.trim().slice(-200)}` };++ return {+ name,+ ok: true,+ model: manifest.model,+ cleanRoom: manifest.cleanRoom === true,+ tris: Number(tris),+ bounds: /bounds\s+(.+)/.exec(out)?.[1]?.trim() ?? null,+ };+}++const names = process.argv.slice(2).filter((a) => !a.startsWith('--'));+if (!names.length) {+ console.error('usage: promote-asset.mjs <name> [<name> ...]');+ process.exit(2);+}++const rows = names.map(promote);+for (const r of rows) {+ if (!r.ok) {+ console.error(`SKIP ${r.name}: ${r.why}`);+ continue;+ }+ const room = r.cleanRoom ? 'clean room' : 'repo-visible run';+ console.log(`${r.name.padEnd(18)} ${String(r.tris).padStart(6)} tris ${r.model} (${room})`);+}+process.exit(rows.every((r) => r.ok) ? 0 : 1);diff --git a/scripts/reliability.test.mjs b/scripts/reliability.test.mjsindex 302dfa68..58a9a000 100644--- a/scripts/reliability.test.mjs+++ b/scripts/reliability.test.mjs@@ -38,7 +38,12 @@ describe('repository reliability contracts', () => {const pkg = await readJson('package.json');const bunfig = await readText('bunfig.toml');const thresholds = JSON.parse((await readText('coverage-thresholds.json')) || '{}');- const readme = await readText('README.md');+ // Collapse whitespace before matching prose. These assertions describe+ // sentences, and a sentence in a hard-wrapped Markdown file contains+ // newlines at positions nobody should have to predict -- the ratchet-policy+ // check below silently stopped matching when a paragraph was reflowed during+ // an edit, which is the opposite of what a documentation guard is for.+ const readme = (await readText('README.md')).replace(/\s+/g, ' ');const workflow = await readText('.github/workflows/ci.yml');expect(pkg.scripts['test:coverage']).toBe(@@ -52,11 +57,11 @@ describe('repository reliability contracts', () => {expect(bunfig).not.toContain('coverageThreshold =');expect(bunfig).toContain('coveragePathIgnorePatterns = [');expect(thresholds).toEqual({- measuredBaseline: { functions: 95.38, lines: 91.8 },+ measuredBaseline: { functions: 95.96, lines: 92.54 },thresholds: { functions: 92, lines: 91 },});- expect(readme).toContain('95.38% functions / 91.80% lines');- expect(readme).toContain('Threshold decreases require an explicit measured rationale.');+ expect(readme).toContain('95.96% functions / 92.54% lines');+ expect(readme).toContain('threshold decreases require an explicit measured rationale.');expect(workflow).toContain('run: bun run test:coverage');expect(workflow).toContain('uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02');expect(workflow).toContain('path: coverage/lcov.info');