fix(nodes): reuse wall draft preview geometry - #550
Open
JimmyZheng-ZJU wants to merge 1 commit into
Open
Conversation
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.
What does this PR do?
This removes per-pointer-move geometry allocation from the 3D wall draft preview.
Previously, every
grid:moveevent constructed a newBoxGeometry, disposed the previous geometry, and assigned the replacement to the preview mesh. Continuous wall drawing therefore created avoidable CPU allocations and GPU resource churn on the editor's hottest interaction path.The preview now mounts one unit
boxGeometryand updates the mesh position, rotation, and scale. Snapping, preview dimensions, visibility, and chained wall placement behavior remain unchanged.In a local 30-event pointer-move sample, the previous path produced roughly 4 MB of short-lived heap growth. With geometry reuse, the sampled heap delta was effectively flat; exact values remain workload- and GC-dependent.
Validation performed:
bun test packages/nodes/src/wall— 71 passedbun run buildinpackages/nodes— passedpackages/nodes/src/wall/tool.tsx— passedHow to test
bun dev, open a project in the 3D editor, and select the Wall tool.Screenshots / screen recording
Not included: this is a resource-lifetime optimization with intentionally unchanged visual output. The interaction was verified manually in both 3D and 2D.
Checklist
bun devbun checkto verify)mainbranchNote
Low Risk
Editor-only preview rendering optimization with no API or wall-creation logic changes; behavior is intended to be visually identical.
Overview
Stops allocating GPU geometry on every pointer move during wall drafting in
tool.tsx. The draft preview mesh now keeps a single unitboxGeometryandupdateWallPreviewdrives size withmesh.scale.set(length, previewHeight, previewThickness)instead of creating a newBoxGeometry, disposing the old one, and swapping it in on eachgrid:move.The preview element changes from an empty
shapeGeometryplaceholder toboxGeometry, with the same visibility rules (hidden until the first move scales/positions the segment, and hidden again when chaining to avoid a one-frame double draw). Snapping, measurements, and chained placement behavior are unchanged.Reviewed by Cursor Bugbot for commit c04b18f. Bugbot is set up for automated code reviews on this repo. Configure here.