From ab4b47ec81c5c20ab059faa6632b702a1687ee43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Heleine?= Date: Sat, 21 Nov 2015 10:46:47 +0100 Subject: [PATCH] Version 2.5 --- README.md | 12 ++- photo-sphere-viewer.js | 186 +++++++++++++++++++++++++++++-------- photo-sphere-viewer.min.js | 2 +- src/PSVNavBar.js | 2 +- src/PhotoSphereViewer.js | 2 +- 5 files changed, 158 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 58fbc57a..61092c0e 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,18 @@ Photo Sphere Viewer uses the [Three.js](http://threejs.org) library, so nothing * `container` (required): the `div` in which the panorama will be displayed. * `autoload` (optional, default to `true`): `true` to automatically load the panorama, `false` to load it later (with the `.load()` method). * `usexmpdata` (optional, default to `true`): `true` if Photo Sphere Viewer must read XMP data, `false` if it is not necessary. + * `cors_anonymous` (optional, default to `true`): `true` to disable the exchange of user credentials via cookies, `false` otherwise. * `pano_size` (optional, default to null) The panorama size, if cropped (unnecessary if XMP data can be read). * `default_position` (optional, default to `{}`) Defines the default position, the first point seen by the user (e.g. `{long: Math.PI, lat: Math.PI/2}`). * `min_fov` (optional, default to `30`): the minimal field of view, in degrees, between 1 and 179. * `max_fov` (optional, default to `90`): the maximal field of view, in degrees, between 1 and 179. * `allow_user_interactions` (optional, default to `true`): If set to `false`, the user won't be able to interact with the panorama (navigation bar is then disabled). - * `tilt_up_max` (optional, default to `Math.PI/2`) The maximal tilt up angle, in radians. - * `tilt_down_max` (optional, default to `Math.PI/2`) The maximal tilt down angle, in radians. - * `min_longitude` (optional, default to 0) The minimal longitude to show. - * `max_longitude` (optional, default to 2π) The maximal longitude to show. - * `zoom_level` (optional, default to `0`) The default zoom level, between 0 and 100. + * `allow_scroll_to_zoom (optional, default to `true`): It set to `false`, the user won't be able to scroll with their mouse to zoom. + * `tilt_up_max` (optional, default to `Math.PI/2`): The maximal tilt up angle, in radians. + * `tilt_down_max` (optional, default to `Math.PI/2`): The maximal tilt down angle, in radians. + * `min_longitude` (optional, default to 0): The minimal longitude to show. + * `max_longitude` (optional, default to 2π): The maximal longitude to show. + * `zoom_level` (optional, default to `0`): The default zoom level, between 0 and 100. * `long_offset` (optional, default to `PI/360`): the longitude to travel per pixel moved by mouse/touch. * `lat_offset` (optional, default to `PI/180`): the latitude to travel per pixel moved by mouse/touch. * `time_anim` (optional, default to `2000`): the panorama will be automatically animated after `time_anim` milliseconds (indicate `false` to deactivate it). diff --git a/photo-sphere-viewer.js b/photo-sphere-viewer.js index c19d0286..0b5fdbea 100644 --- a/photo-sphere-viewer.js +++ b/photo-sphere-viewer.js @@ -1,5 +1,5 @@ /* - * Photo Sphere Viewer v2.4.1 + * Photo Sphere Viewer v2.5 * http://jeremyheleine.me/photo-sphere-viewer * * Copyright (c) 2014,2015 Jérémy Heleine @@ -28,10 +28,10 @@ * @class * @param {object} args - Settings to apply to the viewer * @param {string} args.panorama - Panorama URL or path (absolute or relative) - * @param {HTMLElement} args.container - Panorama container (should be a `div` or equivalent) + * @param {HTMLElement|string} args.container - Panorama container (should be a `div` or equivalent), can be a string (the ID of the element to retrieve) * @param {boolean} [args.autoload=true] - `true` to automatically load the panorama, `false` to load it later (with the {@link PhotoSphereViewer#load|`.load`} method) * @param {boolean} [args.usexmpdata=true] - `true` if Photo Sphere Viewer must read XMP data, `false` if it is not necessary - * @param {boolean} [args.cors_anonymous=true] - `true` There will be no exchange of user credentials via cookies, client-side SSL certificates. + * @param {boolean} [args.cors_anonymous=true] - `true` to disable the exchange of user credentials via cookies, `false` otherwise * @param {object} [args.pano_size=null] - The panorama size, if cropped (unnecessary if XMP data can be read) * @param {number} [args.pano_size.full_width=null] - The full panorama width, before crop (the image width if `null`) * @param {number} [args.pano_size.full_height=null] - The full panorama height, before crop (the image height if `null`) @@ -45,6 +45,7 @@ * @param {number} [args.min_fov=30] - The minimal field of view, in degrees, between 1 and 179 * @param {number} [args.max_fov=90] - The maximal field of view, in degrees, between 1 and 179 * @param {boolean} [args.allow_user_interactions=true] - If set to `false`, the user won't be able to interact with the panorama (navigation bar is then disabled) + * @param {boolean} [args.allow_scroll_to_zoom=true] - It set to `false`, the user won't be able to scroll with their mouse to zoom * @param {number|string} [args.tilt_up_max=π/2] - The maximal tilt up angle, in radians (or in degrees if indicated, e.g. `'30deg'`) * @param {number|string} [args.tilt_down_max=π/2] - The maximal tilt down angle, in radians (or in degrees if indicated, e.g. `'30deg'`) * @param {number|string} [args.min_longitude=0] - The minimal longitude to show @@ -70,6 +71,7 @@ * @param {number} [args.navbar_style.zoomRangeDisk=7] - Zoom range disk diameter in pixels * @param {number} [args.navbar_style.fullscreenRatio=4/3] - Fullscreen icon ratio (width/height) * @param {number} [args.navbar_style.fullscreenThickness=2] - Fullscreen icon thickness in pixels + * @param {number} [args.eyes_offset=5] - Eyes offset in VR mode * @param {string} [args.loading_msg=Loading…] - Loading message * @param {string} [args.loading_img=null] - Loading image URL or path (absolute or relative) * @param {HTMLElement|string} [args.loading_html=null] - An HTML loader (element to append to the container or string representing the HTML) @@ -223,6 +225,26 @@ var PhotoSphereViewer = function(args) { createBuffer(); }; + /** + * Returns Google's XMP data. + * @private + * @param {string} file - Binary file + * @return {string} The data + **/ + + var getXMPData = function(file) { + var a = 0, b = 0; + var data = ''; + + while ((a = file.indexOf('', a)) != -1) { + data = file.substring(a, b); + if (data.indexOf('GPano:') != -1) + return data; + } + + return ''; + }; + /** * Returns the value of a given attribute in the panorama metadata. * @private @@ -265,13 +287,10 @@ var PhotoSphereViewer = function(args) { xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { // Metadata - var binary = xhr.responseText; - var a = binary.indexOf(''); - var data = binary.substring(a, b); + var data = getXMPData(xhr.responseText); - // No data retrieved - if (a == -1 || b == -1 || data.indexOf('GPano:') == -1) { - createBuffer(false); + if (!data.length) { + createBuffer(); return; } @@ -285,6 +304,7 @@ var PhotoSphereViewer = function(args) { cropped_y: parseInt(getAttribute(data, 'CroppedAreaTopPixels')), }; + recalculate_coords = true; createBuffer(); } }; @@ -310,27 +330,44 @@ var PhotoSphereViewer = function(args) { cropped_width: img.width, cropped_height: img.height, cropped_x: null, - cropped_y: null, + cropped_y: null }; - for (attr in pano_size) { - if (pano_size[attr] == null && default_pano_size[attr] !== undefined) + for (var attr in pano_size) { + if (pano_size[attr] === null && default_pano_size[attr] !== undefined) pano_size[attr] = default_pano_size[attr]; } + // Do we have to recalculate the coordinates? + if (recalculate_coords) { + if (pano_size.cropped_width != default_pano_size.cropped_width) { + var rx = default_pano_size.cropped_width / pano_size.cropped_width; + pano_size.cropped_width = default_pano_size.cropped_width; + pano_size.full_width *= rx; + pano_size.cropped_x *= rx; + } + + if (pano_size.cropped_height != default_pano_size.cropped_height) { + var ry = default_pano_size.cropped_height / pano_size.cropped_height; + pano_size.cropped_height = default_pano_size.cropped_height; + pano_size.full_height *= ry; + pano_size.cropped_y *= ry; + } + } + // Middle if cropped_x/y is null - if (pano_size.cropped_x == null) + if (pano_size.cropped_x === null) pano_size.cropped_x = (pano_size.full_width - pano_size.cropped_width) / 2; - if (pano_size.cropped_y == null) + if (pano_size.cropped_y === null) pano_size.cropped_y = (pano_size.full_height - pano_size.cropped_height) / 2; // Size limit for mobile compatibility var max_width = 2048; if (isWebGLSupported()) { - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('webgl'); - max_width = ctx.getParameter(ctx.MAX_TEXTURE_SIZE); + var canvas_tmp = document.createElement('canvas'); + var ctx_tmp = canvas_tmp.getContext('webgl'); + max_width = ctx_tmp.getParameter(ctx_tmp.MAX_TEXTURE_SIZE); } // Buffer width (not too big) @@ -360,10 +397,8 @@ var PhotoSphereViewer = function(args) { }; // CORS when the panorama is not given as a base64 string - if (args.cors_anonymous) { - if (!panorama.match(/^data:image\/[a-z]+;base64/)) - img.setAttribute('crossOrigin', 'anonymous'); - } + if (cors_anonymous && !panorama.match(/^data:image\/[a-z]+;base64/)) + img.setAttribute('crossOrigin', 'anonymous'); img.src = panorama; }; @@ -384,7 +419,7 @@ var PhotoSphereViewer = function(args) { texture.image = img; createScene(texture); - } + }; loader.load(path, onLoad); }; @@ -449,8 +484,10 @@ var PhotoSphereViewer = function(args) { addEvent(document, 'touchend', onMouseUp); addEvent(document, 'touchmove', onTouchMove); - addEvent(canvas_container, 'mousewheel', onMouseWheel); - addEvent(canvas_container, 'DOMMouseScroll', onMouseWheel); + if (scroll_to_zoom) { + addEvent(canvas_container, 'mousewheel', onMouseWheel); + addEvent(canvas_container, 'DOMMouseScroll', onMouseWheel); + } } addEvent(document, 'fullscreenchange', fullscreenToggled); @@ -515,7 +552,7 @@ var PhotoSphereViewer = function(args) { var startStereo = function() { stereo_effect = new THREE.StereoEffect(renderer); - stereo_effect.eyeSeparation = 5; + stereo_effect.eyeSeparation = eyes_offset; stereo_effect.setSize(viewer_size.width, viewer_size.height); startDeviceOrientation(); @@ -603,6 +640,11 @@ var PhotoSphereViewer = function(args) { long = getAngleMeasure(long, true); + triggerAction('position-updated', { + longitude: long, + latitude: lat + }); + render(); if (again) @@ -762,6 +804,19 @@ var PhotoSphereViewer = function(args) { long = long_tmp; lat = lat_tmp; + /** + * Indicates that the position has been modified. + * @callback PhotoSphereViewer~onPositionUpdateed + * @param {object} position - The new position + * @param {number} position.longitude - The longitude in radians + * @param {number} position.latitude - The latitude in radians + **/ + + triggerAction('position-updated', { + longitude: long, + latitude: lat + }); + render(); }; @@ -895,7 +950,7 @@ var PhotoSphereViewer = function(args) { var d = dist(evt.touches[0].clientX, evt.touches[0].clientY, evt.touches[1].clientX, evt.touches[1].clientY); var diff = d - touchzoom_dist; - if (diff != 0) { + if (diff !== 0) { var direction = diff / Math.abs(diff); zoom(zoom_lvl + direction); @@ -927,6 +982,12 @@ var PhotoSphereViewer = function(args) { mouse_x = x; mouse_y = y; + + triggerAction('position-updated', { + longitude: long, + latitude: lat + }); + render(); } }; @@ -989,6 +1050,11 @@ var PhotoSphereViewer = function(args) { long = stayBetween(coords.longitude, PSV_MIN_LONGITUDE, PSV_MAX_LONGITUDE); lat = stayBetween(coords.latitude, PSV_TILT_DOWN_MAX, PSV_TILT_UP_MAX); + triggerAction('position-updated', { + longitude: long, + latitude: lat + }); + render(); }; @@ -1005,7 +1071,7 @@ var PhotoSphereViewer = function(args) { var delta = (evt.detail) ? -evt.detail : evt.wheelDelta; - if (delta != 0) { + if (delta !== 0) { var direction = parseInt(delta / Math.abs(delta)); zoom(zoom_lvl + direction); } @@ -1034,6 +1100,16 @@ var PhotoSphereViewer = function(args) { triggerAction('zoom-updated', zoom_lvl); }; + /** + * Returns the current zoom level. + * @public + * @return {integer} The current zoom level (between 0 and 100) + **/ + + this.getZoomLevel = function() { + return zoom_lvl; + }; + /** * Sets the new zoom level. * @public @@ -1268,7 +1344,7 @@ var PhotoSphereViewer = function(args) { var setNewViewerSize = function(size) { // Checks all the values - for (dim in size) { + for (var dim in size) { // Only width and height matter if (dim == 'width' || dim == 'height') { // Size extraction @@ -1334,8 +1410,8 @@ var PhotoSphereViewer = function(args) { } // Movement speed - var PSV_LONG_OFFSET = (args.long_offset !== undefined) ? parseFloat(args.long_offset) : Math.PI / 360.0; - var PSV_LAT_OFFSET = (args.lat_offset !== undefined) ? parseFloat(args.lat_offset) : Math.PI / 180.0; + var PSV_LONG_OFFSET = (args.long_offset !== undefined) ? parseAngle(args.long_offset) : Math.PI / 360.0; + var PSV_LAT_OFFSET = (args.lat_offset !== undefined) ? parseAngle(args.lat_offset) : Math.PI / 180.0; // Minimum and maximum fields of view in degrees var PSV_FOV_MIN = (args.min_fov !== undefined) ? stayBetween(parseFloat(args.min_fov), 1, 179) : 30; @@ -1356,7 +1432,7 @@ var PhotoSphereViewer = function(args) { max_long = 2 * Math.PI; } - else if (max_long == 0) + else if (max_long === 0) max_long = 2 * Math.PI; var PSV_MIN_LONGITUDE, PSV_MAX_LONGITUDE; @@ -1445,8 +1521,14 @@ var PhotoSphereViewer = function(args) { if (!user_interactions_allowed) display_navbar = false; - // Container - var container = args.container; + // Is "scroll to zoom" allowed? + var scroll_to_zoom = (args.allow_scroll_to_zoom !== undefined) ? !!args.allow_scroll_to_zoom : true; + + // Eyes offset in VR mode + var eyes_offset = (args.eyes_offset !== undefined) ? parseFloat(args.eyes_offset) : 5; + + // Container (ID to retrieve?) + var container = (typeof args.container == 'string') ? document.getElementById(args.container) : args.container; // Size of the viewer var viewer_size, new_viewer_size = {}, real_viewer_size = {}; @@ -1465,9 +1547,12 @@ var PhotoSphereViewer = function(args) { var actions = {}; - // Must we read XMP data? + // Do we have to read XMP data? var readxmp = (args.usexmpdata !== undefined) ? !!args.usexmpdata : true; + // Can we use CORS? + var cors_anonymous = (args.cors_anonymous !== undefined) ? !!args.cors_anonymous : true; + // Cropped size? var pano_size = { full_width: null, @@ -1479,7 +1564,7 @@ var PhotoSphereViewer = function(args) { }; if (args.pano_size !== undefined) { - for (attr in pano_size) { + for (var attr in pano_size) { if (args.pano_size[attr] !== undefined) pano_size[attr] = parseInt(args.pano_size[attr]); } @@ -1487,6 +1572,9 @@ var PhotoSphereViewer = function(args) { readxmp = false; } + // Will we have to recalculate the coordinates? + var recalculate_coords = false; + // Loading message var loading_msg = (args.loading_msg !== undefined) ? args.loading_msg.toString() : 'Loading…'; @@ -1506,7 +1594,6 @@ var PhotoSphereViewer = function(args) { if (autoload) this.load(); }; - /** * Represents the navigation bar. * @class @@ -1580,7 +1667,7 @@ var PSVNavBar = function(psv) { this.setStyle = function(new_style) { // Properties to change - for (property in new_style) { + for (var property in new_style) { // Is this property a property we'll use? if ((property in style) && checkValue(property, new_style[property])) style[property] = new_style[property]; @@ -1779,7 +1866,6 @@ var PSVNavBar = function(psv) { var must_hide_timeout = null; var hidden = false, must_be_hidden = false; }; - /** * Represents a navigation bar button. * @class @@ -2268,6 +2354,30 @@ var PSVNavBarButton = function(psv, type, style) { var button; create(); }; +/* +* Sphoords v0.1 +* http://jeremyheleine.me +* +* Copyright (c) 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. +*/ /** * Sphoords class allowing to retrieve the current orientation of a device supporting the Orientation API. diff --git a/photo-sphere-viewer.min.js b/photo-sphere-viewer.min.js index 5ce5d921..f4bcd5ae 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,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(ft.innerHTML="",Wt&&1===Wt.nodeType)ft.appendChild(Wt);else if(Wt&&"string"==typeof Wt)ft.innerHTML=Wt;else if(Xt){var e=document.createElement("img");e.setAttribute("src",Xt),e.setAttribute("alt",Dt),ft.appendChild(e)}else ft.textContent=Dt;return wt=document.createElement("div"),wt.style.width="100%",wt.style.height="100%",wt.style.position="relative",wt.style.overflow="hidden",t()?void 0===window.THREE?void console.log("PhotoSphereViewer: Three.js is not loaded."):(yt={width:0,height:0,ratio:0},void(At&&!kt.match(/^data:image\/[a-z]+;base64/)?l():d())):void(ft.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(ft.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);Lt={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",kt,!0),e.send(null)},d=function(){var t=new Image;t.onload=function(){var e={full_width:t.width,full_height:t.height,cropped_width:t.width,cropped_height:t.height,cropped_x:null,cropped_y:null};for(attr in Lt)null==Lt[attr]&&void 0!==e[attr]&&(Lt[attr]=e[attr]);null==Lt.cropped_x&&(Lt.cropped_x=(Lt.full_width-Lt.cropped_width)/2),null==Lt.cropped_y&&(Lt.cropped_y=(Lt.full_height-Lt.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(Lt.full_width,o),s=a/Lt.full_width;Lt.full_width=a,Lt.cropped_width*=s,Lt.cropped_x*=s,t.width=Lt.cropped_width,Lt.full_height*=s,Lt.cropped_height*=s,Lt.cropped_y*=s,t.height=Lt.cropped_height;var l=document.createElement("canvas");l.width=Lt.full_width,l.height=Lt.full_height;var r=l.getContext("2d");r.drawImage(t,Lt.cropped_x,Lt.cropped_y,Lt.cropped_width,Lt.cropped_height),c(l.toDataURL("image/jpeg"))},e.cors_anonymous&&(kt.match(/^data:image\/[a-z]+;base64/)||t.setAttribute("crossOrigin","anonymous")),t.src=kt},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!==bt.width&&(ft.style.width=bt.width.css),void 0!==bt.height&&(ft.style.height=bt.height.css),b(),_t=n()?new THREE.WebGLRenderer:new THREE.CanvasRenderer,_t.setSize(yt.width,yt.height),Et=new THREE.Scene,St=new THREE.PerspectiveCamera(Y,yt.ratio,1,300),St.position.set(0,0,0),Et.add(St);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,Et.add(r),Ct=document.createElement("div"),Ct.style.position="absolute",Ct.style.zIndex=0,wt.appendChild(Ct),gt&&(pt.setStyle(mt),pt.create(),wt.appendChild(pt.getBar())),o(window,"resize",b),vt&&(o(Ct,"mousedown",C),o(document,"mousemove",z),o(Ct,"mousemove",D),o(document,"mouseup",S),o(Ct,"touchstart",k),o(document,"touchend",S),o(document,"touchmove",T),o(Ct,"mousewheel",H),o(Ct,"DOMMouseScroll",H)),o(document,"fullscreenchange",O),o(document,"mozfullscreenchange",O),o(document,"webkitfullscreenchange",O),o(document,"MSFullscreenChange",O),Bt.addListener(P),ft.innerHTML="",ft.appendChild(wt);var a=_t.domElement;a.style.display="block",Ct.appendChild(a),h(),it>0&&F(it),m(),$("ready")},h=function(){var e=new THREE.Vector3;e.setX(Math.cos(tt)*Math.sin(nt)),e.setY(Math.sin(tt)),e.setZ(Math.cos(tt)*Math.cos(nt)),St.lookAt(e),null!==zt?zt.render(Et,St):_t.render(Et,St)},p=function(){zt=new THREE.StereoEffect(_t),zt.eyeSeparation=5,zt.setSize(yt.width,yt.height),I(),A(),pt.mustBeHidden(),h(),$("stereo-effect",!0)},g=function(){zt=null,_t.setSize(yt.width,yt.height),pt.mustBeHidden(!1),h(),$("stereo-effect",!1)};this.toggleStereo=function(){null!==zt?g():p()};var m=function(){st!==!1&&(Ft=setTimeout(y,st))},v=function(){tt-=(tt-ut)*ct,nt+=lt;var e=!0;J||(nt=i(nt,Q,et),(nt==Q||nt==et)&&(dt?lt*=-1:(f(),e=!1))),nt=a(nt,!0),h(),e&&(Ht=setTimeout(v,at))},y=function(){v(),$("autorotate",!0)},f=function(){clearTimeout(Ft),Ft=null,clearTimeout(Ht),Ht=null,$("autorotate",!1)};this.toggleAutorotate=function(){clearTimeout(Ft),Ht?f():y()};var b=function(){(ft.clientWidth!=yt.width||ft.clientHeight!=yt.height)&&x({width:ft.clientWidth,height:ft.clientHeight})};this.fitToContainer=function(){b()};var x=function(e){yt.width=void 0!==e.width?parseInt(e.width):yt.width,yt.height=void 0!==e.height?parseInt(e.height):yt.height,yt.ratio=yt.width/yt.height,St&&(St.aspect=yt.ratio,St.updateProjectionMatrix()),_t&&(_t.setSize(yt.width,yt.height),h()),zt&&(zt.setSize(yt.width,yt.height),h())};this.getPosition=function(){return{longitude:nt,latitude:tt}},this.getPositionInDegrees=function(){return{longitude:180*nt/Math.PI,latitude:180*tt/Math.PI}};var w=function(e,t){var n=W(e);J||(n=i(n,Q,et));var o=W(t);o>Math.PI&&(o-=2*Math.PI),o=i(o,U,j),nt=n,tt=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==Ct&&_(parseInt(t.clientX),parseInt(t.clientY))}else 2==e.touches.length&&(S(),e.touches[0].target.parentNode==Ct&&e.touches[1].target.parentNode==Ct&&E(r(e.touches[0].clientX,e.touches[0].clientY,e.touches[1].clientX,e.touches[1].clientY)));D()},_=function(e,t){Rt=e,It=t,f(),Tt=!0},E=function(e){Pt=e,Mt=!0},S=function(){Tt=!1,Mt=!1},z=function(e){e.preventDefault(),R(parseInt(e.clientX),parseInt(e.clientY))},T=function(e){if(1==e.touches.length&&Tt){var t=e.touches[0];t.target.parentNode==Ct&&(e.preventDefault(),R(parseInt(t.clientX),parseInt(t.clientY)))}else if(2==e.touches.length&&e.touches[0].target.parentNode==Ct&&e.touches[1].target.parentNode==Ct&&Mt){e.preventDefault();var n=r(e.touches[0].clientX,e.touches[0].clientY,e.touches[1].clientX,e.touches[1].clientY),o=n-Pt;if(0!=o){var i=o/Math.abs(o);F(it+i),Pt=n}}},R=function(e,t){Tt&&(nt+=(e-Rt)*q,J||(nt=i(nt,Q,et)),nt=a(nt,!0),tt+=(t-It)*V,tt=i(tt,U,j),Rt=e,It=t,h())},I=function(){Bt.start(),f(),$("device-orientation",!0)},M=function(){Bt.stop(),$("device-orientation",!1)};this.toggleDeviceOrientation=function(){Bt.isEventAttached()?M():I()};var P=function(e){nt=i(e.longitude,Q,et),tt=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(it+n)}},F=function(e){it=i(parseInt(Math.round(e)),0,100),St.fov=Y+it/100*(G-Y),St.updateProjectionMatrix(),h(),$("zoom-updated",it)};this.zoom=function(e){F(e)},this.zoomIn=function(){100>it&&F(it+1)},this.zoomOut=function(){it>0&&F(it-1)};var B=function(){return!!(document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement)},O=function(){document.webkitFullscreenElement||document.msFullscreenElement?(xt.width=ft.style.width,xt.height=ft.style.height,ft.style.width="100%",ft.style.height="100%",b()):(ft.webkitRequestFullscreen||ft.msRequestFullscreen)&&(ft.style.width=xt.width,ft.style.height=xt.height,b()),$("fullscreen-mode",B())},A=function(){ft.requestFullscreen?ft.requestFullscreen():ft.mozRequestFullScreen?ft.mozRequestFullScreen():ft.webkitRequestFullscreen?ft.webkitRequestFullscreen():ft.msRequestFullscreen&&ft.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(){gt&&pt.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*at/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"),bt[dim]={css:n+o,unit:o}}};this.addAction=function(e,t){e in Ot||(Ot[e]=[]),Ot[e].push(t)};var $=function(e,t){if(e in Ot&&Ot[e].length)for(var n=0,o=Ot[e].length;o>n;++n)void 0!==t?Ot[e][n](t):Ot[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,et;Z>K?(Q=K,et=Z):(Q=Z,et=K);var tt=0,nt=Q;if(void 0!==e.default_position){if(void 0!==e.default_position.lat){var ot=W(e.default_position.lat);ot>Math.PI&&(ot-=2*Math.PI),tt=i(ot,U,j)}void 0!==e.default_position["long"]&&(nt=i(W(e.default_position["long"]),Q,et))}var it=0;void 0!==e.zoom_level&&(it=i(parseInt(Math.round(e.zoom_level)),0,100));var rt=60,at=1e3/rt,st=2e3;void 0!==e.time_anim&&(st="number"==typeof e.time_anim&&e.time_anim>=0?e.time_anim:!1);var lt=X(void 0!==e.anim_speed?e.anim_speed:"2rpm"),dt=!0;void 0!==e.reverse_anim&&(dt=!!e.reverse_anim);var ct=X(void 0!==e.vertical_anim_speed?e.vertical_anim_speed:"2rpm"),ut=0;if(void 0!==e.vertical_anim_target){var ht=W(e.vertical_anim_target);ht>Math.PI&&(ht-=2*Math.PI),ut=i(ht,U,j)}var pt=new PSVNavBar(this),gt=void 0!==e.navbar?!!e.navbar:!1,mt=void 0!==e.navbar_style?e.navbar_style:{},vt=void 0!==e.allow_user_interactions?!!e.allow_user_interactions:!0;vt||(gt=!1);var yt,ft=e.container,bt={},xt={};void 0!==e.size&&N(e.size);var wt,Ct,kt=e.panorama,_t=null,Et=null,St=null,zt=null,Tt=!1,Rt=0,It=0,Mt=!1,Pt=0,Ht=null,Ft=null,Bt=new Sphoords,Ot={},At=void 0!==e.usexmpdata?!!e.usexmpdata:!0,Lt={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 Lt)void 0!==e.pano_size[attr]&&(Lt[attr]=parseInt(e.pano_size[attr]));At=!1}var Dt=void 0!==e.loading_msg?e.loading_msg.toString():"Loading…",Xt=void 0!==e.loading_img?e.loading_img.toString():null,Wt=void 0!==e.loading_html?e.loading_html:null;void 0!==e.onready&&this.addAction("ready",e.onready);var Nt=void 0!==e.autoload?!!e.autoload:!0;Nt&&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){l.style.backgroundColor=e?n.activeButtonsBackgroundColor: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(){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"))},o=function(){var e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl"))},n=function(e,t,o){e.addEventListener?e.addEventListener(t,o,!1):e.attachEvent("on"+t,o)},i=function(e,t,o){return Math.max(t,Math.min(o,e))},r=function(e,t,o,n){var i=o-e,r=n-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(we.innerHTML="",Ye&&1===Ye.nodeType)we.appendChild(Ye);else if(Ye&&"string"==typeof Ye)we.innerHTML=Ye;else if(Ge){var e=document.createElement("img");e.setAttribute("src",Ge),e.setAttribute("alt",Ve),we.appendChild(e)}else we.textContent=Ve;return ke=document.createElement("div"),ke.style.width="100%",ke.style.height="100%",ke.style.position="relative",ke.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(Xe&&!Se.match(/^data:image\/[a-z]+;base64/)?d():c())):void(we.textContent="Canvas is not supported, update your browser!")};var s=function(e){for(var t=0,o=0,n="";-1!=(t=e.indexOf("",t));)if(n=e.substring(t,o),-1!=n.indexOf("GPano:"))return n;return""},l=function(e,t){var o=e.indexOf("GPano:"+t)+t.length+8,n=e.indexOf('"',o);return e.substring(o,n)},d=function(){var e=null;if(window.XMLHttpRequest)e=new XMLHttpRequest;else{if(!window.ActiveXObject)return void(we.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=s(e.responseText);if(!t.length)return void c();Ne={full_width:parseInt(l(t,"FullPanoWidthPixels")),full_height:parseInt(l(t,"FullPanoHeightPixels")),cropped_width:parseInt(l(t,"CroppedAreaImageWidthPixels")),cropped_height:parseInt(l(t,"CroppedAreaImageHeightPixels")),cropped_x:parseInt(l(t,"CroppedAreaLeftPixels")),cropped_y:parseInt(l(t,"CroppedAreaTopPixels"))},qe=!0,c()}},e.open("GET",Se,!0),e.send(null)},c=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(var n in Ne)null===Ne[n]&&void 0!==t[n]&&(Ne[n]=t[n]);if(qe){if(Ne.cropped_width!=t.cropped_width){var i=t.cropped_width/Ne.cropped_width;Ne.cropped_width=t.cropped_width,Ne.full_width*=i,Ne.cropped_x*=i}if(Ne.cropped_height!=t.cropped_height){var r=t.cropped_height/Ne.cropped_height;Ne.cropped_height=t.cropped_height,Ne.full_height*=r,Ne.cropped_y*=r}}null===Ne.cropped_x&&(Ne.cropped_x=(Ne.full_width-Ne.cropped_width)/2),null===Ne.cropped_y&&(Ne.cropped_y=(Ne.full_height-Ne.cropped_height)/2);var a=2048;if(o()){var s=document.createElement("canvas"),l=s.getContext("webgl");a=l.getParameter(l.MAX_TEXTURE_SIZE)}var d=Math.min(Ne.full_width,a),c=d/Ne.full_width;Ne.full_width=d,Ne.cropped_width*=c,Ne.cropped_x*=c,e.width=Ne.cropped_width,Ne.full_height*=c,Ne.cropped_height*=c,Ne.cropped_y*=c,e.height=Ne.cropped_height;var h=document.createElement("canvas");h.width=Ne.full_width,h.height=Ne.full_height;var p=h.getContext("2d");p.drawImage(e,Ne.cropped_x,Ne.cropped_y,Ne.cropped_width,Ne.cropped_height),u(h.toDataURL("image/jpeg"))},We&&!Se.match(/^data:image\/[a-z]+;base64/)&&e.setAttribute("crossOrigin","anonymous"),e.src=Se},u=function(e){var t=new THREE.Texture,o=new THREE.ImageLoader,n=function(e){t.needsUpdate=!0,t.image=e,h(t)};o.load(e,n)},h=function(e){void 0!==_e.width&&(we.style.width=_e.width.css),void 0!==_e.height&&(we.style.height=_e.height.css),x(),ze=o()?new THREE.WebGLRenderer:new THREE.CanvasRenderer,ze.setSize(ye.width,ye.height),Te=new THREE.Scene,Re=new THREE.PerspectiveCamera(j,ye.ratio,1,300),Re.position.set(0,0,0),Te.add(Re);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,Te.add(r),Ee=document.createElement("div"),Ee.style.position="absolute",Ee.style.zIndex=0,ke.appendChild(Ee),me&&(ge.setStyle(ve),ge.create(),ke.appendChild(ge.getBar())),n(window,"resize",x),fe&&(n(Ee,"mousedown",C),n(document,"mousemove",T),n(Ee,"mousemove",X),n(document,"mouseup",z),n(Ee,"touchstart",k),n(document,"touchend",z),n(document,"touchmove",R),be&&(n(Ee,"mousewheel",F),n(Ee,"DOMMouseScroll",F))),n(document,"fullscreenchange",L),n(document,"mozfullscreenchange",L),n(document,"webkitfullscreenchange",L),n(document,"MSFullscreenChange",L),Ae.addListener(H),we.innerHTML="",we.appendChild(ke);var a=ze.domElement;a.style.display="block",Ee.appendChild(a),p(),re>0&&B(re),v(),q("ready")},p=function(){var e=new THREE.Vector3;e.setX(Math.cos(oe)*Math.sin(ne)),e.setY(Math.sin(oe)),e.setZ(Math.cos(oe)*Math.cos(ne)),Re.lookAt(e),null!==Ie?Ie.render(Te,Re):ze.render(Te,Re)},g=function(){Ie=new THREE.StereoEffect(ze),Ie.eyeSeparation=xe,Ie.setSize(ye.width,ye.height),M(),A(),ge.mustBeHidden(),p(),q("stereo-effect",!0)},m=function(){Ie=null,ze.setSize(ye.width,ye.height),ge.mustBeHidden(!1),p(),q("stereo-effect",!1)};this.toggleStereo=function(){null!==Ie?m():g()};var v=function(){le!==!1&&(Le=setTimeout(y,le))},f=function(){oe-=(oe-he)*ue,ne+=de;var e=!0;Q||(ne=i(ne,ee,te),(ne==ee||ne==te)&&(ce?de*=-1:(b(),e=!1))),ne=a(ne,!0),q("position-updated",{longitude:ne,latitude:oe}),p(),e&&(Oe=setTimeout(f,se))},y=function(){f(),q("autorotate",!0)},b=function(){clearTimeout(Le),Le=null,clearTimeout(Oe),Oe=null,q("autorotate",!1)};this.toggleAutorotate=function(){clearTimeout(Le),Oe?b():y()};var x=function(){(we.clientWidth!=ye.width||we.clientHeight!=ye.height)&&w({width:we.clientWidth,height:we.clientHeight})};this.fitToContainer=function(){x()};var w=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,Re&&(Re.aspect=ye.ratio,Re.updateProjectionMatrix()),ze&&(ze.setSize(ye.width,ye.height),p()),Ie&&(Ie.setSize(ye.width,ye.height),p())};this.getPosition=function(){return{longitude:ne,latitude:oe}},this.getPositionInDegrees=function(){return{longitude:180*ne/Math.PI,latitude:180*oe/Math.PI}};var _=function(e,t){var o=N(e);Q||(o=i(o,ee,te));var n=N(t);n>Math.PI&&(n-=2*Math.PI),n=i(n,Z,U),ne=o,oe=n,q("position-updated",{longitude:ne,latitude:oe}),p()};this.moveTo=function(e,t){_(e,t)};var C=function(e){E(parseInt(e.clientX),parseInt(e.clientY))},k=function(e){if(1==e.touches.length){var t=e.touches[0];t.target.parentNode==Ee&&E(parseInt(t.clientX),parseInt(t.clientY))}else 2==e.touches.length&&(z(),e.touches[0].target.parentNode==Ee&&e.touches[1].target.parentNode==Ee&&S(r(e.touches[0].clientX,e.touches[0].clientY,e.touches[1].clientX,e.touches[1].clientY)));X()},E=function(e,t){Pe=e,He=t,b(),Me=!0},S=function(e){Be=e,Fe=!0},z=function(e){Me=!1,Fe=!1},T=function(e){e.preventDefault(),I(parseInt(e.clientX),parseInt(e.clientY))},R=function(e){if(1==e.touches.length&&Me){var t=e.touches[0];t.target.parentNode==Ee&&(e.preventDefault(),I(parseInt(t.clientX),parseInt(t.clientY)))}else if(2==e.touches.length&&e.touches[0].target.parentNode==Ee&&e.touches[1].target.parentNode==Ee&&Fe){e.preventDefault();var o=r(e.touches[0].clientX,e.touches[0].clientY,e.touches[1].clientX,e.touches[1].clientY),n=o-Be;if(0!==n){var i=n/Math.abs(n);B(re+i),Be=o}}},I=function(e,t){Me&&(ne+=(e-Pe)*V,Q||(ne=i(ne,ee,te)),ne=a(ne,!0),oe+=(t-He)*G,oe=i(oe,Z,U),Pe=e,He=t,q("position-updated",{longitude:ne,latitude:oe}),p())},M=function(){Ae.start(),b(),q("device-orientation",!0)},P=function(){Ae.stop(),q("device-orientation",!1)};this.toggleDeviceOrientation=function(){Ae.isEventAttached()?P():M()};var H=function(e){ne=i(e.longitude,ee,te),oe=i(e.latitude,Z,U),q("position-updated",{longitude:ne,latitude:oe}),p()},F=function(e){e.preventDefault(),e.stopPropagation();var t=e.detail?-e.detail:e.wheelDelta;if(0!==t){var o=parseInt(t/Math.abs(t));B(re+o)}},B=function(e){re=i(parseInt(Math.round(e)),0,100),Re.fov=j+re/100*(Y-j),Re.updateProjectionMatrix(),p(),q("zoom-updated",re)};this.getZoomLevel=function(){return re},this.zoom=function(e){B(e)},this.zoomIn=function(){100>re&&B(re+1)},this.zoomOut=function(){re>0&&B(re-1)};var O=function(){return!!(document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement)},L=function(){document.webkitFullscreenElement||document.msFullscreenElement?(Ce.width=we.style.width,Ce.height=we.style.height,we.style.width="100%",we.style.height="100%",x()):(we.webkitRequestFullscreen||we.msRequestFullscreen)&&(we.style.width=Ce.width,we.style.height=Ce.height,x()),q("fullscreen-mode",O())},A=function(){we.requestFullscreen?we.requestFullscreen():we.mozRequestFullScreen?we.mozRequestFullScreen():we.webkitRequestFullscreen?we.webkitRequestFullscreen():we.msRequestFullscreen&&we.msRequestFullscreen()},D=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen()};this.toggleFullscreen=function(){O()?D():A()};var X=function(){me&&ge.show()},W=function(e){e=e.toString().trim();var t=parseFloat(e.replace(/^(-?[0-9]+(?:\.[0-9]*)?).*$/,"$1")),o=e.replace(/^-?[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();o.match(/(pm|per minute)$/)&&(t/=60);var n=0;switch(o){case"rpm":case"rev per minute":case"revolutions per minute":case"rps":case"rev per second":case"revolutions per second":n=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":n=t*Math.PI/180;break;case"rad per minute":case"radians per minute":case"rad per second":case"radians per second":n=t;break;default:m_anim=!1}return n*se/1e3},N=function(e){e=e.toString().trim();var t=parseFloat(e.replace(/^(-?[0-9]+(?:\.[0-9]*)?).*$/,"$1")),o=e.replace(/^-?[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();return"deg"==o&&(t*=Math.PI/180),a(t)},$=function(e){for(var t in e)if("width"==t||"height"==t){var o=e[t].toString().trim(),n=parseFloat(o.replace(/^([0-9]+(?:\.[0-9]*)?).*$/,"$1")),i=o.replace(/^[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();"%"!=i&&(i="px"),_e[t]={css:n+i,unit:i}}};this.addAction=function(e,t){e in De||(De[e]=[]),De[e].push(t)};var q=function(e,t){if(e in De&&De[e].length)for(var o=0,n=De[e].length;n>o;++o)void 0!==t?De[e][o](t):De[e][o]()};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 V=void 0!==e.long_offset?N(e.long_offset):Math.PI/360,G=void 0!==e.lat_offset?N(e.lat_offset):Math.PI/180,Y=void 0!==e.min_fov?i(parseFloat(e.min_fov),1,179):30,j=void 0!==e.max_fov?i(parseFloat(e.max_fov),1,179):90,U=void 0!==e.tilt_up_max?i(N(e.tilt_up_max),0,Math.PI/2):Math.PI/2,Z=void 0!==e.tilt_down_max?-i(N(e.tilt_down_max),0,Math.PI/2):-Math.PI/2,K=void 0!==e.min_longitude?N(e.min_longitude):0,J=void 0!==e.max_longitude?N(e.max_longitude):0,Q=K==J;Q?(K=0,J=2*Math.PI):0===J&&(J=2*Math.PI);var ee,te;J>K?(ee=K,te=J):(ee=J,te=K);var oe=0,ne=ee;if(void 0!==e.default_position){if(void 0!==e.default_position.lat){var ie=N(e.default_position.lat);ie>Math.PI&&(ie-=2*Math.PI),oe=i(ie,Z,U)}void 0!==e.default_position["long"]&&(ne=i(N(e.default_position["long"]),ee,te))}var re=0;void 0!==e.zoom_level&&(re=i(parseInt(Math.round(e.zoom_level)),0,100));var ae=60,se=1e3/ae,le=2e3;void 0!==e.time_anim&&(le="number"==typeof e.time_anim&&e.time_anim>=0?e.time_anim:!1);var de=W(void 0!==e.anim_speed?e.anim_speed:"2rpm"),ce=!0;void 0!==e.reverse_anim&&(ce=!!e.reverse_anim);var ue=W(void 0!==e.vertical_anim_speed?e.vertical_anim_speed:"2rpm"),he=0;if(void 0!==e.vertical_anim_target){var pe=N(e.vertical_anim_target);pe>Math.PI&&(pe-=2*Math.PI),he=i(pe,Z,U)}var ge=new PSVNavBar(this),me=void 0!==e.navbar?!!e.navbar:!1,ve=void 0!==e.navbar_style?e.navbar_style:{},fe=void 0!==e.allow_user_interactions?!!e.allow_user_interactions:!0;fe||(me=!1);var ye,be=void 0!==e.allow_scroll_to_zoom?!!e.allow_scroll_to_zoom:!0,xe=void 0!==e.eyes_offset?parseFloat(e.eyes_offset):5,we="string"==typeof e.container?document.getElementById(e.container):e.container,_e={},Ce={};void 0!==e.size&&$(e.size);var ke,Ee,Se=e.panorama,ze=null,Te=null,Re=null,Ie=null,Me=!1,Pe=0,He=0,Fe=!1,Be=0,Oe=null,Le=null,Ae=new Sphoords,De={},Xe=void 0!==e.usexmpdata?!!e.usexmpdata:!0,We=void 0!==e.cors_anonymous?!!e.cors_anonymous:!0,Ne={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(var $e in Ne)void 0!==e.pano_size[$e]&&(Ne[$e]=parseInt(e.pano_size[$e]));Xe=!1}var qe=!1,Ve=void 0!==e.loading_msg?e.loading_msg.toString():"Loading…",Ge=void 0!==e.loading_img?e.loading_img.toString():null,Ye=void 0!==e.loading_html?e.loading_html:null;void 0!==e.onready&&this.addAction("ready",e.onready);var je=void 0!==e.autoload?!!e.autoload:!0;je&&this.load()},PSVNavBar=function(e){var t=function(e,t){for(var o=0,n=t.length;n>o;++o)if(t[o]==e)return!0;return!1},o=function(e,o){return t(e,h)&&"string"==typeof o&&("transparent"==o||!!o.match(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/)||!!o.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}\)$/)||!!o.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(o))&&isFinite(o)&&o>=0};this.setStyle=function(e){for(var t in e)t in u&&o(t,e[t])&&(u[t]=e[t])},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 n=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(){n()};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():n()};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,o){var n=function(e,t,o){e.addEventListener?e.addEventListener(t,o,!1):e.attachEvent("on"+t,o)},i=function(){switch(t){case"autorotate":var i=o.buttonsHeight-2*o.autorotateThickness,p=i/10;l=document.createElement("div"),l.style.cssFloat="left",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=o.buttonsHeight+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.position="relative",l.style.cursor="pointer",n(l,"click",function(){e.toggleAutorotate()});var f=document.createElement("div");f.style.boxSizing="inherit",f.style.width=i+"px",f.style.height=i+"px",f.style.borderRadius="50%",f.style.border=o.autorotateThickness+"px solid "+o.buttonsColor,l.appendChild(f);var y=document.createElement("div");y.style.boxSizing="inherit",y.style.width=i+"px",y.style.height=p+"px",y.style.borderRadius="50%",y.style.border=o.autorotateThickness+"px solid "+o.buttonsColor,y.style.position="absolute",y.style.top="50%",y.style.marginTop=-(p/2+o.autorotateThickness)+"px",l.appendChild(y),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=o.buttonsHeight+"px",b.style.backgroundColor=o.buttonsBackgroundColor,b.style.lineHeight=o.buttonsHeight+"px",b.style.color=o.buttonsColor,b.style.cursor="pointer",b.textContent="-",n(b,"click",function(){e.zoomOut()}),l.appendChild(b),r=document.createElement("div"),r.style.cssFloat="left",r.style.boxSizing="inherit",r.style.padding=10+(o.buttonsHeight-o.zoomRangeThickness)/2+"px 5px",r.style.backgroundColor=o.buttonsBackgroundColor,r.style.cursor="pointer",l.appendChild(r),a=document.createElement("div"),a.style.boxSizing="inherit",a.style.width=o.zoomRangeWidth+"px",a.style.height=o.zoomRangeThickness+"px",a.style.backgroundColor=o.buttonsColor,a.style.position="relative",r.appendChild(a),s=document.createElement("div"),s.style.position="absolute",s.style.top=(o.zoomRangeThickness-o.zoomRangeDisk)/2+"px",s.style.left=-(o.zoomRangeDisk/2)+"px",s.style.boxSizing="inherit",s.style.width=o.zoomRangeDisk+"px",s.style.height=o.zoomRangeDisk+"px",s.style.borderRadius="50%",s.style.backgroundColor=o.buttonsColor,e.addAction("zoom-updated",c),n(r,"mousedown",u),n(r,"touchstart",h),n(document,"mousemove",m),n(document,"touchmove",v),n(document,"mouseup",g),n(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=o.buttonsHeight+"px",x.style.backgroundColor=o.buttonsBackgroundColor,x.style.lineHeight=o.buttonsHeight+"px",x.style.color=o.buttonsColor,x.style.cursor="pointer",x.textContent="+",n(x,"click",function(){e.zoomIn()}),l.appendChild(x);break;case"fullscreen":var w=o.buttonsHeight*o.fullscreenRatio,_=.3*o.buttonsHeight,C=(o.buttonsHeight-_)/2,k=.3*w,E=(w-k)/2-o.fullscreenThickness,S=o.buttonsHeight-2*o.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=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.cursor="pointer",n(l,"click",function(){e.toggleFullscreen()});var z=document.createElement("div");z.style.cssFloat="left",z.style.boxSizing="inherit",z.style.width=o.fullscreenThickness+"px",z.style.height=_+"px",z.style.borderStyle="solid",z.style.borderColor=o.buttonsColor+" transparent",z.style.borderWidth=C+"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=o.buttonsColor+" transparent",T.style.borderWidth=o.fullscreenThickness+"px 0",l.appendChild(T);var R=document.createElement("div");R.style.cssFloat="left",R.style.boxSizing="inherit",R.style.marginLeft=k+"px",R.style.width=E+"px",R.style.height=S+"px",R.style.borderStyle="solid",R.style.borderColor=o.buttonsColor+" transparent",R.style.borderWidth=o.fullscreenThickness+"px 0",l.appendChild(R);var I=document.createElement("div");I.style.cssFloat="left",I.style.boxSizing="inherit",I.style.width=o.fullscreenThickness+"px",I.style.height=_+"px",I.style.borderStyle="solid",I.style.borderColor=o.buttonsColor+" transparent",I.style.borderWidth=C+"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=o.buttonsHeight-2*o.gyroscopeThickness,H=P-4*o.gyroscopeThickness,F=P/10;l=document.createElement("div"),l.style.cssFloat="right",l.style.boxSizing="inherit",l.style.padding="10px",l.style.width=o.buttonsHeight+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.position="relative",l.style.cursor="pointer",n(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=o.gyroscopeThickness+"px solid "+o.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=o.gyroscopeThickness+"px solid "+o.buttonsColor,O.style.position="absolute",O.style.top="50%",O.style.left="50%",O.style.marginTop=-(F/2+o.gyroscopeThickness)+"px",O.style.marginLeft=-(H/2+o.gyroscopeThickness)+"px",l.appendChild(O);var L=document.createElement("div");L.style.boxSizing="inherit",L.style.width=F+"px",L.style.height=H+"px",L.style.borderRadius="50%",L.style.border=o.gyroscopeThickness+"px solid "+o.buttonsColor,L.style.position="absolute",L.style.top="50%",L.style.left="50%",L.style.marginTop=-(H/2+o.gyroscopeThickness)+"px",L.style.marginLeft=-(F/2+o.gyroscopeThickness)+"px",l.appendChild(L),e.addAction("device-orientation",d);break;case"virtual-reality":var A=o.buttonsHeight*o.virtualRealityRatio,D=A/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=A+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.cursor="pointer",n(l,"click",function(){e.toggleStereo()});var W=document.createElement("div");W.style.boxSizing="inherit",W.style.width=A+"px",W.style.height=o.buttonsHeight+"px",W.style.borderRadius=o.virtualRealityBorderRadius+"px",W.style.backgroundColor=o.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=o.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=o.backgroundColor,l.appendChild($);var q=document.createElement("div");q.style.boxSizing="inherit",q.style.width=D+"px",q.style.height=o.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=o.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=o.activeButtonsBackgroundColor:l.style.backgroundColor=o.buttonsBackgroundColor},c=function(e){s.style.left=e/100*o.zoomRangeWidth-o.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){y=!0,f(e)},g=function(e){y=!1},m=function(e){e.preventDefault(),f(parseInt(e.clientX))},v=function(e){var t=e.touches[0];(t.target==r||t.target==a||t.target==s)&&(e.preventDefault(),f(parseInt(t.clientX)))},f=function(t){if(y){var n=t-a.getBoundingClientRect().left,i=n/o.zoomRangeWidth*100;e.zoom(i)}},y=!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",o,!1),i=!0,!0):(console.log("Device Orientation API not supported"),!1)},this.stop=function(){i&&(window.removeEventListener("deviceorientation",o,!1),i=!1)},this.toggle=function(){i?this.stop():this.start()},this.isEventAttached=function(){return i};var o=function(e){c=Sphoords.getScreenOrientation();var o=0,i=0;switch(c){case"portrait-primary":o=e.alpha+e.gamma,i=e.beta-90;break;case"landscape-primary":if(o=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(o=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":o=e.alpha-e.gamma,i=180-(e.beta-90),i=270-e.beta}i=t(i),i>=180&&(i-=360),r=t(o),a=Math.max(-90,Math.min(90,i)),s=r*d,l=a*d,n()};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 n=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 53fe0e12..29f40719 100644 --- a/src/PSVNavBar.js +++ b/src/PSVNavBar.js @@ -71,7 +71,7 @@ var PSVNavBar = function(psv) { this.setStyle = function(new_style) { // Properties to change - for (property in new_style) { + for (var property in new_style) { // Is this property a property we'll use? if ((property in style) && checkValue(property, new_style[property])) style[property] = new_style[property]; diff --git a/src/PhotoSphereViewer.js b/src/PhotoSphereViewer.js index 90bc0f76..e2c904a3 100644 --- a/src/PhotoSphereViewer.js +++ b/src/PhotoSphereViewer.js @@ -1,5 +1,5 @@ /* - * Photo Sphere Viewer v2.4.1 + * Photo Sphere Viewer v2.5 * http://jeremyheleine.me/photo-sphere-viewer * * Copyright (c) 2014,2015 Jérémy Heleine