perf(viewer): fold streamed meshes into the camera-fit bounds as they commit, not all at stream end
What
When the camera fits on the first streamed batch, streaming stops calling the fit-bounds accumulator. The stream-end refit then scans every mesh that arrived after that point, in one main-thread task at the end of the load. The final refit is not a rescan by identity: pending.geometry is the same store array the early fit folded. It is a scan of everything appended since.
This PR folds each streamed commit into the robust fit bounds as it lands (RobustFitBoundsAccumulator.scan(), plus scanned()), from useGeometryStreaming, once the camera has fitted. The stream-end update() then only sorts and trims.
Identity
The fitted camera is unchanged by construction. The accumulator folds vertices in index order, and per-commit scans followed by update() give the same result as today's one-shot update().
- Unit tests (
robustFitBoundsAccumulator.test.ts): compact, georeferenced-origin and outlier-tail inputs. Per-commit scans followed byupdate()equalrobustFitBoundsFulland today's one-shot update. An array reset is covered. - Corpus (
streamingCompletionBounds.corpus.real-ifc.test.tsx): FZK, duplex, C20, dental clinic and advanced_model through the real loader, streamed in commits. The stream-end refit runs on a real Camera with and without per-commit scans, and the test requires the same pose, orbit anchor, scene bounds and fitted bounds in three settings:- as loaded;
- translated by (1234.5, ā567.25, 89.125) via per-element origins;
- with retained-kernel instanced-shard bounds outside the flat extent, through the refit's real union path.
Evidence (943794a452, Pop, fleet)
- Viewer unit tests: 107 pass, 0 fail.
- Corpus: 5 pass, 0 fail. The guard fails on a test file that did not load or on a short test count.
- The changeset commit (1087c75a71) touches no code.
Not yet
- No timed verdict. Its exclusive slot comes with the vertex step's (slot 70 in the campaign order).
- Not to be queued before that slot shows a gain with no regressing cell.
š¤ Generated with Claude Code
Summary by CodeRabbit
- Bug Fixes
- Improved camera framing during streamed geometry loading. As additional geometry arrives, it is included in the final fit, keeping the resulting camera view and scene bounds consistent with a full-model fit across tested models and loading conditions. This helps prevent final framing from overlooking geometry received after the initial camera fit, including in restored sessions.