From 47f7d09385c6ad2731ba5cddc3f5bb7abf44da83 Mon Sep 17 00:00:00 2001 From: Yeicor <4929005+Yeicor@users.noreply.github.com> Date: Sun, 18 Feb 2024 18:15:17 +0100 Subject: [PATCH] partial show during load --- src/misc/scene.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/misc/scene.ts b/src/misc/scene.ts index 8a4acbc..d6f9527 100644 --- a/src/misc/scene.ts +++ b/src/misc/scene.ts @@ -54,11 +54,19 @@ export class SceneMgr { console.log("Loading", name, "which has", numChunks, "GLB chunks"); // Start merging each chunk into the current document, replacing or adding as needed + let lastShow = performance.now(); while (true) { let {value: glbData, done} = await glbsSplitter.next(); if (done) break; data.document = await mergePartial(glbData, name, data.document); + await new Promise(r => setTimeout(r, 0)); // Yield to update the UI at 60fps // TODO: Report load progress + + // Show the partial model while loading every once in a while + if (performance.now() - lastShow > settings.displayLoadingEveryMs) { + await this.showCurrentDoc(refData, data); + lastShow = performance.now(); + } } // Display the final fully loaded model