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