You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(print): smooth 3D-preview drag via rAF coalescing + drop holes mid-drag
The preview tore down and rebuilt the entire SVG (~1500 nodes for a
canonical room) on every pointermove. With trackpads firing move events
at up to 1 kHz that meant tens of thousands of DOM ops per second.
Two changes:
- requestAnimationFrame coalesces pointermove + wheel into one render
per display frame.
- While a drag is active we skip the holes pass (~1000 dots with
depth-scaled radius) and per-tile labels (~150 text nodes), keeping
only the wireframe + tile rectangles. Full quality returns on
pointerup.
The helper text was updated so users know the stars hide briefly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: src/ui/print-mode/preview-3d.ts
+26-5Lines changed: 26 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -438,7 +438,7 @@ export function mount3dPreview(host: HTMLElement, register: RegisterRefresh): vo
438
438
consthelper=document.createElement("p");
439
439
helper.className="print-mode-helper";
440
440
helper.textContent=
441
-
"View your room from the observer's eye. Drag to rotate; scroll to dolly forward/back. Each amber rectangle is one paper sheet you'll tape up.";
441
+
"View your room from the observer's eye. Drag to rotate; scroll to dolly forward/back. Each amber rectangle is one paper sheet you'll tape up. (Stars hide while you drag for smooth motion; release to see them again.)";
442
442
panel.append(helper);
443
443
444
444
// ---- Toolbar ----
@@ -489,6 +489,18 @@ export function mount3dPreview(host: HTMLElement, register: RegisterRefresh): vo
489
489
letdragPointer: number|null=null;
490
490
letlastDragX=0;
491
491
letlastDragY=0;
492
+
// requestAnimationFrame coalescing — pointermove fires at 1 kHz on
493
+
// some trackpads; we cap to display refresh and drop quality
494
+
// (no holes, no labels) while a drag is active so each frame stays
495
+
// under a few hundred DOM nodes instead of ~1500.
496
+
letpendingRAF: number|null=null;
497
+
functionscheduleRender(): void{
498
+
if(pendingRAF!==null)return;
499
+
pendingRAF=requestAnimationFrame(()=>{
500
+
pendingRAF=null;
501
+
render();
502
+
});
503
+
}
492
504
493
505
functionsetStatus(msg: string): void{
494
506
status.textContent=msg;
@@ -562,7 +574,7 @@ export function mount3dPreview(host: HTMLElement, register: RegisterRefresh): vo
0 commit comments