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 3D tube surface sampling in audit support checks
Stephen Cheng66236b6a4779
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8c9e657..47e0b99 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,6 +14,7 @@ All notable changes to Anatomy are recorded here. The format follows [Keep a Cha### Fixed+- `audit.mjs` `supports` samples stiff tube surfaces on rings perpendicular to each segment's tangent (`ringAround`) instead of flat horizontal `XY` circles, so horizontal and inclined tubes detect vertical and perpendicular support contacts and no longer bridge air gaps past their flat end caps.- `capture.mjs` waits for the page to load before it touches it, even with `--wait 0`, and gives up with an error when Chrome leaves a request unanswered for 60 s instead of hanging.- `drive.mjs` `until` times a condition inside the page, so one that is already true passes however short the wait, even on a slow machine; a promise that never settles still times out.- Start headless Chrome on Windows from an elevated terminal: `capture.mjs`, `drive.mjs` and `turn-check.mjs` pass `--do-not-de-elevate` there. Chrome otherwise relaunches itself without the elevation, the process the script started exits with code 0, and the check stops with `Chrome exited before startup: 0` while the relaunched browser stays running.diff --git a/kit/audit.mjs b/kit/audit.mjsindex 126ec0d..7fc3293 100644--- a/kit/audit.mjs+++ b/kit/audit.mjs@@ -1085,7 +1085,7 @@ function surfaceOf(shape, spacing = 0.6) {}}} else {- for (const { p, r } of samplesOf(shape, spacing)) for (let k = 0; k < 8; k++) points.push(add3(p, mul3([Math.cos((k * Math.PI) / 4), Math.sin((k * Math.PI) / 4), 0], r)));+ for (const sample of samplesOf(shape, spacing)) points.push(...ringAround(sample, sample.r));}return shape.cut ? points.filter((p) => cutDistance(shape, p) >= -1e-3) : points;}diff --git a/scripts/audit-tube-support.test.mjs b/scripts/audit-tube-support.test.mjsnew file mode 100644index 0000000..c3d3f96--- /dev/null+++ b/scripts/audit-tube-support.test.mjs@@ -0,0 +1,42 @@+import assert from "node:assert/strict";+import test from "node:test";+import * as A from "../kit/audit.mjs";++test("horizontal stiff tube resting on a grounded horizontal tube supports itself and mounted solids", () => {+ const base = A.tube([[0, 0, 0], [10, 0, 0]], 2, { name: "stand.base", ground: true });+ const upper = A.tube([[0, 0, 4], [10, 0, 4]], 2, { name: "upper" });+ const cross = A.tube([[5, -5, 8], [5, 5, 8]], 2, { name: "cross" });+ const cap = A.box([3, -1, 10], [7, 1, 12], { name: "cap" });+ assert.deepEqual(A.supports([cap], [base, upper, cross]), { loose: [], hanging: [], sunk: [] });+});++test("horizontal stiff tube separated from a wall beyond its flat end cap is reported hanging", () => {+ const wall = A.box([-4, -2, -2], [-1.8, 2, 2], { name: "stand.wall", ground: true });+ const pipe = A.tube([[0, 0, 0], [10, 0, 0]], 2, { name: "pipe" });+ const collar = A.box([4, -3, -3], [6, 3, 3], { name: "collar" });+ assert.ok(Math.abs(A.sdf(pipe, [-1.8, 0, 0]) - 1.8) < 1e-9);+ assert.deepEqual(A.supports([wall, collar], [pipe]), { loose: ["collar"], hanging: ["pipe"], sunk: [] });+});++test("horizontal stiff tube whose flat end cap touches a grounded wall is supported", () => {+ const wall = A.box([-4, -2, -2], [-0.05, 2, 2], { name: "stand.wall", ground: true });+ const pipe = A.tube([[0, 0, 0], [10, 0, 0]], 2, { name: "pipe" });+ const collar = A.box([4, -3, -3], [6, 3, 3], { name: "collar" });+ assert.deepEqual(A.supports([wall, collar], [pipe]), { loose: [], hanging: [], sunk: [] });+});++test("inclined stiff tubes detect perpendicular contact and reject perpendicular gaps", () => {+ const lower = A.tube([[0, 0, 0], [6, 0, 8]], 2, { name: "stand.lower", ground: true });+ const touching = A.tube([[-3.2, 0, 2.4], [2.8, 0, 10.4]], 2, { name: "touching" });+ const floating = A.tube([[-3.6, 0, 2.7], [2.4, 0, 10.7]], 2, { name: "floating" });+ assert.deepEqual(A.supports([], [lower, touching]), { loose: [], hanging: [], sunk: [] });+ assert.deepEqual(A.supports([], [lower, floating]), { loose: [], hanging: ["floating"], sunk: [] });+});++test("vertical stiff tubes and limp tubes preserve their support semantics", () => {+ const floor = A.box([-4, -4, -2], [4, 4, 0], { name: "stand.floor", ground: true });+ const column = A.tube([[0, 0, 0], [0, 0, 8]], 1.5, { name: "column" });+ const detached = A.tube([[0, 0, 10], [0, 0, 16]], 1.5, { name: "detached" });+ const cable = A.tube([[0, 0, 20], [10, 0, 20]], 1.5, { name: "cable", limp: true });+ assert.deepEqual(A.supports([floor], [column, detached, cable]), { loose: [], hanging: ["detached"], sunk: [] });+});