← Commit history

Gate walkthrough autoplay on viewer readiness so flyTo animates the live camera

John Lauer ·ea32855af0 ·2mo ago ·parent 8a776af
1 file changed +13
viewer/index.html+13
@@ -1735,6 +1735,19 @@ async function _maybeAutoplayWalkthrough() {   for (let i = 0; i < 25 && (!WALKTHROUGH || WALKTHROUGH.length === 0); i++) {     await new Promise(r => setTimeout(r, 400));   }+  // Wait for the viewer to finish its OWN async setup before starting. It+  // creates its lights, loads the .env, starts the render loop and frames the+  // model well after the GLB resolves, and the framing step swaps the camera.+  // Starting the tour first leaves walkthroughFlyTo animating a camera that is+  // no longer the active one: every step advances, the narration plays, and+  // the view never moves, with nothing logged.+  for (let i = 0; i < 50; i++) {+    try {+      const sc = viewer && viewer.getScene(), en = viewer && viewer.getEngine();+      if (sc && en && en.activeRenderLoops.length > 0 && sc.lights.length > 0) break;+    } catch (e) { /* viewer not up yet */ }+    await new Promise(r => setTimeout(r, 300));+  }   if (!WALKTHROUGH || WALKTHROUGH.length === 0 || _wtActive) return;   let key = 'tsciWtAutoplayed:';   try {