From 679211fc7f6e4e1fd9734a2acf24c1051cc8b174 Mon Sep 17 00:00:00 2001 From: NiHoel Date: Fri, 22 Mar 2019 23:33:50 +0100 Subject: [PATCH] Allowed fading when level 3 is completed --- src/js/libpannellum.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/js/libpannellum.js b/src/js/libpannellum.js index 164468b..f22ce08 100644 --- a/src/js/libpannellum.js +++ b/src/js/libpannellum.js @@ -863,10 +863,19 @@ function Renderer(container) { multiresrecDraw(); } - if (this.tilesLoadedCallback && program.currentNodes - && program.currentNodes.length > 0 && !this.isLoading()) { - this.tilesLoadedCallback(); - delete this.tilesLoadedCallback; + // check if tiles are loaded up to level 3 and issue callback + if (this.tilesLoadedCallback && program.currentNodes && program.currentNodes.length > 0) { + var minLoadedLevel = Number.MAX_SAFE_INTEGER; + for (var i = 0; i < program.currentNodes.length; i++) { + if (!program.currentNodes[i].textureLoaded) { + minLoadedLevel = Math.min(minLoadedLevel, program.currentNodes[i].level) + } + } + + if (minLoadedLevel > 3) { + this.tilesLoadedCallback(); + delete this.tilesLoadedCallback; + } } if (params.returnImage !== undefined) {