teardown(R3): restore manifest runtime guards, dispose cleanup in Backdrop, and doc alignment
All checks were successful
Rat dev preview / Build dev preview (push) Successful in 3m58s
All checks were successful
Rat dev preview / Build dev preview (push) Successful in 3m58s
This commit is contained in:
parent
622b6cbc9f
commit
93bc3fb7e9
5 changed files with 38 additions and 10 deletions
|
|
@ -31,8 +31,8 @@ The ridge scene (`ridge/`): no per-frame WebGL (the baked cards are lit once per
|
|||
the heading (`ring.ts`), the viewer's offset and the camera's angle on its circle, as a camera on a circle round the bake centre sees it (ruling ridge-camera-on-circle;
|
||||
the offset is signed and clamped by `offsetRange`, the one clamp, by the mode: the forward bound with the camera on its heading, the worst-case bound where it circles; the speed by `maxSpeed`,
|
||||
what the baked resident count sustains, applied to the stored choice). `cameraState.ts` is the one owner of the viewer's mode, speed and offset in `ratatoskr.camera`; `heading.ts` owns the view's pose, the direction, the camera's angle over it and its offset, as one segment (module
|
||||
state: the pose at a clock, the mode and speed in force and the ease to the pose the choices owe; any change of a choice, a hold, a bound or reduced motion starts a new segment from the pose it has at that clock, `poseAt(t)` is a pure function of it, and a mode pick eases the angle and the offset one after the other, 300 ms each, in the order that keeps every pose inside the bound; `cameraState.ts` hands it each change synchronously before its listeners and keeps no log; `view.ts` `offsetRange`, given to it by the scene, is the one clamp; angles are normalized into [0, 360) before each stretch so nothing grows with uptime; a manual `hold` sets the mode to still, so a rebuild or a reload keeps it). The motion is one `Element.animate` per card (transform only, a
|
||||
keyframe each second for 30 s and every 50 ms while an ease runs, reissued at 80% and on any change; paused when the tab is hidden or motion is reduced, then constant); a 500 ms timer asks the backdrop for
|
||||
state: the pose at a clock, and the mode and bounded speed in force; any change of a choice, a hold, a bound or reduced motion starts a new segment from the pose it has at that clock with `phi` and `r` clamped directly, `poseAt(t)` is a pure function of it; `heading.ts` subscribes to `cameraState.ts` and keeps no log; `view.ts` `offsetRange`, given to it by the scene, is the one clamp; angles are normalized into [0, 360) before each stretch so nothing grows with uptime; a manual `hold` sets the mode to still, so a rebuild or a reload keeps it). The motion is one `Element.animate` per card (transform only, a
|
||||
keyframe each second for 30 s, reissued at 80% and on any change; paused when the tab is hidden or motion is reduced, then constant); a 500 ms timer asks the backdrop for
|
||||
the arc every pose of the next 30 s passes over (`view.ts` `sweepArc`, sampled four times a second, not its two ends) and mounts the tiles it has made. A still draws the sky and the tiles of the arc into the host canvas at the heading now. A failure
|
||||
anywhere (404, a manifest that is not schema 3, no tile that will decode, no WebGL2, a lighting pass that throws) is the sky-only scene on `FALLBACK_VIEW`,
|
||||
told to the host by the live scene alone, through `onPlanesFail` when the live scene has no cards and `onPlanesOk` when a later one has them (never from a stale
|
||||
|
|
|
|||
|
|
@ -158,7 +158,13 @@ export function createBackdrop(
|
|||
return b;
|
||||
})
|
||||
);
|
||||
if (disposed) return;
|
||||
if (disposed) {
|
||||
made.forEach((t) => {
|
||||
t.canvas.width = 0;
|
||||
t.canvas.height = 0;
|
||||
});
|
||||
return;
|
||||
}
|
||||
made.push({ tile, card, canvas: lighter.light({ colour, geometry }, tile, card) });
|
||||
}
|
||||
held.set(tile, made);
|
||||
|
|
|
|||
|
|
@ -606,7 +606,7 @@ export function createRidgeScene(opts: RidgeOptions): Scene | null {
|
|||
} else if (!paintSky(canvas, sky, undefined, w, h, makeCanvas).ok) return false;
|
||||
}
|
||||
if (opts.backdrop) {
|
||||
// The offsets this place and viewport allow, to the one owner of the pose: a rebuild at another size is a new bound, and the view eases from the pose it has.
|
||||
// The offsets this place and viewport allow, to the heading owner: a rebuild clamps directly from the pose it has.
|
||||
const { manifest } = opts.backdrop;
|
||||
const win = windowFor(manifest.view, w, h);
|
||||
setRange((mode, phi) => offsetRange(manifest, win, mode, phi), clock());
|
||||
|
|
|
|||
|
|
@ -65,6 +65,15 @@ describe('parseManifest', () => {
|
|||
expect(() => parseManifest({ ...w, camera: { r_max_m: 0, r_max_forward_m: 0 } }, '/')).toThrow(/camera/);
|
||||
expect(() => parseManifest({ ...w, camera: { r_max_m: 100, r_max_forward_m: 99 } }, '/')).toThrow(/camera/);
|
||||
expect(() => parseManifest({ ...w, encoding: { ...w.encoding, log_d_max: w.encoding.log_d_min } }, '/')).toThrow(/encoding/);
|
||||
for (const key of ['ring_w', 'tile_w', 'plane_h', 'px_per_deg_h', 'px_per_deg_v'] as const) {
|
||||
expect(() => parseManifest({ ...w, view: { ...w.view, [key]: 0 } }, '/')).toThrow(key);
|
||||
expect(() => parseManifest({ ...w, view: { ...w.view, [key]: -1 } }, '/')).toThrow(key);
|
||||
}
|
||||
expect(() =>
|
||||
parseManifest({ ...w, tiles: w.tiles.map((row: unknown[]) => [row[0], row[1], null]) }, '/')
|
||||
).toThrow(/cards\[2\]/);
|
||||
expect(() => parseManifest({ ...w, place: { ...w.place, tz: undefined } }, '/')).toThrow(/place\.tz/);
|
||||
expect(() => parseManifest({ ...w, place: { ...w.place, tz: 'Not/AZone' } }, '/')).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,16 @@ const num = (x: unknown, label: string): number => {
|
|||
if (typeof x !== 'number' || !Number.isFinite(x)) throw new Error(`ridge manifest ${label}: not a number`);
|
||||
return x;
|
||||
};
|
||||
const pos = (x: unknown, label: string): number => {
|
||||
const n = num(x, label);
|
||||
if (!(n > 0)) throw new Error(`ridge manifest ${label}: must be > 0`);
|
||||
return n;
|
||||
};
|
||||
const zone = (x: unknown): string => {
|
||||
if (typeof x !== 'string') throw new Error('ridge manifest place.tz: not a string');
|
||||
new Intl.DateTimeFormat('en-US', { timeZone: x });
|
||||
return x;
|
||||
};
|
||||
|
||||
export function parseIndex(raw: unknown): RidgeIndex {
|
||||
const r = asObj(raw, 'index');
|
||||
|
|
@ -102,6 +112,9 @@ export function parseManifest(raw: unknown, dir: string): RidgeManifest {
|
|||
};
|
||||
});
|
||||
});
|
||||
for (let i = 0; i < k; i += 1) {
|
||||
if (!grid.some((row) => row[i] !== null)) throw new Error(`ridge manifest cards[${i}]: empty across all tiles`);
|
||||
}
|
||||
const enc = asObj(r.encoding, 'manifest.encoding');
|
||||
const logDMin = num(enc.log_d_min, 'encoding.log_d_min');
|
||||
const logDMax = num(enc.log_d_max, 'encoding.log_d_max');
|
||||
|
|
@ -121,16 +134,16 @@ export function parseManifest(raw: unknown, dir: string): RidgeManifest {
|
|||
lat: num(p.lat, 'place.lat'),
|
||||
lon: num(p.lon, 'place.lon'),
|
||||
altitudeKm: num(p.altitude_km, 'place.altitude_km'),
|
||||
tz: String(p.tz ?? 'UTC'),
|
||||
tz: zone(p.tz),
|
||||
},
|
||||
lookAzDeg: num(v.look_az_deg, 'view.look_az_deg'),
|
||||
ringW: num(v.ring_w, 'view.ring_w'),
|
||||
tileW: num(v.tile_w, 'view.tile_w'),
|
||||
ringW: pos(v.ring_w, 'view.ring_w'),
|
||||
tileW: pos(v.tile_w, 'view.tile_w'),
|
||||
tiles,
|
||||
apron: num(v.apron, 'view.apron'),
|
||||
planeH: num(v.plane_h, 'view.plane_h'),
|
||||
pxPerDegH: num(v.px_per_deg_h, 'view.px_per_deg_h'),
|
||||
pxPerDegV: num(v.px_per_deg_v, 'view.px_per_deg_v'),
|
||||
planeH: pos(v.plane_h, 'view.plane_h'),
|
||||
pxPerDegH: pos(v.px_per_deg_h, 'view.px_per_deg_h'),
|
||||
pxPerDegV: pos(v.px_per_deg_v, 'view.px_per_deg_v'),
|
||||
horizonRow: num(v.horizon_row, 'view.horizon_row'),
|
||||
},
|
||||
encoding: { logDMin, logDMax },
|
||||
|
|
|
|||
Loading…
Reference in a new issue