Skip to content

fix(nodes): reuse wall draft preview geometry - #550

Open
JimmyZheng-ZJU wants to merge 1 commit into
pascalorg:mainfrom
JimmyZheng-ZJU:fix/wall-draft-preview-allocation
Open

fix(nodes): reuse wall draft preview geometry#550
JimmyZheng-ZJU wants to merge 1 commit into
pascalorg:mainfrom
JimmyZheng-ZJU:fix/wall-draft-preview-allocation

Conversation

@JimmyZheng-ZJU

@JimmyZheng-ZJU JimmyZheng-ZJU commented Jul 27, 2026

Copy link
Copy Markdown

What does this PR do?

This removes per-pointer-move geometry allocation from the 3D wall draft preview.

Previously, every grid:move event constructed a new BoxGeometry, 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 boxGeometry and 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 passed
  • bun run build in packages/nodes — passed
  • Biome check for packages/nodes/src/wall/tool.tsx — passed
  • Manual continuous-wall checks in both the 3D editor and 2D floorplan

How to test

  1. Run bun dev, open a project in the 3D editor, and select the Wall tool.
  2. Place the first wall segment, then move the pointer to preview and place a second connected segment; verify the preview follows continuously and retains the expected height and thickness.
  3. Switch to the 2D floorplan and verify wall preview, chained placement, and cancellation still behave as before.

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

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (not applicable: no public API or behavior change)
  • This PR targets the main branch

Note

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 unit boxGeometry and updateWallPreview drives size with mesh.scale.set(length, previewHeight, previewThickness) instead of creating a new BoxGeometry, disposing the old one, and swapping it in on each grid:move.

The preview element changes from an empty shapeGeometry placeholder to boxGeometry, 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.

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.

1 participant