fix: Defer initial WebGL render until DOM layout completes for auto-loaded STL
This commit is contained in:
@@ -349,6 +349,11 @@
|
||||
frame = 0;
|
||||
if (!vertexCount) return;
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
if (rect.width < 10 || rect.height < 10) {
|
||||
// Container layout is not ready yet; retry on next frame
|
||||
requestDraw();
|
||||
return;
|
||||
}
|
||||
const width = Math.max(1, Math.round(rect.width * renderScale));
|
||||
const height = Math.max(1, Math.round(rect.height * renderScale));
|
||||
if (canvas.width !== width || canvas.height !== height) {
|
||||
@@ -503,6 +508,9 @@
|
||||
yawVelocity = 0;
|
||||
pitchVelocity = 0;
|
||||
|
||||
// Defer rendering to post-reflow rAF so canvas dimensions are ready
|
||||
requestAnimationFrame(() => {
|
||||
requestDraw();
|
||||
setTimeout(() => {
|
||||
introAnimating = true;
|
||||
introStartTime = performance.now();
|
||||
@@ -511,6 +519,7 @@
|
||||
startZoom = zoom;
|
||||
requestDraw();
|
||||
}, 150);
|
||||
});
|
||||
|
||||
requestDraw();
|
||||
return { name, triangles: vertexCount / 3 };
|
||||
|
||||
Reference in New Issue
Block a user