From 5656fe6f07fddf58a209edb7fa93bb8c87226d01 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 24 Feb 2023 18:42:13 -0500 Subject: [PATCH] Allow `loadScene` to be called from `load` event handler (fixes #1144). --- src/js/pannellum.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/js/pannellum.js b/src/js/pannellum.js index 76eb06f..0977f9f 100644 --- a/src/js/pannellum.js +++ b/src/js/pannellum.js @@ -1787,13 +1787,14 @@ function renderInit() { if (config.backgroundColor !== undefined) params.backgroundColor = config.backgroundColor; renderer.init(panoImage, config.type, config.haov * Math.PI / 180, config.vaov * Math.PI / 180, config.vOffset * Math.PI / 180, renderInitCallback, params); + } catch(event) { + // Panorama not loaded + if (config.dynamic !== true) { // Allow image to be garbage collected panoImage = undefined; } - } catch(event) { - // Panorama not loaded - + // Display error if there is a bad texture if (event.type == 'webgl error' || event.type == 'no webgl') { anError(); @@ -1842,6 +1843,11 @@ function renderInitCallback() { preview = undefined; } loaded = true; + + if (config.dynamic !== true) { + // Allow image to be garbage collected + panoImage = undefined; + } animateInit();