diff --git a/photo-sphere-viewer.js b/photo-sphere-viewer.js index b047b4193..03ab35f82 100644 --- a/photo-sphere-viewer.js +++ b/photo-sphere-viewer.js @@ -1,5 +1,5 @@ /* - * Photo Sphere Viewer v2.4 + * Photo Sphere Viewer v2.4.1 * http://jeremyheleine.me/photo-sphere-viewer * * Copyright (c) 2014,2015 Jérémy Heleine @@ -150,11 +150,13 @@ var PhotoSphereViewer = function(args) { * Returns the measure of an angle (between 0 and 2π). * @private * @param {number} angle - The angle to reduce + * @param {boolean} [is_2pi_allowed=false] - Can the measure be equal to 2π? * @return {number} The wanted measure **/ - var getAngleMeasure = function(angle) { - return angle - Math.floor(angle / (2.0 * Math.PI)) * 2.0 * Math.PI; + var getAngleMeasure = function(angle, is_2pi_allowed) { + is_2pi_allowed = (is_2pi_allowed !== undefined) ? !!is_2pi_allowed : false; + return (is_2pi_allowed && angle == 2 * Math.PI) ? 2 * Math.PI : angle - Math.floor(angle / (2.0 * Math.PI)) * 2.0 * Math.PI; }; /** @@ -581,7 +583,7 @@ var PhotoSphereViewer = function(args) { var again = true; - if (PSV_MIN_LONGITUDE != PSV_MAX_LONGITUDE) { + if (!whole_circle) { long = stayBetween(long, PSV_MIN_LONGITUDE, PSV_MAX_LONGITUDE); if (long == PSV_MIN_LONGITUDE || long == PSV_MAX_LONGITUDE) { @@ -596,7 +598,7 @@ var PhotoSphereViewer = function(args) { } } - long = getAngleMeasure(long); + long = getAngleMeasure(long, true); render(); @@ -744,7 +746,7 @@ var PhotoSphereViewer = function(args) { var moveTo = function(longitude, latitude) { var long_tmp = parseAngle(longitude); - if (PSV_MIN_LONGITUDE != PSV_MAX_LONGITUDE) + if (!whole_circle) long_tmp = stayBetween(long_tmp, PSV_MIN_LONGITUDE, PSV_MAX_LONGITUDE); var lat_tmp = parseAngle(latitude); @@ -912,10 +914,10 @@ var PhotoSphereViewer = function(args) { if (mousedown) { long += (x - mouse_x) * PSV_LONG_OFFSET; - if (PSV_MIN_LONGITUDE != PSV_MAX_LONGITUDE) + if (!whole_circle) long = stayBetween(long, PSV_MIN_LONGITUDE, PSV_MAX_LONGITUDE); - long = getAngleMeasure(long); + long = getAngleMeasure(long, true); lat += (y - mouse_y) * PSV_LAT_OFFSET; lat = stayBetween(lat, PSV_TILT_DOWN_MAX, PSV_TILT_UP_MAX); @@ -1340,14 +1342,29 @@ var PhotoSphereViewer = function(args) { var PSV_TILT_UP_MAX = (args.tilt_up_max !== undefined) ? stayBetween(parseAngle(args.tilt_up_max), 0, Math.PI / 2.0) : Math.PI / 2.0; var PSV_TILT_DOWN_MAX = (args.tilt_down_max !== undefined) ? -stayBetween(parseAngle(args.tilt_down_max), 0, Math.PI / 2.0) : -Math.PI / 2.0; - // Minimum and maximum visible longitudes ((min = max) => whole circle) - var PSV_MIN_LONGITUDE = (args.min_longitude !== undefined) ? parseAngle(args.min_longitude) : 0; - var PSV_MAX_LONGITUDE = (args.max_longitude !== undefined) ? parseAngle(args.max_longitude) : 0; + // Minimum and maximum visible longitudes + var min_long = (args.min_longitude !== undefined) ? parseAngle(args.min_longitude) : 0; + var max_long = (args.max_longitude !== undefined) ? parseAngle(args.max_longitude) : 0; - if (PSV_MAX_LONGITUDE < PSV_MIN_LONGITUDE) { - var long_tmp = PSV_MIN_LONGITUDE; - PSV_MIN_LONGITUDE = PSV_MAX_LONGITUDE; - PSV_MAX_LONGITUDE = long_tmp; + var whole_circle = (min_long == max_long); + + if (whole_circle) { + min_long = 0; + max_long = 2 * Math.PI; + } + + else if (max_long == 0) + max_long = 2 * Math.PI; + + var PSV_MIN_LONGITUDE, PSV_MAX_LONGITUDE; + if (min_long < max_long) { + PSV_MIN_LONGITUDE = min_long; + PSV_MAX_LONGITUDE = max_long; + } + + else { + PSV_MIN_LONGITUDE = max_long; + PSV_MAX_LONGITUDE = min_long; } // Default position diff --git a/photo-sphere-viewer.min.js b/photo-sphere-viewer.min.js index d5a51f27e..f05e9a96f 100644 --- a/photo-sphere-viewer.min.js +++ b/photo-sphere-viewer.min.js @@ -1 +1 @@ -var PhotoSphereViewer=function(e){var t=function(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))},n=function(){var e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl"))},o=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent("on"+t,n)},i=function(e,t,n){return Math.max(t,Math.min(n,e))},r=function(e,t,n,o){var i=n-e,r=o-t;return i*i+r*r},a=function(e){return e-2*Math.floor(e/(2*Math.PI))*Math.PI};this.load=function(){if(ve.innerHTML="",De&&1===De.nodeType)ve.appendChild(De);else if(De&&"string"==typeof De)ve.innerHTML=De;else if(Le){var e=document.createElement("img");e.setAttribute("src",Le),e.setAttribute("alt",Ae),ve.appendChild(e)}else ve.textContent=Ae;return be=document.createElement("div"),be.style.width="100%",be.style.height="100%",be.style.position="relative",be.style.overflow="hidden",t()?void 0===window.THREE?void console.log("PhotoSphereViewer: Three.js is not loaded."):(me={width:0,height:0,ratio:0},void(Be&&!we.match(/^data:image\/[a-z]+;base64/)?l():d())):void(ve.textContent="Canvas is not supported, update your browser!")};var s=function(e,t){var n=e.indexOf("GPano:"+t)+t.length+8,o=e.indexOf('"',n);return e.substring(n,o)},l=function(){var e=null;if(window.XMLHttpRequest)e=new XMLHttpRequest;else{if(!window.ActiveXObject)return void(ve.textContent="XHR is not supported, update your browser!");try{e=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){e=new ActiveXObject("Microsoft.XMLHTTP")}}e.onreadystatechange=function(){if(4==e.readyState&&200==e.status){var t=e.responseText,n=t.indexOf(""),i=t.substring(n,o);if(-1==n||-1==o||-1==i.indexOf("GPano:"))return void d(!1);Oe={full_width:parseInt(s(i,"FullPanoWidthPixels")),full_height:parseInt(s(i,"FullPanoHeightPixels")),cropped_width:parseInt(s(i,"CroppedAreaImageWidthPixels")),cropped_height:parseInt(s(i,"CroppedAreaImageHeightPixels")),cropped_x:parseInt(s(i,"CroppedAreaLeftPixels")),cropped_y:parseInt(s(i,"CroppedAreaTopPixels"))},d()}},e.open("GET",we,!0),e.send(null)},d=function(){var e=new Image;e.onload=function(){var t={full_width:e.width,full_height:e.height,cropped_width:e.width,cropped_height:e.height,cropped_x:null,cropped_y:null};for(attr in Oe)null==Oe[attr]&&void 0!==t[attr]&&(Oe[attr]=t[attr]);null==Oe.cropped_x&&(Oe.cropped_x=(Oe.full_width-Oe.cropped_width)/2),null==Oe.cropped_y&&(Oe.cropped_y=(Oe.full_height-Oe.cropped_height)/2);var o=2048;if(n()){var i=document.createElement("canvas"),r=i.getContext("webgl");o=r.getParameter(r.MAX_TEXTURE_SIZE)}var a=Math.min(Oe.full_width,o),s=a/Oe.full_width;Oe.full_width=a,Oe.cropped_width*=s,Oe.cropped_x*=s,e.width=Oe.cropped_width,Oe.full_height*=s,Oe.cropped_height*=s,Oe.cropped_y*=s,e.height=Oe.cropped_height;var l=document.createElement("canvas");l.width=Oe.full_width,l.height=Oe.full_height;var r=l.getContext("2d");r.drawImage(e,Oe.cropped_x,Oe.cropped_y,Oe.cropped_width,Oe.cropped_height),c(l.toDataURL("image/jpeg"))},we.match(/^data:image\/[a-z]+;base64/)||e.setAttribute("crossOrigin","anonymous"),e.src=we},c=function(e){var t=new THREE.Texture,n=new THREE.ImageLoader,o=function(e){t.needsUpdate=!0,t.image=e,u(t)};n.load(e,o)},u=function(e){void 0!==ye.width&&(ve.style.width=ye.width.css),void 0!==ye.height&&(ve.style.height=ye.height.css),b(),Ce=n()?new THREE.WebGLRenderer:new THREE.CanvasRenderer,Ce.setSize(me.width,me.height),ke=new THREE.Scene,_e=new THREE.PerspectiveCamera(Y,me.ratio,1,300),_e.position.set(0,0,0),ke.add(_e);var t=new THREE.SphereGeometry(200,32,32),i=new THREE.MeshBasicMaterial({map:e,overdraw:!0}),r=new THREE.Mesh(t,i);r.scale.x=-1,ke.add(r),xe=document.createElement("div"),xe.style.position="absolute",xe.style.zIndex=0,be.appendChild(xe),he&&(ue.setStyle(pe),ue.create(),be.appendChild(ue.getBar())),o(window,"resize",b),ge&&(o(xe,"mousedown",C),o(document,"mousemove",z),o(xe,"mousemove",D),o(document,"mouseup",S),o(xe,"touchstart",k),o(document,"touchend",S),o(document,"touchmove",T),o(xe,"mousewheel",P),o(xe,"DOMMouseScroll",P)),o(document,"fullscreenchange",O),o(document,"mozfullscreenchange",O),o(document,"webkitfullscreenchange",O),o(document,"MSFullscreenChange",O),Pe.addListener(H),ve.innerHTML="",ve.appendChild(be);var a=Ce.domElement;a.style.display="block",xe.appendChild(a),h(),ne>0&&F(ne),m(),$("ready")},h=function(){var e=new THREE.Vector3;e.setX(Math.cos(Q)*Math.sin(ee)),e.setY(Math.sin(Q)),e.setZ(Math.cos(Q)*Math.cos(ee)),_e.lookAt(e),null!==Ee?Ee.render(ke,_e):Ce.render(ke,_e)},p=function(){Ee=new THREE.StereoEffect(Ce),Ee.eyeSeparation=5,Ee.setSize(me.width,me.height),I(),A(),ue.mustBeHidden(),h(),$("stereo-effect",!0)},g=function(){Ee=null,Ce.setSize(me.width,me.height),ue.mustBeHidden(!1),h(),$("stereo-effect",!1)};this.toggleStereo=function(){null!==Ee?g():p()};var m=function(){re!==!1&&(He=setTimeout(y,re))},v=function(){Q-=(Q-de)*le,ee+=ae;var e=!0;K!=Z&&(ee=i(ee,K,Z),(ee==K||ee==Z)&&(se?ae*=-1:(f(),e=!1))),ee=a(ee),h(),e&&(Me=setTimeout(v,ie))},y=function(){v(),$("autorotate",!0)},f=function(){clearTimeout(He),He=null,clearTimeout(Me),Me=null,$("autorotate",!1)};this.toggleAutorotate=function(){clearTimeout(He),Me?f():y()};var b=function(){(ve.clientWidth!=me.width||ve.clientHeight!=me.height)&&x({width:ve.clientWidth,height:ve.clientHeight})};this.fitToContainer=function(){b()};var x=function(e){me.width=void 0!==e.width?parseInt(e.width):me.width,me.height=void 0!==e.height?parseInt(e.height):me.height,me.ratio=me.width/me.height,_e&&(_e.aspect=me.ratio,_e.updateProjectionMatrix()),Ce&&(Ce.setSize(me.width,me.height),h()),Ee&&(Ee.setSize(me.width,me.height),h())};this.getPosition=function(){return{longitude:ee,latitude:Q}},this.getPositionInDegrees=function(){return{longitude:180*ee/Math.PI,latitude:180*Q/Math.PI}};var w=function(e,t){var n=W(e);K!=Z&&(n=i(n,K,Z));var o=W(t);o>Math.PI&&(o-=2*Math.PI),o=i(o,U,j),ee=n,Q=o,h()};this.moveTo=function(e,t){w(e,t)};var C=function(e){_(parseInt(e.clientX),parseInt(e.clientY))},k=function(e){if(1==e.touches.length){var t=e.touches[0];t.target.parentNode==xe&&_(parseInt(t.clientX),parseInt(t.clientY))}else 2==e.touches.length&&(S(),e.touches[0].target.parentNode==xe&&e.touches[1].target.parentNode==xe&&E(r(e.touches[0].clientX,e.touches[0].clientY,e.touches[1].clientX,e.touches[1].clientY)));D()},_=function(e,t){ze=e,Te=t,f(),Se=!0},E=function(e){Ie=e,Re=!0},S=function(e){Se=!1,Re=!1},z=function(e){e.preventDefault(),R(parseInt(e.clientX),parseInt(e.clientY))},T=function(e){if(1==e.touches.length&&Se){var t=e.touches[0];t.target.parentNode==xe&&(e.preventDefault(),R(parseInt(t.clientX),parseInt(t.clientY)))}else if(2==e.touches.length&&e.touches[0].target.parentNode==xe&&e.touches[1].target.parentNode==xe&&Re){e.preventDefault();var n=r(e.touches[0].clientX,e.touches[0].clientY,e.touches[1].clientX,e.touches[1].clientY),o=n-Ie;if(0!=o){var i=o/Math.abs(o);F(ne+i),Ie=n}}},R=function(e,t){Se&&(ee+=(e-ze)*q,K!=Z&&(ee=i(ee,K,Z)),ee=a(ee),Q+=(t-Te)*V,Q=i(Q,U,j),ze=e,Te=t,h())},I=function(){Pe.start(),f(),$("device-orientation",!0)},M=function(){Pe.stop(),$("device-orientation",!1)};this.toggleDeviceOrientation=function(){Pe.isEventAttached()?M():I()};var H=function(e){ee=i(e.longitude,K,Z),Q=i(e.latitude,U,j),h()},P=function(e){e.preventDefault(),e.stopPropagation();var t=e.detail?-e.detail:e.wheelDelta;if(0!=t){var n=parseInt(t/Math.abs(t));F(ne+n)}},F=function(e){ne=i(parseInt(Math.round(e)),0,100),_e.fov=Y+ne/100*(G-Y),_e.updateProjectionMatrix(),h(),$("zoom-updated",ne)};this.zoom=function(e){F(e)},this.zoomIn=function(){100>ne&&F(ne+1)},this.zoomOut=function(){ne>0&&F(ne-1)};var B=function(){return!!(document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement)},O=function(){document.webkitFullscreenElement||document.msFullscreenElement?(fe.width=ve.style.width,fe.height=ve.style.height,ve.style.width="100%",ve.style.height="100%",b()):(ve.webkitRequestFullscreen||ve.msRequestFullscreen)&&(ve.style.width=fe.width,ve.style.height=fe.height,b()),$("fullscreen-mode",B())},A=function(){ve.requestFullscreen?ve.requestFullscreen():ve.mozRequestFullScreen?ve.mozRequestFullScreen():ve.webkitRequestFullscreen?ve.webkitRequestFullscreen():ve.msRequestFullscreen&&ve.msRequestFullscreen()},L=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen()};this.toggleFullscreen=function(){B()?L():A()};var D=function(){he&&ue.show()},X=function(e){e=e.toString().trim();var t=parseFloat(e.replace(/^(-?[0-9]+(?:\.[0-9]*)?).*$/,"$1")),n=e.replace(/^-?[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();n.match(/(pm|per minute)$/)&&(t/=60);var o=0;switch(n){case"rpm":case"rev per minute":case"revolutions per minute":case"rps":case"rev per second":case"revolutions per second":o=2*t*Math.PI;break;case"dpm":case"deg per minute":case"degrees per minute":case"dps":case"deg per second":case"degrees per second":o=t*Math.PI/180;break;case"rad per minute":case"radians per minute":case"rad per second":case"radians per second":o=t;break;default:m_anim=!1}return o*ie/1e3},W=function(e){e=e.toString().trim();var t=parseFloat(e.replace(/^(-?[0-9]+(?:\.[0-9]*)?).*$/,"$1")),n=e.replace(/^-?[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();return"deg"==n&&(t*=Math.PI/180),a(t)},N=function(e){for(dim in e)if("width"==dim||"height"==dim){var t=e[dim].toString().trim(),n=parseFloat(t.replace(/^([0-9]+(?:\.[0-9]*)?).*$/,"$1")),o=t.replace(/^[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();"%"!=o&&(o="px"),ye[dim]={css:n+o,unit:o}}};this.addAction=function(e,t){e in Fe||(Fe[e]=[]),Fe[e].push(t)};var $=function(e,t){if(e in Fe&&Fe[e].length)for(var n=0,o=Fe[e].length;o>n;++n)void 0!==t?Fe[e][n](t):Fe[e][n]()};if(void 0===e||void 0===e.panorama||void 0===e.container)return void console.log("PhotoSphereViewer: no value given for panorama or container");var q=void 0!==e.long_offset?parseFloat(e.long_offset):Math.PI/360,V=void 0!==e.lat_offset?parseFloat(e.lat_offset):Math.PI/180,G=void 0!==e.min_fov?i(parseFloat(e.min_fov),1,179):30,Y=void 0!==e.max_fov?i(parseFloat(e.max_fov),1,179):90,j=void 0!==e.tilt_up_max?i(W(e.tilt_up_max),0,Math.PI/2):Math.PI/2,U=void 0!==e.tilt_down_max?-i(W(e.tilt_down_max),0,Math.PI/2):-Math.PI/2,K=void 0!==e.min_longitude?W(e.min_longitude):0,Z=void 0!==e.max_longitude?W(e.max_longitude):0;if(K>Z){var J=K;K=Z,Z=J}var Q=0,ee=K;if(void 0!==e.default_position){if(void 0!==e.default_position.lat){var te=W(e.default_position.lat);te>Math.PI&&(te-=2*Math.PI),Q=i(te,U,j)}void 0!==e.default_position["long"]&&(ee=i(W(e.default_position["long"]),K,Z))}var ne=0;void 0!==e.zoom_level&&(ne=i(parseInt(Math.round(e.zoom_level)),0,100));var oe=60,ie=1e3/oe,re=2e3;void 0!==e.time_anim&&(re="number"==typeof e.time_anim&&e.time_anim>=0?e.time_anim:!1);var ae=X(void 0!==e.anim_speed?e.anim_speed:"2rpm"),se=!0;void 0!==e.reverse_anim&&(se=!!e.reverse_anim);var le=X(void 0!==e.vertical_anim_speed?e.vertical_anim_speed:"2rpm"),de=0;if(void 0!==e.vertical_anim_target){var ce=W(e.vertical_anim_target);ce>Math.PI&&(ce-=2*Math.PI),de=i(ce,U,j)}var ue=new PSVNavBar(this),he=void 0!==e.navbar?!!e.navbar:!1,pe=void 0!==e.navbar_style?e.navbar_style:{},ge=void 0!==e.allow_user_interactions?!!e.allow_user_interactions:!0;ge||(he=!1);var me,ve=e.container,ye={},fe={};void 0!==e.size&&N(e.size);var be,xe,we=e.panorama,Ce=null,ke=null,_e=null,Ee=null,Se=!1,ze=0,Te=0,Re=!1,Ie=0,Me=null,He=null,Pe=new Sphoords,Fe={},Be=void 0!==e.usexmpdata?!!e.usexmpdata:!0,Oe={full_width:null,full_height:null,cropped_width:null,cropped_height:null,cropped_x:null,cropped_y:null};if(void 0!==e.pano_size){for(attr in Oe)void 0!==e.pano_size[attr]&&(Oe[attr]=parseInt(e.pano_size[attr]));Be=!1}var Ae=void 0!==e.loading_msg?e.loading_msg.toString():"Loading…",Le=void 0!==e.loading_img?e.loading_img.toString():null,De=void 0!==e.loading_html?e.loading_html:null;void 0!==e.onready&&this.addAction("ready",e.onready);var Xe=void 0!==e.autoload?!!e.autoload:!0;Xe&&this.load()},PSVNavBar=function(e){var t=function(e,t){for(var n=0,o=t.length;o>n;++n)if(t[n]==e)return!0;return!1},n=function(e,n){return t(e,h)&&"string"==typeof n&&("transparent"==n||!!n.match(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/)||!!n.match(/^rgb\((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])(,\s*(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}\)$/)||!!n.match(/^rgba\(((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5]),\s*){3}(0(\.[0-9]*)?|1)\)$/))||t(e,p)&&!isNaN(parseFloat(n))&&isFinite(n)&&n>=0};this.setStyle=function(e){for(property in e)property in u&&n(property,e[property])&&(u[property]=e[property])},this.create=function(){r=document.createElement("div"),r.style.backgroundColor=u.backgroundColor,r.style.position="absolute",r.style.zIndex=10,r.style.bottom=0,r.style.width="100%",r.style.boxSizing="content-box",r.style.transition="bottom 0.4s ease-out",a=new PSVNavBarButton(e,"autorotate",u),r.appendChild(a.getButton()),s=new PSVNavBarButton(e,"zoom",u),r.appendChild(s.getButton()),l=new PSVNavBarButton(e,"fullscreen",u),r.appendChild(l.getButton()),Sphoords.isDeviceOrientationSupported&&(d=new PSVNavBarButton(e,"orientation",u),r.appendChild(d.getButton()),c=new PSVNavBarButton(e,"virtual-reality",u),r.appendChild(c.getButton()))},this.getBar=function(){return r};var o=function(){g&&(clearTimeout(g),!m&&v&&(g=setTimeout(i,5e3))),m&&(r.style.bottom=0,m=!1,v&&(g=setTimeout(i,5e3)))};this.show=function(){o()};var i=function(){m||(r.style.bottom=-r.offsetHeight+1+"px",m=!0)};this.hide=function(){i()},this.isHidden=function(){return m},this.mustBeHidden=function(e){v=void 0!==e?!!e:!0,v?i():o()};var r,a,s,l,d,c,u={backgroundColor:"rgba(61, 61, 61, 0.5)",buttonsColor:"rgba(255, 255, 255, 0.7)",buttonsBackgroundColor:"transparent",activeButtonsBackgroundColor:"rgba(255, 255, 255, 0.1)",buttonsHeight:20,autorotateThickness:1,zoomRangeWidth:50,zoomRangeThickness:1,zoomRangeDisk:7,fullscreenRatio:4/3,fullscreenThickness:2,gyroscopeThickness:1,virtualRealityRatio:4/3,virtualRealityBorderRadius:2},h=["backgroundColor","buttonsColor","buttonsBackgroundColor","activeButtonsBackgroundColor"],p=["buttonsHeight","autorotateThickness","zoomRangeWidth","zoomRangeThickness","zoomRangeDisk","fullscreenRatio","fullscreenThickness"],g=null,m=!1,v=!1},PSVNavBarButton=function(e,t,n){var o=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent("on"+t,n)},i=function(){switch(t){case"autorotate":var i=n.buttonsHeight-2*n.autorotateThickness,p=i/10;l=document.createElement("div"),l.style.cssFloat="left",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=n.buttonsHeight+"px",l.style.height=n.buttonsHeight+"px",l.style.backgroundColor=n.buttonsBackgroundColor,l.style.position="relative",l.style.cursor="pointer",o(l,"click",function(){e.toggleAutorotate()});var y=document.createElement("div");y.style.boxSizing="inherit",y.style.width=i+"px",y.style.height=i+"px",y.style.borderRadius="50%",y.style.border=n.autorotateThickness+"px solid "+n.buttonsColor,l.appendChild(y);var f=document.createElement("div");f.style.boxSizing="inherit",f.style.width=i+"px",f.style.height=p+"px",f.style.borderRadius="50%",f.style.border=n.autorotateThickness+"px solid "+n.buttonsColor,f.style.position="absolute",f.style.top="50%",f.style.marginTop=-(p/2+n.autorotateThickness)+"px",l.appendChild(f),e.addAction("autorotate",d);break;case"zoom":l=document.createElement("div"),l.style.cssFloat="left",l.style.boxSizing="inherit";var b=document.createElement("div");b.style.cssFloat="left",b.style.boxSizing="inherit",b.style.padding="10px",b.style.height=n.buttonsHeight+"px",b.style.backgroundColor=n.buttonsBackgroundColor,b.style.lineHeight=n.buttonsHeight+"px",b.style.color=n.buttonsColor,b.style.cursor="pointer",b.textContent="-",o(b,"click",function(){e.zoomOut()}),l.appendChild(b),r=document.createElement("div"),r.style.cssFloat="left",r.style.boxSizing="inherit",r.style.padding=10+(n.buttonsHeight-n.zoomRangeThickness)/2+"px 5px",r.style.backgroundColor=n.buttonsBackgroundColor,r.style.cursor="pointer",l.appendChild(r),a=document.createElement("div"),a.style.boxSizing="inherit",a.style.width=n.zoomRangeWidth+"px",a.style.height=n.zoomRangeThickness+"px",a.style.backgroundColor=n.buttonsColor,a.style.position="relative",r.appendChild(a),s=document.createElement("div"),s.style.position="absolute",s.style.top=(n.zoomRangeThickness-n.zoomRangeDisk)/2+"px",s.style.left=-(n.zoomRangeDisk/2)+"px",s.style.boxSizing="inherit",s.style.width=n.zoomRangeDisk+"px",s.style.height=n.zoomRangeDisk+"px",s.style.borderRadius="50%",s.style.backgroundColor=n.buttonsColor,e.addAction("zoom-updated",c),o(r,"mousedown",u),o(r,"touchstart",h),o(document,"mousemove",m),o(document,"touchmove",v),o(document,"mouseup",g),o(document,"touchend",g),a.appendChild(s);var x=document.createElement("div");x.style.cssFloat="left",x.style.boxSizing="inherit",x.style.padding="10px",x.style.height=n.buttonsHeight+"px",x.style.backgroundColor=n.buttonsBackgroundColor,x.style.lineHeight=n.buttonsHeight+"px",x.style.color=n.buttonsColor,x.style.cursor="pointer",x.textContent="+",o(x,"click",function(){e.zoomIn()}),l.appendChild(x);break;case"fullscreen":var w=n.buttonsHeight*n.fullscreenRatio,C=.3*n.buttonsHeight,k=(n.buttonsHeight-C)/2,_=.3*w,E=(w-_)/2-n.fullscreenThickness,S=n.buttonsHeight-2*n.fullscreenThickness;l=document.createElement("div"),l.style.cssFloat="right",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=w+"px",l.style.height=n.buttonsHeight+"px",l.style.backgroundColor=n.buttonsBackgroundColor,l.style.cursor="pointer",o(l,"click",function(){e.toggleFullscreen()});var z=document.createElement("div");z.style.cssFloat="left",z.style.boxSizing="inherit",z.style.width=n.fullscreenThickness+"px",z.style.height=C+"px",z.style.borderStyle="solid",z.style.borderColor=n.buttonsColor+" transparent",z.style.borderWidth=k+"px 0",l.appendChild(z);var T=document.createElement("div");T.style.cssFloat="left",T.style.boxSizing="inherit",T.style.width=E+"px",T.style.height=S+"px",T.style.borderStyle="solid",T.style.borderColor=n.buttonsColor+" transparent",T.style.borderWidth=n.fullscreenThickness+"px 0",l.appendChild(T);var R=document.createElement("div");R.style.cssFloat="left",R.style.boxSizing="inherit",R.style.marginLeft=_+"px",R.style.width=E+"px",R.style.height=S+"px",R.style.borderStyle="solid",R.style.borderColor=n.buttonsColor+" transparent",R.style.borderWidth=n.fullscreenThickness+"px 0",l.appendChild(R);var I=document.createElement("div");I.style.cssFloat="left",I.style.boxSizing="inherit",I.style.width=n.fullscreenThickness+"px",I.style.height=C+"px",I.style.borderStyle="solid",I.style.borderColor=n.buttonsColor+" transparent",I.style.borderWidth=k+"px 0",l.appendChild(I);var M=document.createElement("div");M.style.clear="left",l.appendChild(M),e.addAction("fullscreen-mode",d);break;case"orientation":var H=n.buttonsHeight-2*n.gyroscopeThickness,P=H-4*n.gyroscopeThickness,F=H/10;l=document.createElement("div"),l.style.cssFloat="right",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=n.buttonsHeight+"px",l.style.height=n.buttonsHeight+"px",l.style.backgroundColor=n.buttonsBackgroundColor,l.style.position="relative",l.style.cursor="pointer",o(l,"click",function(){e.toggleDeviceOrientation()});var B=document.createElement("div");B.style.boxSizing="inherit",B.style.width=H+"px",B.style.height=H+"px",B.style.borderRadius="50%",B.style.border=n.gyroscopeThickness+"px solid "+n.buttonsColor,l.appendChild(B);var O=document.createElement("div");O.style.boxSizing="inherit",O.style.width=P+"px",O.style.height=F+"px",O.style.borderRadius="50%",O.style.border=n.gyroscopeThickness+"px solid "+n.buttonsColor,O.style.position="absolute",O.style.top="50%",O.style.left="50%",O.style.marginTop=-(F/2+n.gyroscopeThickness)+"px",O.style.marginLeft=-(P/2+n.gyroscopeThickness)+"px",l.appendChild(O);var A=document.createElement("div");A.style.boxSizing="inherit",A.style.width=F+"px",A.style.height=P+"px",A.style.borderRadius="50%",A.style.border=n.gyroscopeThickness+"px solid "+n.buttonsColor,A.style.position="absolute",A.style.top="50%",A.style.left="50%",A.style.marginTop=-(P/2+n.gyroscopeThickness)+"px",A.style.marginLeft=-(F/2+n.gyroscopeThickness)+"px",l.appendChild(A),e.addAction("device-orientation",d);break;case"virtual-reality":var L=n.buttonsHeight*n.virtualRealityRatio,D=L/4,X=D/2;l=document.createElement("div"),l.style.cssFloat="right",l.style.position="relative",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=L+"px",l.style.height=n.buttonsHeight+"px",l.style.backgroundColor=n.buttonsBackgroundColor,l.style.cursor="pointer",o(l,"click",function(){e.toggleStereo()});var W=document.createElement("div");W.style.boxSizing="inherit",W.style.width=L+"px",W.style.height=n.buttonsHeight+"px",W.style.borderRadius=n.virtualRealityBorderRadius+"px",W.style.backgroundColor=n.buttonsColor,l.appendChild(W);var N=document.createElement("div");N.style.boxSizing="inherit",N.style.width=D+"px",N.style.height=D+"px",N.style.position="absolute",N.style.top=X+10+"px",N.style.left=X+10+"px",N.style.borderRadius="50%",N.style.backgroundColor=n.backgroundColor,l.appendChild(N);var $=document.createElement("div");$.style.boxSizing="inherit",$.style.width=D+"px",$.style.height=D+"px",$.style.position="absolute",$.style.top=X+10+"px",$.style.right=X+10+"px",$.style.borderRadius="50%",$.style.backgroundColor=n.backgroundColor,l.appendChild($);var q=document.createElement("div");q.style.boxSizing="inherit",q.style.width=D+"px",q.style.height=n.buttonsHeight/2+"px",q.style.position="absolute",q.style.left="50%",q.style.bottom="10px",q.style.marginLeft=-(D/2)+"px",q.style.borderTopLeftRadius="50% 60%",q.style.borderTopRightRadius="50% 60%",q.style.backgroundColor=n.backgroundColor,l.appendChild(q),e.addAction("stereo-effect",d)}};this.getButton=function(){return l};var r,a,s,l,d=function(e){e?l.style.backgroundColor=n.activeButtonsBackgroundColor:l.style.backgroundColor=n.buttonsBackgroundColor},c=function(e){s.style.left=e/100*n.zoomRangeWidth-n.zoomRangeDisk/2+"px"},u=function(e){p(parseInt(e.clientX))},h=function(e){var t=e.touches[0];(t.target==r||t.target==a||t.target==s)&&p(parseInt(t.clientX))},p=function(e){f=!0,y(e)},g=function(e){f=!1},m=function(e){e.preventDefault(),y(parseInt(e.clientX))},v=function(e){var t=e.touches[0];(t.target==r||t.target==a||t.target==s)&&(e.preventDefault(),y(parseInt(t.clientX)))},y=function(t){if(f){var o=t-a.getBoundingClientRect().left,i=o/n.zoomRangeWidth*100;e.zoom(i)}},f=!1;i()},Sphoords=function(){var e=function(){var e=navigator.userAgent;return/Gecko\/[0-9.]+/.test(e)?"Gecko":/Chrome\/[0-9.]+/.test(e)?"Blink":/AppleWebKit\/[0-9.]+/.test(e)?"WebKit":/Trident\/[0-9.]+/.test(e)?"Trident":/Opera\/[0-9.]+/.test(e)?"Presto":"Gecko"},t=function(e){return e-360*Math.floor(e/360)};this.start=function(){return Sphoords.isDeviceOrientationSupported?(window.addEventListener("deviceorientation",n,!1),i=!0,!0):(console.log("Device Orientation API not supported"),!1)},this.stop=function(){i&&(window.removeEventListener("deviceorientation",n,!1),i=!1)},this.toggle=function(){i?this.stop():this.start()},this.isEventAttached=function(){return i};var n=function(e){c=Sphoords.getScreenOrientation();var n=0,i=0;switch(c){case"portrait-primary":n=e.alpha+e.gamma,i=e.beta-90;break;case"landscape-primary":if(n=e.alpha+e.beta-90,i=-e.gamma-90,Math.abs(e.beta)>90)switch(u){case"Blink":i+=180;break;case"Gecko":default:i=-i}break;case"landscape-secondary":if(n=e.alpha-e.beta+90,i=e.gamma-90,Math.abs(e.beta)>90)switch(u){case"Blink":i+=180;break;case"Gecko":default:i=-i}break;case"portrait-secondary":n=e.alpha-e.gamma,i=180-(e.beta-90),i=270-e.beta}i=t(i),i>=180&&(i-=360),r=t(n),a=Math.max(-90,Math.min(90,i)),s=r*d,l=a*d,o()};this.getCoordinates=function(){return{longitude:s,latitude:l}},this.getCoordinatesInDegrees=function(){return{longitude:r,latitude:a}},this.getScreenOrientation=function(){return c},this.addListener=function(e){h.push(e)};var o=function(){if(h.length)for(var e=0,t=h.length;t>e;++e)h[e]({longitude:s,latitude:l})},i=!1,r=0,a=0,s=0,l=0,d=Math.PI/180,c=Sphoords.getScreenOrientation(),u=e(),h=[]};Sphoords.getScreenOrientation=function(){var e=null;return screen.orientation?e=screen.orientation:screen.mozOrientation?e=screen.mozOrientation:screen.msOrientation&&(e=screen.msOrientation),null!==e&&"object"==typeof e?e.type:e},Sphoords.isDeviceOrientationSupported=!1,function(){function e(t){null!==t&&null!==t.alpha&&(Sphoords.isDeviceOrientationSupported=!0,window.removeEventListener("deviceorientation",e))}window.DeviceOrientationEvent&&null!==Sphoords.getScreenOrientation()&&window.addEventListener("deviceorientation",e)}(); \ No newline at end of file +var PhotoSphereViewer=function(e){var t=function(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))},n=function(){var e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl"))},o=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent("on"+t,n)},i=function(e,t,n){return Math.max(t,Math.min(n,e))},r=function(e,t,n,o){var i=n-e,r=o-t;return i*i+r*r},a=function(e,t){return t=void 0!==t?!!t:!1,t&&e==2*Math.PI?2*Math.PI:e-2*Math.floor(e/(2*Math.PI))*Math.PI};this.load=function(){if(fe.innerHTML="",We&&1===We.nodeType)fe.appendChild(We);else if(We&&"string"==typeof We)fe.innerHTML=We;else if(Xe){var e=document.createElement("img");e.setAttribute("src",Xe),e.setAttribute("alt",De),fe.appendChild(e)}else fe.textContent=De;return we=document.createElement("div"),we.style.width="100%",we.style.height="100%",we.style.position="relative",we.style.overflow="hidden",t()?void 0===window.THREE?void console.log("PhotoSphereViewer: Three.js is not loaded."):(ye={width:0,height:0,ratio:0},void(Ae&&!ke.match(/^data:image\/[a-z]+;base64/)?l():d())):void(fe.textContent="Canvas is not supported, update your browser!")};var s=function(e,t){var n=e.indexOf("GPano:"+t)+t.length+8,o=e.indexOf('"',n);return e.substring(n,o)},l=function(){var e=null;if(window.XMLHttpRequest)e=new XMLHttpRequest;else{if(!window.ActiveXObject)return void(fe.textContent="XHR is not supported, update your browser!");try{e=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){e=new ActiveXObject("Microsoft.XMLHTTP")}}e.onreadystatechange=function(){if(4==e.readyState&&200==e.status){var t=e.responseText,n=t.indexOf(""),i=t.substring(n,o);if(-1==n||-1==o||-1==i.indexOf("GPano:"))return void d(!1);Le={full_width:parseInt(s(i,"FullPanoWidthPixels")),full_height:parseInt(s(i,"FullPanoHeightPixels")),cropped_width:parseInt(s(i,"CroppedAreaImageWidthPixels")),cropped_height:parseInt(s(i,"CroppedAreaImageHeightPixels")),cropped_x:parseInt(s(i,"CroppedAreaLeftPixels")),cropped_y:parseInt(s(i,"CroppedAreaTopPixels"))},d()}},e.open("GET",ke,!0),e.send(null)},d=function(){var e=new Image;e.onload=function(){var t={full_width:e.width,full_height:e.height,cropped_width:e.width,cropped_height:e.height,cropped_x:null,cropped_y:null};for(attr in Le)null==Le[attr]&&void 0!==t[attr]&&(Le[attr]=t[attr]);null==Le.cropped_x&&(Le.cropped_x=(Le.full_width-Le.cropped_width)/2),null==Le.cropped_y&&(Le.cropped_y=(Le.full_height-Le.cropped_height)/2);var o=2048;if(n()){var i=document.createElement("canvas"),r=i.getContext("webgl");o=r.getParameter(r.MAX_TEXTURE_SIZE)}var a=Math.min(Le.full_width,o),s=a/Le.full_width;Le.full_width=a,Le.cropped_width*=s,Le.cropped_x*=s,e.width=Le.cropped_width,Le.full_height*=s,Le.cropped_height*=s,Le.cropped_y*=s,e.height=Le.cropped_height;var l=document.createElement("canvas");l.width=Le.full_width,l.height=Le.full_height;var r=l.getContext("2d");r.drawImage(e,Le.cropped_x,Le.cropped_y,Le.cropped_width,Le.cropped_height),c(l.toDataURL("image/jpeg"))},ke.match(/^data:image\/[a-z]+;base64/)||e.setAttribute("crossOrigin","anonymous"),e.src=ke},c=function(e){var t=new THREE.Texture,n=new THREE.ImageLoader,o=function(e){t.needsUpdate=!0,t.image=e,u(t)};n.load(e,o)},u=function(e){void 0!==be.width&&(fe.style.width=be.width.css),void 0!==be.height&&(fe.style.height=be.height.css),b(),_e=n()?new THREE.WebGLRenderer:new THREE.CanvasRenderer,_e.setSize(ye.width,ye.height),Ee=new THREE.Scene,Se=new THREE.PerspectiveCamera(Y,ye.ratio,1,300),Se.position.set(0,0,0),Ee.add(Se);var t=new THREE.SphereGeometry(200,32,32),i=new THREE.MeshBasicMaterial({map:e,overdraw:!0}),r=new THREE.Mesh(t,i);r.scale.x=-1,Ee.add(r),Ce=document.createElement("div"),Ce.style.position="absolute",Ce.style.zIndex=0,we.appendChild(Ce),ge&&(pe.setStyle(me),pe.create(),we.appendChild(pe.getBar())),o(window,"resize",b),ve&&(o(Ce,"mousedown",C),o(document,"mousemove",z),o(Ce,"mousemove",D),o(document,"mouseup",S),o(Ce,"touchstart",k),o(document,"touchend",S),o(document,"touchmove",T),o(Ce,"mousewheel",H),o(Ce,"DOMMouseScroll",H)),o(document,"fullscreenchange",O),o(document,"mozfullscreenchange",O),o(document,"webkitfullscreenchange",O),o(document,"MSFullscreenChange",O),Be.addListener(P),fe.innerHTML="",fe.appendChild(we);var a=_e.domElement;a.style.display="block",Ce.appendChild(a),h(),ie>0&&F(ie),m(),$("ready")},h=function(){var e=new THREE.Vector3;e.setX(Math.cos(te)*Math.sin(ne)),e.setY(Math.sin(te)),e.setZ(Math.cos(te)*Math.cos(ne)),Se.lookAt(e),null!==ze?ze.render(Ee,Se):_e.render(Ee,Se)},p=function(){ze=new THREE.StereoEffect(_e),ze.eyeSeparation=5,ze.setSize(ye.width,ye.height),I(),A(),pe.mustBeHidden(),h(),$("stereo-effect",!0)},g=function(){ze=null,_e.setSize(ye.width,ye.height),pe.mustBeHidden(!1),h(),$("stereo-effect",!1)};this.toggleStereo=function(){null!==ze?g():p()};var m=function(){se!==!1&&(Fe=setTimeout(y,se))},v=function(){te-=(te-ue)*ce,ne+=le;var e=!0;J||(ne=i(ne,Q,ee),(ne==Q||ne==ee)&&(de?le*=-1:(f(),e=!1))),ne=a(ne,!0),h(),e&&(He=setTimeout(v,ae))},y=function(){v(),$("autorotate",!0)},f=function(){clearTimeout(Fe),Fe=null,clearTimeout(He),He=null,$("autorotate",!1)};this.toggleAutorotate=function(){clearTimeout(Fe),He?f():y()};var b=function(){(fe.clientWidth!=ye.width||fe.clientHeight!=ye.height)&&x({width:fe.clientWidth,height:fe.clientHeight})};this.fitToContainer=function(){b()};var x=function(e){ye.width=void 0!==e.width?parseInt(e.width):ye.width,ye.height=void 0!==e.height?parseInt(e.height):ye.height,ye.ratio=ye.width/ye.height,Se&&(Se.aspect=ye.ratio,Se.updateProjectionMatrix()),_e&&(_e.setSize(ye.width,ye.height),h()),ze&&(ze.setSize(ye.width,ye.height),h())};this.getPosition=function(){return{longitude:ne,latitude:te}},this.getPositionInDegrees=function(){return{longitude:180*ne/Math.PI,latitude:180*te/Math.PI}};var w=function(e,t){var n=W(e);J||(n=i(n,Q,ee));var o=W(t);o>Math.PI&&(o-=2*Math.PI),o=i(o,U,j),ne=n,te=o,h()};this.moveTo=function(e,t){w(e,t)};var C=function(e){_(parseInt(e.clientX),parseInt(e.clientY))},k=function(e){if(1==e.touches.length){var t=e.touches[0];t.target.parentNode==Ce&&_(parseInt(t.clientX),parseInt(t.clientY))}else 2==e.touches.length&&(S(),e.touches[0].target.parentNode==Ce&&e.touches[1].target.parentNode==Ce&&E(r(e.touches[0].clientX,e.touches[0].clientY,e.touches[1].clientX,e.touches[1].clientY)));D()},_=function(e,t){Re=e,Ie=t,f(),Te=!0},E=function(e){Pe=e,Me=!0},S=function(e){Te=!1,Me=!1},z=function(e){e.preventDefault(),R(parseInt(e.clientX),parseInt(e.clientY))},T=function(e){if(1==e.touches.length&&Te){var t=e.touches[0];t.target.parentNode==Ce&&(e.preventDefault(),R(parseInt(t.clientX),parseInt(t.clientY)))}else if(2==e.touches.length&&e.touches[0].target.parentNode==Ce&&e.touches[1].target.parentNode==Ce&&Me){e.preventDefault();var n=r(e.touches[0].clientX,e.touches[0].clientY,e.touches[1].clientX,e.touches[1].clientY),o=n-Pe;if(0!=o){var i=o/Math.abs(o);F(ie+i),Pe=n}}},R=function(e,t){Te&&(ne+=(e-Re)*q,J||(ne=i(ne,Q,ee)),ne=a(ne,!0),te+=(t-Ie)*V,te=i(te,U,j),Re=e,Ie=t,h())},I=function(){Be.start(),f(),$("device-orientation",!0)},M=function(){Be.stop(),$("device-orientation",!1)};this.toggleDeviceOrientation=function(){Be.isEventAttached()?M():I()};var P=function(e){ne=i(e.longitude,Q,ee),te=i(e.latitude,U,j),h()},H=function(e){e.preventDefault(),e.stopPropagation();var t=e.detail?-e.detail:e.wheelDelta;if(0!=t){var n=parseInt(t/Math.abs(t));F(ie+n)}},F=function(e){ie=i(parseInt(Math.round(e)),0,100),Se.fov=Y+ie/100*(G-Y),Se.updateProjectionMatrix(),h(),$("zoom-updated",ie)};this.zoom=function(e){F(e)},this.zoomIn=function(){100>ie&&F(ie+1)},this.zoomOut=function(){ie>0&&F(ie-1)};var B=function(){return!!(document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement)},O=function(){document.webkitFullscreenElement||document.msFullscreenElement?(xe.width=fe.style.width,xe.height=fe.style.height,fe.style.width="100%",fe.style.height="100%",b()):(fe.webkitRequestFullscreen||fe.msRequestFullscreen)&&(fe.style.width=xe.width,fe.style.height=xe.height,b()),$("fullscreen-mode",B())},A=function(){fe.requestFullscreen?fe.requestFullscreen():fe.mozRequestFullScreen?fe.mozRequestFullScreen():fe.webkitRequestFullscreen?fe.webkitRequestFullscreen():fe.msRequestFullscreen&&fe.msRequestFullscreen()},L=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen()};this.toggleFullscreen=function(){B()?L():A()};var D=function(){ge&&pe.show()},X=function(e){e=e.toString().trim();var t=parseFloat(e.replace(/^(-?[0-9]+(?:\.[0-9]*)?).*$/,"$1")),n=e.replace(/^-?[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();n.match(/(pm|per minute)$/)&&(t/=60);var o=0;switch(n){case"rpm":case"rev per minute":case"revolutions per minute":case"rps":case"rev per second":case"revolutions per second":o=2*t*Math.PI;break;case"dpm":case"deg per minute":case"degrees per minute":case"dps":case"deg per second":case"degrees per second":o=t*Math.PI/180;break;case"rad per minute":case"radians per minute":case"rad per second":case"radians per second":o=t;break;default:m_anim=!1}return o*ae/1e3},W=function(e){e=e.toString().trim();var t=parseFloat(e.replace(/^(-?[0-9]+(?:\.[0-9]*)?).*$/,"$1")),n=e.replace(/^-?[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();return"deg"==n&&(t*=Math.PI/180),a(t)},N=function(e){for(dim in e)if("width"==dim||"height"==dim){var t=e[dim].toString().trim(),n=parseFloat(t.replace(/^([0-9]+(?:\.[0-9]*)?).*$/,"$1")),o=t.replace(/^[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();"%"!=o&&(o="px"),be[dim]={css:n+o,unit:o}}};this.addAction=function(e,t){e in Oe||(Oe[e]=[]),Oe[e].push(t)};var $=function(e,t){if(e in Oe&&Oe[e].length)for(var n=0,o=Oe[e].length;o>n;++n)void 0!==t?Oe[e][n](t):Oe[e][n]()};if(void 0===e||void 0===e.panorama||void 0===e.container)return void console.log("PhotoSphereViewer: no value given for panorama or container");var q=void 0!==e.long_offset?parseFloat(e.long_offset):Math.PI/360,V=void 0!==e.lat_offset?parseFloat(e.lat_offset):Math.PI/180,G=void 0!==e.min_fov?i(parseFloat(e.min_fov),1,179):30,Y=void 0!==e.max_fov?i(parseFloat(e.max_fov),1,179):90,j=void 0!==e.tilt_up_max?i(W(e.tilt_up_max),0,Math.PI/2):Math.PI/2,U=void 0!==e.tilt_down_max?-i(W(e.tilt_down_max),0,Math.PI/2):-Math.PI/2,K=void 0!==e.min_longitude?W(e.min_longitude):0,Z=void 0!==e.max_longitude?W(e.max_longitude):0,J=K==Z;J?(K=0,Z=2*Math.PI):0==Z&&(Z=2*Math.PI);var Q,ee;Z>K?(Q=K,ee=Z):(Q=Z,ee=K);var te=0,ne=Q;if(void 0!==e.default_position){if(void 0!==e.default_position.lat){var oe=W(e.default_position.lat);oe>Math.PI&&(oe-=2*Math.PI),te=i(oe,U,j)}void 0!==e.default_position["long"]&&(ne=i(W(e.default_position["long"]),Q,ee))}var ie=0;void 0!==e.zoom_level&&(ie=i(parseInt(Math.round(e.zoom_level)),0,100));var re=60,ae=1e3/re,se=2e3;void 0!==e.time_anim&&(se="number"==typeof e.time_anim&&e.time_anim>=0?e.time_anim:!1);var le=X(void 0!==e.anim_speed?e.anim_speed:"2rpm"),de=!0;void 0!==e.reverse_anim&&(de=!!e.reverse_anim);var ce=X(void 0!==e.vertical_anim_speed?e.vertical_anim_speed:"2rpm"),ue=0;if(void 0!==e.vertical_anim_target){var he=W(e.vertical_anim_target);he>Math.PI&&(he-=2*Math.PI),ue=i(he,U,j)}var pe=new PSVNavBar(this),ge=void 0!==e.navbar?!!e.navbar:!1,me=void 0!==e.navbar_style?e.navbar_style:{},ve=void 0!==e.allow_user_interactions?!!e.allow_user_interactions:!0;ve||(ge=!1);var ye,fe=e.container,be={},xe={};void 0!==e.size&&N(e.size);var we,Ce,ke=e.panorama,_e=null,Ee=null,Se=null,ze=null,Te=!1,Re=0,Ie=0,Me=!1,Pe=0,He=null,Fe=null,Be=new Sphoords,Oe={},Ae=void 0!==e.usexmpdata?!!e.usexmpdata:!0,Le={full_width:null,full_height:null,cropped_width:null,cropped_height:null,cropped_x:null,cropped_y:null};if(void 0!==e.pano_size){for(attr in Le)void 0!==e.pano_size[attr]&&(Le[attr]=parseInt(e.pano_size[attr]));Ae=!1}var De=void 0!==e.loading_msg?e.loading_msg.toString():"Loading…",Xe=void 0!==e.loading_img?e.loading_img.toString():null,We=void 0!==e.loading_html?e.loading_html:null;void 0!==e.onready&&this.addAction("ready",e.onready);var Ne=void 0!==e.autoload?!!e.autoload:!0;Ne&&this.load()},PSVNavBar=function(e){var t=function(e,t){for(var n=0,o=t.length;o>n;++n)if(t[n]==e)return!0;return!1},n=function(e,n){return t(e,h)&&"string"==typeof n&&("transparent"==n||!!n.match(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/)||!!n.match(/^rgb\((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])(,\s*(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}\)$/)||!!n.match(/^rgba\(((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5]),\s*){3}(0(\.[0-9]*)?|1)\)$/))||t(e,p)&&!isNaN(parseFloat(n))&&isFinite(n)&&n>=0};this.setStyle=function(e){for(property in e)property in u&&n(property,e[property])&&(u[property]=e[property])},this.create=function(){r=document.createElement("div"),r.style.backgroundColor=u.backgroundColor,r.style.position="absolute",r.style.zIndex=10,r.style.bottom=0,r.style.width="100%",r.style.boxSizing="content-box",r.style.transition="bottom 0.4s ease-out",a=new PSVNavBarButton(e,"autorotate",u),r.appendChild(a.getButton()),s=new PSVNavBarButton(e,"zoom",u),r.appendChild(s.getButton()),l=new PSVNavBarButton(e,"fullscreen",u),r.appendChild(l.getButton()),Sphoords.isDeviceOrientationSupported&&(d=new PSVNavBarButton(e,"orientation",u),r.appendChild(d.getButton()),c=new PSVNavBarButton(e,"virtual-reality",u),r.appendChild(c.getButton()))},this.getBar=function(){return r};var o=function(){g&&(clearTimeout(g),!m&&v&&(g=setTimeout(i,5e3))),m&&(r.style.bottom=0,m=!1,v&&(g=setTimeout(i,5e3)))};this.show=function(){o()};var i=function(){m||(r.style.bottom=-r.offsetHeight+1+"px",m=!0)};this.hide=function(){i()},this.isHidden=function(){return m},this.mustBeHidden=function(e){v=void 0!==e?!!e:!0,v?i():o()};var r,a,s,l,d,c,u={backgroundColor:"rgba(61, 61, 61, 0.5)",buttonsColor:"rgba(255, 255, 255, 0.7)",buttonsBackgroundColor:"transparent",activeButtonsBackgroundColor:"rgba(255, 255, 255, 0.1)",buttonsHeight:20,autorotateThickness:1,zoomRangeWidth:50,zoomRangeThickness:1,zoomRangeDisk:7,fullscreenRatio:4/3,fullscreenThickness:2,gyroscopeThickness:1,virtualRealityRatio:4/3,virtualRealityBorderRadius:2},h=["backgroundColor","buttonsColor","buttonsBackgroundColor","activeButtonsBackgroundColor"],p=["buttonsHeight","autorotateThickness","zoomRangeWidth","zoomRangeThickness","zoomRangeDisk","fullscreenRatio","fullscreenThickness"],g=null,m=!1,v=!1},PSVNavBarButton=function(e,t,n){var o=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent("on"+t,n)},i=function(){switch(t){case"autorotate":var i=n.buttonsHeight-2*n.autorotateThickness,p=i/10;l=document.createElement("div"),l.style.cssFloat="left",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=n.buttonsHeight+"px",l.style.height=n.buttonsHeight+"px",l.style.backgroundColor=n.buttonsBackgroundColor,l.style.position="relative",l.style.cursor="pointer",o(l,"click",function(){e.toggleAutorotate()});var y=document.createElement("div");y.style.boxSizing="inherit",y.style.width=i+"px",y.style.height=i+"px",y.style.borderRadius="50%",y.style.border=n.autorotateThickness+"px solid "+n.buttonsColor,l.appendChild(y);var f=document.createElement("div");f.style.boxSizing="inherit",f.style.width=i+"px",f.style.height=p+"px",f.style.borderRadius="50%",f.style.border=n.autorotateThickness+"px solid "+n.buttonsColor,f.style.position="absolute",f.style.top="50%",f.style.marginTop=-(p/2+n.autorotateThickness)+"px",l.appendChild(f),e.addAction("autorotate",d);break;case"zoom":l=document.createElement("div"),l.style.cssFloat="left",l.style.boxSizing="inherit";var b=document.createElement("div");b.style.cssFloat="left",b.style.boxSizing="inherit",b.style.padding="10px",b.style.height=n.buttonsHeight+"px",b.style.backgroundColor=n.buttonsBackgroundColor,b.style.lineHeight=n.buttonsHeight+"px",b.style.color=n.buttonsColor,b.style.cursor="pointer",b.textContent="-",o(b,"click",function(){e.zoomOut()}),l.appendChild(b),r=document.createElement("div"),r.style.cssFloat="left",r.style.boxSizing="inherit",r.style.padding=10+(n.buttonsHeight-n.zoomRangeThickness)/2+"px 5px",r.style.backgroundColor=n.buttonsBackgroundColor,r.style.cursor="pointer",l.appendChild(r),a=document.createElement("div"),a.style.boxSizing="inherit",a.style.width=n.zoomRangeWidth+"px",a.style.height=n.zoomRangeThickness+"px",a.style.backgroundColor=n.buttonsColor,a.style.position="relative",r.appendChild(a),s=document.createElement("div"),s.style.position="absolute",s.style.top=(n.zoomRangeThickness-n.zoomRangeDisk)/2+"px",s.style.left=-(n.zoomRangeDisk/2)+"px",s.style.boxSizing="inherit",s.style.width=n.zoomRangeDisk+"px",s.style.height=n.zoomRangeDisk+"px",s.style.borderRadius="50%",s.style.backgroundColor=n.buttonsColor,e.addAction("zoom-updated",c),o(r,"mousedown",u),o(r,"touchstart",h),o(document,"mousemove",m),o(document,"touchmove",v),o(document,"mouseup",g),o(document,"touchend",g),a.appendChild(s);var x=document.createElement("div");x.style.cssFloat="left",x.style.boxSizing="inherit",x.style.padding="10px",x.style.height=n.buttonsHeight+"px",x.style.backgroundColor=n.buttonsBackgroundColor,x.style.lineHeight=n.buttonsHeight+"px",x.style.color=n.buttonsColor,x.style.cursor="pointer",x.textContent="+",o(x,"click",function(){e.zoomIn()}),l.appendChild(x);break;case"fullscreen":var w=n.buttonsHeight*n.fullscreenRatio,C=.3*n.buttonsHeight,k=(n.buttonsHeight-C)/2,_=.3*w,E=(w-_)/2-n.fullscreenThickness,S=n.buttonsHeight-2*n.fullscreenThickness;l=document.createElement("div"),l.style.cssFloat="right",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=w+"px",l.style.height=n.buttonsHeight+"px",l.style.backgroundColor=n.buttonsBackgroundColor,l.style.cursor="pointer",o(l,"click",function(){e.toggleFullscreen()});var z=document.createElement("div");z.style.cssFloat="left",z.style.boxSizing="inherit",z.style.width=n.fullscreenThickness+"px",z.style.height=C+"px",z.style.borderStyle="solid",z.style.borderColor=n.buttonsColor+" transparent",z.style.borderWidth=k+"px 0",l.appendChild(z);var T=document.createElement("div");T.style.cssFloat="left",T.style.boxSizing="inherit",T.style.width=E+"px",T.style.height=S+"px",T.style.borderStyle="solid",T.style.borderColor=n.buttonsColor+" transparent",T.style.borderWidth=n.fullscreenThickness+"px 0",l.appendChild(T);var R=document.createElement("div");R.style.cssFloat="left",R.style.boxSizing="inherit",R.style.marginLeft=_+"px",R.style.width=E+"px",R.style.height=S+"px",R.style.borderStyle="solid",R.style.borderColor=n.buttonsColor+" transparent",R.style.borderWidth=n.fullscreenThickness+"px 0",l.appendChild(R);var I=document.createElement("div");I.style.cssFloat="left",I.style.boxSizing="inherit",I.style.width=n.fullscreenThickness+"px",I.style.height=C+"px",I.style.borderStyle="solid",I.style.borderColor=n.buttonsColor+" transparent",I.style.borderWidth=k+"px 0",l.appendChild(I);var M=document.createElement("div");M.style.clear="left",l.appendChild(M),e.addAction("fullscreen-mode",d);break;case"orientation":var P=n.buttonsHeight-2*n.gyroscopeThickness,H=P-4*n.gyroscopeThickness,F=P/10;l=document.createElement("div"),l.style.cssFloat="right",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=n.buttonsHeight+"px",l.style.height=n.buttonsHeight+"px",l.style.backgroundColor=n.buttonsBackgroundColor,l.style.position="relative",l.style.cursor="pointer",o(l,"click",function(){e.toggleDeviceOrientation()});var B=document.createElement("div");B.style.boxSizing="inherit",B.style.width=P+"px",B.style.height=P+"px",B.style.borderRadius="50%",B.style.border=n.gyroscopeThickness+"px solid "+n.buttonsColor,l.appendChild(B);var O=document.createElement("div");O.style.boxSizing="inherit",O.style.width=H+"px",O.style.height=F+"px",O.style.borderRadius="50%",O.style.border=n.gyroscopeThickness+"px solid "+n.buttonsColor,O.style.position="absolute",O.style.top="50%",O.style.left="50%",O.style.marginTop=-(F/2+n.gyroscopeThickness)+"px",O.style.marginLeft=-(H/2+n.gyroscopeThickness)+"px",l.appendChild(O);var A=document.createElement("div");A.style.boxSizing="inherit",A.style.width=F+"px",A.style.height=H+"px",A.style.borderRadius="50%",A.style.border=n.gyroscopeThickness+"px solid "+n.buttonsColor,A.style.position="absolute",A.style.top="50%",A.style.left="50%",A.style.marginTop=-(H/2+n.gyroscopeThickness)+"px",A.style.marginLeft=-(F/2+n.gyroscopeThickness)+"px",l.appendChild(A),e.addAction("device-orientation",d);break;case"virtual-reality":var L=n.buttonsHeight*n.virtualRealityRatio,D=L/4,X=D/2;l=document.createElement("div"),l.style.cssFloat="right",l.style.position="relative",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=L+"px",l.style.height=n.buttonsHeight+"px",l.style.backgroundColor=n.buttonsBackgroundColor,l.style.cursor="pointer",o(l,"click",function(){e.toggleStereo()});var W=document.createElement("div");W.style.boxSizing="inherit",W.style.width=L+"px",W.style.height=n.buttonsHeight+"px",W.style.borderRadius=n.virtualRealityBorderRadius+"px",W.style.backgroundColor=n.buttonsColor,l.appendChild(W);var N=document.createElement("div");N.style.boxSizing="inherit",N.style.width=D+"px",N.style.height=D+"px",N.style.position="absolute",N.style.top=X+10+"px",N.style.left=X+10+"px",N.style.borderRadius="50%",N.style.backgroundColor=n.backgroundColor,l.appendChild(N);var $=document.createElement("div");$.style.boxSizing="inherit",$.style.width=D+"px",$.style.height=D+"px",$.style.position="absolute",$.style.top=X+10+"px",$.style.right=X+10+"px",$.style.borderRadius="50%",$.style.backgroundColor=n.backgroundColor,l.appendChild($);var q=document.createElement("div");q.style.boxSizing="inherit",q.style.width=D+"px",q.style.height=n.buttonsHeight/2+"px",q.style.position="absolute",q.style.left="50%",q.style.bottom="10px",q.style.marginLeft=-(D/2)+"px",q.style.borderTopLeftRadius="50% 60%",q.style.borderTopRightRadius="50% 60%",q.style.backgroundColor=n.backgroundColor,l.appendChild(q),e.addAction("stereo-effect",d)}};this.getButton=function(){return l};var r,a,s,l,d=function(e){e?l.style.backgroundColor=n.activeButtonsBackgroundColor:l.style.backgroundColor=n.buttonsBackgroundColor},c=function(e){s.style.left=e/100*n.zoomRangeWidth-n.zoomRangeDisk/2+"px"},u=function(e){p(parseInt(e.clientX))},h=function(e){var t=e.touches[0];(t.target==r||t.target==a||t.target==s)&&p(parseInt(t.clientX))},p=function(e){f=!0,y(e)},g=function(e){f=!1},m=function(e){e.preventDefault(),y(parseInt(e.clientX))},v=function(e){var t=e.touches[0];(t.target==r||t.target==a||t.target==s)&&(e.preventDefault(),y(parseInt(t.clientX)))},y=function(t){if(f){var o=t-a.getBoundingClientRect().left,i=o/n.zoomRangeWidth*100;e.zoom(i)}},f=!1;i()},Sphoords=function(){var e=function(){var e=navigator.userAgent;return/Gecko\/[0-9.]+/.test(e)?"Gecko":/Chrome\/[0-9.]+/.test(e)?"Blink":/AppleWebKit\/[0-9.]+/.test(e)?"WebKit":/Trident\/[0-9.]+/.test(e)?"Trident":/Opera\/[0-9.]+/.test(e)?"Presto":"Gecko"},t=function(e){return e-360*Math.floor(e/360)};this.start=function(){return Sphoords.isDeviceOrientationSupported?(window.addEventListener("deviceorientation",n,!1),i=!0,!0):(console.log("Device Orientation API not supported"),!1)},this.stop=function(){i&&(window.removeEventListener("deviceorientation",n,!1),i=!1)},this.toggle=function(){i?this.stop():this.start()},this.isEventAttached=function(){return i};var n=function(e){c=Sphoords.getScreenOrientation();var n=0,i=0;switch(c){case"portrait-primary":n=e.alpha+e.gamma,i=e.beta-90;break;case"landscape-primary":if(n=e.alpha+e.beta-90,i=-e.gamma-90,Math.abs(e.beta)>90)switch(u){case"Blink":i+=180;break;case"Gecko":default:i=-i}break;case"landscape-secondary":if(n=e.alpha-e.beta+90,i=e.gamma-90,Math.abs(e.beta)>90)switch(u){case"Blink":i+=180;break;case"Gecko":default:i=-i}break;case"portrait-secondary":n=e.alpha-e.gamma,i=180-(e.beta-90),i=270-e.beta}i=t(i),i>=180&&(i-=360),r=t(n),a=Math.max(-90,Math.min(90,i)),s=r*d,l=a*d,o()};this.getCoordinates=function(){return{longitude:s,latitude:l}},this.getCoordinatesInDegrees=function(){return{longitude:r,latitude:a}},this.getScreenOrientation=function(){return c},this.addListener=function(e){h.push(e)};var o=function(){if(h.length)for(var e=0,t=h.length;t>e;++e)h[e]({longitude:s,latitude:l})},i=!1,r=0,a=0,s=0,l=0,d=Math.PI/180,c=Sphoords.getScreenOrientation(),u=e(),h=[]};Sphoords.getScreenOrientation=function(){var e=null;return screen.orientation?e=screen.orientation:screen.mozOrientation?e=screen.mozOrientation:screen.msOrientation&&(e=screen.msOrientation),null!==e&&"object"==typeof e?e.type:e},Sphoords.isDeviceOrientationSupported=!1,function(){function e(t){null!==t&&null!==t.alpha&&(Sphoords.isDeviceOrientationSupported=!0,window.removeEventListener("deviceorientation",e))}window.DeviceOrientationEvent&&null!==Sphoords.getScreenOrientation()&&window.addEventListener("deviceorientation",e)}(); \ No newline at end of file diff --git a/src/PSVNavBar.js b/src/PSVNavBar.js index b2300d54d..53fe0e12c 100644 --- a/src/PSVNavBar.js +++ b/src/PSVNavBar.js @@ -1,28 +1,3 @@ -/* - * Photo Sphere Viewer v2.4 - * http://jeremyheleine.me/photo-sphere-viewer - * - * Copyright (c) 2014,2015 Jérémy Heleine - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - /** * Represents the navigation bar. * @class diff --git a/src/PSVNavBarButton.js b/src/PSVNavBarButton.js index 38272b37c..f82544f12 100644 --- a/src/PSVNavBarButton.js +++ b/src/PSVNavBarButton.js @@ -1,28 +1,3 @@ -/* - * Photo Sphere Viewer v2.4 - * http://jeremyheleine.me/photo-sphere-viewer - * - * Copyright (c) 2014,2015 Jérémy Heleine - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - /** * Represents a navigation bar button. * @class diff --git a/src/PhotoSphereViewer.js b/src/PhotoSphereViewer.js index d4c1bc500..6ca8cd708 100644 --- a/src/PhotoSphereViewer.js +++ b/src/PhotoSphereViewer.js @@ -1,5 +1,5 @@ /* - * Photo Sphere Viewer v2.4 + * Photo Sphere Viewer v2.4.1 * http://jeremyheleine.me/photo-sphere-viewer * * Copyright (c) 2014,2015 Jérémy Heleine @@ -150,11 +150,13 @@ var PhotoSphereViewer = function(args) { * Returns the measure of an angle (between 0 and 2π). * @private * @param {number} angle - The angle to reduce + * @param {boolean} [is_2pi_allowed=false] - Can the measure be equal to 2π? * @return {number} The wanted measure **/ - var getAngleMeasure = function(angle) { - return angle - Math.floor(angle / (2.0 * Math.PI)) * 2.0 * Math.PI; + var getAngleMeasure = function(angle, is_2pi_allowed) { + is_2pi_allowed = (is_2pi_allowed !== undefined) ? !!is_2pi_allowed : false; + return (is_2pi_allowed && angle == 2 * Math.PI) ? 2 * Math.PI : angle - Math.floor(angle / (2.0 * Math.PI)) * 2.0 * Math.PI; }; /** @@ -581,7 +583,7 @@ var PhotoSphereViewer = function(args) { var again = true; - if (PSV_MIN_LONGITUDE != PSV_MAX_LONGITUDE) { + if (!whole_circle) { long = stayBetween(long, PSV_MIN_LONGITUDE, PSV_MAX_LONGITUDE); if (long == PSV_MIN_LONGITUDE || long == PSV_MAX_LONGITUDE) { @@ -596,7 +598,7 @@ var PhotoSphereViewer = function(args) { } } - long = getAngleMeasure(long); + long = getAngleMeasure(long, true); render(); @@ -744,7 +746,7 @@ var PhotoSphereViewer = function(args) { var moveTo = function(longitude, latitude) { var long_tmp = parseAngle(longitude); - if (PSV_MIN_LONGITUDE != PSV_MAX_LONGITUDE) + if (!whole_circle) long_tmp = stayBetween(long_tmp, PSV_MIN_LONGITUDE, PSV_MAX_LONGITUDE); var lat_tmp = parseAngle(latitude); @@ -912,10 +914,10 @@ var PhotoSphereViewer = function(args) { if (mousedown) { long += (x - mouse_x) * PSV_LONG_OFFSET; - if (PSV_MIN_LONGITUDE != PSV_MAX_LONGITUDE) + if (!whole_circle) long = stayBetween(long, PSV_MIN_LONGITUDE, PSV_MAX_LONGITUDE); - long = getAngleMeasure(long); + long = getAngleMeasure(long, true); lat += (y - mouse_y) * PSV_LAT_OFFSET; lat = stayBetween(lat, PSV_TILT_DOWN_MAX, PSV_TILT_UP_MAX); @@ -1340,14 +1342,29 @@ var PhotoSphereViewer = function(args) { var PSV_TILT_UP_MAX = (args.tilt_up_max !== undefined) ? stayBetween(parseAngle(args.tilt_up_max), 0, Math.PI / 2.0) : Math.PI / 2.0; var PSV_TILT_DOWN_MAX = (args.tilt_down_max !== undefined) ? -stayBetween(parseAngle(args.tilt_down_max), 0, Math.PI / 2.0) : -Math.PI / 2.0; - // Minimum and maximum visible longitudes ((min = max) => whole circle) - var PSV_MIN_LONGITUDE = (args.min_longitude !== undefined) ? parseAngle(args.min_longitude) : 0; - var PSV_MAX_LONGITUDE = (args.max_longitude !== undefined) ? parseAngle(args.max_longitude) : 0; + // Minimum and maximum visible longitudes + var min_long = (args.min_longitude !== undefined) ? parseAngle(args.min_longitude) : 0; + var max_long = (args.max_longitude !== undefined) ? parseAngle(args.max_longitude) : 0; - if (PSV_MAX_LONGITUDE < PSV_MIN_LONGITUDE) { - var long_tmp = PSV_MIN_LONGITUDE; - PSV_MIN_LONGITUDE = PSV_MAX_LONGITUDE; - PSV_MAX_LONGITUDE = long_tmp; + var whole_circle = (min_long == max_long); + + if (whole_circle) { + min_long = 0; + max_long = 2 * Math.PI; + } + + else if (max_long == 0) + max_long = 2 * Math.PI; + + var PSV_MIN_LONGITUDE, PSV_MAX_LONGITUDE; + if (min_long < max_long) { + PSV_MIN_LONGITUDE = min_long; + PSV_MAX_LONGITUDE = max_long; + } + + else { + PSV_MIN_LONGITUDE = max_long; + PSV_MAX_LONGITUDE = min_long; } // Default position