An agent skill for creating detailed, interactive isometric illustrations of real-world machines and complex systems. Generates polished SVGs with optional WebGL shaders and 3D effects.
fix(drive): require a controller for turn and orbit actions
aakash-kharbe7d99a0eba49
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 89ba272..5403ee2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,6 +13,8 @@ All notable changes to Anatomy are recorded here. The format follows [Keep a Cha### Fixed+- Reject drive `turn` and `orbit` actions when the page has no callable 3D turn controller, instead of reporting an unchanged figure as a successful turn.+- Preserve configured pipe clearances in broad-phase solid and pipe sampling.- Observe replacement and late-mounted DOM targets through useInView.- Check texture line attachments against rounded rectangle corners, including separate radii, SVG clamping and transformed outlines.diff --git a/scripts/drive-turn-controller.test.mjs b/scripts/drive-turn-controller.test.mjsnew file mode 100644index 0000000..b5a7878--- /dev/null+++ b/scripts/drive-turn-controller.test.mjs@@ -0,0 +1,49 @@+import assert from "node:assert/strict";+import { execFile } from "node:child_process";+import { mkdtemp, rm, writeFile, access } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { promisify } from "node:util";+import test from "node:test";++const execute = promisify(execFile);+async function run(actions, script = "") {+ const directory = await mkdtemp(join(tmpdir(), "anatomy-driver-regression-"));+ try {+ const page = join(directory, "figure.html");+ const file = join(directory, "actions.json");+ const output = join(directory, "orbit.png");+ await writeFile(page, `<!doctype html><div class="iso-plate" style="width:240px;height:120px"><span data-readout>rest</span></div><script>${script}</script>`);+ await writeFile(file, JSON.stringify(typeof actions === "function" ? actions(output) : actions));+ let result;+ try { result = { code: 0, ...await execute(process.execPath, ["scripts/drive.mjs", page, "--actions", file], { timeout: 15000 }) }; }+ catch (error) { result = { code: error.code, stdout: error.stdout, stderr: error.stderr }; }+ result.hasImage = await access(output).then(() => true, () => false);+ console.log(JSON.stringify(result));+ return result;+ } finally { await rm(directory, { recursive: true, force: true }); }+}++for (const script of ["", "window.__isoTurn={}"])+ for (const action of ["turn", "orbit"])+ test(`${action} rejects a missing callable turn controller (${script || "absent"})`, async () => {+ const result = await run(out => [action === "turn" ? ["turn", 90] : ["orbit", out, 0, 90, 90], ["eval", "'AFTER_FAILED_TURN'"]], script);+ assert.equal(result.code, 1);+ assert.match(result.stderr, /requires window\.__isoTurn\.set/);+ assert.doesNotMatch(result.stdout, /AFTER_FAILED_TURN/);+ assert.equal(result.hasImage, false);+ });++const controller = "window.turns=[];window.__isoTurn={set(value){window.turns.push(value);document.querySelector('[data-readout]').textContent=JSON.stringify(value)}}";+test("turn preserves numeric, named-group and object poses", async () => {+ const result = await run([["turn", 90], ["turn", 0.5, "lift"], ["turn", {dial:45,lift:1}], ["eval", "window.turns"]], controller);+ assert.equal(result.code, 0);+ assert.match(result.stdout, /eval: \[90,\{"lift":0.5\},\{"dial":45,"lift":1\}\]/);+});++test("orbit still visits its requested poses and writes an image", async () => {+ const result = await run(out => [["orbit", out, 0, 90, 90], ["eval", "window.turns"]], controller);+ assert.equal(result.code, 0);+ assert.match(result.stdout, /eval: \[0,90\]/);+ assert.equal(result.hasImage, true);+});diff --git a/scripts/drive.mjs b/scripts/drive.mjsindex e8d60af..e93d198 100644--- a/scripts/drive.mjs+++ b/scripts/drive.mjs@@ -261,14 +261,14 @@ async function main() {} else if (kind === "turn") {const [value, group] = args;const call = group ? `window.__isoTurn.set(${JSON.stringify({ [group]: value })})` : `window.__isoTurn.set(${typeof value === "object" ? JSON.stringify(value) : Number(value)})`;- await evaluate(`(()=>{if(!window.__isoTurn)return false;${call};return new Promise((done)=>requestAnimationFrame(()=>requestAnimationFrame(()=>done(true))))})()`);+ await evaluate(`(()=>{if(typeof window.__isoTurn?.set!=="function")throw new Error("${kind} action requires window.__isoTurn.set");${call};return new Promise((done)=>requestAnimationFrame(()=>requestAnimationFrame(()=>done(true))))})()`);} else if (kind === "orbit") {const [out, from, to, step, selector, scale, region, columns] = args;const frames = [];const labels = [];for (let at = from; step > 0 ? at <= to + 1e-9 : at >= to - 1e-9; at += step) {const angle = Math.round(at * 1000) / 1000;- await evaluate(`(()=>{if(!window.__isoTurn)return false;window.__isoTurn.set(${angle});return new Promise((done)=>requestAnimationFrame(()=>requestAnimationFrame(()=>done(true))))})()`);+ await evaluate(`(()=>{if(typeof window.__isoTurn?.set!=="function")throw new Error("${kind} action requires window.__isoTurn.set");window.__isoTurn.set(${angle});return new Promise((done)=>requestAnimationFrame(()=>requestAnimationFrame(()=>done(true))))})()`);frames.push(await capture(selector, scale ?? 0.5, region));labels.push(`${angle}°`);}