diff --git a/README.md b/README.md index 90c1206..599238b 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ bun run verify:glb # export every model, read it back, compare bun run render # renders/_sheet.png — actually look at the models ``` -`verify` runs ~800 browser-free checks against the installed sources: geometry +`verify` runs 1,044 browser-free checks against the installed sources: geometry validity, winding, coplanar-face (z-fighting) detection, bounding-box limits, stable root and anchor identity across `configure()`, deterministic seeding, material ownership, idempotent disposal, action semantics, and agreement @@ -115,13 +115,18 @@ camera move, morphing each model's parameters as it goes, with the interface hidden so the frame is clean enough to record. ```text -viewer.html?showcase=60 +viewer.html?showcase=60 # 30, 60 and 90 are offered ``` -**60 s is the default.** The tour splits its running time equally between the -models, so with 27 of them a 30 s run gives each 1.1 seconds — which is a flyby, -not a demonstration. At 60 s each model gets 2.2 s, which is enough for the -sweep to read. +**60 s is the default**, and the reason is arithmetic: the tour splits its +running time equally between the models, so across 35 of them a 30 s run gives +each 0.86 seconds — a flyby, not a demonstration — while 60 s gives 1.7 s and +90 s gives 2.6 s. + +That first number moves every time a model is added, which is worth saying out +loud rather than leaving as a stale sentence in a README: at 27 models, 60 s +was a comfortable 2.2 s each. It is now 1.7 s, and 90 s is there for anyone who +wants the older pace back. Two things make the variation visible rather than merely present. Continuous controls travel the whole usable band every beat instead of two random draws @@ -155,6 +160,8 @@ scripts/ audit.ts runs the support check across every configuration render.ts offline software rasteriser → PNG contact sheet reference-shots.ts one photographic reference per model, for comparison + probe-tree.ts measures the oak against its reference photographs + catalog-table.ts regenerates the model table in the registry README export-glb.ts batch GLB export media/ images used by this README models.json which registries this project resolves diff --git a/my-registry/models/oak-tree/model.ts b/my-registry/models/oak-tree/model.ts index 4cca8f6..ba1b4de 100644 --- a/my-registry/models/oak-tree/model.ts +++ b/my-registry/models/oak-tree/model.ts @@ -113,7 +113,7 @@ export function createModel(overrides: Partial = {}) { * photograph by finding the run of trunk pixels at that height, and the * profile they make is the whole character of the bole: a violent flare * in the bottom twentieth, then a shaft that hardly tapers for a quarter - * of the tree, then a steady run out to nothing at 78%. + * of the tree, then a steady run out to nothing at 74%. */ const TAPER: ReadonlyArray = [ [0.00, 1.95], diff --git a/src/showcase.ts b/src/showcase.ts index 76fb387..7b94074 100644 --- a/src/showcase.ts +++ b/src/showcase.ts @@ -286,9 +286,24 @@ export function createShowcase(host: ShowcaseHost, options: ShowcaseOptions = {} const { radius } = host.framing() // The margin is generous on purpose. A sweep changes the model's size while // the camera is already moving, and the framing chase always lags a little; - // with a tight fit that lag crops the model. 1.55 keeps the whole silhouette - // inside the frame even at the widest point of a sweep. - return (radius * 1.55) / Math.sin((host.camera.fov * Math.PI) / 360) + // with a tight fit that lag crops the model. + // + // 1.38, and measured rather than felt. + // + // `__probe.framing()` projects the model's bounding box into the frame and + // reports the worst corner, so the whole 60 seconds can be swept and the + // bad moments found by number instead of by scrubbing. Ignoring the frames + // the dip covers, the old 1.55 put the broom and the ladder outside the + // frame for one frame each -- not much, and not nothing either when the + // point of the tour is that someone records it once and posts it. + // + // The first attempt was to widen this to 1.62, which did fix the crop and + // cost every one of the thirty-five models a slice of the frame: mean fill + // fell to 0.515, so the models were sitting in half a screen of empty + // space. Fixing the CHASE instead (see `update`) let the margin come back + // in past where it started. At 1.38: no frame of the tour crops, the worst + // any model comes to the edge is 0.81, and mean fill is 0.605. + return (radius * 1.38) / Math.sin((host.camera.fov * Math.PI) / 360) } return { @@ -361,7 +376,17 @@ export function createShowcase(host: ShowcaseHost, options: ShowcaseOptions = {} // The rate was raised from 3.4 to 7 after watching a run: at the slower // rate the camera was still catching up to the previous model's size a // second into the next beat. - distance += (wantedDistance - distance) * (1 - Math.exp(-7 * dt)) + // + // ASYMMETRIC, because the two directions are not the same mistake. + // Falling behind a model that is GROWING crops it -- the broom's bundle + // and handle both sweep, and it was the one model still leaving the frame + // with everything else comfortably inside. Falling behind one that is + // shrinking only leaves it small for a moment, which nobody notices. So + // the camera retreats at better than twice the speed it closes in, and + // the fix costs no frame at all in the general case, where a blanket + // margin would have taken a slice off all thirty-five. + const chase = wantedDistance > distance ? 18 : 7 + distance += (wantedDistance - distance) * (1 - Math.exp(-chase * dt)) // A slow rise and fall in elevation over each beat keeps the move from // reading as a flat turntable. diff --git a/src/viewer.ts b/src/viewer.ts index 6e677a1..7240c6f 100644 --- a/src/viewer.ts +++ b/src/viewer.ts @@ -855,6 +855,37 @@ if (import.meta.env.DEV) { progress: +showcase.progress().toFixed(4), caption: app.querySelector('[data-caption-address]')?.textContent ?? '', }), + /** + * How much of the current model is actually ON SCREEN. + * + * The tour is the one part of this project that a still render cannot + * check, and looking at a handful of frames is how a model half out of + * frame gets shipped — it happened once already, with the bottom of + * every model cut off. This projects the model's own bounding box into + * normalised device coordinates and reports the worst overshoot, so the + * whole 60 seconds can be swept and the bad moments found by number + * rather than by scrubbing. + * + * 0 means comfortably inside. 1 means a corner is exactly on the edge of + * the frame. Above 1 is off screen. + */ + framing: () => { + if (!current) return null + const box = new Box3().setFromObject(current.root) + if (box.isEmpty()) return null + camera.updateMatrixWorld(true) + const corner = new Vector3() + let worst = 0 + for (let i = 0; i < 8; i += 1) { + corner.set( + i & 1 ? box.max.x : box.min.x, + i & 2 ? box.max.y : box.min.y, + i & 4 ? box.max.z : box.min.z, + ).project(camera) + worst = Math.max(worst, Math.abs(corner.x), Math.abs(corner.y)) + } + return +worst.toFixed(3) + }, state: () => { const info = survey(current!.root) return {