From 9f51965775e762815f40826045ac62c178192e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nico=20H=C3=B6llerich?= Date: Sun, 17 May 2020 23:34:23 +0200 Subject: [PATCH] Fixes * checkZoom * numerical errors when checking sub tiles * catch rejected promises --- src/js/libpannellum.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/js/libpannellum.js b/src/js/libpannellum.js index 2c84d57..02a2ba7 100644 --- a/src/js/libpannellum.js +++ b/src/js/libpannellum.js @@ -1026,7 +1026,8 @@ function Renderer(container) { if (program.currentNodes[i].textureLoaded > 1) { //transform input parameters from [-1,1]² to [0,1]² in screen coordinates (i.e. y-axis pointing downwards) let v = program.currentNodes[i].vertices; - let factor = Math.pow(2, image.maxLevel - program.currentNodes[i].level - 1); + let level = program.currentNodes[i].level; + let factor = program.level == level ? Math.pow(2, image.maxLevel - level - 1) : 0; // Upload extents of tile relative to full panorama gl.uniform1f(program.bb, (-v[0][1] + texelHeight/4 + 1) / 2); @@ -1280,12 +1281,12 @@ function Renderer(container) { var children = []; var childrenIndices = [[0, 0]]; - if (dimX > dimXC) { + if (dimX - dimXC > epsilon) { childrenIndices.push([1, 0]); - if (dimY > dimYC) + if (dimY - dimYC > epsilon) childrenIndices.push([1, 1]); } - if (dimY > dimYC) + if (dimY - dimYC > epsilon) childrenIndices.push([0, 1]); for (var child of childrenIndices) { @@ -1661,7 +1662,9 @@ function Renderer(container) { this.callback(this.texture, true); } releaseTextureImageLoader(this); - }) + }).catch(() => { + this.callback(this.texture, false); + }); } else { this.image.src = src; } @@ -1720,7 +1723,7 @@ function Renderer(container) { * @param {number} hfov - Horizontal field of view to check at. */ function checkZoom(hfov) { - if (image.type == 'multires') { + if (imageType == 'multires') { // Find optimal level var newLevel = 1; while (newLevel < image.maxLevel &&