@egjs/view360
Version:
360 integrated viewing solution from inside-out view to outside-in view. It provides user-friendly service by rotating 360 degrees through various user interaction such as motion sensor and touch.
9 lines • 92.7 kB
JavaScript
/*
Copyright (c) 2017-present NAVER Corp.
name: @egjs/view360
license: MIT
author: NAVER Corp.
repository: https://github.com/naver/egjs-view360
version: 3.6.4
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@egjs/component"),require("promise-polyfill"),require("@egjs/agent"),require("@egjs/axes"),require("gl-matrix"),require("@egjs/imready")):"function"==typeof define&&define.amd?define(["@egjs/component","promise-polyfill","@egjs/agent","@egjs/axes","gl-matrix","@egjs/imready"],e):((t="undefined"!=typeof globalThis?globalThis:t||self).eg=t.eg||{},t.eg.view360=e(t.eg.Component,t.Promise,t.eg.agent,t.eg.Axes,t.glMatrix,t.eg.ImReady))}(this,function(c,s,a,u,_,r){"use strict";var n="3.6.4",o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};function l(t,e){function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var h=function(){return(h=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function i(t,a,s,u){return new(s=s||Promise)(function(i,e){function n(t){try{o(u.next(t))}catch(t){e(t)}}function r(t){try{o(u.throw(t))}catch(t){e(t)}}function o(t){var e;t.done?i(t.value):((e=t.value)instanceof s?e:new s(function(t){t(e)})).then(n,r)}o((u=u.apply(t,a||[])).next())})}function d(i,n){var r,o,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,o&&(a=2&e[0]?o.return:e[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,e[1])).done)return a;switch(o=0,a&&(e=[2&e[0],a.value]),e[0]){case 0:case 1:a=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,o=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){s.label=e[1];break}if(6===e[0]&&s.label<a[1]){s.label=a[1],a=e;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(e);break}a[2]&&s.ops.pop(),s.trys.pop();continue}e=n.call(i,s)}catch(t){e=[6,t],o=0}finally{r=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function f(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],n=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function p(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(function(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var n,r,o=i.call(t),a=[];try{for(;(void 0===e||0<e--)&&!(n=o.next()).done;)a.push(n.value)}catch(t){r={error:t}}finally{try{n&&!n.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}return a}(arguments[e]));return t}var g="undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")(),m=g.document,v=g.navigator,t=a(),e=t.os.name,y=t.browser.name,x="ios"===e,w="mac"===e&&"safari"===y;g.Float32Array=void 0!==g.Float32Array?g.Float32Array:g.Array;g.Float32Array,g.getComputedStyle;function E(t){return 180*t/Math.PI}var R=g.navigator&&g.navigator.userAgent,T="ontouchstart"in g,C="ondevicemotion"in g,I=g.DeviceMotionEvent,b=g.devicePixelRatio,P=function(){for(var t,e=null!==(t=null==m?void 0:m.documentElement.style)&&void 0!==t?t:{},i=["transform","webkitTransform","msTransform","mozTransform"],n=0,r=i.length;n<r;n++)if(i[n]in e)return i[n];return""}(),A=g.CSS&&g.CSS.supports&&g.CSS.supports("will-change","transform"),O=!1,S=function(){var t=window.navigator;t.xr&&(t.xr.isSessionSupported?t.xr.isSessionSupported("immersive-vr").then(function(t){O=t}).catch(function(){}):t.xr.supportsSession&&t.xr.supportsSession("immersive-vr").then(function(t){O=t}).catch(function(){}))},D={isPowerOfTwo:function(t){return t&&0==(t&t-1)}};D.extractPitchFromQuat=function(t){var e,t=(e=t,t=_.vec3.fromValues(0,0,1),_.vec3.transformQuat(t,t,e),t);return-1*Math.atan2(t[1],Math.sqrt(Math.pow(t[0],2)+Math.pow(t[2],2)))},D.hypot=Math.hypot||function(t,e){return Math.sqrt(t*t+e*e)};var M={PITCH_DELTA:1,YAW_DELTA_BY_ROLL:2,YAW_DELTA_BY_YAW:3};M[M.PITCH_DELTA]={targetAxis:[0,1,0],meshPoint:[0,0,1]},M[M.YAW_DELTA_BY_ROLL]={targetAxis:[0,1,0],meshPoint:[1,0,0]},M[M.YAW_DELTA_BY_YAW]={targetAxis:[1,0,0],meshPoint:[0,0,1]};function V(t,e){var i=t[0]*e[1]-e[0]*t[1];return-Math.atan2(i,_.vec2.dot(t,e))}D.yawOffsetBetween=function(t,e){t=_.vec2.fromValues(t[0],t[2]),e=_.vec2.fromValues(e[0],e[2]);return _.vec2.normalize(t,t),_.vec2.normalize(e,e),-V(t,e)},D.sign=function(t){return Math.sign?Math.sign(t):Number(0<t)-Number(t<0)||+t},D.toDegree=E,D.getRotationDelta=function(t,e,i){var n=_.vec3.fromValues(M[i].targetAxis[0],M[i].targetAxis[1],M[i].targetAxis[2]),r=M[i].meshPoint,o=_.quat.clone(t),a=_.quat.clone(e);_.quat.normalize(o,o),_.quat.normalize(a,a);var s=_.vec3.fromValues(0,0,1),u=_.vec3.fromValues(0,0,1);_.vec3.transformQuat(s,s,o),_.vec3.transformQuat(u,u,a),_.vec3.transformQuat(n,n,a);var h=0<_.vec3.dot(n,_.vec3.cross(_.vec3.create(),s,u))?1:-1,c=_.vec3.fromValues(r[0],r[1],r[2]),t=i!==M.YAW_DELTA_BY_YAW?_.vec3.fromValues(0,h,0):_.vec3.fromValues(h,0,0);_.vec3.transformQuat(c,c,a),_.vec3.transformQuat(t,t,a);e=c,n=t,c=_.vec3.create();_.vec3.cross(c,e,n),_.vec3.normalize(c,c);t=c[0],e=c[1],n=c[2],u=_.vec3.fromValues(r[0],r[1],r[2]);_.vec3.transformQuat(u,u,a),s=_.vec3.fromValues(r[0],r[1],r[2]),_.vec3.transformQuat(s,s,o);r=Math.abs(s[0]*t+s[1]*e+s[2]*n),o=_.vec3.create();_.vec3.subtract(o,s,_.vec3.scale(_.vec3.create(),c,r));c=(o[0]*u[0]+o[1]*u[1]+o[2]*u[2])/(_.vec3.length(o)*_.vec3.length(u));1<c&&(c=1);var c=Math.acos(c),o=_.vec3.cross(_.vec3.create(),u,o),r=t*o[0]+e*o[1]+n*o[2],r=i!==M.YAW_DELTA_BY_YAW?0<r?1:-1:r<0?1:-1;return E(c*r*h)},D.angleBetweenVec2=V;var F=-1,t=null,e=null,y=/Chrome\/([0-9]+)\.(?:[0-9]*)\.([0-9]*)\.([0-9]*)/i.exec(R);y&&(F=parseInt(y[1],10),t=y[2],e=y[3]);var L,N,U=F,Q=65===F&&"3325"===t&&parseInt(e,10)<148,z=/Android/i.test(R),G=[.2,.2],B={NONE:"none",YAWPITCH:"yawPitch",VR:"VR"},W=g.MathUtil||{};W.degToRad=Math.PI/180,W.radToDeg=180/Math.PI,W.Vector2=function(t,e){this.x=t||0,this.y=e||0},W.Vector2.prototype={constructor:W.Vector2,set:function(t,e){return this.x=t,this.y=e,this},copy:function(t){return this.x=t.x,this.y=t.y,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}},W.Vector3=function(t,e,i){this.x=t||0,this.y=e||0,this.z=i||0},W.Vector3.prototype={constructor:W.Vector3,set:function(t,e,i){return this.x=t,this.y=e,this.z=i,this},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},normalize:function(){var t=this.length();return 0!==t?(t=1/t,this.multiplyScalar(t)):(this.x=0,this.y=0,this.z=0),this},multiplyScalar:function(t){this.x*=t,this.y*=t,this.z*=t},applyQuaternion:function(t){var e=this.x,i=this.y,n=this.z,r=t.x,o=t.y,a=t.z,s=t.w,u=s*e+o*n-a*i,h=s*i+a*e-r*n,t=s*n+r*i-o*e,n=-r*e-o*i-a*n;return this.x=u*s+n*-r+h*-a-t*-o,this.y=h*s+n*-o+t*-r-u*-a,this.z=t*s+n*-a+u*-o-h*-r,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},crossVectors:function(t,e){var i=t.x,n=t.y,r=t.z,o=e.x,t=e.y,e=e.z;return this.x=n*e-r*t,this.y=r*o-i*e,this.z=i*t-n*o,this}},W.Quaternion=function(t,e,i,n){this.x=t||0,this.y=e||0,this.z=i||0,this.w=void 0!==n?n:1},W.Quaternion.prototype={constructor:W.Quaternion,set:function(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},setFromEulerXYZ:function(t,e,i){var n=Math.cos(t/2),r=Math.cos(e/2),o=Math.cos(i/2),t=Math.sin(t/2),e=Math.sin(e/2),i=Math.sin(i/2);return this.x=t*r*o+n*e*i,this.y=n*e*o-t*r*i,this.z=n*r*i+t*e*o,this.w=n*r*o-t*e*i,this},setFromEulerYXZ:function(t,e,i){var n=Math.cos(t/2),r=Math.cos(e/2),o=Math.cos(i/2),t=Math.sin(t/2),e=Math.sin(e/2),i=Math.sin(i/2);return this.x=t*r*o+n*e*i,this.y=n*e*o-t*r*i,this.z=n*r*i-t*e*o,this.w=n*r*o+t*e*i,this},setFromAxisAngle:function(t,e){var i=e/2,e=Math.sin(i);return this.x=t.x*e,this.y=t.y*e,this.z=t.z*e,this.w=Math.cos(i),this},multiply:function(t){return this.multiplyQuaternions(this,t)},multiplyQuaternions:function(t,e){var i=t.x,n=t.y,r=t.z,o=t.w,a=e.x,s=e.y,t=e.z,e=e.w;return this.x=i*e+o*a+n*t-r*s,this.y=n*e+o*s+r*a-i*t,this.z=r*e+o*t+i*s-n*a,this.w=o*e-i*a-n*s-r*t,this},inverse:function(){return this.x*=-1,this.y*=-1,this.z*=-1,this.normalize(),this},normalize:function(){var t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);return 0===t?(this.x=0,this.y=0,this.z=0,this.w=1):(t=1/t,this.x=this.x*t,this.y=this.y*t,this.z=this.z*t,this.w=this.w*t),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var i=this.x,n=this.y,r=this.z,o=this.w,a=o*t.w+i*t.x+n*t.y+r*t.z;if(a<0?(this.w=-t.w,this.x=-t.x,this.y=-t.y,this.z=-t.z,a=-a):this.copy(t),1<=a)return this.w=o,this.x=i,this.y=n,this.z=r,this;var s=Math.acos(a),t=Math.sqrt(1-a*a);if(Math.abs(t)<.001)return this.w=.5*(o+this.w),this.x=.5*(i+this.x),this.y=.5*(n+this.y),this.z=.5*(r+this.z),this;a=Math.sin((1-e)*s)/t,t=Math.sin(e*s)/t;return this.w=o*a+this.w*t,this.x=i*a+this.x*t,this.y=n*a+this.y*t,this.z=r*a+this.z*t,this},setFromUnitVectors:function(t,e){return void 0===L&&(L=new W.Vector3),(N=t.dot(e)+1)<1e-6?(N=0,Math.abs(t.x)>Math.abs(t.z)?L.set(-t.y,t.x,0):L.set(0,-t.z,t.y)):L.crossVectors(t,e),this.x=L.x,this.y=L.y,this.z=L.z,this.w=N,this.normalize(),this}};var k,X,Y,q,j,H,K,Z,J,$=null!==(t=null==v?void 0:v.userAgent)&&void 0!==t?t:"",tt=g.Util||{};function et(t,e,i,n,r){c=t,a=n?n.fieldOfView:null,o=r.depthNear,h=r.depthFar,l=Math.tan(a?a.upDegrees*H:K),u=Math.tan(a?a.downDegrees*H:K),f=Math.tan(a?a.leftDegrees*H:K),d=Math.tan(a?a.rightDegrees*H:K),s=2/(f+d),a=2/(l+u),c[0]=s,c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=a,c[6]=0,c[7]=0,c[8]=-(f-d)*s*.5,c[9]=(l-u)*a*.5,c[10]=h/(o-h),c[11]=-1,c[12]=0,c[13]=0,c[14]=h*o/(o-h),c[15]=0;var o,a,s,u,h,c,l,d,f,_,p,g,m,v,y,x,w,E,R,T,C,I,b,P,A,O,t=i.orientation||Z,r=i.position||J;f=e,d=r,l=(s=t)[0],u=s[1],a=s[2],o=s[3],c=l*(h=l+l),r=l*(i=u+u),s=l*(t=a+a),l=u*i,u*=t,a*=t,h*=o,i*=o,t*=o,f[0]=1-(l+a),f[1]=r+t,f[2]=s-i,f[3]=0,f[4]=r-t,f[5]=1-(c+a),f[6]=u+h,f[7]=0,f[8]=s+i,f[9]=u-h,f[10]=1-(c+l),f[11]=0,f[12]=d[0],f[13]=d[1],f[14]=d[2],f[15]=1,n&&(C=A=e,T=n.offset,P=T[0],b=T[1],I=T[2],C===A?(A[12]=C[0]*P+C[4]*b+C[8]*I+C[12],A[13]=C[1]*P+C[5]*b+C[9]*I+C[13],A[14]=C[2]*P+C[6]*b+C[10]*I+C[14],A[15]=C[3]*P+C[7]*b+C[11]*I+C[15]):(_=C[0],m=C[1],x=C[2],E=C[3],p=C[4],v=C[5],O=C[6],R=C[7],g=C[8],y=C[9],w=C[10],T=C[11],A[0]=_,A[1]=m,A[2]=x,A[3]=E,A[4]=p,A[5]=v,A[6]=O,A[7]=R,A[8]=g,A[9]=y,A[10]=w,A[11]=T,A[12]=_*P+p*b+g*I+C[12],A[13]=m*P+v*b+y*I+C[13],A[14]=x*P+O*b+w*I+C[14],A[15]=E*P+R*b+T*I+C[15])),a=(t=r=e)[0],s=t[1],i=t[2],u=t[3],h=t[4],c=t[5],l=t[6],d=t[7],f=t[8],n=t[9],_=t[10],p=t[11],g=t[12],m=t[13],v=t[14],y=t[15],(t=(x=a*c-s*h)*(O=_*y-p*v)-(w=a*l-i*h)*(A=n*y-p*m)+(E=a*d-u*h)*(P=n*v-_*m)+(R=s*l-i*c)*(b=f*y-p*g)-(T=s*d-u*c)*(I=f*v-_*g)+(C=i*d-u*l)*(e=f*m-n*g))&&(t=1/t,r[0]=(c*O-l*A+d*P)*t,r[1]=(i*A-s*O-u*P)*t,r[2]=(m*C-v*T+y*R)*t,r[3]=(_*T-n*C-p*R)*t,r[4]=(l*b-h*O-d*I)*t,r[5]=(a*O-i*b+u*I)*t,r[6]=(v*E-g*C-y*w)*t,r[7]=(f*C-_*E+p*w)*t,r[8]=(h*A-c*b+d*e)*t,r[9]=(s*b-a*A-u*e)*t,r[10]=(g*T-m*E+y*x)*t,r[11]=(n*E-f*T-p*x)*t,r[12]=(c*I-h*P-l*e)*t,r[13]=(a*P-s*I+i*e)*t,r[14]=(m*w-g*R-v*x)*t,r[15]=(f*R-n*w+_*x)*t)}tt.MIN_TIMESTEP=.001,tt.MAX_TIMESTEP=1,tt.base64=function(t,e){return"data:"+t+";base64,"+e},tt.clamp=function(t,e,i){return Math.min(Math.max(e,t),i)},tt.lerp=function(t,e,i){return t+(e-t)*i},tt.isIOS=(k=/iPad|iPhone|iPod/.test(null==v?void 0:v.platform),function(){return k}),tt.isWebViewAndroid=(X=-1!==$.indexOf("Version")&&-1!==$.indexOf("Android")&&-1!==$.indexOf("Chrome"),function(){return X}),tt.isSafari=(Y=/^((?!chrome|android).)*safari/i.test($),function(){return Y}),tt.isFirefoxAndroid=(q=-1!==$.indexOf("Firefox")&&-1!==$.indexOf("Android"),function(){return q}),tt.isR7=(j=-1!==$.indexOf("R7 Build"),function(){return j}),tt.isLandscapeMode=function(){var t=90===g.orientation||-90===g.orientation;return tt.isR7()?!t:t},tt.isTimestampDeltaValid=function(t){return!isNaN(t)&&(!(t<=tt.MIN_TIMESTEP)&&!(t>tt.MAX_TIMESTEP))},tt.getScreenWidth=function(){return Math.max(g.screen.width,g.screen.height)*g.devicePixelRatio},tt.getScreenHeight=function(){return Math.min(g.screen.width,g.screen.height)*g.devicePixelRatio},tt.requestFullscreen=function(t){if(tt.isWebViewAndroid())return!1;if(t.requestFullscreen)t.requestFullscreen();else if(t.webkitRequestFullscreen)t.webkitRequestFullscreen();else if(t.mozRequestFullScreen)t.mozRequestFullScreen();else{if(!t.msRequestFullscreen)return!1;t.msRequestFullscreen()}return!0},tt.exitFullscreen=function(){if(m.exitFullscreen)m.exitFullscreen();else if(m.webkitExitFullscreen)m.webkitExitFullscreen();else if(m.mozCancelFullScreen)m.mozCancelFullScreen();else{if(!m.msExitFullscreen)return!1;m.msExitFullscreen()}return!0},tt.getFullscreenElement=function(){return m.fullscreenElement||m.webkitFullscreenElement||m.mozFullScreenElement||m.msFullscreenElement},tt.linkProgram=function(t,e,i,n){var r=t.createShader(t.VERTEX_SHADER);t.shaderSource(r,e),t.compileShader(r);e=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(e,i),t.compileShader(e);var o,a=t.createProgram();for(o in t.attachShader(a,r),t.attachShader(a,e),n)t.bindAttribLocation(a,n[o],o);return t.linkProgram(a),t.deleteShader(r),t.deleteShader(e),a},tt.getProgramUniforms=function(t,e){for(var i={},n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),r="",o=0;o<n;o++)i[r=t.getActiveUniform(e,o).name.replace("[0]","")]=t.getUniformLocation(e,r);return i},tt.orthoMatrix=function(t,e,i,n,r,o,a){var s=1/(e-i),u=1/(n-r),h=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*h,t[11]=0,t[12]=(e+i)*s,t[13]=(r+n)*u,t[14]=(a+o)*h,t[15]=1,t},tt.copyArray=function(t,e){for(var i=0,n=t.length;i<n;i++)e[i]=t[i]},tt.isMobile=function(){var t,e=!1;return t=$||(null==v?void 0:v.vendor)||g.opera,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0),e},tt.extend=function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t},tt.safariCssSizeWorkaround=function(t){var e,i;tt.isIOS()&&(e=t.style.width,i=t.style.height,t.style.width=parseInt(e)+1+"px",t.style.height=parseInt(i)+"px",setTimeout(function(){t.style.width=e,t.style.height=i},100)),g.Util=tt,g.canvas=t},tt.isDebug=function(){return tt.getQueryParameter("debug")},tt.getQueryParameter=function(t){t=t.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");t=new RegExp("[\\?&]"+t+"=([^&#]*)").exec(location.search);return null===t?"":decodeURIComponent(t[1].replace(/\+/g," "))},tt.frameDataFromPose=(H=Math.PI/180,K=.25*Math.PI,Z=new Float32Array([0,0,0,1]),J=new Float32Array([0,0,0]),function(t,e,i){return!(!t||!e)&&(t.pose=e,t.timestamp=e.timestamp,et(t.leftProjectionMatrix,t.leftViewMatrix,e,i.getEyeParameters("left"),i),et(t.rightProjectionMatrix,t.rightViewMatrix,e,i.getEyeParameters("right"),i),!0)}),tt.isInsideCrossDomainIFrame=function(){var t=g.self!==g.top,e=tt.getDomainFromUrl(m.referrer),i=tt.getDomainFromUrl(g.location.href);return t&&e!==i},tt.getDomainFromUrl=function(t){t=-1<t.indexOf("://")?t.split("/")[2]:t.split("/")[0];return t=t.split(":")[0]};var it=function(){function t(t){this.predictionTimeS=t,this.previousQ=new W.Quaternion,this.previousTimestampS=null,this.deltaQ=new W.Quaternion,this.outQ=new W.Quaternion}return t.prototype.getPrediction=function(t,e,i){if(!this.previousTimestampS)return this.previousQ.copy(t),this.previousTimestampS=i,t;var n=new W.Vector3;n.copy(e),n.normalize();e=e.length();if(e<20*W.degToRad)return tt.isDebug()&&console.log("Moving slowly, at %s deg/s: no prediction",(W.radToDeg*e).toFixed(1)),this.outQ.copy(t),this.previousQ.copy(t),this.outQ;this.previousTimestampS;e*=this.predictionTimeS;return this.deltaQ.setFromAxisAngle(n,e),this.outQ.copy(this.previousQ),this.outQ.multiply(this.deltaQ),this.previousQ.copy(t),this.previousTimestampS=i,this.outQ},t}(),nt=function(e){function t(){var t=e.call(this)||this;return t._onDeviceMotion=t._onDeviceMotion.bind(t),t._onDeviceOrientation=t._onDeviceOrientation.bind(t),t._onChromeWithoutDeviceMotion=t._onChromeWithoutDeviceMotion.bind(t),t.isWithoutDeviceMotion=Q,t.isAndroid=z,t.stillGyroVec=_.vec3.create(),t.rawGyroVec=_.vec3.create(),t.adjustedGyroVec=_.vec3.create(),t._timer=-1,t.lastDevicemotionTimestamp=0,t._isEnabled=!1,t.enable(),t}l(t,e);var i=t.prototype;return i.enable=function(){this.isAndroid&&g.addEventListener("deviceorientation",this._onDeviceOrientation),this.isWithoutDeviceMotion?g.addEventListener("deviceorientation",this._onChromeWithoutDeviceMotion):g.addEventListener("devicemotion",this._onDeviceMotion),this._isEnabled=!0},i.disable=function(){g.removeEventListener("deviceorientation",this._onDeviceOrientation),g.removeEventListener("deviceorientation",this._onChromeWithoutDeviceMotion),g.removeEventListener("devicemotion",this._onDeviceMotion),this._isEnabled=!1},i._onChromeWithoutDeviceMotion=function(t){var e=t.alpha,i=t.beta,t=t.gamma;null!==e&&(e=(e||0)*Math.PI/180,i=(i||0)*Math.PI/180,t=(t||0)*Math.PI/180,this.trigger(new c.ComponentEvent("devicemotion",{inputEvent:{deviceorientation:{alpha:e,beta:i,gamma:-t}}})))},i._onDeviceOrientation=function(){var t=this;this._timer&&clearTimeout(this._timer),this._timer=g.setTimeout(function(){(new Date).getTime()-t.lastDevicemotionTimestamp<200&&_.vec3.copy(t.stillGyroVec,t.rawGyroVec)},200)},i._onDeviceMotion=function(t){var e=!(null==t.rotationRate.alpha),i=!(null==t.accelerationIncludingGravity.x);0!==t.interval&&e&&i&&((i=h({},t)).interval=t.interval,i.timeStamp=t.timeStamp,i.type=t.type,i.rotationRate={alpha:t.rotationRate.alpha,beta:t.rotationRate.beta,gamma:t.rotationRate.gamma},i.accelerationIncludingGravity={x:t.accelerationIncludingGravity.x,y:t.accelerationIncludingGravity.y,z:t.accelerationIncludingGravity.z},i.acceleration={x:t.acceleration.x,y:t.acceleration.y,z:t.acceleration.z},this.isAndroid&&(_.vec3.set(this.rawGyroVec,t.rotationRate.alpha||0,t.rotationRate.beta||0,t.rotationRate.gamma||0),_.vec3.subtract(this.adjustedGyroVec,this.rawGyroVec,this.stillGyroVec),this.lastDevicemotionTimestamp=(new Date).getTime(),i.adjustedRotationRate={alpha:this.adjustedGyroVec[0],beta:this.adjustedGyroVec[1],gamma:this.adjustedGyroVec[2]}),this.trigger(new c.ComponentEvent("devicemotion",{inputEvent:i})))},t}(c),rt=function(){function t(t,e){this.set(t,e)}var e=t.prototype;return e.set=function(t,e){this.sample=t,this.timestampS=e},e.copy=function(t){this.set(t.sample,t.timestampS)},t}(),ot=function(){function t(t){this.addGyroMeasurement=function(t,e){this.currentGyroMeasurement.set(t,e);e-=this.previousGyroMeasurement.timestampS;tt.isTimestampDeltaValid(e)&&this.run_(),this.previousGyroMeasurement.copy(this.currentGyroMeasurement)},this.kFilter=t,this.currentAccelMeasurement=new rt,this.currentGyroMeasurement=new rt,this.previousGyroMeasurement=new rt,tt.isIOS()?this.filterQ=new W.Quaternion(-1,0,0,1):this.filterQ=new W.Quaternion(1,0,0,1),this.previousFilterQ=new W.Quaternion,this.previousFilterQ.copy(this.filterQ),this.accelQ=new W.Quaternion,this.isOrientationInitialized=!1,this.estimatedGravity=new W.Vector3,this.measuredGravity=new W.Vector3,this.gyroIntegralQ=new W.Quaternion}var e=t.prototype;return e.addAccelMeasurement=function(t,e){this.currentAccelMeasurement.set(t,e)},e.getOrientation=function(){return this.filterQ},e.run_=function(){if(!this.isOrientationInitialized)return this.accelQ=this.accelToQuaternion_(this.currentAccelMeasurement.sample),this.previousFilterQ.copy(this.accelQ),void(this.isOrientationInitialized=!0);var t=this.currentGyroMeasurement.timestampS-this.previousGyroMeasurement.timestampS,e=this.gyroToQuaternionDelta_(this.currentGyroMeasurement.sample,t);this.gyroIntegralQ.multiply(e),this.filterQ.copy(this.previousFilterQ),this.filterQ.multiply(e);t=new W.Quaternion;t.copy(this.filterQ),t.inverse(),this.estimatedGravity.set(0,0,-1),this.estimatedGravity.applyQuaternion(t),this.estimatedGravity.normalize(),this.measuredGravity.copy(this.currentAccelMeasurement.sample),this.measuredGravity.normalize();e=new W.Quaternion;e.setFromUnitVectors(this.estimatedGravity,this.measuredGravity),e.inverse(),tt.isDebug()&&console.log("Delta: %d deg, G_est: (%s, %s, %s), G_meas: (%s, %s, %s)",W.radToDeg*tt.getQuaternionAngle(e),this.estimatedGravity.x.toFixed(1),this.estimatedGravity.y.toFixed(1),this.estimatedGravity.z.toFixed(1),this.measuredGravity.x.toFixed(1),this.measuredGravity.y.toFixed(1),this.measuredGravity.z.toFixed(1));t=new W.Quaternion;t.copy(this.filterQ),t.multiply(e),this.filterQ.slerp(t,1-this.kFilter),this.previousFilterQ.copy(this.filterQ)},e.accelToQuaternion_=function(t){var e=new W.Vector3;e.copy(t),e.normalize();t=new W.Quaternion;return t.setFromUnitVectors(new W.Vector3(0,0,-1),e),t.inverse(),t},e.gyroToQuaternionDelta_=function(t,e){var i=new W.Quaternion,n=new W.Vector3;return n.copy(t),n.normalize(),i.setFromAxisAngle(n,t.length()*e),i},t}();ot.prototype.run_=function(){if(!this.isOrientationInitialized)return this.accelQ=this.accelToQuaternion_(this.currentAccelMeasurement.sample),this.previousFilterQ.copy(this.accelQ),void(this.isOrientationInitialized=!0);var t=this.currentGyroMeasurement.timestampS-this.previousGyroMeasurement.timestampS,e=this.gyroToQuaternionDelta_(this.currentGyroMeasurement.sample,t);this.gyroIntegralQ.multiply(e),this.filterQ.copy(this.previousFilterQ),this.filterQ.multiply(e);t=new W.Quaternion;t.copy(this.filterQ),t.inverse(),this.estimatedGravity.set(0,0,-1),this.estimatedGravity.applyQuaternion(t),this.estimatedGravity.normalize(),this.measuredGravity.copy(this.currentAccelMeasurement.sample),this.measuredGravity.normalize();e=new W.Quaternion;e.setFromUnitVectors(this.estimatedGravity,this.measuredGravity),e.inverse();t=new W.Quaternion;t.copy(this.filterQ),t.multiply(e),this.filterQ.slerp(t,1-this.kFilter),this.previousFilterQ.copy(this.filterQ),this.isFilterQuaternionInitialized||(this.isFilterQuaternionInitialized=!0)},ot.prototype.getOrientation=function(){return this.isFilterQuaternionInitialized?this.filterQ:null};for(var at=function(e){function t(){var t=e.call(this)||this;return t.deviceMotion=new nt,t.accelerometer=new W.Vector3,t.gyroscope=new W.Vector3,t._onDeviceMotionChange=t._onDeviceMotionChange.bind(t),t._onScreenOrientationChange=t._onScreenOrientationChange.bind(t),t.filter=new ot(.98),t.posePredictor=new it(.04),t.filterToWorldQ=new W.Quaternion,t.isFirefoxAndroid=tt.isFirefoxAndroid(),t.isIOS=x||w,t.isChromeUsingDegrees=66<=U,t._isEnabled=!1,t.isIOS?t.filterToWorldQ.setFromAxisAngle(new W.Vector3(1,0,0),Math.PI/2):t.filterToWorldQ.setFromAxisAngle(new W.Vector3(1,0,0),-Math.PI/2),t.inverseWorldToScreenQ=new W.Quaternion,t.worldToScreenQ=new W.Quaternion,t.originalPoseAdjustQ=new W.Quaternion,t.originalPoseAdjustQ.setFromAxisAngle(new W.Vector3(0,0,1),-g.orientation*Math.PI/180),t._setScreenTransform(),tt.isLandscapeMode()&&t.filterToWorldQ.multiply(t.inverseWorldToScreenQ),t.resetQ=new W.Quaternion,t.deviceMotion.on("devicemotion",t._onDeviceMotionChange),t.enable(),t}l(t,e);var i=t.prototype;return i.enable=function(){this.isEnabled()||(this.deviceMotion.enable(),this._isEnabled=!0,g.addEventListener("orientationchange",this._onScreenOrientationChange))},i.disable=function(){this.isEnabled()&&(this.deviceMotion.disable(),this._isEnabled=!1,g.removeEventListener("orientationchange",this._onScreenOrientationChange))},i.isEnabled=function(){return this._isEnabled},i.destroy=function(){this.disable(),this.deviceMotion=null},i.getOrientation=function(){var t,e=this;if(this.deviceMotion.isWithoutDeviceMotion&&this._deviceOrientationQ){this.deviceOrientationFixQ=this.deviceOrientationFixQ||(new W.Quaternion).setFromAxisAngle(new W.Vector3(0,1,0),-e._alpha),t=this._deviceOrientationQ,(n=new W.Quaternion).copy(t),n.multiply(this.filterToWorldQ),n.multiply(this.resetQ),n.multiply(this.worldToScreenQ),n.multiplyQuaternions(this.deviceOrientationFixQ,n);var i=_.quat.fromValues(n.x,n.y,n.z,n.w);return _.quat.normalize(i,i)}if(!(t=this.filter.getOrientation()))return null;var n=this._convertFusionToPredicted(t),i=_.quat.fromValues(n.x,n.y,n.z,n.w);return _.quat.normalize(i,i)},i._triggerChange=function(){var t=this.getOrientation();t&&(this._prevOrientation?_.quat.equals(this._prevOrientation,t)||this.trigger(new c.ComponentEvent("change",{quaternion:t})):this._prevOrientation=t)},i._convertFusionToPredicted=function(t){this.predictedQ=this.posePredictor.getPrediction(t,this.gyroscope,this.previousTimestampS);t=new W.Quaternion;return t.copy(this.filterToWorldQ),t.multiply(this.resetQ),t.multiply(this.predictedQ),t.multiply(this.worldToScreenQ),t},i._onDeviceMotionChange=function(t){var e=t.inputEvent,i=e.deviceorientation,n=e.accelerationIncludingGravity,t=e.adjustedRotationRate||e.rotationRate,e=e.timeStamp/1e3;i?(this._alpha||(this._alpha=i.alpha),this._deviceOrientationQ=this._deviceOrientationQ||new W.Quaternion,this._deviceOrientationQ.setFromEulerYXZ(i.beta,i.alpha,i.gamma),this._triggerChange()):(this.isFirefoxAndroid&&(e/=1e3),this.accelerometer.set(-n.x,-n.y,-n.z),this.gyroscope.set(t.alpha,t.beta,t.gamma),(this.isIOS||this.isFirefoxAndroid||this.isChromeUsingDegrees)&&this.gyroscope.multiplyScalar(Math.PI/180),this.filter.addAccelMeasurement(this.accelerometer,e),this.filter.addGyroMeasurement(this.gyroscope,e),this._triggerChange(),this.previousTimestampS=e)},i._onScreenOrientationChange=function(){this._setScreenTransform()},i._setScreenTransform=function(){this.worldToScreenQ.set(0,0,0,1);var t=g.orientation;switch(t){case 0:break;case 90:case-90:case 180:this.worldToScreenQ.setFromAxisAngle(new W.Vector3(0,0,1),t/-180*Math.PI)}this.inverseWorldToScreenQ.copy(this.worldToScreenQ),this.inverseWorldToScreenQ.inverse()},t}(c),st=function(n){function t(t,e){void 0===e&&(e={});var i=n.call(this)||this;return i.element=t,i._prevQuaternion=null,i._quaternion=null,i.fusionPoseSensor=null,i.options=h({scale:1,threshold:0},e),i._onPoseChange=i._onPoseChange.bind(i),i}l(t,n);var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){return this.observer||(this.observer=t,this.fusionPoseSensor=new at,this.fusionPoseSensor.enable(),this._attachEvent()),this},e.disconnect=function(){return this.observer&&(this._dettachEvent(),this.fusionPoseSensor.disable(),this.fusionPoseSensor.destroy(),this.fusionPoseSensor=null,this.observer=null),this},e.destroy=function(){this.disconnect(),this.element=null,this.options=null,this.axes=null,this._prevQuaternion=null,this._quaternion=null},e._onPoseChange=function(t){if(!this._prevQuaternion)return this._prevQuaternion=_.quat.clone(t.quaternion),void(this._quaternion=_.quat.clone(t.quaternion));var n,e,i;_.quat.copy(this._prevQuaternion,this._quaternion),_.quat.copy(this._quaternion,t.quaternion),this.observer.change(this,t,(n=this.axes,[(e=this._prevQuaternion,i=this._quaternion,t=D.getRotationDelta(e,i,M.YAW_DELTA_BY_YAW),D.getRotationDelta(e,i,M.YAW_DELTA_BY_ROLL)*Math.sin(D.extractPitchFromQuat(i))+t),(i=this._prevQuaternion,t=this._quaternion,D.getRotationDelta(i,t,M.PITCH_DELTA))].reduce(function(t,e,i){return n[i]&&(t[n[i]]=e),t},{})))},e._attachEvent=function(){this.fusionPoseSensor.on("change",this._onPoseChange)},e._dettachEvent=function(){this.fusionPoseSensor.off("change",this._onPoseChange)},t}(c),ut=null,ht=0,ct=function(){function t(){if(ht++,ut)return ut;(ut=this)._onDeviceOrientation=this._onDeviceOrientation.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._spinR=0,this._screenOrientationAngle=0,g.addEventListener("deviceorientation",this._onDeviceOrientation),g.addEventListener("orientationchange",this._onOrientationChange)}var e=t.prototype;return e.getRadian=function(){return this._spinR+_.glMatrix.toRadian(this._screenOrientationAngle)},e.unref=function(){0<--ht||(g.removeEventListener("deviceorientation",this._onDeviceOrientation),g.removeEventListener("orientationchange",this._onOrientationChange),this._spinR=0,this._screenOrientationAngle=0,ut=null,ht=0)},e._onDeviceOrientation=function(t){var e;null!==t.beta&&null!==t.gamma&&(e=_.glMatrix.toRadian(t.beta),t=_.glMatrix.toRadian(t.gamma),this._spinR=Math.atan2(Math.cos(e)*Math.sin(t),Math.sin(e)))},e._onOrientationChange=function(){g.screen&&g.screen.orientation&&void 0!==g.screen.orientation.angle?this._screenOrientationAngle=screen.orientation.angle:void 0!==g.orientation&&(this._screenOrientationAngle=0<=g.orientation?g.orientation:360+g.orientation)},t}(),lt=function(r){function t(t,e){void 0===e&&(e={});t=r.call(this,t,e)||this;return t._useRotation=!1,t._screenRotationAngle=null,t.setUseRotation(!(!e||!e.useRotation)),t._userDirection=u.DIRECTION_ALL,t}l(t,r);var e=t.prototype;return e.setUseRotation=function(t){this._useRotation=t,this._screenRotationAngle&&(this._screenRotationAngle.unref(),this._screenRotationAngle=null),this._useRotation&&(this._screenRotationAngle=new ct)},e.connect=function(t){return this._userDirection=this._direction,this._useRotation&&this._direction&u.DIRECTION_ALL&&(this._direction=u.DIRECTION_HORIZONTAL),r.prototype.connect.call(this,t)},e.destroy=function(){this._useRotation&&this._screenRotationAngle&&this._screenRotationAngle.unref(),r.prototype.destroy.call(this)},e._getOffset=function(t,e){if(!1===this._useRotation)return r.prototype._getOffset.call(this,t,e);var i=r.prototype._getOffset.call(this,t,[!0,!0]),n=[0,0],e=this._screenRotationAngle.getRadian(),t=Math.cos(e),e=Math.sin(e);return n[0]=i[0]*t-i[1]*e,n[1]=i[1]*t+i[0]*e,this._userDirection&u.DIRECTION_HORIZONTAL?this._userDirection&u.DIRECTION_VERTICAL||(n[1]=0):n[0]=0,n},t}(u.PanInput),dt=_.vec3.fromValues(0,1,0),ft=function(t){function e(){var e=t.call(this)||this;return e._fusionPoseSensor=new at,e._quaternion=_.quat.create(),e._fusionPoseSensor.enable(),e._fusionPoseSensor.on("change",function(t){e._quaternion=t.quaternion,e.trigger(new c.ComponentEvent("change",{isTrusted:!0}))}),e}l(e,t);var i=e.prototype;return i.getCombinedQuaternion=function(t){var e=_.quat.setAxisAngle(_.quat.create(),dt,_.glMatrix.toRadian(-t)),t=_.quat.conjugate(_.quat.create(),this._quaternion);return _.quat.multiply(_.quat.create(),t,e)},i.destroy=function(){this.off(),this._fusionPoseSensor&&(this._fusionPoseSensor.off(),this._fusionPoseSensor.destroy(),this._fusionPoseSensor=null)},e}(c),_t=[-180,180],pt=[-90,90],gt=[-180,180],mt=function(i){function t(t){var e=i.call(this)||this;e.options={};t=h({element:null,yaw:0,pitch:0,fov:65,showPolePoint:!1,useZoom:!0,useKeyboard:!0,gyroMode:B.YAWPITCH,touchDirection:6,yawRange:_t,pitchRange:pt,fovRange:[30,110],aspectRatio:1},t);return e._element=t.element,e._initialFov=t.fov,e._enabled=!1,e._isAnimating=!1,e._deviceQuaternion=null,e._initAxes(t),e.option(t),e}l(t,i);var e=t.prototype;return e.updatePanScale=function(t){void 0===t&&(t={});var e=this._axes.get().fov,t=t.height||parseInt(window.getComputedStyle(this._element).height,10),t=G[0]*e/this._initialFov*320/t;return this._axesPanInput.options.scale=[t,t],this._axes.options.deceleration=.0014*e/110,this},e.option=function(t,e){if(!t)return this._getOptions();if(t&&"string"==typeof t&&void 0===e)return this._getOptions(t);var i={},n=[];return"string"==typeof t?(n.push(t),i[t]=e):(t=t,n=Object.keys(t),i=h({},t)),this._setOptions(this._getValidatedOptions(i)),this._applyOptions(n),this},e.enable=function(){return this._enabled||(this._enabled=!0,this._applyOptions(Object.keys(this.options)),this.updatePanScale()),this},e.disable=function(t){return void 0===t&&(t=!1),this._enabled&&(t||this._resetOrientation(),this._axes.disconnect(),this._enabled=!1),this},e.lookAt=function(t,e){var i=t.yaw,n=t.pitch,r=t.fov,t=this._axes.get(),i=void 0===i?0:i-t.yaw,n=void 0===n?0:n-t.pitch,t=void 0===r?0:r-t.fov;this._axes.options.maximumDuration=1/0,this._axes.setBy({yaw:i,pitch:n,fov:t},e)},e.getYawPitch=function(){var t=this._axes.get();return{yaw:t.yaw,pitch:t.pitch}},e.getFov=function(){return this._axes.get().fov},e.getQuaternion=function(){var t=this._axes.get();return this._deviceQuaternion.getCombinedQuaternion(t.yaw)},e.shouldRenderWithQuaternion=function(){return this.options.gyroMode===B.VR},e.destroy=function(){this._axes&&this._axes.destroy(),this._axesPanInput&&this._axesPanInput.destroy(),this._axesWheelInput&&this._axesWheelInput.destroy(),this._axesTiltMotionInput&&this._axesTiltMotionInput.destroy(),this._axesPinchInput&&this._axesPinchInput.destroy(),this._axesMoveKeyInput&&this._axesMoveKeyInput.destroy(),this._deviceQuaternion&&this._deviceQuaternion.destroy()},e._initAxes=function(t){var e=this,i=this._updateYawRange(t.yawRange,t.fov,t.aspectRatio),n=this._updatePitchRange(t.pitchRange,t.fov,t.showPolePoint),r=t.gyroMode===B.VR;this._axesPanInput=new lt(this._element,{useRotation:r}),this._axesWheelInput=new u.WheelInput(this._element,{scale:-4}),this._axesTiltMotionInput=null,this._axesPinchInput=T?new u.PinchInput(this._element,{scale:-1}):null,this._axesMoveKeyInput=new u.MoveKeyInput(this._element,{scale:[-6,6]}),this._axes=new u({yaw:{range:i,circular:this._isCircular(i),bounce:[0,0]},pitch:{range:n,circular:this._isCircular(n),bounce:[0,0]},fov:{range:t.fovRange,circular:[!1,!1],bounce:[0,0]}},{deceleration:.0014,maximumDuration:1e3},{yaw:t.yaw,pitch:t.pitch,fov:t.fov}).on({hold:function(t){e._axes.options.maximumDuration=1e3,e.trigger(new c.ComponentEvent("hold",{isTrusted:t.isTrusted}))},change:function(t){0!==t.delta.fov&&(e._updateControlScale(t),e.updatePanScale()),e._triggerChange(t)},release:function(t){e._triggerChange(t)},animationEnd:function(t){e.trigger(new c.ComponentEvent("animationEnd",{isTrusted:t.isTrusted}))}})},e._getValidatedOptions=function(t){return t.yawRange&&(t.yawRange=this._getValidYawRange(t.yawRange,t.fov,t.aspectRatio)),t.pitchRange&&(t.pitchRange=this._getValidPitchRange(t.pitchRange,t.fov)),t},e._getOptions=function(t){var e;return"string"==typeof t?e=this.options[t]:0===arguments.length&&(e=this.options),e},e._setOptions=function(t){for(var e in t)this.options[e]=t[e]},e._applyOptions=function(t){var e,i,n,r=this.options,o=this._axes,a=r.gyroMode===B.VR,s=r.gyroMode===B.YAWPITCH,u=a?2&r.touchDirection:r.touchDirection;t.some(function(t){return"showPolePoint"===t||"fov"===t||"aspectRatio"===t||"yawRange"===t||"pitchRange"===t})&&(0<=t.indexOf("fov")&&(o.setTo({fov:r.fov}),this.updatePanScale()),this._updateControlScale()),t.some(function(t){return"fovRange"===t})&&(e=r.fovRange,i=o.get().fov,n=o.get().fov,_.vec2.copy(o.axis.fov.range,e),n<e[0]?n=e[0]:i>e[1]&&(n=e[1]),i!==n&&(o.setTo({fov:n},0),this._updateControlScale(),this.updatePanScale())),t.some(function(t){return"gyroMode"===t})&&C&&(this._axesTiltMotionInput&&(this._axes.disconnect(this._axesTiltMotionInput),this._axesTiltMotionInput.destroy(),this._axesTiltMotionInput=null),this._deviceQuaternion&&(this._deviceQuaternion.destroy(),this._deviceQuaternion=null),a?this._initDeviceQuaternion():s&&(this._axesTiltMotionInput=new st(this._element),this._axes.connect(["yaw","pitch"],this._axesTiltMotionInput)),this._axesPanInput.setUseRotation(a)),t.some(function(t){return"useKeyboard"===t})&&(r.useKeyboard?o.connect(["yaw","pitch"],this._axesMoveKeyInput):o.disconnect(this._axesMoveKeyInput)),t.some(function(t){return"useZoom"===t})&&(a=r.useZoom,o.disconnect(this._axesWheelInput),a&&o.connect(["fov"],this._axesWheelInput)),this._togglePinchInputByOption(r.touchDirection,r.useZoom),t.some(function(t){return"touchDirection"===t})&&this._enabled&&this._enableTouch(u)},e._togglePinchInputByOption=function(t,e){this._axesPinchInput&&(this._axes.disconnect(this._axesPinchInput),e&&6===t&&-1===this._axes._inputs.indexOf(this._axesPinchInput)&&this._axes.connect(["fov"],this._axesPinchInput))},e._enableTouch=function(t){this._axesPanInput&&this._axes.disconnect(this._axesPanInput);var e=2&t?"yaw":null,t=4&t?"pitch":null;this._axes.connect([e,t],this._axesPanInput)},e._initDeviceQuaternion=function(){var e=this;this._deviceQuaternion=new ft,this._deviceQuaternion.on("change",function(t){e._triggerChange(t)})},e._getValidYawRange=function(t,e,i){i=this._adjustAspectRatio(i||this.options.aspectRatio||1),i=(e||this._axes.get().fov)*i;return t[1]-t[0]>=i?t:this.options.yawRange||_t},e._getValidPitchRange=function(t,e){e=e||this._axes.get().fov;return t[1]-t[0]>=e?t:this.options.pitchRange||pt},e._isCircular=function(t){return t[1]-t[0]<360?[!1,!1]:[!0,!0]},e._updateControlScale=function(t){var e=this.options,i=this._axes.get().fov,n=this._updatePitchRange(e.pitchRange,i,e.showPolePoint),r=this._updateYawRange(e.yawRange,i,e.aspectRatio),i=this._axes.get(),e=i.yaw,i=i.pitch;return _.vec2.copy(this._axes.axis.yaw.range,r),_.vec2.copy(this._axes.axis.pitch.range,n),this._axes.axis.yaw.circular=this._isCircular(r),this._axes.axis.pitch.circular=this._isCircular(n),e<r[0]?e=r[0]:e>r[1]&&(e=r[1]),i<n[0]?i=n[0]:i>n[1]&&(i=n[1]),t&&t.set({yaw:e,pitch:i}),this._axes.setTo({yaw:e,pitch:i},0),this},e._updatePitchRange=function(t,e,i){if(this.options.gyroMode===B.VR)return gt;var n=t[1]-t[0],e=e/2;return!i||n<180?[t[0]+e,t[1]-e]:t.concat()},e._updateYawRange=function(t,e,i){if(this.options.gyroMode===B.VR)return _t;if(360<=t[1]-t[0])return t.concat();e=D.toDegree(Math.atan2(i,1/Math.tan(_.glMatrix.toRadian(e/2))));return[t[0]+e,t[1]-e]},e._triggerChange=function(t){var e=this._axes.get(),i=this.options,t={targetElement:i.element,isTrusted:t.isTrusted,yaw:e.yaw,pitch:e.pitch,fov:e.fov,quaternion:null};i.gyroMode===B.VR&&this._deviceQuaternion&&(t.quaternion=this._deviceQuaternion.getCombinedQuaternion(e.yaw)),this.trigger(new c.ComponentEvent("change",t))},e._adjustAspectRatio=function(t){for(var e=[.52,.54,.563,.57,.584,.59,.609,.67,.702,.72,.76,.78,.82,.92,.97,1,1.07,1.14,1.19,1.25,1.32,1.38,1.4,1.43,1.53,1.62,1.76,1.77,1.86,1.96,2.26,2.3,2.6,3,5,6],i=[.51,.54,.606,.56,.628,.63,.647,.71,.736,.757,.78,.77,.8,.89,.975,1,1.07,1.1,1.15,1.18,1.22,1.27,1.3,1.33,1.39,1.45,1.54,1.55,1.58,1.62,1.72,1.82,1.92,2,2.24,2.3],n=-1,r=0;r<e.length-1;r++)if(e[r]<=t&&t<=e[r+1]){n=r;break}if(-1===n)return t<e[0]?i[0]:i[i[0].length-1];var o=e[n],a=e[n+1],s=i[n],i=i[n+1];return this._lerp(s,i,(t-o)/(a-o))},e._lerp=function(t,e,i){return t+i*(e-t)},e._resetOrientation=function(){var t=this.options;return this._axes.setTo({yaw:t.yaw,pitch:t.pitch,fov:t.fov},0),this},t.VERSION=n,t.CONTROL_MODE_VR=1,t.CONTROL_MODE_YAWPITCH=2,t.TOUCH_DIRECTION_ALL=6,t.TOUCH_DIRECTION_YAW=2,t.TOUCH_DIRECTION_PITCH=4,t.TOUCH_DIRECTION_NONE=1,t}(c),vt={INVALID_DEVICE:10,NO_WEBGL:11,FAIL_IMAGE_LOAD:12,FAIL_BIND_TEXTURE:13,INVALID_RESOURCE:14,RENDERING_CONTEXT_LOST:15},yt={READY:"ready",VIEW_CHANGE:"viewChange",ANIMATION_END:"animationEnd",ERROR:"error"},xt={EQUIRECTANGULAR:"equirectangular",CUBEMAP:"cubemap",CUBESTRIP:"cubestrip",PANORAMA:"panorama",STEREOSCOPIC_EQUI:"stereoequi"},wt={TOP_BOTTOM:"3dv",LEFT_RIGHT:"3dh",NONE:""},Et="view360-canvas",Rt=function(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return t.forEach(function(i){Object.keys(i).forEach(function(t){var e=i[t];Array.isArray(n[t])&&Array.isArray(e)?n[t]=p(n[t],e):n[t]=e})}),n},Tt=function(t,e){var i,n;if("object"==typeof e?(i=e.src,n=e.type):"string"==typeof e&&(i=e),!i)return!1;e=document.createElement("source");e.src=i,n&&(e.type=n),t.appendChild(e)},Ct={0:"NO_ERROR",1280:"INVALID_ENUM",1281:"INVALID_VALUE",1282:"INVALID_OPERATION",1285:"OUT_OF_MEMORY",1286:"INVALID_FRAMEBUFFER_OPERATION",37442:"CONTEXT_LOST_WEBGL"},It=null,bt=function(){function e(){}return e.createShader=function(t,e,i){e=t.createShader(e);return t.shaderSource(e,i),t.compileShader(e),t.getShaderParameter(e,t.COMPILE_STATUS)?e:(console.error(t.getShaderInfoLog(e)),null)},e.createProgram=function(t,e,i){var n=t.createProgram();return t.attachShader(n,e),t.attachShader(n,i),t.linkProgram(n),t.deleteShader(e),t.deleteShader(i),t.getProgramParameter(n,t.LINK_STATUS)?n:(t.deleteProgram(n),null)},e.initBuffer=function(t,e,i,n,r){var o=t.createBuffer();return t.bindBuffer(e,o),t.bufferData(e,i,t.STATIC_DRAW),o&&(o.itemSize=n,o.numItems=i.length/n),void 0!==r&&(t.enableVertexAttribArray(r),t.vertexAttribPointer(r,o.itemSize,t.FLOAT,!1,0,0)),o},e.getWebglContext=function(t,e){var i,n,r=null,o=h({preserveDrawingBuffer:!1,antialias:!1},e),e=function(t){return t.statusMessage};t.addEventListener("webglcontextcreationerror",e);try{for(var a=f(["webgl","experimental-webgl","webkit-3d","moz-webgl"]),s=a.next();!s.done;s=a.next()){var u=s.value;try{r=t.getContext(u,o)}catch(t){}if(r)break}}catch(t){i={error:t}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return t.removeEventListener("webglcontextcreationerror",e),r},e.createTexture=function(t,e){var i=t.createTexture();return t.bindTexture(e,i),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(e,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(e,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindTexture(e,null),i},e.isWebGLAvailable=function(){var t;return null===It&&(t=document.createElement("canvas"),t=e.getWebglContext(t),It=!!t,!t||(t=t.getExtension("WEBGL_lose_context"))&&t.loseContext()),!!It},e.isStableWebGL=function(){var t,e=a(),i=!0;return"android"!==e.os.name||((t=parseFloat(e.os.version))<=4.3&&1<=t||4.4===t&&"chrome"!==e.browser.name)&&(i=!1),i},e.getErrorNameFromWebGLErrorCode=function(t){return t in Ct?Ct[t]:"UNKNOWN_ERROR"},e.texImage2D=function(t,e,i){try{t.texImage2D(e,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,i)}catch(t){console.error("WebGLUtils.texImage2D error:",t)}},e.getMaxTextureSize=function(t){return t.getParameter(t.MAX_TEXTURE_SIZE)},e}(),e=a(),Pt="ie"===e.browser.name&&11===e.browser.majorVersion,At={ERROR:"error"},Ot=function(e){function t(){var t=e.call(this)||this;return t._forceDimension=null,t._pixelCanvas=null,t._pixelContext=null,t}l(t,e);var i=t.prototype;return i.render=function(t){var e=t.gl,i=t.shaderProgram,n=t.indexBuffer,r=t.mvMatrix,t=t.pMatrix;e.uniformMatrix4fv(i.pMatrixUniform,!1,t),e.uniformMatrix4fv(i.mvMatrixUniform,!1,r),n&&e.drawElements(e.TRIANGLES,n.numItems,e.UNSIGNED_SHORT,0)},i.getDimension=function(t){return{width:t.naturalWidth||t.videoWidth,height:t.naturalHeight||t.videoHeight}},i.updateShaderData=function(t){},i._initPixelSource=function(t,e){var i;void 0===e&&(e=null),(Pt&&t instanceof HTMLVideoElement||e)&&(t=(i=e||this.getDimension(t)).width,i=i.height,this._pixelCanvas=document.createElement("canvas"),this._pixelCanvas.width=t,this._pixelCanvas.height=i,this._pixelContext=this._pixelCanvas.getContext("2d")),this._forceDimension=e},i._getPixelSource=function(t){if(!this._pixelCanvas)return t;var e=this.getDimension(t),i=this._forceDimension||e;return this._pixelCanvas.width!==i.width&&(this._pixelCanvas.width=i.width),this._pixelCanvas.height!==i.height&&(this._pixelCanvas.height=i.height),this._forceDimension?this._pixelContext.drawImage(t,0,0,e.width,e.height,0,0,i.width,i.height):this._pixelContext.drawImage(t,0,0),this._pixelCanvas},i._extractTileConfig=function(t){return(Array.isArray(t.tileConfig)?t.tileConfig:Array.apply(void 0,p(Array(6))).map(function(){return t.tileConfig})).map(function(t){return h({flipHorizontal:!1,rotation:0},t)})},i._triggerError=function(t){console.error("Renderer Error:",t),this.trigger(new c.ComponentEvent(At.ERROR,{message:"string"==typeof t?t:t.message}))},t.EVENTS=At,t}(c),St=function(t){function h(){return null!==t&&t.apply(this,arguments)||this}l(h,t);var e=h.prototype;return h.extractOrder=function(t){return t.order||"RLUDBF"},e.getVertexPositionData=function(){return h._VERTEX_POSITION_DATA=null!==h._VERTEX_POSITION_DATA?h._VERTEX_POSITION_DATA:[1,-1,1,-1,-1,1,-1,1,1,1,1,1,-1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,1,-1,1,1,-1,1,1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,-1,1,1,-1,-1,1,-1,1,1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1]},e.getIndexData=function(){if(h._INDEX_DATA)return h._INDEX_DATA;for(var t=[],e=this.getVertexPositionData(),i=0;i<e.length/3;i+=4)t.push(i,i+2,i+1,i,i+3,i+2);return h._INDEX_DATA=t},e.getTextureCoordData=function(t){var e=this,i=t.image,t=t.imageConfig,n=h.extractOrder(t),u=this.getVertexPositionData(),r=this._extractTileConfig(t),o=t.trim;return"BFUDRL".split("").map(function(t){return r[n.indexOf(t)]}).map(function(t,e){for(var i=Math.floor(t.rotation/90),n=t.flipHorizontal?[0,1,2,3]:[1,0,3,2],r=0;r<Math.abs(i);r++)t.flipHorizontal&&0<i||!t.flipHorizontal&&i<0?n.push(n.shift()):n.unshift(n.pop());for(var o=u.slice(12*e,12*e+12),a=[],s=0;s<4;s++)a[n[s]]=o.splice(0,3);return a}).map(function(t){return e._shrinkCoord({image:i,faceCoords:t,trim:o})}).reduce(function(t,e){return p(t,e.reduce(function(t,e){return p(t,e)},[]))},[])},e.getVertexShaderSource=function(){return"\nattribute vec3 aVertexPosition;\nattribute vec3 aTextureCoord;\nuniform mat4 uMVMatrix;\nuniform mat4 uPMatrix;\nvarying highp vec3 vVertexDirectionVector;\nvoid main(void) {\n vVertexDirectionVector = aTextureCoord;\n gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);\n}"},e.getFragmentShaderSource=function(){return"\nprecision highp float;\nuniform samplerCube uSampler;\nvarying highp vec3 vVertexDirectionVector;\nvoid main(void) {\n gl_FragColor = textureCube(uSampler, vVertexDirectionVector);\n}"},e.updateTexture=function(t,e,i){var i=h.extractOrder(i),n={};i.split("").forEach(function(t,e){n[t]=e});try{if(e instanceof Array)for(var r=0;r<6;r++){var o=n["RLUDBF"[r]];bt.texImage2D(t,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e[o])}else for(var a=this.getMaxCubeMapTextureSize(t,e),r=0;r<6;r++){var o=n["RLUDBF"[r]],s=this.extractTileFromImage(e,o,a);bt.texImage2D(t,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,s)}}catch(t){this._triggerError(t)}},e.bindTexture=function(t,e,i,n){t.bindTexture(t.TEXTURE_CUBE_MAP,e),this.updateTexture(t,i,n)},e.getSourceTileSize=function(t){var e=this.getDimension(t),i=e.width,t=e.height,e=i/t,i=e==1/6?i:6==e?t:e==2/3?i/2:i/3;return i},e.extractTileFromImage=function(t,e,i){var n=this.getDimension(t).width,r=this.getSourceTileSize(t),o=document.createElement("canvas");o.width=i,o.height=i;var a=o.getContext("2d"),s=n/r,n=r*e%(r*s),s=Math.floor(e/s)*r;return a.drawImage(t,n,s,r,r,0,0,i,i),o},e.getMaxCubeMapTextureSize=function(t,e){var i=a(),n=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),r=this.getSourceTileSize(e);if("ie"===i.browser.name&&11===i.browser.majorVersion&&!D.isPowerOfTwo(r))for(var o=1;o<n;o*=2)if(!(o<r)){r=o;break}return"ios"===i.os.name&&(9===(i=i.os.majorVersion)&&(r=1024),8===i&&(r=512)),Math.min(n,r)},e._shrinkCoord=function(t){var e=t.image,n=t.faceCoords,i=1-t.trim*(2/(Array.isArray(e)?this.getDimension(e[0]).width:this.getSourceTileSize(e))),r=[0,1,2].map(function(e){var i=D.sign(n[0][e]);return n.some(function(t){return D.sign(t[e])!==i})}).map(function(t){return t?i:1});return n.map(function(t){return t.map(function(t,e){return t*r[e]})})},h._VERTEX_POSITION_DATA=null,h._INDEX_DATA=null,h}(Ot),Dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}l(e,t);var i=e.prototype;return i.getVertexShaderSource=function(){return"\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform mat4 uMVMatrix;\nuniform mat4 uPMatrix;\nvarying highp vec2 vTextureCoord;\nvoid main(void) {\n vTextureCoord = aTextureCoord;\n gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);\n}"},i.getFragmentShaderSource=function(){return"\n#define PI 3.14159265359\nprecision highp float;\nvarying highp vec2 vTextureC