diff --git a/src/js/libpannellum.js b/src/js/libpannellum.js index 293ab16..2669a20 100644 --- a/src/js/libpannellum.js +++ b/src/js/libpannellum.js @@ -464,7 +464,7 @@ function Renderer(container, image, imageType, dynamic) { z = Math.cos(horizonRoll) * Math.cos(horizonPitch) * Math.sin(pitch) + Math.cos(pitch) * (-Math.cos(yaw) * Math.sin(horizonPitch) + Math.cos(horizonPitch) * Math.sin(horizonRoll) * Math.sin(yaw)); - pitch = Math.asin(z); + pitch = Math.asin(Math.max(Math.min(z, 1), -1)); yaw = Math.atan2(y, x); // Calculate roll @@ -474,9 +474,9 @@ function Renderer(container, image, imageType, dynamic) { Math.cos(orig_pitch) * (Math.cos(horizonPitch) * Math.sin(horizonRoll) * Math.cos(orig_yaw) + Math.sin(orig_yaw) * Math.sin(horizonPitch))], w = [-Math.cos(pitch) * Math.sin(yaw), Math.cos(pitch) * Math.cos(yaw)]; - var roll_adj = Math.acos((v[0]*w[0] + v[1]*w[1]) / + var roll_adj = Math.acos(Math.max(Math.min((v[0]*w[0] + v[1]*w[1]) / (Math.sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]) * - Math.sqrt(w[0]*w[0]+w[1]*w[1]))); + Math.sqrt(w[0]*w[0]+w[1]*w[1])), 1), -1)); if (v[2] < 0) roll_adj = 2 * Math.PI - roll_adj; roll += roll_adj; diff --git a/src/standalone/standalone.js b/src/standalone/standalone.js index 5e33cfc..f12f0af 100644 --- a/src/standalone/standalone.js +++ b/src/standalone/standalone.js @@ -18,13 +18,15 @@ function parseURLParameters() { for (var i = 0; i < URL.length; i++) { var option = URL[i].split('=')[0]; var value = URL[i].split('=')[1]; - if ( value == '' ) continue; // skip options with empty values in URL config + if (value == '') + continue; // Skip options with empty values in URL config switch(option) { - case 'hfov': case 'pitch': case 'yaw': case 'haov': case 'vaov': case 'vOffset': - case 'minHfov': case 'maxHfov': case 'minPitch': case 'maxPitch': case 'minYaw': case 'maxYaw': - configFromURL[option] = value; + case 'hfov': case 'pitch': case 'yaw': case 'haov': case 'vaov': + case 'minHfov': case 'maxHfov': case 'minPitch': case 'maxPitch': + case 'minYaw': case 'maxYaw': case 'vOffset': case 'autoRotate': + configFromURL[option] = Number(value); break; - case 'autoLoad': case 'autoRotate': case 'ignoreGPanoXMP': + case 'autoLoad': case 'ignoreGPanoXMP': configFromURL[option] = JSON.parse(value); break; case 'tour':