diff --git a/media/kit.png b/media/kit.png index 48ded35..ecee56b 100644 Binary files a/media/kit.png and b/media/kit.png differ diff --git a/media/models.png b/media/models.png index 62e9de8..f3dbb12 100644 Binary files a/media/models.png and b/media/models.png differ diff --git a/models.lock.json b/models.lock.json index 791b1b5..85dfb78 100644 --- a/models.lock.json +++ b/models.lock.json @@ -82,7 +82,7 @@ "address": "@medieval-kit/core", "source": "file:my-registry/dist/registry.json", "version": "workspace", - "installedAt": "2026-08-23T12:45:30.043Z", + "installedAt": "2026-08-26T19:00:27.476Z", "files": [ { "path": "src\\models\\medieval-kit\\core\\geometry.ts", @@ -362,11 +362,11 @@ "address": "@medieval-kit/wooden-bench", "source": "file:my-registry/dist/registry.json", "version": "workspace", - "installedAt": "2026-08-23T09:56:44.514Z", + "installedAt": "2026-08-26T19:00:27.478Z", "files": [ { "path": "src\\models\\medieval-kit\\wooden-bench\\model.ts", - "sourceHash": "3b3468721c72911d1fd9eb54da61828cdc666c1b5a86871c5c5997ab9cc37533" + "sourceHash": "bb0aa806250a40e1bb52da17a79ba2c969327ef82a7b74d55b0819f9751e7d2c" } ], "dependencies": [ diff --git a/my-registry/models/wooden-bench/model.ts b/my-registry/models/wooden-bench/model.ts index bea13b4..de959e2 100644 --- a/my-registry/models/wooden-bench/model.ts +++ b/my-registry/models/wooden-bench/model.ts @@ -122,10 +122,34 @@ export function createModel(overrides: Partial = {}) { // so the joint is an overlap rather than two faces meeting. const footThickness = footWidth * 0.3 const footRise = archHeight + legHeight * 0.07 + + /** + * Each foot narrows on the way UP by exactly the board's own taper. + * + * This is the protrusion, and it was reported twice before I found it: + * the first time I planed the through-tenons and answered the wrong + * question. The feet were built at `footWidth`, the board's width at + * the GROUND -- but a foot starts at the top of the arch, a third of + * the way up, where the board has not widened that far yet. So every + * foot stood proud of the board it hangs from, on both sides, as a + * hard shoulder at shin height: 14 mm by default and 32 mm at full + * splay. Setting the splay to zero made it vanish, which is what + * finally named the cause. + * + * The leg's outer edge is a straight line from `footWidth / 2` at the + * floor to `legWidth / 2` under the seat, and the foot's outer face + * has to lie ON that line rather than run vertically up from its foot. + * A tapered box narrows about its own centre, so taking twice the + * taper off the top width moves the outer face in by exactly the taper + * -- and moves the inner face out by the same, which narrows the arch + * as it rises, which is also what a splayed leg does. + */ + const footTaper = spread * (footRise / legHeight) + const footTop = Math.max(footThickness * 0.3, footThickness - footTaper * 2) for (const foot of [-1, 1]) { legPieces.push(taperedBoxGeometry( [footThickness, timber * 1.35], - [footThickness * 0.92, timber * 1.35], + [footTop, timber * 1.35], footRise, [ side * legX + foot * (footWidth - footThickness) / 2, diff --git a/scripts/probe-bench.ts b/scripts/probe-bench.ts new file mode 100644 index 0000000..539b7ae --- /dev/null +++ b/scripts/probe-bench.ts @@ -0,0 +1,146 @@ +/** + * Measures what stands proud of the bench, and where. + * + * "There is something sticking out of the bench again" is a real report and an + * unmeasurable one. The first time it came in I planed the through-tenons from + * 42 mm to 3 and called it done — which answered the tenons rather than the + * question. The question is: over the whole thing a person sits on and swings + * their legs past, what stands proud, and by how much? + * + * Two measurements, because there turned out to be two kinds: + * + * 1. Above the SEAT. The tenons, and anything else ending up over the + * surface. 3 mm is a plane's shaving; 10 mm you feel; 40 mm you sit on. + * 2. A STEP in the leg's silhouette. A leg board that widens smoothly on the + * way down is a splayed leg; one that suddenly juts outward is a shoulder + * at shin height, and that is what was actually wrong. + * + * Both are swept across the sliders, because a bench that is smooth at one + * setting and studded at another is still a bench you would not sit on. + */ +import { Mesh, type Object3D } from 'three/webgpu' + +import { createModel } from '@/models/medieval-kit/wooden-bench/model.ts' + +/** Every triangle of a part as nine numbers. */ +function triangles(part: Object3D): number[][] { + const out: number[][] = [] + part.updateWorldMatrix(true, true) + part.traverse((child) => { + const mesh = child as Mesh + if (!mesh.isMesh) return + const pos = mesh.geometry.getAttribute('position') + for (let i = 0; i < pos.count; i += 3) { + const t: number[] = [] + for (let k = 0; k < 3; k += 1) { + t.push(pos.getX(i + k), pos.getY(i + k), pos.getZ(i + k)) + } + out.push(t) + } + }) + return out +} + +/** + * The silhouette's half-width at a height, by SLICING the triangles. + * + * The first version of this sampled vertices into height bands and reported a + * 0.0 mm step for a leg carrying a 17 mm shoulder. A tapered box has corners + * only at its top and its bottom, so every band between them came out empty, + * got skipped, and the comparison that would have caught the fault never ran — + * the same failure as a check that passes by not running. Cutting the actual + * triangles gives a width at any height, whether a corner happens to be there + * or not. + */ +function halfWidthAt(tris: number[][], y: number): number { + let widest = 0 + for (const t of tris) { + for (let e = 0; e < 3; e += 1) { + const a = e * 3 + const b = ((e + 1) % 3) * 3 + const ya = t[a + 1]! + const yb = t[b + 1]! + if (ya === yb) continue + if ((ya - y) * (yb - y) > 0) continue + const f = (y - ya) / (yb - ya) + widest = Math.max(widest, Math.abs(t[a]! + (t[b]! - t[a]!) * f)) + } + } + return widest +} + +const CASES: Array<[string, Record]> = [ + ['default', {}], + ['short', { length: 0.9 }], + ['long', { length: 2.4 }], + ['low', { height: 0.32 }], + ['tall', { height: 0.58 }], + ['narrow', { width: 0.2 }], + ['wide', { width: 0.42 }], + ['splayed', { splay: 0.5 }], + ['upright', { splay: 0 }], + ['inset out', { inset: 0.04 }], + ['inset in', { inset: 0.24 }], +] + +console.log('case above the seat worst step in the leg silhouette') +let worstProud = 0 +let worstStep = 0 +for (const [label, patch] of CASES) { + const model = createModel(patch as never) + + const seatTris = triangles(model.parts.seat.anchor) + const seatTop = Math.max(...seatTris.flatMap((t) => [t[1]!, t[4]!, t[7]!])) + const legTris = triangles(model.parts.legs.anchor) + const other = [ + ...legTris, + ...(model.parts.stretcher ? triangles(model.parts.stretcher.anchor) : []), + ] + const peak = Math.max(...other.flatMap((t) => [t[1]!, t[4]!, t[7]!])) + const proud = peak - seatTop + worstProud = Math.max(worstProud, proud) + + /** + * Walk up the leg BELOW THE SEAT. A shoulder shows as the width dropping. + * + * Stopping at the seat's underside is not a convenience, it is the + * difference between measuring the fault and measuring the design. Scanned + * to the full height of the part, the biggest drop is 66 mm at 86% of the + * way up — which is precisely where the leg board ends and only the through + * tenon carries on into the seat. That is what a tenon IS. Reporting it as a + * shoulder buries the real one, at the feet, under a bigger number that is + * not a fault at all. + */ + const seatBottom = Math.min(...seatTris.flatMap((t) => [t[1]!, t[4]!, t[7]!])) + const ys = legTris.flatMap((t) => [t[1]!, t[4]!, t[7]!]) + const low = Math.min(...ys) + const high = seatBottom + const steps = 220 + let drop = 0 + let at = 0 + let previous = halfWidthAt(legTris, low + (high - low) * 0.004) + for (let i = 1; i <= steps; i += 1) { + const f = 0.004 + (i / steps) * 0.98 + const w = halfWidthAt(legTris, low + (high - low) * f) + if (w > 0 && previous > 0 && previous - w > drop) { + drop = previous - w + at = f * 100 + } + if (w > 0) previous = w + } + worstStep = Math.max(worstStep, drop) + console.log( + `${label.padEnd(12)} ${(proud * 1000).toFixed(1).padStart(6)} mm ` + + `${(drop * 1000).toFixed(1).padStart(6)} mm at ${at.toFixed(0).padStart(2)}% of the leg`, + ) + model.dispose() +} + +console.log('') +console.log(`worst proud of the seat : ${(worstProud * 1000).toFixed(1)} mm`) +console.log(`worst shoulder on a leg : ${(worstStep * 1000).toFixed(1)} mm`) +if (worstProud > 0.006 || worstStep > 0.004) { + console.log('FAIL — you would feel that.') + process.exit(1) +} +console.log('Nothing on this bench catches.') diff --git a/src/models/medieval-kit/wooden-bench/model.ts b/src/models/medieval-kit/wooden-bench/model.ts index bea13b4..de959e2 100644 --- a/src/models/medieval-kit/wooden-bench/model.ts +++ b/src/models/medieval-kit/wooden-bench/model.ts @@ -122,10 +122,34 @@ export function createModel(overrides: Partial = {}) { // so the joint is an overlap rather than two faces meeting. const footThickness = footWidth * 0.3 const footRise = archHeight + legHeight * 0.07 + + /** + * Each foot narrows on the way UP by exactly the board's own taper. + * + * This is the protrusion, and it was reported twice before I found it: + * the first time I planed the through-tenons and answered the wrong + * question. The feet were built at `footWidth`, the board's width at + * the GROUND -- but a foot starts at the top of the arch, a third of + * the way up, where the board has not widened that far yet. So every + * foot stood proud of the board it hangs from, on both sides, as a + * hard shoulder at shin height: 14 mm by default and 32 mm at full + * splay. Setting the splay to zero made it vanish, which is what + * finally named the cause. + * + * The leg's outer edge is a straight line from `footWidth / 2` at the + * floor to `legWidth / 2` under the seat, and the foot's outer face + * has to lie ON that line rather than run vertically up from its foot. + * A tapered box narrows about its own centre, so taking twice the + * taper off the top width moves the outer face in by exactly the taper + * -- and moves the inner face out by the same, which narrows the arch + * as it rises, which is also what a splayed leg does. + */ + const footTaper = spread * (footRise / legHeight) + const footTop = Math.max(footThickness * 0.3, footThickness - footTaper * 2) for (const foot of [-1, 1]) { legPieces.push(taperedBoxGeometry( [footThickness, timber * 1.35], - [footThickness * 0.92, timber * 1.35], + [footTop, timber * 1.35], footRise, [ side * legX + foot * (footWidth - footThickness) / 2,