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(audit): honor configured clearance envelopes
Rudy Celekli7d256475eed5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex fe3a3ed..2114447 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,8 @@ All notable changes to Anatomy are recorded here. The format follows [Keep a Cha### Fixed+- Preserve configured pipe clearances in broad-phase solid and pipe sampling.+- `scripts/drive.mjs` now fails when a browser evaluation throws or rejects, rather than reporting a clean successful session.- The arcade cabinet now accepts coins with reduced motion enabled, preserving the meter, credit and power-on events when the coin animation is skipped.- The turning dial stops its idle tour when reduced motion is enabled while the page is open and cancels its pending automatic restart while preserving keyboard and pointer input.diff --git a/kit/audit.mjs b/kit/audit.mjsindex 7fa64e1..4c4a9fd 100644--- a/kit/audit.mjs+++ b/kit/audit.mjs@@ -883,6 +883,7 @@ export function clearances(tubes, solids, { ratio = 0.5, least = 0.2, spacing =};const poseOf = new Map([...tubes, ...solids].map((shape) => [shape, placed(shape, state)]));const offsets = new Map([...tubes, ...solids].map((shape) => [shape, offsetAt(shape, state)]));+ const widest = new Map(tubes.map((tube) => [tube, poseOf.get(tube).radii.reduce((r, next) => Math.max(r, next), 0)]));const together = (a, b) => len3(sub3(offsets.get(a), offsets.get(b))) < 0.05;const runsBy = new Map();for (const tube of tubes) runsBy.set(tube.owner, [...(runsBy.get(tube.owner) ?? []), tube]);@@ -927,9 +928,9 @@ export function clearances(tubes, solids, { ratio = 0.5, least = 0.2, spacing =if (matches(tube.touch, shape.name) || matches(shape.touch, tube.name)) continue;const other = poseOf.get(shape);const ob = boundsOf(other);- if (!overlaps(tb, ob, 4)) continue;+ if (!overlaps(tb, ob, Math.max(4, gapOf(widest.get(tube))))) continue;for (const sample of samples) {- if (!overlaps({ min: sample.p, max: sample.p }, ob, sample.r + 3)) continue;+ if (!overlaps({ min: sample.p, max: sample.p }, ob, sample.r + Math.max(3, gapOf(sample.r)))) continue;const gap = gapOf(sample.r);const clearance = clearanceTo(other, sample);if (clearance >= gap) continue;@@ -947,10 +948,13 @@ export function clearances(tubes, solids, { ratio = 0.5, least = 0.2, spacing =const tb = poseOf.get(tubes[b]);if (tubes[a].owner && tubes[a].owner === tubes[b].owner && tubes[a].joined) continue;if (matches(tubes[a].touch, tubes[b].name) || matches(tubes[b].touch, tubes[a].name)) continue;- if (!overlaps(boundsOf(ta), boundsOf(tb), 3)) continue;const bundled = tubes[a].bundle && tubes[a].bundle === tubes[b].bundle;+ const widestB = widest.get(tubes[b]);+ const envelope = bundled ? 3 : Math.max(3, gapOf(Math.min(widest.get(tubes[a]), widestB)));+ if (!overlaps(boundsOf(ta), boundsOf(tb), envelope)) continue;for (const sample of samples) {- if (!overlaps({ min: sample.p, max: sample.p }, boundsOf(tb), sample.r + 3)) continue;+ const envelope = bundled ? 3 : Math.max(3, gapOf(Math.min(sample.r, widestB)));+ if (!overlaps({ min: sample.p, max: sample.p }, boundsOf(tb), sample.r + envelope)) continue;const clearance = sample.edge >= sample.r ? sdf(tb, sample.p) - sample.r : Math.min(...ringAround(sample, sample.r).map((q) => sdf(tb, q)));const r = centreline(tb, sample.p).r;const gap = bundled ? touching : gapOf(Math.min(sample.r, r));diff --git a/scripts/audit-clearance-envelope.test.mjs b/scripts/audit-clearance-envelope.test.mjsnew file mode 100644index 0000000..5db50b0--- /dev/null+++ b/scripts/audit-clearance-envelope.test.mjs@@ -0,0 +1,39 @@+import assert from "node:assert/strict";+import test from "node:test";+import * as A from "../kit/audit.mjs";+const route = (x, r, name) => A.tube([[x, 0, 0], [x, 0, 200]], r, { name, owner: name });+const run = (tubes, solids, options = {}) => A.clearances(tubes, solids, { spacing: 10, mounts: new Map(), ...options });+test("large pipe detects the required clearance to a real solid", () => {+ const tube = route(0,20,"pipe"),solid = A.ball([29,0,100],1,{name:"solid"});+ assert.equal(A.sdf(solid,[20,0,100]),8);+ const result = run([tube],[solid]);+ assert.equal(result.length,1);assert.equal(result[0].kind,"close");assert.equal(result[0].need,10);assert.ok(Math.abs(result[0].clearance-8)<1e-8);+});+test("large parallel pipes detect required clearance in either order", () => {+ const tubes = [route(0,20,"first"),route(48,20,"second")];+ for(const input of [tubes,[...tubes].reverse()]){+ const result = run(input,[]);assert.equal(result.length,1);assert.equal(result[0].need,10);assert.equal(result[0].clearance,8);+ }+});+test("explicit least clearance also controls both broad phases", () => {+ const tube=route(0,1,"pipe"),solid=A.ball([10,0,100],1,{name:"solid"});+ assert.equal(run([tube],[solid],{least:10})[0]?.clearance,8);+ assert.equal(run([tube,route(10,1,"other")],[],{least:10})[0]?.clearance,8);+});+test("posed pipes retain their authored required clearance", () => {+ const tube={...route(0,20,"pipe"),move:[5,0,0],ride:"pipe"};+ const solid=A.ball([34,0,100],1,{name:"solid"});+ const result=run([tube],[solid],{state:{shares:{pipe:1},label:"apart"}});+ assert.equal(result.length,1);assert.equal(result[0].clearance,8);assert.equal(result[0].state,"apart");+});+test("healthy gaps, explicit smaller clearance and touch exemptions remain accepted", () => {+ const tube=route(0,20,"pipe");+ assert.equal(run([tube],[A.ball([32,0,100],1,{name:"solid"})]).length,0);+ assert.equal(run([tube],[A.ball([29,0,100],1,{name:"solid"})],{ratio:.1}).length,0);+ assert.equal(run([{...tube,touch:["solid"]}],[A.ball([29,0,100],1,{name:"solid"})]).length,0);+ assert.equal(run([tube,route(51,20,"other")],[]).length,0);+});+test("existing small penetrating and separated pipes keep their results", () => {+ assert.equal(run([route(0,1,"first"),route(1.5,1,"second")],[])[0]?.kind,"through");+ assert.equal(run([route(0,1,"first"),route(4,1,"second")],[]).length,0);+});