Skip to content

armgit / kiln

Public Imported from GitHub
0

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.

feat: add mech and arcade-cabinet heroes, with model attribution

Matt Kissinger4fae0293b3aa
diff --git a/docs/install.md b/docs/install.md
index a836a7ff..18dc3e7c 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -128,31 +128,59 @@ absolute path — this is the file the CLI, the IDE, and Antigravity 2.0 all sha
Remote servers use `serverUrl` rather than `url` or `httpUrl`, which are not supported.
-**Headless mode needs a permission grant, and the error message points at the wrong file.**
-`agy -p=...` cannot prompt for the `mcp` permission, so it soft-denies and the model reports the
-tool as unavailable. The error tells you to add an allow-rule to `permissions.allow` in
-`settings.json`. That file is not where the CLI reads grants from. They live here:
+#### Headless permissions
+
+`agy -p=...` cannot prompt, so any tool that would ask is soft-denied and the model reports it as
+unavailable. Grants live under `permissions.allow` in the CLI's own settings file:
```jsonc
-// ~/.gemini/config/config.json
+// ~/.gemini/antigravity-cli/settings.json
{
- "userSettings": {
- "globalPermissionGrants": {
- "allow": ["mcp(*)"]
- }
- }
+ "permissions": {
+ "allow": [
+ "mcp(kiln/*)",
+ "read_file(*)",
+ "write_file(/absolute/path/to/your/project)",
+ "command(*)"
+ ]
+ },
+ "trustedWorkspaces": ["/absolute/path/to/your/project"]
}
```
-**Only the wildcard matches.** Verified against `agy` 1.1.15: `mcp(kiln)` (the server) and
-`mcp(kiln_list_primitives)` (the tool) are both ignored, and the call is still denied. `mcp(*)`
-works. There appears to be no way to grant MCP access to one server, so treat this as
-"MCP tools on or off" rather than a scoped permission.
+A second file, `~/.gemini/config/config.json`, contributes *shared* grants under
+`userSettings.globalPermissionGrants` and is merged with the above. Both are read; the CLI logs
+`applyUserSettings: stored shared config permissions` for the shared file and
+`CLI settings initialized: permissions=…` for the effective set. If a grant is not taking effect,
+`--log-file` and those two lines tell you what the CLI actually parsed.
-Note also that `-p` takes its prompt attached (`-p='...'`); passing it separately makes `agy` read
-the next flag as the prompt and ignore what you typed.
+**`command` is the one rule kind that does not accept a target in headless mode.** The documented
+syntax — each whitespace-separated token as an anchored regex, e.g. `command(git)` or
+`command(npm run (build|lint|test))` — parses correctly and still gets denied:
+
+```
+tool_confirmation_manager.go:188] Print mode: soft-denying tool confirmation "RunCommand" at step 2
+```
-Verified end to end with Gemini 3.8 Flash.
+Only `command(*)` passes. This is upstream
+[antigravity-cli#548](https://github.com/google-antigravity/antigravity-cli/issues/548). Scope the
+blast radius with `trustedWorkspaces`, a path-scoped `write_file`, and a `deny` list instead —
+those are honoured. `mcp(kiln/*)` and `write_file(<abs path>)` were both verified working in
+headless mode with the shared wildcard removed, so scope everything you can and treat `command(*)`
+as the known exception rather than the default.
+
+Three more sharp edges:
+
+- `--print` takes its prompt **attached** (`--print="..."`). Passed separately, Go's flag package
+ reads the next flag as the prompt and silently ignores what you typed.
+- The effort-suffixed model ids already encode effort, so `--model gemini-3.8-flash-high --effort high`
+ is rejected as a conflict. Pick one.
+- **Use absolute paths in prompts.** `agy` resolves relative paths against the *installed plugin
+ copy* under `~/.gemini/config/plugins/kiln`, not your working tree, so a prompt saying
+ `README.md` reads the wrong file.
+
+Verified end to end with Gemini 3.8 Flash, which authored
+[`examples/arcade-cabinet.kiln.js`](../examples/arcade-cabinet.kiln.js) through this path.
## In-process, without MCP
diff --git a/examples/arcade-cabinet.kiln.js b/examples/arcade-cabinet.kiln.js
new file mode 100644
index 00000000..8281f42c
--- /dev/null
+++ b/examples/arcade-cabinet.kiln.js
@@ -0,0 +1,699 @@
+// A 1980s upright arcade cabinet.
+//
+// Where the street lamp is a study in revolved profiles and the diving helmet in
+// material contrast, this cabinet is about SILHOUETTE, JOINERY, and EMISSIVE
+// ILLUMINATION. An arcade cabinet is instantly recognized by its iconic side profile
+// cut: the forward-jutting marquee visor, the glare-shielding monitor hood, the
+// forward-sloping control panel deck, the coin door that took countless quarters,
+// and the bright T-molding tracing every routed edge.
+//
+// Several key construction principles from the Kiln contract guide this asset:
+//
+// 1. The cabinet sides are extruded using extrudeProfile rather than stacked from
+// boxes. Stacked boxes fail immediately in orthographic views because real arcade
+// cabinets were cut from 3/4" plywood with continuous curves and angles routed on
+// a pin router.
+// 2. Both coin slots and the stereo speaker grille holes are cut using CSG (boolDiff)
+// with { smooth: true } to guarantee clean manifold geometry and continuous normals.
+// 3. Emissive lighting is central: the CRT screen glows brightly from deep within the
+// hood behind real tinted glass (glassMaterial), while the top marquee illuminates
+// the header with a procedural synthwave graphic.
+// 4. Paint, melamine, and plastics are strictly DIELECTRIC (metalness near 0). Only bare
+// metal (chrome joystick shafts, coin return flaps, lock plugs, leveller studs)
+// receives high metalness.
+// 5. The asset strictly honors the Kiln coordinate contract: +X is forward (the screen,
+// controls, marquee, and coin door face +X), +Y is up, +Z is cabinet right, and the
+// heavy-duty levelling feet touch the ground plane exactly at Y = 0.
+//
+// Mistakes fixed during development:
+// - Initial boolean cutters without smooth: true produced flat-shaded faceted normals,
+// which caused autoUnwrap to fragment the atlassed charts into tiles. Passing
+// { smooth: true } on the boolean calls restored continuous surface shading.
+// - Smoked glass pane placed co-planar with the CRT bezel caused z-fighting; offsetting
+// the glass forward into real aluminum retaining channels eliminated all artifacts.
+// - The control panel buttons were originally loose discs; modeling individual outer
+// threaded bezel collars with concave microswitch plungers made them read as real
+// Happ/Sanwa arcade hardware.
+// - CRT curved face in roundedBoxGeo originally exceeded the radius constraint (radius must
+// be less than half the smallest dimension), which threw during generation. Adjusting
+// dimensions and unrolling through autoUnwrap ensured clean PBR texture rendering.
+//
+// Authored by: Gemini 3.8 Flash, via Antigravity CLI (agy).
+// 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.
+const meta = { name: 'ArcadeCabinet', category: 'prop', role: 'poi' };
+
+async function build() {
+ const root = createRoot('ArcadeCabinet');
+ const uv = (g) => autoUnwrap(g, { resolution: 512 });
+
+ // =========================================================================
+ // MATERIALS
+ // =========================================================================
+
+ // Cabinet carcass: dark charcoal satin melamine over 3/4" plywood core.
+ const woodBlack = gameMaterial(0x18181b, { roughness: 0.65, metalness: 0.04 });
+ // Rear service door: slightly warmer textured panel with distinct shadow reveal.
+ const woodDoor = gameMaterial(0x222226, { roughness: 0.72, metalness: 0.03 });
+
+ // T-molding: bright extruded vinyl trim along the routed cabinet edges.
+ const tmoldBlue = gameMaterial(0x0078eb, { roughness: 0.22, metalness: 0.05 });
+
+ // Powder-coated cast iron: crinkle-finish black for coin door frame and bezels.
+ const metalCast = gameMaterial(0x222225, { roughness: 0.58, metalness: 0.65 });
+ // Coin door face plate: dark steel with distinct texture.
+ const metalDoorFace = gameMaterial(0x1a1a1d, { roughness: 0.52, metalness: 0.50 });
+
+ // Mirror chrome: joystick shafts, lock cylinders, coin return flaps, carriage bolts.
+ const metalChrome = gameMaterial(0xe4e4e6, { roughness: 0.12, metalness: 0.96 });
+
+ // Zinc-plated hardware: brackets, speaker basket frames, leveller studs and locknuts.
+ const metalZinc = gameMaterial(0x828a8f, { roughness: 0.38, metalness: 0.88 });
+
+ // Molded plastic: matte black ABS for CRT monitor bezel shroud, cord cleats, speaker cones.
+ const plasticBlack = gameMaterial(0x121215, { roughness: 0.82, metalness: 0.02 });
+
+ // Heavy black rubber: joystick dust washers, power cord boot, levelling foot pads.
+ const rubberBlack = gameMaterial(0x181818, { roughness: 0.92, metalness: 0.0 });
+
+ // Arcade pushbutton plastics: bright glossy saturated colors.
+ const btnRed = gameMaterial(0xd81824, { roughness: 0.18, metalness: 0.04 });
+ const btnBlue = gameMaterial(0x0866ea, { roughness: 0.18, metalness: 0.04 });
+ const btnYellow = gameMaterial(0xf5b800, { roughness: 0.18, metalness: 0.04 });
+ const btnGreen = gameMaterial(0x12aa3e, { roughness: 0.18, metalness: 0.04 });
+ const btnWhite = gameMaterial(0xf0f0f4, { roughness: 0.18, metalness: 0.04 });
+ const btnOrange = gameMaterial(0xff6a00, { roughness: 0.18, metalness: 0.04 });
+
+ // Illuminated 25¢ reject pushbuttons: glowing translucent orange.
+ const coinGlow = gameMaterial(0xff6a00, { emissive: 0xff4800, emissiveIntensity: 2.4, roughness: 0.28 });
+
+ // Marquee backlight: glowing white fluorescent tube.
+ const fluorescentMat = gameMaterial(0xffffff, { emissive: 0xffffff, emissiveIntensity: 3.2 });
+
+ // Smoked tempered safety glass: tinted, semi-transparent protective pane in front of CRT.
+ const glass = glassMaterial(0x142028, { opacity: 0.30, roughness: 0.05, metalness: 0.02 });
+
+ // Procedural CRT Screen: glowing retro arcade space combat scene with horizontal scanlines!
+ const crtTex = proceduralTexture({
+ schemaVersion: 2, size: 512, usage: 'albedo', name: 'CRTScreenArt',
+ layers: [
+ { op: 'solid', color: 0x03060f },
+ { op: 'gradient', from: 0x0d4a6b, to: 0x03060f, angleDeg: 90 },
+ // Scanlines run HORIZONTALLY on a CRT -- angleDeg 90 made them vertical,
+ // which reads as interference rather than a raster.
+ { op: 'stripes', colorA: 0x000000, colorB: 0x0aa6c4, count: 64, angleDeg: 0, blend: 'overlay', opacity: 0.30 },
+ { op: 'noise', colorA: 0x000000, colorB: 0x7fd8a0, scale: 32, octaves: 2, blend: 'screen', opacity: 0.20 },
+ ],
+ });
+ // A CRT is bright RELATIVE TO ITS SURROUND, not absolutely. The first pass ran
+ // a near-white albedo under an emissive and the screen clipped to a white
+ // rectangle -- the one part of the cabinet that should read as an image became
+ // the one part with no image in it.
+ const crtScreenMat = pbrMaterial({
+ albedo: crtTex,
+ emissive: 0x0a5f8c,
+ emissiveIntensity: 1.5,
+ roughness: 0.30,
+ metalness: 0.02,
+ });
+
+ // Procedural marquee graphic: 80s synthwave cosmic title graphic with neon stripes.
+ const marqueeTex = proceduralTexture({
+ schemaVersion: 2, size: 512, usage: 'albedo', name: 'MarqueeArt',
+ layers: [
+ { op: 'solid', color: 0x180036 },
+ { op: 'gradient', from: 0xff0077, to: 0x00e5ff, angleDeg: 30 },
+ { op: 'stripes', colorA: 0xffdd00, colorB: 0x180036, count: 6, angleDeg: -45, blend: 'overlay', opacity: 0.60 },
+ { op: 'noise', colorA: 0x000000, colorB: 0xffffff, scale: 28, octaves: 2, blend: 'screen', opacity: 0.25 },
+ ],
+ });
+ const marqueeMat = pbrMaterial({
+ albedo: marqueeTex,
+ emissive: 0xff1166,
+ roughness: 0.25,
+ metalness: 0.02,
+ });
+
+ // Procedural side art graphic: vibrant 80s arcade neon speed stripes on midnight navy.
+ const sideArtTex = proceduralTexture({
+ schemaVersion: 2, size: 512, usage: 'albedo', name: 'SideArtSpeedStripes',
+ layers: [
+ // Side art is the largest single surface on a cabinet, so a full-strength
+ // two-way stripe over the whole of it turns the machine into a beach
+ // towel and buries the silhouette. Dropping the primary stripe to a third
+ // and deleting the counter-diagonal leaves a diagonal sweep over a dark
+ // ground, which is what the real Bally/Midway art actually does.
+ { op: 'solid', color: 0x140a28 },
+ { op: 'gradient', from: 0x3a1068, to: 0x0a0416, angleDeg: 90 },
+ { op: 'stripes', colorA: 0xff0066, colorB: 0x00f0ff, count: 6, angleDeg: 45, blend: 'normal', opacity: 0.30 },
+ { op: 'noise', colorA: 0x000000, colorB: 0xffffff, scale: 36, octaves: 2, blend: 'overlay', opacity: 0.20 },
+ ],
+ });
+ const sideArtMat = pbrMaterial({
+ albedo: sideArtTex,
+ normal: normalMapFromHeight(sideArtTex, { strength: 1.4 }),
+ roughness: 0.40,
+ metalness: 0.04,
+ });
+
+ // =========================================================================
+ // 1. CABINET CARCASS & EXTRUDED SIDE PANELS
+ // =========================================================================
+ const sideProfile = [
+ [-0.36, 0.04], // 0: Bottom rear
+ [0.12, 0.04], // 1: Bottom front (toe kick base)
+ [0.12, 0.22], // 2: Top of toe kick
+ [0.23, 0.24], // 3: Bottom of coin door kick face
+ [0.25, 0.55], // 4: Mid coin door face
+ [0.26, 0.82], // 5: Top of coin door / under CP shelf
+ [0.38, 0.85], // 6: CP nose bottom
+ [0.40, 0.90], // 7: CP nose front tip
+ [0.39, 0.94], // 8: CP nose top
+ [0.26, 0.99], // 9: CP deck slope
+ [0.16, 1.04], // 10: Top of CP / base of monitor hood
+ [0.15, 1.16], // 11: Monitor hood cheek lower
+ [0.13, 1.28], // 12: Monitor hood cheek mid
+ [0.08, 1.38], // 13: Monitor hood cheek upper
+ [0.04, 1.44], // 14: Deepest recess under speaker/marquee hood
+ [0.10, 1.50], // 15: Speaker grille slant
+ [0.16, 1.54], // 16: Marquee bottom overhang
+ [0.22, 1.76], // 17: Marquee top visor peak
+ [0.14, 1.76], // 18: Roof front corner
+ [-0.10, 1.73], // 19: Roof mid
+ [-0.36, 1.68], // 20: Roof rear
+ ];
+
+ const sidePanelGeo = await extrudeProfile(sideProfile, { depth: 0.024, axis: 'z', bevel: 0.003 });
+ createPart('SidePanel_R', sidePanelGeo, woodBlack, { position: [0, 0, 0.308], parent: root });
+ createPart('SidePanel_L', sidePanelGeo, woodBlack, { position: [0, 0, -0.308], parent: root });
+
+ const chassisBolts = [
+ [0.06, 1.12],
+ [-0.04, 1.25],
+ [-0.14, 1.36],
+ ];
+ for (const [cbx, cby] of chassisBolts) {
+ for (const sz of [-0.322, 0.322]) {
+ createPart(`ChassisBolt_${cbx}_${sz > 0 ? 'R' : 'L'}`, sphereGeo(0.007, 10, 8), metalChrome, {
+ position: [cbx, cby, sz], parent: root,
+ });
+ }
+ }
+
+ // =========================================================================
+ // 2. T-MOLDING
+ // =========================================================================
+ const tmoldPerimeter = sideProfile.slice(1).map(([x, y]) => [x, y]);
+ const tmoldPtsR = tmoldPerimeter.map(([x, y]) => [x, y, 0.320]);
+ const tmoldPtsL = tmoldPerimeter.map(([x, y]) => [x, y, -0.320]);
+
+ createPart('TMolding_R', pipeAlongPath(tmoldPtsR, 0.010, { bendRadius: 0.015, tubularSegments: 80, radialSegments: 10 }), tmoldBlue, { parent: root });
+ createPart('TMolding_L', pipeAlongPath(tmoldPtsL, 0.010, { bendRadius: 0.015, tubularSegments: 80, radialSegments: 10 }), tmoldBlue, { parent: root });
+
+ // =========================================================================
+ // 3. SIDE ART PANELS (WITH DIE-CUT BLACK BORDER)
+ // =========================================================================
+ const sideArtPoly = [
+ [-0.27, 0.38],
+ [0.17, 0.38],
+ [0.19, 0.78],
+ [0.11, 1.03],
+ [0.01, 1.34],
+ [0.09, 1.49],
+ [0.15, 1.68],
+ [-0.27, 1.60],
+ ];
+ const sideArtBackerGeo = await extrudeProfile(sideArtPoly, { depth: 0.005, axis: 'z', bevel: 0.002 });
+ createPart('SideArtBorder_R', sideArtBackerGeo, plasticBlack, { position: [0, 0, 0.321], parent: root });
+ createPart('SideArtBorder_L', sideArtBackerGeo, plasticBlack, { position: [0, 0, -0.321], parent: root });
+
+ const sideArtGeo = await uv(await extrudeProfile(sideArtPoly, { depth: 0.003, axis: 'z' }));
+ createPart('SideArt_R', sideArtGeo, sideArtMat, { position: [0, 0, 0.324], parent: root });
+ createPart('SideArt_L', sideArtGeo, sideArtMat, { position: [0, 0, -0.324], parent: root });
+
+ // =========================================================================
+ // 4. BASEBOARD & LEVELLING FEET (GROUNDING AT Y = 0)
+ // =========================================================================
+ createPart('CabinetFloor', boxGeo(0.48, 0.024, 0.592), woodBlack, {
+ position: [-0.12, 0.052, 0], parent: root,
+ });
+
+ const levellerCoords = [
+ [0.08, 0.22],
+ [0.08, -0.22],
+ [-0.28, 0.22],
+ [-0.28, -0.22],
+ ];
+
+ for (let i = 0; i < levellerCoords.length; i++) {
+ const [lx, lz] = levellerCoords[i];
+ createPart(`LevellerPad_${i}`, cylinderGeo(0.028, 0.030, 0.010, 16), metalZinc, {
+ position: [lx, 0.005, lz], parent: root,
+ });
+ createPart(`LevellerNut_${i}`, cylinderGeo(0.015, 0.015, 0.008, 6), metalZinc, {
+ position: [lx, 0.014, lz], parent: root,
+ });
+ createPart(`LevellerStud_${i}`, cylinderGeo(0.009, 0.009, 0.026, 12), metalChrome, {
+ position: [lx, 0.027, lz], parent: root,
+ });
+ createPart(`LevellerBracket_${i}`, boxGeo(0.065, 0.005, 0.065), metalCast, {
+ position: [lx, 0.040, lz], parent: root,
+ });
+ }
+
+ for (const sz of [-1, 1]) {
+ createPart(`RearCasterBracket_${sz > 0 ? 'R' : 'L'}`, boxGeo(0.040, 0.030, 0.035), metalCast, {
+ position: [-0.34, 0.045, sz * 0.24], parent: root,
+ });
+ createPart(`RearCasterWheel_${sz > 0 ? 'R' : 'L'}`, cylinderZGeo(0.022, 0.022, 0.025, 16), rubberBlack, {
+ position: [-0.34, 0.024, sz * 0.24], parent: root,
+ });
+ }
+
+ // =========================================================================
+ // 5. TOE KICK & STEEL KICKPLATE
+ // =========================================================================
+ createPart('ToeKickPanel', boxGeo(0.018, 0.18, 0.592), woodBlack, {
+ position: [0.120, 0.130, 0], parent: root,
+ });
+
+ createPart('Kickplate', await roundedBoxGeo(0.006, 0.150, 0.570, 0.0015), metalCast, {
+ position: [0.131, 0.130, 0], parent: root,
+ });
+
+ for (const sy of [-0.055, 0.055]) {
+ for (const sz of [-0.24, 0.24]) {
+ createPart(`KickplateBolt_${sy > 0 ? 'T' : 'B'}_${sz > 0 ? 'R' : 'L'}`, sphereGeo(0.006, 8, 6), metalChrome, {
+ position: [0.134, 0.130 + sy, sz], parent: root,
+ });
+ }
+ }
+
+ // =========================================================================
+ // 6. LOWER FRONT & DOUBLE COIN DOOR (CSG COIN SLOTS)
+ // =========================================================================
+ createPart('CoinDoorBulkhead', boxGeo(0.020, 0.580, 0.592), woodBlack, {
+ position: [0.245, 0.530, 0], parent: root,
+ });
+
+ createPart('CoinDoorFrame', await roundedBoxGeo(0.024, 0.440, 0.360, 0.008), metalCast, {
+ position: [0.266, 0.530, 0], parent: root,
+ });
+
+ createPart('CoinDoorInner', await roundedBoxGeo(0.016, 0.410, 0.330, 0.006), metalDoorFace, {
+ position: [0.274, 0.530, 0], parent: root,
+ });
+
+ createPart('CoinDoorCenterRib', boxGeo(0.018, 0.410, 0.012), metalCast, {
+ position: [0.278, 0.530, 0], parent: root,
+ });
+
+ createPart('CoinLockBezel', cylinderXGeo(0.013, 0.013, 0.016, 16), metalChrome, {
+ position: [0.284, 0.705, 0], parent: root,
+ });
+ createPart('CoinLockCore', cylinderXGeo(0.008, 0.008, 0.018, 12), metalZinc, {
+ position: [0.286, 0.705, 0], parent: root,
+ });
+ createPart('CoinLockSlot', boxGeo(0.020, 0.008, 0.002), metalCast, {
+ position: [0.287, 0.705, 0], parent: root,
+ });
+
+ createPart('InsertCoinBadge', boxGeo(0.003, 0.022, 0.160), metalZinc, {
+ position: [0.282, 0.655, 0], parent: root,
+ });
+
+ const bezelGeo = await roundedBoxGeo(0.016, 0.076, 0.066, 0.004);
+
+ const bezelL = new THREE.Mesh(bezelGeo, metalCast);
+ bezelL.position.set(0.280, 0.605, -0.075);
+ const slotCutterL = new THREE.Mesh(boxGeo(0.030, 0.032, 0.004), metalCast);
+ slotCutterL.position.set(0.280, 0.615, -0.075);
+ const coinSlotMeshL = await boolDiff('CoinSlotL', bezelL, slotCutterL, { smooth: true });
+ root.add(coinSlotMeshL);
+
+ const bezelR = new THREE.Mesh(bezelGeo, metalCast);
+ bezelR.position.set(0.280, 0.605, 0.075);
+ const slotCutterR = new THREE.Mesh(boxGeo(0.030, 0.032, 0.004), metalCast);
+ slotCutterR.position.set(0.280, 0.615, 0.075);
+ const coinSlotMeshR = await boolDiff('CoinSlotR', bezelR, slotCutterR, { smooth: true });
+ root.add(coinSlotMeshR);
+
+ for (const sz of [-0.075, 0.075]) {
+ const sideName = sz > 0 ? 'R' : 'L';
+ createPart(`CoinRejectBtn_${sideName}`, await roundedBoxGeo(0.014, 0.024, 0.038, 0.003), coinGlow, {
+ position: [0.288, 0.545, sz], parent: root,
+ });
+ createPart(`CoinRejectBezel_${sideName}`, await roundedBoxGeo(0.008, 0.030, 0.044, 0.002), plasticBlack, {
+ position: [0.283, 0.545, sz], parent: root,
+ });
+ }
+
+ for (const sz of [-0.075, 0.075]) {
+ const sideName = sz > 0 ? 'R' : 'L';
+ createPart(`CoinReturnPocket_${sideName}`, await roundedBoxGeo(0.024, 0.074, 0.068, 0.004), metalCast, {
+ position: [0.278, 0.385, sz], parent: root,
+ });
+ createPart(`CoinReturnFlap_${sideName}`, boxGeo(0.004, 0.052, 0.050), metalChrome, {
+ position: [0.284, 0.385, sz], rotation: [0, 0, 16], parent: root,
+ });
+ }
+
+ for (const sy of [-0.19, 0.19]) {
+ for (const sz of [-0.155, 0.155]) {
+ createPart(`CoinFrameBolt_${sy > 0 ? 'T' : 'B'}_${sz > 0 ? 'R' : 'L'}`, sphereGeo(0.005, 8, 6), metalChrome, {
+ position: [0.278, 0.530 + sy, sz], parent: root,
+ });
+ }
+ }
+
+ createPart('UnderCPShelf', boxGeo(0.125, 0.020, 0.592), woodBlack, {
+ position: [0.320, 0.835, 0], parent: root,
+ });
+
+ // =========================================================================
+ // 7. CONTROL PANEL (C.P.) ASSEMBLY & BUTTON ARRAYS
+ // =========================================================================
+ const cpSlopeRad = -0.410;
+ const cpSlopeDeg = -23.5;
+
+ createPart('ControlPanelDeck', boxGeo(0.252, 0.020, 0.590), woodBlack, {
+ position: [0.275, 0.990, 0], rotation: [0, 0, cpSlopeDeg], parent: root,
+ });
+
+ createPart('CPO_PlateP1', boxGeo(0.230, 0.002, 0.270), gameMaterial(0x101428, { roughness: 0.35, metalness: 0.05 }), {
+ position: [0.275 - 0.011 * Math.sin(cpSlopeRad), 0.990 + 0.011 * Math.cos(cpSlopeRad), -0.145],
+ rotation: [0, 0, cpSlopeDeg], parent: root,
+ });
+ createPart('CPO_PlateP2', boxGeo(0.230, 0.002, 0.270), gameMaterial(0x281014, { roughness: 0.35, metalness: 0.05 }), {
+ position: [0.275 - 0.011 * Math.sin(cpSlopeRad), 0.990 + 0.011 * Math.cos(cpSlopeRad), 0.145],
+ rotation: [0, 0, cpSlopeDeg], parent: root,
+ });
+
+ createPart('CPFrontNosing', cylinderZGeo(0.012, 0.012, 0.592, 20), metalCast, {
+ position: [0.392, 0.938, 0], parent: root,
+ });
+
+ for (const sz of [-0.298, 0.298]) {
+ createPart(`CPMountBracket_${sz > 0 ? 'R' : 'L'}`, boxGeo(0.180, 0.012, 0.008), metalZinc, {
+ position: [0.275, 0.990, sz], rotation: [0, 0, cpSlopeDeg], parent: root,
+ });
+ for (const sx of [-0.06, 0.06]) {
+ createPart(`CPMountBolt_${sz > 0 ? 'R' : 'L'}_${sx > 0 ? 'F' : 'B'}`, sphereGeo(0.005, 8, 6), metalChrome, {
+ position: [0.275 + sx * Math.cos(cpSlopeRad), 0.990 + sx * Math.sin(cpSlopeRad), sz + (sz > 0 ? 0.005 : -0.005)],
+ parent: root,
+ });
+ }
+ }
+
+ for (const sz of [-0.18, 0.18]) {
+ const pName = sz > 0 ? 'P2' : 'P1';
+ const startX = 0.198, startY = 1.025;
+ createPart(`StartBtnBezel_${pName}`, cylinderGeo(0.015, 0.016, 0.006, 16), plasticBlack, {
+ position: [startX, startY, sz], rotation: [0, 0, cpSlopeDeg], parent: root,
+ });
+ createPart(`StartBtnPlunger_${pName}`, cylinderGeo(0.011, 0.011, 0.008, 16), btnWhite, {
+ position: [startX - 0.003 * Math.sin(cpSlopeRad), startY + 0.003 * Math.cos(cpSlopeRad), sz],
+ rotation: [0, 0, cpSlopeDeg], parent: root,
+ });
+ }
+
+ const joystickZ = [-0.165, 0.165];
+ for (let p = 0; p < 2; p++) {
+ const jz = joystickZ[p];
+ const pName = p === 0 ? 'P1' : 'P2';
+ const ballMat = p === 0 ? btnRed : btnBlue;
+ const jBaseX = 0.280, jBaseY = 0.988;
+
+ createPart(`JoyMount_${pName}`, boxGeo(0.065, 0.004, 0.065), metalCast, {
+ position: [jBaseX, jBaseY + 0.010, jz], rotation: [0, 0, cpSlopeDeg], parent: root,
+ });
+
+ createPart(`JoyWasher_${pName}`, cylinderGeo(0.026, 0.026, 0.003, 24), rubberBlack, {
+ position: [jBaseX, jBaseY + 0.014, jz], rotation: [0, 0, cpSlopeDeg], parent: root,
+ });
+
+ const shaftLen = 0.052;
+ const nx = -Math.sin(cpSlopeRad), ny = Math.cos(cpSlopeRad);
+ createPart(`JoyShaft_${pName}`, cylinderGeo(0.005, 0.005, shaftLen, 16), metalChrome, {
+ position: [jBaseX + nx * (shaftLen / 2 + 0.014), jBaseY + ny * (shaftLen / 2 + 0.014), jz],
+ rotation: [0, 0, cpSlopeDeg], parent: root,
+ });
+
+ createPart(`JoyBall_${pName}`, sphereGeo(0.018, 20, 16), ballMat, {
+ position: [jBaseX + nx * (shaftLen + 0.022), jBaseY + ny * (shaftLen + 0.022), jz],
+ parent: root,
+ });
+ }
+
+ const buttonColorsP1 = [
+ [btnRed, btnBlue, btnYellow],
+ [btnGreen, btnWhite, btnOrange],
+ ];
+ const buttonColorsP2 = [
+ [btnBlue, btnYellow, btnRed],
+ [btnWhite, btnGreen, btnOrange],
+ ];
+
+ const buttonDefs = [
+ { pName: 'P1', centerZ: -0.165, colors: buttonColorsP1 },
+ { pName: 'P2', centerZ: 0.165, colors: buttonColorsP2 },
+ ];
+
+ for (const bDef of buttonDefs) {
+ const { pName, centerZ, colors } = bDef;
+ for (let row = 0; row < 2; row++) {
+ for (let col = 0; col < 3; col++) {
+ const localX = 0.022 - row * 0.036 + (col === 2 ? 0.006 : 0);
+ const localZ = 0.052 + col * 0.034;
+ const bz = pName === 'P1' ? centerZ + localZ : centerZ - localZ;
+
+ const bx = 0.280 + localX * Math.cos(cpSlopeRad);
+ const by = 0.988 + localX * Math.sin(cpSlopeRad) + 0.012;
+
+ createPart(`BtnBezel_${pName}_r${row}_c${col}`, cylinderGeo(0.015, 0.016, 0.007, 20), plasticBlack, {
+ position: [bx, by, bz], rotation: [0, 0, cpSlopeDeg], parent: root,
+ });
+
+ const plungerMat = colors[row][col];
+ createPart(`BtnPlunger_${pName}_r${row}_c${col}`, cylinderGeo(0.011, 0.011, 0.009, 20), plungerMat, {
+ position: [bx - 0.002 * Math.sin(cpSlopeRad), by + 0.002 * Math.cos(cpSlopeRad), bz],
+ rotation: [0, 0, cpSlopeDeg], parent: root,
+ });
+ }
+ }
+ }
+
+ // =========================================================================
+ // 8. MONITOR HOUSING, CRT SCREEN (WITH SCANLINES) & REAL GLASS COVER
+ // =========================================================================
+ const monitorAngleDeg = 73.3;
+ const monitorRad = (monitorAngleDeg * Math.PI) / 180;
+ const monMidX = 0.100, monMidY = 1.240;
+
+ createPart('MonitorRearChamber', boxGeo(0.420, 0.180, 0.588), woodBlack, {
+ position: [monMidX - 0.090 * Math.sin(monitorRad), monMidY - 0.090 * Math.cos(monitorRad), 0],
+ rotation: [0, 0, monitorAngleDeg], parent: root,
+ });
+
+ createPart('MonitorBezelFrame', boxGeo(0.420, 0.024, 0.588), plasticBlack, {
+ position: [monMidX, monMidY, 0], rotation: [0, 0, monitorAngleDeg], parent: root,
+ });
+
+ createPart('MonitorBezelInner', boxGeo(0.310, 0.032, 0.410), plasticBlack, {
+ position: [monMidX, monMidY, 0], rotation: [0, 0, monitorAngleDeg], parent: root,
+ });
+
+ createPart('InstructionStrip', boxGeo(0.050, 0.034, 0.380), btnWhite, {
+ position: [monMidX + 0.145 * Math.cos(monitorRad), monMidY - 0.145 * Math.sin(monitorRad), 0],
+ rotation: [0, 0, monitorAngleDeg], parent: root,
+ });
+
+ const crtGeo = await uv(await roundedBoxGeo(0.270, 0.060, 0.370, 0.018, { style: 'round', segments: 16 }));
+ createPart('CRTScreen', crtGeo, crtScreenMat, {
+ position: [monMidX - 0.016 * Math.sin(monitorRad), monMidY - 0.016 * Math.cos(monitorRad), 0],
+ rotation: [0, 0, monitorAngleDeg], parent: root,
+ });
+
+ createPart('MonitorSafetyGlass', boxGeo(0.416, 0.006, 0.584), glass, {
+ position: [monMidX + 0.016 * Math.sin(monitorRad), monMidY + 0.016 * Math.cos(monitorRad), 0],
+ rotation: [0, 0, monitorAngleDeg], parent: root,
+ });
+
+ createPart('GlassRetainerBottom', boxGeo(0.016, 0.020, 0.590), metalCast, {
+ position: [0.165, 1.045, 0], parent: root,
+ });
+ createPart('GlassRetainerTop', boxGeo(0.016, 0.020, 0.590), metalCast, {
+ position: [0.045, 1.435, 0], parent: root,
+ });
+
+ for (const sz of [-0.22, 0, 0.22]) {
+ createPart(`GlassScrew_B_${sz < 0 ? 'L' : sz > 0 ? 'R' : 'M'}`, sphereGeo(0.004, 8, 6), metalChrome, {
+ position: [0.174, 1.045, sz], parent: root,
+ });
+ createPart(`GlassScrew_T_${sz < 0 ? 'L' : sz > 0 ? 'R' : 'M'}`, sphereGeo(0.004, 8, 6), metalChrome, {
+ position: [0.054, 1.435, sz], parent: root,
+ });
+ }
+
+ // =========================================================================
+ // 9. SPEAKER GRILLE & AUDIO (CSG SOUND HOLES)
+ // =========================================================================
+ const baffleMesh = new THREE.Mesh(boxGeo(0.155, 0.018, 0.588), woodBlack);
+
+ const speakerHoleCutters = [];
+ for (const zSpeaker of [-0.15, 0.15]) {
+ for (let dx = -0.038; dx <= 0.038; dx += 0.018) {
+ for (let dz = -0.038; dz <= 0.038; dz += 0.018) {
+ if (dx * dx + dz * dz <= 0.042 * 0.042) {
+ const cutter = new THREE.Mesh(cylinderGeo(0.0055, 0.0055, 0.040, 10), woodBlack);
+ cutter.position.set(dx, 0, zSpeaker + dz);
+ speakerHoleCutters.push(cutter);
+ }
+ }
+ }
+ }
+
+ const speakerBaffle = await boolDiff('SpeakerBaffle', baffleMesh, ...speakerHoleCutters, { smooth: true });
+ speakerBaffle.position.set(0.100, 1.490, 0);
+ speakerBaffle.rotation.z = Math.atan2(0.10, 0.12);
+ root.add(speakerBaffle);
+
+ const baffleRad = Math.atan2(0.10, 0.12);
+ for (const zSpeaker of [-0.15, 0.15]) {
+ const sideName = zSpeaker > 0 ? 'R' : 'L';
+ const spkX = 0.100 - 0.018 * Math.sin(baffleRad);
+ const spkY = 1.490 + 0.018 * Math.cos(baffleRad);
+
+ createPart(`SpeakerBasket_${sideName}`, torusGeo(0.046, 0.004, 8, 20), metalZinc, {
+ position: [spkX, spkY, zSpeaker], rotation: [0, 0, baffleRad * 180 / Math.PI + 90], parent: root,
+ });
+ createPart(`SpeakerCone_${sideName}`, cylinderGeo(0.042, 0.016, 0.018, 20), plasticBlack, {
+ position: [spkX, spkY, zSpeaker], rotation: [0, 0, baffleRad * 180 / Math.PI + 90], parent: root,
+ });
+ createPart(`SpeakerDustCap_${sideName}`, sphereGeo(0.012, 12, 10), metalChrome, {
+ position: [spkX + 0.008 * Math.sin(baffleRad), spkY - 0.008 * Math.cos(baffleRad), zSpeaker], parent: root,
+ });
+ }
+
+ // =========================================================================
+ // 10. ILLUMINATED MARQUEE HEADER
+ // =========================================================================
+ const marqueeAngleDeg = 74.7;
+ const marqueeMidX = 0.190, marqueeMidY = 1.650;
+
+ createPart('MarqueeSign', boxGeo(0.226, 0.005, 0.584), marqueeMat, {
+ position: [marqueeMidX, marqueeMidY, 0], rotation: [0, 0, marqueeAngleDeg], parent: root,
+ });
+
+ createPart('MarqueeFluorescentTube', cylinderZGeo(0.012, 0.012, 0.500, 16), fluorescentMat, {
+ position: [0.155, 1.650, 0], parent: root,
+ });
+ for (const sz of [-0.255, 0.255]) {
+ createPart(`TubeSocket_${sz > 0 ? 'R' : 'L'}`, boxGeo(0.024, 0.030, 0.018), btnWhite, {
+ position: [0.155, 1.650, sz], parent: root,
+ });
+ }
+
+ createPart('MarqueeBoxRoof', boxGeo(0.120, 0.018, 0.588), woodBlack, {
+ position: [0.160, 1.765, 0], parent: root,
+ });
+ createPart('MarqueeBoxFloor', boxGeo(0.120, 0.018, 0.588), woodBlack, {
+ position: [0.110, 1.545, 0], parent: root,
+ });
+
+ createPart('MarqueeRetainerBottom', await roundedBoxGeo(0.018, 0.020, 0.592, 0.003), metalCast, {
+ position: [0.160, 1.540, 0], parent: root,
+ });
+ createPart('MarqueeRetainerTop', await roundedBoxGeo(0.018, 0.020, 0.592, 0.003), metalCast, {
+ position: [0.220, 1.760, 0], parent: root,
+ });
+
+ for (const sz of [-0.22, 0, 0.22]) {
+ createPart(`MarqueeScrew_B_${sz < 0 ? 'L' : sz > 0 ? 'R' : 'M'}`, sphereGeo(0.004, 8, 6), metalChrome, {
+ position: [0.170, 1.540, sz], parent: root,
+ });
+ createPart(`MarqueeScrew_T_${sz < 0 ? 'L' : sz > 0 ? 'R' : 'M'}`, sphereGeo(0.004, 8, 6), metalChrome, {
+ position: [0.230, 1.760, sz], parent: root,
+ });
+ }
+
+ // =========================================================================
+ // 11. CABINET ROOF & POWER SWITCH
+ // =========================================================================
+ createPart('CabinetRoof', boxGeo(0.584, 0.022, 0.590), woodBlack, {
+ position: [-0.070, 1.730, 0], rotation: [0, 0, 7.8], parent: root,
+ });
+
+ createPart('RoofFanGrille', cylinderGeo(0.065, 0.065, 0.004, 24), metalCast, {
+ position: [-0.080, 1.745, 0], parent: root,
+ });
+
+ createPart('PowerSwitchBox', await roundedBoxGeo(0.040, 0.025, 0.060, 0.004), metalCast, {
+ position: [-0.260, 1.715, 0], parent: root,
+ });
+ createPart('PowerSwitchRocker', boxGeo(0.022, 0.012, 0.035), btnRed, {
+ position: [-0.260, 1.728, 0], rotation: [0, 0, 15], parent: root,
+ });
+
+ // =========================================================================
+ // 12. REAR PANEL, VENT SLOTS (ARRAYED), SERVICE DOOR & POWER
+ // =========================================================================
+ createPart('RearWall', boxGeo(0.020, 1.640, 0.590), woodBlack, {
+ position: [-0.355, 0.860, 0], parent: root,
+ });
+
+ const ventSlot0 = createPart('VentSlot0', await roundedBoxGeo(0.012, 0.010, 0.380, 0.003), metalCast, {
+ position: [-0.356, 1.340, 0], parent: root,
+ });
+ arrayLinear('VentSlot', ventSlot0, 9, [0, 0.026, 0], root);
+
+ createPart('ServiceDoor', await roundedBoxGeo(0.016, 0.820, 0.520, 0.006), woodDoor, {
+ position: [-0.360, 0.720, 0], parent: root,
+ });
+
+ createPart('ServiceLockBezel', cylinderXGeo(0.012, 0.012, 0.018, 16), metalChrome, {
+ position: [-0.368, 1.100, 0], parent: root,
+ });
+ createPart('ServiceLockCore', cylinderXGeo(0.008, 0.008, 0.020, 12), metalZinc, {
+ position: [-0.369, 1.100, 0], parent: root,
+ });
+
+ for (const sy of [-0.32, 0.32]) {
+ createPart(`ServiceHingeLeaf_${sy > 0 ? 'T' : 'B'}`, boxGeo(0.006, 0.050, 0.040), metalZinc, {
+ position: [-0.367, 0.720 + sy, -0.250], parent: root,
+ });
+ createPart(`ServiceHingePin_${sy > 0 ? 'T' : 'B'}`, cylinderGeo(0.006, 0.006, 0.056, 12), metalCast, {
+ position: [-0.368, 0.720 + sy, -0.250], parent: root,
+ });
+ }
+
+ createPart('ServiceDoorLatch', await roundedBoxGeo(0.014, 0.040, 0.080, 0.005), metalCast, {
+ position: [-0.366, 0.720, 0.210], parent: root,
+ });
+
+ createPart('PowerInletHousing', await roundedBoxGeo(0.016, 0.050, 0.040, 0.004), plasticBlack, {
+ position: [-0.362, 0.160, -0.160], parent: root,
+ });
+ createPart('PowerStrainRelief', cylinderXGeo(0.010, 0.007, 0.040, 12), rubberBlack, {
+ position: [-0.380, 0.160, -0.160], parent: root,
+ });
+ createPart('PowerCordDrop', cylinderGeo(0.006, 0.006, 0.120, 10), rubberBlack, {
+ position: [-0.395, 0.100, -0.160], parent: root,
+ });
+
+ for (const sy of [-0.14, 0.14]) {
+ createPart(`CordCleat_${sy > 0 ? 'T' : 'B'}`, boxGeo(0.035, 0.020, 0.025), plasticBlack, {
+ position: [-0.370, 0.400 + sy, -0.160], parent: root,
+ });
+ }
+
+ createPart('WarningBadge', boxGeo(0.002, 0.045, 0.075), gameMaterial(0xffcc00, { roughness: 0.4, metalness: 0.05 }), {
+ position: [-0.366, 0.240, -0.160], parent: root,
+ });
+
+ createPart('SpecBadge', boxGeo(0.002, 0.060, 0.090), metalZinc, {
+ position: [-0.366, 1.220, 0.140], parent: root,
+ });
+
+ return root;
+}
diff --git a/examples/diving-helmet.kiln.js b/examples/diving-helmet.kiln.js
index 7fb27022..1dbbf13e 100644
--- a/examples/diving-helmet.kiln.js
+++ b/examples/diving-helmet.kiln.js
@@ -41,6 +41,9 @@
// chest and back panel and shoulders that are not on any conic section. Getting
// that would mean lofting or deforming a shell rather than revolving one, which
// is a different construction than the one this example exists to show.
+//
+// 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.
const meta = { name: 'DivingHelmet', category: 'prop', role: 'poi' };
async function build() {
diff --git a/examples/field-gun.kiln.js b/examples/field-gun.kiln.js
index b88f81be..52f54055 100644
--- a/examples/field-gun.kiln.js
+++ b/examples/field-gun.kiln.js
@@ -9,6 +9,9 @@
// Every surface carries a procedural albedo plus a derived normal map, so the
// difference between the CPU rasterizer and a GPU PBR render is the whole story
// the contact sheet tells.
+//
+// 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.
const meta = { name: 'FieldGun', category: 'prop', role: 'poi' };
async function build() {
diff --git a/examples/mech.kiln.js b/examples/mech.kiln.js
new file mode 100644
index 00000000..e1562e8a
--- /dev/null
+++ b/examples/mech.kiln.js
@@ -0,0 +1,372 @@
+// A reverse-jointed industrial walker.
+//
+// Every other hero in this repository is a thing that exists, and the reference
+// does the arguing. A mech has no reference photograph, so the only thing
+// holding it together is INTERNAL CONSISTENCY: the joints have to be joints, the
+// pistons have to shorten when the leg folds, the armour has to be panels with
+// edges and fasteners rather than a shrink-wrap, and every plate has to look
+// like it was bolted on by someone who could reach it.
+//
+// The technique this file exists for is orienting flat armour along a bone.
+// beamBetween will run a cylinder between any two points, which is why limbs
+// built from it read as pipe-cleaners. A mech needs flat plate, and a box only
+// aligns to a bone if you rotate it. Both legs lie in a plane of constant Z, so
+// the whole rotation collapses to one angle about Z:
+//
+// rotZ = -atan2(dx, dy)
+//
+// measured from +Y, which is the axis a box's height runs along. That one line
+// is what lets armour, hydraulics and hardpoints all be placed by naming two
+// joint positions instead of by guessing Euler triples.
+//
+// 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.
+const meta = { name: 'Walker', category: 'vehicle', role: 'hero' };
+
+async function build() {
+ const root = createRoot('Walker');
+ const uv = (g) => autoUnwrap(g, { resolution: 1024 });
+ const D = Math.PI / 180;
+
+ // ---------- Bone maths ----------
+ const mid = (a, b) => [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2];
+ const dist = (a, b) => Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]);
+ const boneRot = (a, b) => -Math.atan2(b[0] - a[0], b[1] - a[1]) / D;
+ // Point a fraction f along a bone, for hanging hardpoints off it.
+ const along = (a, b, f) => [0, 1, 2].map((k) => a[k] + (b[k] - a[k]) * f);
+
+ // ---------- Materials ----------
+ const armorAlbedo = proceduralTexture({
+ schemaVersion: 2, size: 1024, usage: 'albedo', name: 'ArmorPlate',
+ layers: [
+ { op: 'solid', color: 0x55604f },
+ { op: 'noise', colorA: 0x424c3e, colorB: 0x6f7b67, scale: 40, octaves: 4, seed: 5, blend: 'overlay', opacity: 0.50 },
+ { op: 'noise', colorA: 0x38402f, colorB: 0x55604f, scale: 14, octaves: 3, seed: 23, blend: 'multiply', opacity: 0.14 },
+ ],
+ });
+ // Painted plate over armour steel. Paint is a DIELECTRIC: at high metalness
+ // this whole machine becomes a dark mirror and every panel edge disappears.
+ const armor = pbrMaterial({
+ albedo: armorAlbedo, normal: normalMapFromHeight(armorAlbedo, { strength: 1.6 }),
+ roughness: 0.52, metalness: 0.15,
+ });
+
+ const steelAlbedo = proceduralTexture({
+ schemaVersion: 2, size: 512, usage: 'albedo', name: 'MachinedSteel',
+ layers: [
+ { op: 'solid', color: 0x8d939a },
+ { op: 'noise', colorA: 0x767c83, colorB: 0xacb2b9, scale: 44, octaves: 3, seed: 11, blend: 'overlay', opacity: 0.50 },
+ ],
+ });
+ // Bare machined steel: rams, joint pins, the gun. This is the material that
+ // says which parts move.
+ const steel = pbrMaterial({
+ albedo: steelAlbedo, normal: normalMapFromHeight(steelAlbedo, { strength: 1.0 }),
+ roughness: 0.28, metalness: 0.94,
+ });
+
+ // Caution striping, on the pelvis and the pod cover -- the two places a crew
+ // chief would actually put it, because they are the two things that swing.
+ const hazardAlbedo = proceduralTexture({
+ schemaVersion: 2, size: 512, usage: 'albedo', name: 'Hazard',
+ layers: [
+ { op: 'stripes', colorA: 0xd6a11c, colorB: 0x1f1e1b, count: 7, angleDeg: 45 },
+ { op: 'noise', colorA: 0x3a3830, colorB: 0xbcbcb2, scale: 30, octaves: 4, seed: 31, blend: 'overlay', opacity: 0.35 },
+ ],
+ });
+ const hazard = pbrMaterial({
+ albedo: hazardAlbedo, normal: normalMapFromHeight(hazardAlbedo, { strength: 1.2 }),
+ roughness: 0.58, metalness: 0.10,
+ });
+
+ // A second, darker armour value. One paint colour over a five-metre machine
+ // flattens it: every plate reads at the same tone and the silhouette does all
+ // the work alone. Real vehicles are repainted in panels and the lower legs are
+ // the parts that get scuffed and resprayed, so darkening those separates the
+ // legs from the torso without inventing a fantasy colour.
+ const armorDarkAlbedo = proceduralTexture({
+ schemaVersion: 2, size: 1024, usage: 'albedo', name: 'ArmorPlateDark',
+ layers: [
+ { op: 'solid', color: 0x454f3a },
+ { op: 'noise', colorA: 0x363f2c, colorB: 0x5a664f, scale: 40, octaves: 4, seed: 5, blend: 'overlay', opacity: 0.50 },
+ { op: 'noise', colorA: 0x2c3323, colorB: 0x454f3a, scale: 14, octaves: 3, seed: 23, blend: 'multiply', opacity: 0.16 },
+ ],
+ });
+ const armorDark = pbrMaterial({
+ albedo: armorDarkAlbedo, normal: normalMapFromHeight(armorDarkAlbedo, { strength: 1.6 }),
+ roughness: 0.54, metalness: 0.15,
+ });
+
+ const hose = gameMaterial(0x17171a, { roughness: 0.90, metalness: 0.0 });
+ const canopy = glassMaterial(0x2b4f56, { opacity: 0.52, roughness: 0.05, metalness: 0 });
+ const glow = gameMaterial(0x9ff0ff, { emissive: 0x3ad6ee, emissiveIntensity: 3.2, roughness: 0.40 });
+
+ // ---------- Helpers ----------
+ const plate = async (name, w, h, d, r, position, opts = {}) =>
+ createPart(name, await uv(await roundedBoxGeo(w, h, d, r)), opts.mat ?? armor, {
+ position, rotation: opts.rotation, parent: opts.parent ?? root,
+ });
+
+ // Armour laid ALONG a bone: sized to the bone length, centred on it, and
+ // turned by the single Z angle derived above.
+ const boneArmor = async (name, a, b, w, d, r, grow = 0.0, mat = armor) =>
+ plate(name, w, dist(a, b) + grow, d, r, mid(a, b), { rotation: [0, 0, boneRot(a, b)], mat });
+
+ // A ring of fasteners around a panel edge. Bolts are the cheapest thing in the
+ // asset and they are most of what separates armour from a beveled cube.
+ const boltRow = (name, from, to, count, r = 0.024) => {
+ for (let i = 0; i < count; i++) {
+ const f = count === 1 ? 0.5 : i / (count - 1);
+ createPart(`${name}_${i}`, sphereGeo(r, 8, 6), steel, {
+ position: [0, 1, 2].map((k) => from[k] + (to[k] - from[k]) * f), parent: root,
+ });
+ }
+ };
+
+ // ---------- Legs ----------
+ // Digitigrade: the knee breaks FORWARD and high, the shin sweeps back, and the
+ // ankle sits over the middle of a long foot. A mech with human knees reads as
+ // a person in a costume.
+ for (const sz of [-1, 1]) {
+ const side = sz > 0 ? 'R' : 'L';
+ const HIP = [0.00, 2.58, sz * 0.44];
+ const KNEE = [0.48, 1.66, sz * 0.48];
+ const ANKLE = [-0.04, 0.56, sz * 0.46];
+
+ // Thigh: a steel ram inside a two-piece armour shell.
+ beamBetween(`ThighRam_${side}`, HIP, KNEE, 0.085, steel, { parent: root });
+ await boneArmor(`ThighPlate_${side}`, HIP, KNEE, 0.30, 0.40, 0.045, -0.18);
+ await boneArmor(`ThighShoulder_${side}`, HIP, along(HIP, KNEE, 0.34), 0.38, 0.48, 0.06, 0.0);
+
+ // Knee: a real pin joint, and an armour cap over it so the pin is not the
+ // outermost thing on the leg.
+ createPart(`KneePin_${side}`, cylinderZGeo(0.155, 0.155, 0.46, 20), steel, { position: KNEE, parent: root });
+ await plate(`KneeCap_${side}`, 0.34, 0.36, 0.20, 0.05, [KNEE[0] + 0.10, KNEE[1] + 0.02, KNEE[2] + sz * 0.28], {
+ rotation: [0, 0, -18], mat: armorDark,
+ });
+
+ // Shin. Darker paint below the knee, so the leg separates from the torso.
+ beamBetween(`ShinRam_${side}`, KNEE, ANKLE, 0.075, steel, { parent: root });
+ await boneArmor(`ShinPlate_${side}`, KNEE, ANKLE, 0.28, 0.42, 0.045, -0.16, armorDark);
+ await boneArmor(`ShinGuard_${side}`, along(KNEE, ANKLE, 0.10), along(KNEE, ANKLE, 0.62), 0.16, 0.50, 0.04, 0.0, armorDark);
+
+ // Hydraulics. Each is a sleeve on the fixed half and a bright rod on the
+ // moving half, offset OUTBOARD of the armour so it is visible -- a piston
+ // buried inside a limb is triangles nobody will ever see.
+ const hipAnchor = [HIP[0] - 0.20, HIP[1] - 0.10, HIP[2] + sz * 0.34];
+ const thighMid = along(HIP, KNEE, 0.58);
+ const thighRamEnd = [thighMid[0] - 0.10, thighMid[1], thighMid[2] + sz * 0.34];
+ beamBetween(`ThighPistonRod_${side}`, hipAnchor, thighRamEnd, 0.038, steel, { parent: root });
+ await boneArmor(`ThighPistonBody_${side}`, hipAnchor, mid(hipAnchor, thighRamEnd), 0.10, 0.10, 0.03, 0.0, steel);
+
+ const kneeAnchor = [KNEE[0] + 0.06, KNEE[1] - 0.14, KNEE[2] + sz * 0.36];
+ const ankleAnchor = [ANKLE[0] + 0.02, ANKLE[1] + 0.16, ANKLE[2] + sz * 0.34];
+ beamBetween(`ShinPistonRod_${side}`, kneeAnchor, ankleAnchor, 0.034, steel, { parent: root });
+ await boneArmor(`ShinPistonBody_${side}`, kneeAnchor, mid(kneeAnchor, ankleAnchor), 0.09, 0.09, 0.028, 0.0, steel);
+
+ // Hydraulic lines, sagging the way a hose does rather than running straight.
+ const hosePath = bezierCurve([
+ [HIP[0] - 0.28, HIP[1] - 0.16, HIP[2] + sz * 0.10],
+ [KNEE[0] - 0.34, KNEE[1] + 0.42, KNEE[2] + sz * 0.06],
+ [KNEE[0] - 0.10, KNEE[1] - 0.10, KNEE[2] + sz * 0.02],
+ [ANKLE[0] - 0.10, ANKLE[1] + 0.20, ANKLE[2] + sz * 0.04],
+ ], 26);
+ createPart(`HydraulicLine_${side}`, curveToMesh(hosePath, 0.030, 26, 8), hose, { parent: root });
+
+ // Ankle and foot. The foot is an extruded wedge, not a box: a walker that
+ // carries eight tonnes needs a long toe and a heel spur, and the plan shape
+ // is the only thing selling the weight.
+ createPart(`AnklePin_${side}`, cylinderZGeo(0.125, 0.125, 0.40, 18), steel, {
+ position: [ANKLE[0], ANKLE[1] - 0.06, ANKLE[2]], parent: root,
+ });
+ const footOutline = [
+ [0.62, 0.00], [0.52, 0.19], [0.24, 0.27], [-0.16, 0.26],
+ [-0.42, 0.17], [-0.46, 0.00], [-0.42, -0.17], [-0.16, -0.26],
+ [0.24, -0.27], [0.52, -0.19],
+ ];
+ createPart(`Foot_${side}`, await uv(await extrudeProfile(footOutline, {
+ depth: 0.28, axis: 'y', bevel: 0.035,
+ })), armor, { position: [ANKLE[0] + 0.06, 0.14, ANKLE[2]], parent: root });
+ // The ankle pin has to actually REACH the foot. Left as a pin floating over a
+ // deck, the leg reads as two disconnected props -- the single most damaging
+ // error in the first render. A real walker carries the load through a clevis:
+ // two cheek plates straddling the pin, bolted down onto the foot deck.
+ for (const cz of [-1, 1]) {
+ await plate(`AnkleClevis_${side}${cz > 0 ? 'A' : 'B'}`, 0.34, 0.36, 0.07, 0.030,
+ [ANKLE[0] + 0.01, 0.45, ANKLE[2] + cz * 0.185], { mat: steel });
+ }
+ // Load-bearing column down the middle, so the joint is not just two fins.
+ beamBetween(`AnkleColumn_${side}`, [ANKLE[0], ANKLE[1] - 0.06, ANKLE[2]],
+ [ANKLE[0] + 0.04, 0.26, ANKLE[2]], 0.105, steel, { parent: root });
+ // Toe claws.
+ for (const tz of [-1, 0, 1]) {
+ createPart(`Toe_${side}${tz + 1}`, await uv(await roundedBoxGeo(0.26, 0.12, 0.17, 0.030)), steel, {
+ position: [ANKLE[0] + 0.72, 0.075, ANKLE[2] + tz * 0.20], parent: root,
+ });
+ }
+ createPart(`HeelSpur_${side}`, await uv(await roundedBoxGeo(0.20, 0.14, 0.26, 0.035)), steel, {
+ position: [ANKLE[0] - 0.50, 0.085, ANKLE[2]], parent: root,
+ });
+
+ // Hip actuator housing.
+ createPart(`HipPin_${side}`, cylinderZGeo(0.185, 0.185, 0.30, 20), steel, {
+ position: [HIP[0], HIP[1], HIP[2] + sz * 0.06], parent: root,
+ });
+ await plate(`HipHousing_${side}`, 0.52, 0.50, 0.26, 0.06, [HIP[0], HIP[1], HIP[2] + sz * 0.20]);
+ }
+
+ // ---------- Pelvis and waist ----------
+ await plate('Pelvis', 0.92, 0.62, 1.06, 0.09, [0, 2.62, 0]);
+ // The caution panel goes on the swinging cover, not on a random flat.
+ await plate('PelvisCover', 0.10, 0.40, 0.72, 0.03, [0.50, 2.56, 0], { mat: hazard });
+ boltRow('PelvisBolt', [0.48, 2.80, -0.40], [0.48, 2.80, 0.40], 5);
+ createPart('WaistRing', cylinderGeo(0.34, 0.34, 0.26, 24), steel, { position: [0, 3.03, 0], parent: root });
+ createPart('WaistCollar', torusGeo(0.36, 0.045, 8, 28), steel, { position: [0, 3.14, 0], parent: root });
+
+ // ---------- Torso ----------
+ await plate('Torso', 1.02, 0.98, 1.26, 0.10, [0.02, 3.60, 0]);
+ // Sloped glacis over the chest, because a flat vertical front is the one thing
+ // no armoured machine has ever had.
+ await plate('Glacis', 0.24, 0.86, 1.16, 0.05, [0.50, 3.62, 0], { rotation: [0, 0, 16] });
+ boltRow('GlacisBoltT', [0.60, 3.98, -0.48], [0.60, 3.98, 0.48], 7, 0.022);
+ boltRow('GlacisBoltB', [0.56, 3.24, -0.48], [0.56, 3.24, 0.48], 7, 0.022);
+
+ // Reactor and heat sink on the back, with real fins.
+ await plate('ReactorHousing', 0.44, 0.80, 0.98, 0.07, [-0.66, 3.58, 0]);
+ for (let i = 0; i < 9; i++) {
+ createPart(`HeatFin_${i}`, await uv(await roundedBoxGeo(0.16, 0.62, 0.05, 0.012)), steel, {
+ position: [-0.90, 3.58, -0.40 + i * 0.10], parent: root,
+ });
+ }
+ createPart('ReactorGlow', await uv(await roundedBoxGeo(0.06, 0.44, 0.72, 0.02)), glow, {
+ position: [-0.86, 3.58, 0], parent: root,
+ });
+
+ // ---------- Cockpit ----------
+ // The canopy is a real inset: frame first, glass behind it. Glass flush with
+ // the hull reads as a painted rectangle.
+ await plate('CanopyFrame', 0.14, 0.60, 0.86, 0.04, [0.62, 3.70, 0], { rotation: [0, 0, 16] });
+ createPart('Canopy', await uv(await roundedBoxGeo(0.09, 0.48, 0.74, 0.03)), canopy, {
+ position: [0.64, 3.70, 0], rotation: [0, 0, 16], parent: root,
+ });
+ createPart('CockpitGlow', await uv(await roundedBoxGeo(0.03, 0.30, 0.56, 0.01)), glow, {
+ position: [0.55, 3.68, 0], rotation: [0, 0, 16], parent: root,
+ });
+ // Grab handle and the step a pilot uses to get in. Somebody has to board this.
+ beamBetween('BoardingHandle', [0.66, 3.24, 0.44], [0.66, 3.06, 0.44], 0.022, steel, { parent: root });
+ createPart('BoardingStep', await uv(await roundedBoxGeo(0.22, 0.06, 0.30, 0.02)), steel, {
+ position: [0.56, 2.90, 0.44], parent: root,
+ });
+
+ // ---------- Sensor head ----------
+ await plate('SensorHead', 0.52, 0.34, 0.72, 0.07, [0.16, 4.28, 0]);
+ createPart('SensorNeck', cylinderGeo(0.14, 0.16, 0.20, 16), steel, { position: [0.16, 4.10, 0], parent: root });
+ createPart('EyeSlit', await uv(await roundedBoxGeo(0.05, 0.10, 0.54, 0.02)), glow, {
+ position: [0.43, 4.28, 0], parent: root,
+ });
+ await plate('EyeBrow', 0.16, 0.09, 0.62, 0.02, [0.40, 4.40, 0], { rotation: [0, 0, 22] });
+ for (const sz of [-1, 1]) {
+ beamBetween(`Antenna_${sz > 0 ? 'R' : 'L'}`,
+ [-0.02, 4.42, sz * 0.26], [-0.16, 5.02, sz * 0.36], 0.014, steel, { parent: root });
+ createPart(`AntennaTip_${sz > 0 ? 'R' : 'L'}`, sphereGeo(0.032, 10, 8), glow, {
+ position: [-0.16, 5.02, sz * 0.36], parent: root,
+ });
+ }
+
+ // ---------- Shoulders ----------
+ for (const sz of [-1, 1]) {
+ const side = sz > 0 ? 'R' : 'L';
+ createPart(`ShoulderPin_${side}`, cylinderZGeo(0.20, 0.20, 0.34, 20), steel, {
+ position: [0.04, 3.74, sz * 0.74], parent: root,
+ });
+ await plate(`Pauldron_${side}`, 0.78, 0.62, 0.38, 0.10, [0.04, 3.86, sz * 0.94], { rotation: [0, 0, -8] });
+ boltRow(`PauldronBolt${side}`, [-0.26, 4.10, sz * 0.94], [0.30, 4.10, sz * 0.94], 4, 0.022);
+ }
+
+ // ---------- Right arm: autocannon ----------
+ {
+ const SH = [0.04, 3.66, 0.80];
+ const ELBOW = [0.20, 2.98, 0.92];
+ beamBetween('UpperArmRamR', SH, ELBOW, 0.085, steel, { parent: root });
+ await boneArmor('UpperArmPlateR', SH, ELBOW, 0.30, 0.34, 0.05, -0.14);
+ createPart('ElbowPinR', cylinderZGeo(0.135, 0.135, 0.34, 18), steel, { position: ELBOW, parent: root });
+
+ await plate('GunBody', 0.92, 0.40, 0.38, 0.06, [0.58, 2.92, 0.92]);
+ await plate('GunReceiver', 0.36, 0.30, 0.44, 0.05, [0.24, 2.92, 0.92], { mat: steel });
+ // A bored barrel, not a rod with a dark cap on the end. The bore is a real
+ // boolean, so it survives being looked at down the muzzle.
+ // First pass made this too thin and it read as a grey pipe. A cannon that
+ // fires something worth mounting on an eight-tonne chassis has a barrel you
+ // can see from the side, so every radius here went up by about half.
+ const barrelSolid = new THREE.Mesh(await revolveProfile([
+ [0.000, 1.02], [0.155, 1.02], [0.146, 1.16], [0.112, 1.30],
+ [0.106, 1.72], [0.132, 1.76], [0.132, 1.90], [0.000, 1.90],
+ ], { segments: 32, axis: 'x', smooth: true }), steel);
+ const bore = new THREE.Mesh(cylinderXGeo(0.062, 0.062, 1.10, 20), steel);
+ bore.position.set(1.46, 0, 0);
+ const barrel = await boolDiff('Barrel', barrelSolid, bore, { smooth: true });
+ barrel.name = 'Barrel';
+ barrel.geometry = await uv(barrel.geometry);
+ barrel.position.set(0, 2.92, 0.92);
+ root.add(barrel);
+ // Vented cooling shroud. The ring of slots down the jacket is the detail
+ // that actually says "autocannon" rather than "tube", and stacked rings
+ // cost far less than boring twenty real holes through the barrel.
+ for (let s = 0; s < 5; s++) {
+ const sx = 1.16 + s * 0.105;
+ createPart(`ShroudRing_${s}`, torusGeo(0.132, 0.020, 8, 20), steel, {
+ position: [sx, 2.92, 0.92], rotation: [0, 90, 0], parent: root,
+ });
+ }
+ // Muzzle brake ports.
+ for (const bz of [-1, 1]) {
+ createPart(`MuzzlePort_${bz > 0 ? 'R' : 'L'}`, await uv(await roundedBoxGeo(0.11, 0.06, 0.05, 0.014)), steel, {
+ position: [1.84, 2.92, 0.92 + bz * 0.115], parent: root,
+ });
+ }
+ // Ammo feed from the torso, as a chain of links rather than one grey tube.
+ const feed = bezierCurve([
+ [-0.10, 3.30, 0.62], [0.10, 3.16, 0.86], [0.16, 3.02, 0.94], [0.22, 2.98, 0.92],
+ ], 16);
+ createPart('AmmoFeed', curveToMesh(feed, 0.052, 16, 8), hose, { parent: root });
+ createPart('FeedCollar', torusGeo(0.062, 0.016, 8, 16), steel, {
+ position: [0.12, 3.14, 0.88], rotation: [40, 0, 30], parent: root,
+ });
+ }
+
+ // ---------- Left arm: missile pod ----------
+ {
+ const SH = [0.04, 3.66, -0.80];
+ const ELBOW = [0.18, 3.02, -0.92];
+ beamBetween('UpperArmRamL', SH, ELBOW, 0.085, steel, { parent: root });
+ await boneArmor('UpperArmPlateL', SH, ELBOW, 0.30, 0.34, 0.05, -0.14);
+ createPart('ElbowPinL', cylinderZGeo(0.135, 0.135, 0.34, 18), steel, { position: ELBOW, parent: root });
+
+ // Nine real tubes, bored through the block. Nine dark discs painted on a
+ // face is the version of this that falls apart the moment the camera moves.
+ const podSolid = new THREE.Mesh(await roundedBoxGeo(0.62, 0.72, 0.70, 0.06), armor);
+ const tubes = [];
+ for (let r = -1; r <= 1; r++) {
+ for (let c = -1; c <= 1; c++) {
+ const t = new THREE.Mesh(cylinderXGeo(0.088, 0.088, 0.80, 16), armor);
+ t.position.set(0.10, r * 0.215, c * 0.215);
+ tubes.push(t);
+ }
+ }
+ const pod = await boolDiff('MissilePod', podSolid, ...tubes, { smooth: true });
+ pod.name = 'MissilePod';
+ pod.geometry = await uv(pod.geometry);
+ pod.position.set(0.44, 2.98, -0.94);
+ root.add(pod);
+
+ await plate('PodCover', 0.09, 0.66, 0.16, 0.03, [0.76, 2.98, -1.34], { mat: hazard });
+ for (const hy of [-1, 1]) {
+ createPart(`PodHinge_${hy > 0 ? 'U' : 'D'}`, cylinderXGeo(0.030, 0.030, 0.16, 10), steel, {
+ position: [0.74, 2.98 + hy * 0.28, -1.30], parent: root,
+ });
+ }
+ boltRow('PodBolt', [0.12, 3.32, -1.24], [0.12, 2.64, -1.24], 4, 0.022);
+ }
+
+ return root;
+}
diff --git a/examples/penny-farthing.kiln.js b/examples/penny-farthing.kiln.js
index 755077c0..e62db3b0 100644
--- a/examples/penny-farthing.kiln.js
+++ b/examples/penny-farthing.kiln.js
@@ -15,6 +15,9 @@
// checked against the wheel radius at t = 0.25, 0.5 and 0.75 before it was
// rendered once, because a spline that passes through a 1.4 m wheel is not
// something a six-view contact sheet will necessarily show you.
+//
+// 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.
const meta = { name: 'PennyFarthing', category: 'vehicle', role: 'hero' };
async function build() {
diff --git a/examples/street-lamp.kiln.js b/examples/street-lamp.kiln.js
index 5f47e030..95a7153f 100644
--- a/examples/street-lamp.kiln.js
+++ b/examples/street-lamp.kiln.js
@@ -20,6 +20,9 @@
// 2. The lantern was scaled off the column instead of off a person. A real gas
// lamp head is roughly two feet tall and reads as the subject of the object;
// a small one turns the whole asset into a pole.
+//
+// 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.
const meta = { name: 'StreetLamp', category: 'prop', role: 'poi' };
async function build() {