akhaliq HF Staff commited on
Commit
e89850a
·
1 Parent(s): 3b8c22c

Fix viewer overlay state hiding the reconstructed iframe

Browse files

After a successful reconstruction, the pipeline called
setViewerState('idle') — which shows the "Ready / Upload an image"
overlay on top of the iframe. The overlay covered the loaded 3D scene,
making it look stuck.

Add a 'ready' state that hides every overlay and reveals the iframe.
Use 'ready' at both completion points (iframe onload and after HTML
bundling) instead of 'idle'.

Files changed (1) hide show
  1. app.py +18 -7
app.py CHANGED
@@ -615,15 +615,26 @@ INDEX_HTML = r"""<!doctype html>
615
 
616
  function setViewerState(state, opts) {
617
  opts = opts || {};
618
- viewerIdle.classList.toggle("hidden", state !== "idle");
619
- viewerLoading.classList.toggle("hidden", state !== "loading");
620
- viewerError.classList.toggle("hidden", state !== "error");
621
- if (state === "loading") {
 
 
 
 
622
  loadingTitle.textContent = opts.title || "Reconstructing scene";
623
  loadingDetail.textContent = opts.detail || "Running model inference";
624
  progressBar.style.width = (opts.progress || 0) + "%";
625
  }
626
- if (state === "error") errorDetail.textContent = opts.detail || "Unknown error";
 
 
 
 
 
 
 
627
  }
628
 
629
  function setReady(ready) {
@@ -744,7 +755,7 @@ INDEX_HTML = r"""<!doctype html>
744
  viewerFrame.src = viewerUrl;
745
  viewerFrame.onload = () => {
746
  viewerFrame.classList.add("ready");
747
- setViewerState("idle");
748
  };
749
 
750
  setViewerState("loading", { title: "Bundling HTML", detail: "Embedding assets for download", progress: 92 });
@@ -752,7 +763,7 @@ INDEX_HTML = r"""<!doctype html>
752
  const htmlUrl = html.data[0].url;
753
  setDownload(dlHtml, htmlUrl, "Download HTML viewer — Ready");
754
 
755
- setViewerState("idle");
756
  toastMsg("Reconstruction complete");
757
  } catch (err) {
758
  console.error(err);
 
615
 
616
  function setViewerState(state, opts) {
617
  opts = opts || {};
618
+ const isReady = state === "ready";
619
+ const isLoading = state === "loading";
620
+ const isError = state === "error";
621
+ const isIdle = state === "idle";
622
+ viewerIdle.classList.toggle("hidden", !isIdle);
623
+ viewerLoading.classList.toggle("hidden", !isLoading);
624
+ viewerError.classList.toggle("hidden", !isError);
625
+ if (isLoading) {
626
  loadingTitle.textContent = opts.title || "Reconstructing scene";
627
  loadingDetail.textContent = opts.detail || "Running model inference";
628
  progressBar.style.width = (opts.progress || 0) + "%";
629
  }
630
+ if (isError) errorDetail.textContent = opts.detail || "Unknown error";
631
+ viewerFrame.classList.toggle("ready", isReady);
632
+ if (isReady) {
633
+ // Hide every overlay so the iframe takes the full surface.
634
+ viewerIdle.classList.add("hidden");
635
+ viewerLoading.classList.add("hidden");
636
+ viewerError.classList.add("hidden");
637
+ }
638
  }
639
 
640
  function setReady(ready) {
 
755
  viewerFrame.src = viewerUrl;
756
  viewerFrame.onload = () => {
757
  viewerFrame.classList.add("ready");
758
+ setViewerState("ready");
759
  };
760
 
761
  setViewerState("loading", { title: "Bundling HTML", detail: "Embedding assets for download", progress: 92 });
 
763
  const htmlUrl = html.data[0].url;
764
  setDownload(dlHtml, htmlUrl, "Download HTML viewer — Ready");
765
 
766
+ setViewerState("ready");
767
  toastMsg("Reconstruction complete");
768
  } catch (err) {
769
  console.error(err);