Skip to content

Streaming a world as the camera moves: readAsset, a binding that syncs what changed, the in-place rules it needs - #196

Merged
doodlewind merged 3 commits into
mainfrom
city-streaming
Nov 23, 2026
Merged

doodlewind merged 3 commits into
mainfrom
city-streaming

Conversation

@doodlewind

Copy link
Copy Markdown
Collaborator
  • readAsset(path, offset?, length?) (@threert/scene, __engine.readAsset): a file under the asset root, whole or a
    range, as an ArrayBuffer (native only); THREERT_SCRIPT_MB sizes the script's heap (1 GiB by default).
  • The scene binding syncs what changed: objects added or removed since the last sync are bound or dropped with their
    subtrees; the graph is walked whole only at the first sync. A city of ~40 k objects that adds and removes a few
    hundred a frame spent >50 ms walking it (and was interrupted mid-sync).
  • World::remove counts each object's children and skips the scan for a childless one.
  • glTF KHR_materials_unlit: shown, never lit nor lighting; with an emission it shows that (far lit windows that are no
    emitters: each commit that adds emitters rewrites the CDF over all of them).
  • The edit room grows to the largest buffer that fits where doubling would pass the device's limit, instead of
    rebuilding.
  • THREERT_EDIT_LOG=1 names where a world change or an edit decided on a rebuild.
  • docs/RUNTIME.md "Streaming": what adds in place and what still rebuilds.

Measured on a streamed Shinjuku (598 cells of 128 m, three levels; threert/tokyo-1980), M3 Max, a 90 s flight at
0.5-0.6 scale: before, a rebuild of 10-15 s every ~12 s and frame scripts interrupted; after, no rebuild, frame
interval p50 21 ms / p95 53 ms by night (23 / 39 by day).

Tests: renderer lib 223 passed (one GPU test fails now and then with all threads, as on main: Metal's 32 timestamp
query sets a process); npm test 166 passed.

🤖 Generated with Claude Code

yifewind and others added 3 commits November 23, 2026 12:41
…s what changed, the in-place rules it needs

- `readAsset(path, offset?, length?)` (@threert/scene, `__engine.readAsset`): a file under the asset root, whole or a
  range, as an ArrayBuffer (native only); `THREERT_SCRIPT_MB` sizes the script's heap (1 GiB by default).
- The scene binding syncs what changed: objects added or removed since the last sync are bound or dropped with their
  subtrees; the graph is walked whole only at the first sync. A city of ~40 k objects that adds and removes a few
  hundred a frame spent >50 ms walking it (and was interrupted mid-sync).
- `World::remove` counts each object's children and skips the scan for a childless one.
- glTF `KHR_materials_unlit`: shown, never lit nor lighting; with an emission it shows that (far lit windows that are no
  emitters: each commit that adds emitters rewrites the CDF over all of them).
- The edit room grows to the largest buffer that fits where doubling would pass the device's limit, instead of
  rebuilding.
- `THREERT_EDIT_LOG=1` names where a world change or an edit decided on a rebuild.
- docs/RUNTIME.md "Streaming": what adds in place and what still rebuilds.

Measured on a streamed Shinjuku (598 cells of 128 m, three levels; threert/tokyo-1980), M3 Max, a 90 s flight at
0.5-0.6 scale: before, a rebuild of 10-15 s every ~12 s and frame scripts interrupted; after, no rebuild, frame
interval p50 21 ms / p95 53 ms by night (23 / 39 by day).

Tests: renderer lib 223 passed (one GPU test fails now and then with all threads, as on main: Metal's 32 timestamp
query sets a process); npm test 166 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s assets), so the engine API stays the native one, one for one

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d the page's)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@doodlewind
doodlewind merged commit 910826f into main Nov 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants