Repository navigation
Viewer CPU: one scene walk per frame, nested node batching (port of bottosson/performance) - #1232
Merged
Merged
Conversation
- scene-matrices: one dirty-tracked matrix update per frame instead of three's full update in every pass; subtrees nothing in the frame draws (batched originals, a soloed level's shadow-only content) are hidden for the render only and skipped by the walk while the layout revision holds. - Node batching reaches nodes nested under hosts (cabinet modules, items on items, wall/ceiling-hosted items); a host's edits, gestures and tint release what it carries. Cabinets, cabinet modules and shelves opt in. - Solo re-hide, shadow bounds and fences no longer walk the scene every frame. Waterfront 41-49 -> ~16 ms frame CPU, apartment 29 -> ~15 ms (dev build, RTX 3060 Ti, High tier). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Item batches skip the per-pass depth sort (opaque; the prepass lays depth). - Fog samples a cloud-free horizon radiance: the clouds fade out at the fog's elevation, so the two fbm calls per fragment and cloudTime (which moved every frame) drop out of every fogged material. - The room light's level arrays move to a shared uniform group bumped only when a level moves: as per-object array uniforms they were re-uploaded for every object in every pass (~760 writeBuffer a frame in the apartment, now 1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sort - The occlusion culler (#1228) runs inside the render, where `renderWithSceneMatrices` hides subtrees nothing draws: the merged originals it rasterizes as walls and slabs. They count as shown again (`isSetAsideForRender`), as the merged outline already does; test added. - Item batches keep three's front-to-back sort: `sortObjects = false` was justified by the depth pre-pass, which #1228 removed, and on a GPU-bound editor the overdraw costs more than the sort saves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cc958c4. Configure here.
| const overrides = useLiveNodeOverrides.getState() | ||
| if (overrides.get(nodeId as AnyNodeId) || useLiveTransforms.getState().get(nodeId)) return null | ||
| if (batchable.scope === 'wall' && node.parentId && overrides.get(node.parentId as AnyNodeId)) { | ||
| const liveTransforms = useLiveTransforms.getState() |
There was a problem hiding this comment.
Redundant useLiveTransforms.getState() call before variable declaration
Low Severity
useLiveTransforms.getState() is called inline at the end of line 172 to check the node itself, and then called again on line 173 to store in liveTransforms for the hostsBusy check. The variable declared on line 173 could be hoisted above line 172 and reused in both places, avoiding the redundant state access.
Reviewed by Cursor Bugbot for commit cc958c4. Configure here.
Moving an item (e.g. a bedside carrying a lamp) hitched for seconds and could hop floors: - Placement: hovering another floor's furniture, slab, wall, ceiling or roof (past the building edge, through a window) re-parented the item to that floor mid-gesture. With a level selected, the move tool now ignores surfaces on other levels; the floor cursor keeps following the selected one. - Leaving a host back to the floor kept the surface move's live transform, a building-space cursor (the host's top, level height included), which the remounted item read level-local: a bedside left on a 4th-floor bed floated ~10 m up until the next floor move. The detach publishes the floor pose. - Daylight rooms rebuilt (thousands of rays, ~1.6 s) on every scene edit; furniture edits and child-list-only changes no longer trigger it (a moved lamp still does, through its light's position). - The live stair/elevator opening systems replanned on a level's child list changing; they now ignore child lists, as the document reconcile already does. - Node batching cascaded releases from any dirty node, including a level whose child list changed: the whole floor's batches were released and rejoined. Levels, buildings and sites no longer cascade (also fixes two history tests that expected only a wall's own openings to release). Measured on a 5-level condo, moving a bedside with an item on top across the screen: worst frame 2.3 s -> 0.5-0.85 s, no level hops, correct height. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Port of @bottosson's
bottosson/performancebranch onto main, with two adjustments for what landed since (#1228). His two commits are kept as authored.From bottosson/performance
lib/scene-matrices.ts). Three's per-render matrix update is replaced by one walk per frame that only rebuilds what changed. Subtrees no pass can draw (merged originals, a soloed level's shadow-only content) are set aside for the render.Port adjustments
isSetAsideForRender, as the merged outline already does. A test covers it and fails without the fix.sortObjects = falsewas justified by the depth pre-pass, which Viewer perf: occlusion culling, high tier without AO pre-pass, readable highlights #1228 removed. On a GPU-bound editor the overdraw costs more than the sort saves.Moving items (found while testing this PR, pre-existing on main)
Moving an item that carries another (a bedside with a lamp on top) hitched for seconds and could hop floors:
Moving a bedside with an item on top across the screen (5-level condo): worst frame 2.3 s -> 0.5-0.85 s, no level hops, correct height.
Measured (M5 Max headless, High)
Draw counts are unchanged (culling intact), and before/after renders are identical.
Test plan
check-types, viewer (1348), core (7062), nodes (5230), editor (2856) tests, biome🤖 Generated with Claude Code
Note
High Risk
Touches core rendering (matrices, passes, shadows), batch membership, occlusion, and daylight shaders—regressions could affect visuals, culling, or lighting; manual/vis validation is important.
Overview
Scene and render path: Adds
scene-matrices.tsso one walk per frame updates world matrices incrementally, temporarily hides subtrees nothing draws (merged originals, idle shadow-only), and wraps post-processing / key renders inrenderWithSceneMatrices.LayerPassIndexexposes a layout revision for that walk;reveal-posemarks posed objects so they recompose every frame.Nested node batching:
BatchableConfigdocs and batch candidate logic now follow a host chain to a level (not only direct level children). New helpers (hostChain,hostsBusy,addBatchableDescendants) propagate dirty releases, tints, and deferrals to carried batchable nodes (cabinet runs → modules, etc.). Cabinet and cabinet-module use a sharedcabinetBatchable(cooktop burners stay excluded); shelf uses newstaticBatchable. Container types (level/building/site) no longer cascade child-list churn to the whole floor.Viewer CPU / lighting: Key-light shadow bounds skip double-counting nested registry roots and use
expandByWorldBoundsinstead of per-objectexpandByObjectmatrix spam. Daylight rooms rebuild only on structural edits (roomInputsChanged+ furniture-type filter + child-list-only skips), lamp feed keys include quantized world positions, and level height uniforms sit in a shared TSL group with updates only when Y/offset change. Fog useshorizonRadiance(no cloud noise / extra uniforms there).Occlusion / visibility: Meshes temporarily hidden only for the optimized render count as “shown” via
isSetAsideForRenderso occlusion culling and merged outlines stay correct for batched originals.Editor / core sync: Placement coordinator reparenting back to the floor publishes the floor live transform and gates surface hit handlers to the active level so drafts don’t jump floors mid-gesture. Elevator/stair opening sync passes
ignoreChildListsintochangedInputs. Fence system idles when no fence follows surfaces. LevelSystem re-applies shadow-only masks when layout revision moves after hidden rebuilds. Scene visibility idempotent re-hides track applied mask.Tests cover
roomInputsChangedand occlusion with set-aside occluders.Reviewed by Cursor Bugbot for commit 29ffa64. Bugbot is set up for automated code reviews on this repo. Configure here.