@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.
8 lines • 92.2 kB
JavaScript
/*
Copyright (c) 2017 NAVER Corp.
@egjs/view360 project is licensed under the MIT license
@egjs/view360 JavaScript library
https://github.com/naver/egjs-view360
@version 3.2.2-rc
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@egjs/axes"),require("@egjs/component")):"function"==typeof define&&define.amd?define(["exports","@egjs/axes","@egjs/component"],e):e((t.eg=t.eg||{},t.eg.view360={}),t.eg.Axes,t.eg.Component)}(this,function(t,u,e){"use strict";function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}function h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var G="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var i,n=(function(t,e){t.exports=function(){function u(t){return"function"==typeof t}var i=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},n=0,e=void 0,r=void 0,s=function(t,e){d[n]=t,d[n+1]=e,2===(n+=2)&&(r?r(f):m())},t="undefined"!=typeof window?window:void 0,o=t||{},a=o.MutationObserver||o.WebKitMutationObserver,h="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),c="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function l(){var t=setTimeout;return function(){return t(f,1)}}var d=new Array(1e3);function f(){for(var t=0;t<n;t+=2){var e=d[t],i=d[t+1];e(i),d[t]=void 0,d[t+1]=void 0}n=0}var _,p,v,g,m=void 0;function y(t,e){var i=this,n=new this.constructor(E);void 0===n[w]&&Q(n);var r=i._state;if(r){var o=arguments[r-1];s(function(){return N(r,n,o,i._result)})}else V(i,n,t,e);return n}function x(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=new this(E);return P(e,t),e}m=h?function(){return process.nextTick(f)}:a?(p=0,v=new a(f),g=document.createTextNode(""),v.observe(g,{characterData:!0}),function(){g.data=p=++p%2}):c?((_=new MessageChannel).port1.onmessage=f,function(){return _.port2.postMessage(0)}):void 0===t?function(){try{var t=Function("return this")().require("vertx");return void 0===(e=t.runOnLoop||t.runOnContext)?l():function(){e(f)}}catch(t){return l()}}():l();var w=Math.random().toString(36).substring(2);function E(){}var T=void 0,R=1,A=2,I={error:null};function C(t){try{return t.then}catch(t){return I.error=t,I}}function S(t,e,i,n){try{t.call(e,i,n)}catch(t){return t}}function b(t,e,i){var n,r,o,a;e.constructor===t.constructor&&i===y&&e.constructor.resolve===x?(o=t,(a=e)._state===R?M(o,a._result):a._state===A?D(o,a._result):V(a,void 0,function(t){return P(o,t)},function(t){return D(o,t)})):i===I?(D(t,I.error),I.error=null):void 0===i?M(t,e):u(i)?(n=e,r=i,s(function(e){var i=!1,t=S(r,n,function(t){i||(i=!0,n!==t?P(e,t):M(e,t))},function(t){i||(i=!0,D(e,t))},e._label);!i&&t&&(i=!0,D(e,t))},t)):M(t,e)}function P(t,e){var i,n;t===e?D(t,new TypeError("You cannot resolve a promise with itself")):(n=typeof(i=e),null===i||"object"!==n&&"function"!==n?M(t,e):b(t,e,C(e)))}function O(t){t._onerror&&t._onerror(t._result),L(t)}function M(t,e){t._state===T&&(t._result=e,t._state=R,0!==t._subscribers.length&&s(L,t))}function D(t,e){t._state===T&&(t._state=A,t._result=e,s(O,t))}function V(t,e,i,n){var r=t._subscribers,o=r.length;t._onerror=null,r[o]=e,r[o+R]=i,r[o+A]=n,0===o&&t._state&&s(L,t)}function L(t){var e=t._subscribers,i=t._state;if(0!==e.length){for(var n=void 0,r=void 0,o=t._result,a=0;a<e.length;a+=3)n=e[a],r=e[a+i],n?N(i,n,r,o):r(o);t._subscribers.length=0}}function N(t,e,i,n){var r=u(i),o=void 0,a=void 0,s=void 0,h=void 0;if(r){if((o=function(t,e){try{return t(e)}catch(t){return I.error=t,I}}(i,n))===I?(h=!0,a=o.error,o.error=null):s=!0,e===o)return void D(e,new TypeError("A promises callback cannot return that same promise."))}else o=n,s=!0;e._state!==T||(r&&s?P(e,o):h?D(e,a):t===R?M(e,o):t===A&&D(e,o))}var F=0;function Q(t){t[w]=F++,t._state=void 0,t._result=void 0,t._subscribers=[]}var U=function(){function t(t,e){this._instanceConstructor=t,this.promise=new t(E),this.promise[w]||Q(this.promise),i(e)?(this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?M(this.promise,this._result):(this.length=this.length||0,this._enumerate(e),0===this._remaining&&M(this.promise,this._result))):D(this.promise,new Error("Array Methods must be provided an Array"))}return t.prototype._enumerate=function(t){for(var e=0;this._state===T&&e<t.length;e++)this._eachEntry(t[e],e)},t.prototype._eachEntry=function(e,t){var i=this._instanceConstructor,n=i.resolve;if(n===x){var r=C(e);if(r===y&&e._state!==T)this._settledAt(e._state,t,e._result);else if("function"!=typeof r)this._remaining--,this._result[t]=e;else if(i===z){var o=new i(E);b(o,e,r),this._willSettleAt(o,t)}else this._willSettleAt(new i(function(t){return t(e)}),t)}else this._willSettleAt(n(e),t)},t.prototype._settledAt=function(t,e,i){var n=this.promise;n._state===T&&(this._remaining--,t===A?D(n,i):this._result[e]=i),0===this._remaining&&M(n,this._result)},t.prototype._willSettleAt=function(t,e){var i=this;V(t,void 0,function(t){return i._settledAt(R,e,t)},function(t){return i._settledAt(A,e,t)})},t}(),z=function(){function e(t){this[w]=F++,this._result=this._state=void 0,this._subscribers=[],E!==t&&("function"!=typeof t&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof e?function(e,t){try{t(function(t){P(e,t)},function(t){D(e,t)})}catch(t){D(e,t)}}(this,t):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return e.prototype.catch=function(t){return this.then(null,t)},e.prototype.finally=function(e){var i=this.constructor;return u(e)?this.then(function(t){return i.resolve(e()).then(function(){return t})},function(t){return i.resolve(e()).then(function(){throw t})}):this.then(e,e)},e}();return z.prototype.then=y,z.all=function(t){return new U(this,t).promise},z.race=function(r){var o=this;return i(r)?new o(function(t,e){for(var i=r.length,n=0;n<i;n++)o.resolve(r[n]).then(t,e)}):new o(function(t,e){return e(new TypeError("You must pass an array to race."))})},z.resolve=x,z.reject=function(t){var e=new this(E);return D(e,t),e},z._setScheduler=function(t){r=t},z._setAsap=function(t){s=t},z._asap=s,z.polyfill=function(){var t=void 0;if(void 0!==G)t=G;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var e=t.Promise;if(e){var i=null;try{i=Object.prototype.toString.call(e.resolve())}catch(t){}if("[object Promise]"===i&&!e.cast)return}t.Promise=z},z.Promise=z}()}(i={exports:{}},i.exports),i.exports),o="undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")(),a=o.document,s=o.navigator.userAgent,l=-1!==s.indexOf("Safari")&&-1===s.indexOf("Chrome")&&-1!==s.indexOf("Mac OS X");o.Float32Array=void 0!==o.Float32Array?o.Float32Array:o.Array;o.Float32Array;var d=o.getComputedStyle,f=o.navigator.userAgent,_="ontouchstart"in o,p="ondevicemotion"in o,v=o.DeviceMotionEvent,g=o.devicePixelRatio;(function(){for(var t=a.documentElement.style,e=["transform","webkitTransform","msTransform","mozTransform"],i=0,n=e.length;i<n;i++)if(e[i]in t)return})(),o.CSS&&o.CSS.supports&&o.CSS.supports("will-change","transform");var m,y,x=window.MathUtil||{};x.degToRad=Math.PI/180,x.radToDeg=180/Math.PI,x.Vector2=function(t,e){this.x=t||0,this.y=e||0},x.Vector2.prototype={constructor:x.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}},x.Vector3=function(t,e,i){this.x=t||0,this.y=e||0,this.z=i||0},x.Vector3.prototype={constructor:x.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();if(0!==t){var e=1/t;this.multiplyScalar(e)}else this.x=0,this.y=0,this.z=0;return 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,h=s*e+o*n-a*i,u=s*i+a*e-r*n,c=s*n+r*i-o*e,l=-r*e-o*i-a*n;return this.x=h*s+l*-r+u*-a-c*-o,this.y=u*s+l*-o+c*-r-h*-a,this.z=c*s+l*-a+h*-o-u*-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,a=e.y,s=e.z;return this.x=n*s-r*a,this.y=r*o-i*s,this.z=i*a-n*o,this}},x.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},x.Quaternion.prototype={constructor:x.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),a=Math.sin(t/2),s=Math.sin(e/2),h=Math.sin(i/2);return this.x=a*r*o+n*s*h,this.y=n*s*o-a*r*h,this.z=n*r*h+a*s*o,this.w=n*r*o-a*s*h,this},setFromEulerYXZ:function(t,e,i){var n=Math.cos(t/2),r=Math.cos(e/2),o=Math.cos(i/2),a=Math.sin(t/2),s=Math.sin(e/2),h=Math.sin(i/2);return this.x=a*r*o+n*s*h,this.y=n*s*o-a*r*h,this.z=n*r*h-a*s*o,this.w=n*r*o+a*s*h,this},setFromAxisAngle:function(t,e){var i=e/2,n=Math.sin(i);return this.x=t.x*n,this.y=t.y*n,this.z=t.z*n,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,h=e.z,u=e.w;return this.x=i*u+o*a+n*h-r*s,this.y=n*u+o*s+r*a-i*h,this.z=r*u+o*h+i*s-n*a,this.w=o*u-i*a-n*s-r*h,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 this.w=0===t?(this.x=0,this.y=0,this.z=0,1):(t=1/t,this.x=this.x*t,this.y=this.y*t,this.z=this.z*t,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),h=Math.sqrt(1-a*a);if(Math.abs(h)<.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;var u=Math.sin((1-e)*s)/h,c=Math.sin(e*s)/h;return this.w=o*u+this.w*c,this.x=i*u+this.x*c,this.y=n*u+this.y*c,this.z=r*u+this.z*c,this},setFromUnitVectors:function(t,e){return void 0===m&&(m=new x.Vector3),(y=t.dot(e)+1)<1e-6?(y=0,Math.abs(t.x)>Math.abs(t.z)?m.set(-t.y,t.x,0):m.set(0,-t.z,t.y)):m.crossVectors(t,e),this.x=m.x,this.y=m.y,this.z=m.z,this.w=y,this.normalize(),this}};var w,E,T,R,A,I=x,C=(I.MathUtil,window.Util||{});C.MIN_TIMESTEP=.001,C.MAX_TIMESTEP=1,C.base64=function(t,e){return"data:"+t+";base64,"+e},C.clamp=function(t,e,i){return Math.min(Math.max(e,t),i)},C.lerp=function(t,e,i){return t+(e-t)*i},C.race=function(n){return Promise.race?Promise.race(n):new Promise(function(t,e){for(var i=0;i<n.length;i++)n[i].then(t,e)})},C.isIOS=(w=/iPad|iPhone|iPod/.test(navigator.platform),function(){return w}),C.isWebViewAndroid=(E=-1!==navigator.userAgent.indexOf("Version")&&-1!==navigator.userAgent.indexOf("Android")&&-1!==navigator.userAgent.indexOf("Chrome"),function(){return E}),C.isSafari=(T=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),function(){return T}),C.isFirefoxAndroid=(R=-1!==navigator.userAgent.indexOf("Firefox")&&-1!==navigator.userAgent.indexOf("Android"),function(){return R}),C.isR7=(A=-1!==navigator.userAgent.indexOf("R7 Build"),function(){return A}),C.isLandscapeMode=function(){var t=90==window.orientation||-90==window.orientation;return C.isR7()?!t:t},C.isTimestampDeltaValid=function(t){return!isNaN(t)&&(!(t<=C.MIN_TIMESTEP)&&!(t>C.MAX_TIMESTEP))},C.getScreenWidth=function(){return Math.max(window.screen.width,window.screen.height)*window.devicePixelRatio},C.getScreenHeight=function(){return Math.min(window.screen.width,window.screen.height)*window.devicePixelRatio},C.requestFullscreen=function(t){if(C.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},C.exitFullscreen=function(){if(document.exitFullscreen)document.exitFullscreen();else if(document.webkitExitFullscreen)document.webkitExitFullscreen();else if(document.mozCancelFullScreen)document.mozCancelFullScreen();else{if(!document.msExitFullscreen)return!1;document.msExitFullscreen()}return!0},C.getFullscreenElement=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},C.linkProgram=function(t,e,i,n){var r=t.createShader(t.VERTEX_SHADER);t.shaderSource(r,e),t.compileShader(r);var o=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(o,i),t.compileShader(o);var a=t.createProgram();for(var s in t.attachShader(a,r),t.attachShader(a,o),n)t.bindAttribLocation(a,n[s],s);return t.linkProgram(a),t.deleteShader(r),t.deleteShader(o),a},C.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},C.orthoMatrix=function(t,e,i,n,r,o,a){var s=1/(e-i),h=1/(n-r),u=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*h,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+i)*s,t[13]=(r+n)*h,t[14]=(a+o)*u,t[15]=1,t},C.copyArray=function(t,e){for(var i=0,n=t.length;i<n;i++)e[i]=t[i]},C.isMobile=function(){var t,e=!1;return t=navigator.userAgent||navigator.vendor||window.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},C.extend=function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t},C.safariCssSizeWorkaround=function(t){if(C.isIOS()){var 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)}window.Util=C,window.canvas=t},C.isDebug=function(){return C.getQueryParameter("debug")},C.getQueryParameter=function(t){t=t.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var e=new RegExp("[\\?&]"+t+"=([^&#]*)").exec(location.search);return null===e?"":decodeURIComponent(e[1].replace(/\+/g," "))},C.frameDataFromPose=function(){var Ot=Math.PI/180,Mt=.25*Math.PI;var Dt=new Float32Array([0,0,0,1]),Vt=new Float32Array([0,0,0]);function n(t,e,i,n,r){var o,a,s,h,u,c,l,d,f,_;o=t,a=n?n.fieldOfView:null,s=r.depthNear,h=r.depthFar,u=Math.tan(a?a.upDegrees*Ot:Mt),c=Math.tan(a?a.downDegrees*Ot:Mt),l=Math.tan(a?a.leftDegrees*Ot:Mt),d=Math.tan(a?a.rightDegrees*Ot:Mt),f=2/(l+d),_=2/(u+c),o[0]=f,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=_,o[6]=0,o[7]=0,o[8]=-(l-d)*f*.5,o[9]=(u-c)*_*.5,o[10]=h/(s-h),o[11]=-1,o[12]=0,o[13]=0,o[14]=h*s/(s-h),o[15]=0;var p,v,g,m,y,x,w,E,T,R,A,I,C,S,b,P,O,M,D,V,L,N,F,Q,U,z,G,W,X,Y,B,k,H,j,q,K,Z,J,$,tt,et,it,nt,rt,ot,at,st,ht,ut,ct,lt,dt,ft,_t,pt,vt,gt,mt,yt,xt,wt,Et,Tt,Rt,At,It,Ct,St,bt=i.orientation||Dt,Pt=i.position||Vt;p=e,g=Pt,m=(v=bt)[0],y=v[1],x=v[2],w=v[3],A=m*(E=m+m),I=m*(T=y+y),C=m*(R=x+x),S=y*T,b=y*R,P=x*R,O=w*E,M=w*T,D=w*R,p[0]=1-(S+P),p[1]=I+D,p[2]=C-M,p[3]=0,p[4]=I-D,p[5]=1-(A+P),p[6]=b+O,p[7]=0,p[8]=C+M,p[9]=b-O,p[10]=1-(A+S),p[11]=0,p[12]=g[0],p[13]=g[1],p[14]=g[2],p[15]=1,n&&(L=V=e,N=n.offset,q=N[0],K=N[1],Z=N[2],V[15]=L===V?(V[12]=L[0]*q+L[4]*K+L[8]*Z+L[12],V[13]=L[1]*q+L[5]*K+L[9]*Z+L[13],V[14]=L[2]*q+L[6]*K+L[10]*Z+L[14],L[3]*q+L[7]*K+L[11]*Z+L[15]):(F=L[0],Q=L[1],U=L[2],z=L[3],G=L[4],W=L[5],X=L[6],Y=L[7],B=L[8],k=L[9],H=L[10],j=L[11],V[0]=F,V[1]=Q,V[2]=U,V[3]=z,V[4]=G,V[5]=W,V[6]=X,V[7]=Y,V[8]=B,V[9]=k,V[10]=H,V[11]=j,V[12]=F*q+G*K+B*Z+L[12],V[13]=Q*q+W*K+k*Z+L[13],V[14]=U*q+X*K+H*Z+L[14],z*q+Y*K+j*Z+L[15])),tt=($=J=e)[0],et=$[1],it=$[2],nt=$[3],rt=$[4],ot=$[5],at=$[6],st=$[7],ht=$[8],ut=$[9],ct=$[10],lt=$[11],dt=$[12],ft=$[13],_t=$[14],pt=$[15],(St=(vt=tt*ot-et*rt)*(Ct=ct*pt-lt*_t)-(gt=tt*at-it*rt)*(It=ut*pt-lt*ft)+(mt=tt*st-nt*rt)*(At=ut*_t-ct*ft)+(yt=et*at-it*ot)*(Rt=ht*pt-lt*dt)-(xt=et*st-nt*ot)*(Tt=ht*_t-ct*dt)+(wt=it*st-nt*at)*(Et=ht*ft-ut*dt))&&(St=1/St,J[0]=(ot*Ct-at*It+st*At)*St,J[1]=(it*It-et*Ct-nt*At)*St,J[2]=(ft*wt-_t*xt+pt*yt)*St,J[3]=(ct*xt-ut*wt-lt*yt)*St,J[4]=(at*Rt-rt*Ct-st*Tt)*St,J[5]=(tt*Ct-it*Rt+nt*Tt)*St,J[6]=(_t*mt-dt*wt-pt*gt)*St,J[7]=(ht*wt-ct*mt+lt*gt)*St,J[8]=(rt*It-ot*Rt+st*Et)*St,J[9]=(et*Rt-tt*It-nt*Et)*St,J[10]=(dt*xt-ft*mt+pt*vt)*St,J[11]=(ut*mt-ht*xt-lt*vt)*St,J[12]=(ot*Tt-rt*At-at*Et)*St,J[13]=(tt*At-et*Tt+it*Et)*St,J[14]=(ft*gt-dt*yt-_t*vt)*St,J[15]=(ht*yt-ut*gt+ct*vt)*St)}return function(t,e,i){return!(!t||!e)&&(t.pose=e,t.timestamp=e.timestamp,n(t.leftProjectionMatrix,t.leftViewMatrix,e,i.getEyeParameters("left"),i),n(t.rightProjectionMatrix,t.rightViewMatrix,e,i.getEyeParameters("right"),i),!0)}}(),C.isInsideCrossDomainIFrame=function(){var t=window.self!==window.top,e=C.getDomainFromUrl(document.referrer),i=C.getDomainFromUrl(window.location.href);return t&&e!==i},C.getDomainFromUrl=function(t){return(-1<t.indexOf("://")?t.split("/")[2]:t.split("/")[0]).split(":")[0]};var S=C;function b(t){this.predictionTimeS=t,this.previousQ=new I.Quaternion,this.previousTimestampS=null,this.deltaQ=new I.Quaternion,this.outQ=new I.Quaternion}b.prototype.getPrediction=function(t,e,i){if(!this.previousTimestampS)return this.previousQ.copy(t),this.previousTimestampS=i,t;var n=new I.Vector3;n.copy(e),n.normalize();var r=e.length();if(r<20*I.degToRad)return S.isDebug()&&console.log("Moving slowly, at %s deg/s: no prediction",(I.radToDeg*r).toFixed(1)),this.outQ.copy(t),this.previousQ.copy(t),this.outQ;this.previousTimestampS;var o=r*this.predictionTimeS;return this.deltaQ.setFromAxisAngle(n,o),this.outQ.copy(this.previousQ),this.outQ.multiply(this.deltaQ),this.previousQ.copy(t),this.previousTimestampS=i,this.outQ};var P=b,O={};O.ARRAY_TYPE="undefined"!=typeof Float32Array?Float32Array:Array;var M=Math.PI/180;O.toRadian=function(t){return t*M},O.toDegree=function(t){return t/M},O.EPSILON=1e-4;var D={create:function(){var t=new O.ARRAY_TYPE(3);return t[0]=0,t[1]=0,t[2]=0,t},fromValues:function(t,e,i){var n=new O.ARRAY_TYPE(3);return n[0]=t,n[1]=e,n[2]=i,n},set:function(t,e,i,n){return t[0]=e,t[1]=i,t[2]=n,t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},scale:function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t},subtract:function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t},length:function(t){var e=t[0],i=t[1],n=t[2];return Math.sqrt(e*e+i*i+n*n)},normalize:function(t,e){var i=e[0],n=e[1],r=e[2],o=i*i+n*n+r*r;return 0<o&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o),t},dot:function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},cross:function(t,e,i){var n=e[0],r=e[1],o=e[2],a=i[0],s=i[1],h=i[2];return t[0]=r*h-o*s,t[1]=o*a-n*h,t[2]=n*s-r*a,t},transformQuat:function(t,e,i){var n=e[0],r=e[1],o=e[2],a=i[0],s=i[1],h=i[2],u=i[3],c=u*n+s*o-h*r,l=u*r+h*n-a*o,d=u*o+a*r-s*n,f=-a*n-s*r-h*o;return t[0]=c*u+f*-a+l*-h-d*-s,t[1]=l*u+f*-s+d*-a-c*-h,t[2]=d*u+f*-h+c*-s-l*-a,t},rotateZ:function(t,e,i,n){var r=[],o=[];return r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],o[0]=r[0]*Math.cos(n)-r[1]*Math.sin(n),o[1]=r[0]*Math.sin(n)+r[1]*Math.cos(n),o[2]=r[2],t[0]=o[0]+i[0],t[1]=o[1]+i[1],t[2]=o[2]+i[2],t}},V={copy:function(t,e){return t[0]=e[0],t[1]=e[1],t}},L={create:function(){var t=new O.ARRAY_TYPE(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},clone:function(t){var e=new O.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},fromValues:function(t,e,i,n){var r=new O.ARRAY_TYPE(4);return r[0]=t,r[1]=e,r[2]=i,r[3]=n,r},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},setAxisAngle:function(t,e,i){i*=.5;var n=Math.sin(i);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(i),t},multiply:function(t,e,i){var n=e[0],r=e[1],o=e[2],a=e[3],s=i[0],h=i[1],u=i[2],c=i[3];return t[0]=n*c+a*s+r*u-o*h,t[1]=r*c+a*h+o*s-n*u,t[2]=o*c+a*u+n*h-r*s,t[3]=a*c-n*s-r*h-o*u,t},rotateX:function(t,e,i){i*=.5;var n=e[0],r=e[1],o=e[2],a=e[3],s=Math.sin(i),h=Math.cos(i);return t[0]=n*h+a*s,t[1]=r*h+o*s,t[2]=o*h-r*s,t[3]=a*h-n*s,t},rotateY:function(t,e,i){i*=.5;var n=e[0],r=e[1],o=e[2],a=e[3],s=Math.sin(i),h=Math.cos(i);return t[0]=n*h-o*s,t[1]=r*h+a*s,t[2]=o*h+n*s,t[3]=a*h-r*s,t},conjugate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},normalize:function(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],a=i*i+n*n+r*r+o*o;return 0<a&&(a=1/Math.sqrt(a),t[0]=i*a,t[1]=n*a,t[2]=r*a,t[3]=o*a),t},equals:function(t,e){var i=t[0],n=t[1],r=t[2],o=t[3],a=e[0],s=e[1],h=e[2],u=e[3];return Math.abs(i-a)<=O.EPSILON*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(n-s)<=O.EPSILON*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(r-h)<=O.EPSILON*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(o-u)<=O.EPSILON*Math.max(1,Math.abs(o),Math.abs(u))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}},N={};N.create=function(){var t=new O.ARRAY_TYPE(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},N.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},N.rotateX=function(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[4],a=e[5],s=e[6],h=e[7],u=e[8],c=e[9],l=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*r+u*n,t[5]=a*r+c*n,t[6]=s*r+l*n,t[7]=h*r+d*n,t[8]=u*r-o*n,t[9]=c*r-a*n,t[10]=l*r-s*n,t[11]=d*r-h*n,t},N.rotateY=function(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[0],a=e[1],s=e[2],h=e[3],u=e[8],c=e[9],l=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*r-u*n,t[1]=a*r-c*n,t[2]=s*r-l*n,t[3]=h*r-d*n,t[8]=o*n+u*r,t[9]=a*n+c*r,t[10]=s*n+l*r,t[11]=h*n+d*r,t},N.fromQuat=function(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],a=i+i,s=n+n,h=r+r,u=i*a,c=n*a,l=n*s,d=r*a,f=r*s,_=r*h,p=o*a,v=o*s,g=o*h;return t[0]=1-l-_,t[1]=c+g,t[2]=d-v,t[3]=0,t[4]=c-g,t[5]=1-u-_,t[6]=f+p,t[7]=0,t[8]=d+v,t[9]=f-p,t[10]=1-u-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},N.perspective=function(t,e,i,n,r){var o=1/Math.tan(e/2),a=1/(n-r);return t[0]=o/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(r+n)*a,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*r*n*a,t[15]=0,t};var F={isPowerOfTwo:function(t){return t&&0==(t&t-1)}};F.extractPitchFromQuat=function(t){var e,i,n=(e=t,i=D.fromValues(0,0,1),D.transformQuat(i,i,e),i);return-1*Math.atan2(n[1],Math.sqrt(Math.pow(n[0],2)+Math.pow(n[2],2)))};var Q={PITCH_DELTA:1,YAW_DELTA_BY_ROLL:2,YAW_DELTA_BY_YAW:3};Q[Q.PITCH_DELTA]={targetAxis:[0,1,0],meshPoint:[0,0,1]},Q[Q.YAW_DELTA_BY_ROLL]={targetAxis:[0,1,0],meshPoint:[1,0,0]},Q[Q.YAW_DELTA_BY_YAW]={targetAxis:[1,0,0],meshPoint:[0,0,1]},F.getRotationDelta=function(t,e,i){var n=D.fromValues(Q[i].targetAxis[0],Q[i].targetAxis[1],Q[i].targetAxis[2]),r=Q[i].meshPoint,o=L.clone(t),a=L.clone(e);L.normalize(o,o),L.normalize(a,a);var s=D.fromValues(0,0,1),h=D.fromValues(0,0,1);D.transformQuat(s,s,o),D.transformQuat(h,h,a),D.transformQuat(n,n,a);var u,c=0<D.dot(n,D.cross(D.create(),s,h))?1:-1,l=D.fromValues(r[0],r[1],r[2]);u=i!==Q.YAW_DELTA_BY_YAW?D.fromValues(0,c,0):D.fromValues(c,0,0),D.transformQuat(l,l,a),D.transformQuat(u,u,a);var d=l,f=u,_=D.create();D.cross(_,d,f),D.normalize(_,_);var p=_[0],v=_[1],g=_[2];h=D.fromValues(r[0],r[1],r[2]),D.transformQuat(h,h,a),s=D.fromValues(r[0],r[1],r[2]),D.transformQuat(s,s,o);var m=Math.abs(s[0]*p+s[1]*v+s[2]*g),y=D.create();D.subtract(y,s,D.scale(D.create(),_,m));var x=(y[0]*h[0]+y[1]*h[1]+y[2]*h[2])/(D.length(y)*D.length(h));1<x&&(x=1);var w=Math.acos(x),E=D.cross(D.create(),h,y);m=p*E[0]+v*E[1]+g*E[2];var T=w*(i!==Q.YAW_DELTA_BY_YAW?0<m?1:-1:m<0?1:-1)*c;return O.toDegree(T)};var U=-1,z=null,W=null,X=/Chrome\/([0-9]+)\.(?:[0-9]*)\.([0-9]*)\.([0-9]*)/i.exec(f);X&&(U=parseInt(X[1],10),z=X[2],W=X[3]);var Y=U,B=65===U&&"3325"===z&&parseInt(W,10)<148,k=/Android/i.test(f),H=[.2,.2],j={NONE:"none",YAWPITCH:"yawPitch",VR:"VR"},q=function(e){function t(){var t;return(t=e.call(this)||this)._onDeviceMotion=t._onDeviceMotion.bind(h(h(t))),t._onDeviceOrientation=t._onDeviceOrientation.bind(h(h(t))),t._onChromeWithoutDeviceMotion=t._onChromeWithoutDeviceMotion.bind(h(h(t))),t.isWithoutDeviceMotion=B,t.isAndroid=k,t.stillGyroVec=D.create(),t.rawGyroVec=D.create(),t.adjustedGyroVec=D.create(),t._timer=null,t.lastDevicemotionTimestamp=0,t._isEnabled=!1,t.enable(),t}r(t,e);var i=t.prototype;return i._onChromeWithoutDeviceMotion=function(t){var e=t.alpha,i=t.beta,n=t.gamma;null!==e&&(e=(e||0)*Math.PI/180,i=(i||0)*Math.PI/180,n=(n||0)*Math.PI/180,this.trigger("devicemotion",{inputEvent:{deviceorientation:{alpha:e,beta:i,gamma:-n}}}))},i._onDeviceOrientation=function(){var t=this;this._timer&&clearTimeout(this._timer),this._timer=setTimeout(function(){(new Date).getTime()-t.lastDevicemotionTimestamp<200&&D.copy(t.stillGyroVec,t.rawGyroVec)},200)},i._onDeviceMotion=function(t){var e=!(null==t.rotationRate.alpha),i=!(null==t.accelerationIncludingGravity.x);if(0!==t.interval&&e&&i){var n=c({},t);n.interval=t.interval,n.timeStamp=t.timeStamp,n.type=t.type,n.rotationRate={alpha:t.rotationRate.alpha,beta:t.rotationRate.beta,gamma:t.rotationRate.gamma},n.accelerationIncludingGravity={x:t.accelerationIncludingGravity.x,y:t.accelerationIncludingGravity.y,z:t.accelerationIncludingGravity.z},n.acceleration={x:t.acceleration.x,y:t.acceleration.y,z:t.acceleration.z},this.isAndroid&&(D.set(this.rawGyroVec,t.rotationRate.alpha||0,t.rotationRate.beta||0,t.rotationRate.gamma||0),D.subtract(this.adjustedGyroVec,this.rawGyroVec,this.stillGyroVec),this.lastDevicemotionTimestamp=(new Date).getTime(),n.adjustedRotationRate={alpha:this.adjustedGyroVec[0],beta:this.adjustedGyroVec[1],gamma:this.adjustedGyroVec[2]}),this.trigger("devicemotion",{inputEvent:n})}},i.enable=function(){this.isAndroid&&o.addEventListener("deviceorientation",this._onDeviceOrientation),this.isWithoutDeviceMotion?o.addEventListener("deviceorientation",this._onChromeWithoutDeviceMotion):o.addEventListener("devicemotion",this._onDeviceMotion),this._isEnabled=!0},i.disable=function(){o.removeEventListener("deviceorientation",this._onDeviceOrientation),o.removeEventListener("deviceorientation",this._onChromeWithoutDeviceMotion),o.removeEventListener("devicemotion",this._onDeviceMotion),this._isEnabled=!1},t}(e);function K(t,e){this.set(t,e)}K.prototype.set=function(t,e){this.sample=t,this.timestampS=e},K.prototype.copy=function(t){this.set(t.sample,t.timestampS)};var Z=K;function J(t){this.kFilter=t,this.currentAccelMeasurement=new Z,this.currentGyroMeasurement=new Z,this.previousGyroMeasurement=new Z,S.isIOS()?this.filterQ=new I.Quaternion(-1,0,0,1):this.filterQ=new I.Quaternion(1,0,0,1),this.previousFilterQ=new I.Quaternion,this.previousFilterQ.copy(this.filterQ),this.accelQ=new I.Quaternion,this.isOrientationInitialized=!1,this.estimatedGravity=new I.Vector3,this.measuredGravity=new I.Vector3,this.gyroIntegralQ=new I.Quaternion}J.prototype.addAccelMeasurement=function(t,e){this.currentAccelMeasurement.set(t,e)},J.prototype.addGyroMeasurement=function(t,e){this.currentGyroMeasurement.set(t,e);var i=e-this.previousGyroMeasurement.timestampS;S.isTimestampDeltaValid(i)&&this.run_(),this.previousGyroMeasurement.copy(this.currentGyroMeasurement)},J.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);var i=new I.Quaternion;i.copy(this.filterQ),i.inverse(),this.estimatedGravity.set(0,0,-1),this.estimatedGravity.applyQuaternion(i),this.estimatedGravity.normalize(),this.measuredGravity.copy(this.currentAccelMeasurement.sample),this.measuredGravity.normalize();var n=new I.Quaternion;n.setFromUnitVectors(this.estimatedGravity,this.measuredGravity),n.inverse(),S.isDebug()&&console.log("Delta: %d deg, G_est: (%s, %s, %s), G_meas: (%s, %s, %s)",I.radToDeg*S.getQuaternionAngle(n),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));var r=new I.Quaternion;r.copy(this.filterQ),r.multiply(n),this.filterQ.slerp(r,1-this.kFilter),this.previousFilterQ.copy(this.filterQ)},J.prototype.getOrientation=function(){return this.filterQ},J.prototype.accelToQuaternion_=function(t){var e=new I.Vector3;e.copy(t),e.normalize();var i=new I.Quaternion;return i.setFromUnitVectors(new I.Vector3(0,0,-1),e),i.inverse(),i},J.prototype.gyroToQuaternionDelta_=function(t,e){var i=new I.Quaternion,n=new I.Vector3;return n.copy(t),n.normalize(),i.setFromAxisAngle(n,t.length()*e),i};var $=J;$.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);var i=new I.Quaternion;i.copy(this.filterQ),i.inverse(),this.estimatedGravity.set(0,0,-1),this.estimatedGravity.applyQuaternion(i),this.estimatedGravity.normalize(),this.measuredGravity.copy(this.currentAccelMeasurement.sample),this.measuredGravity.normalize();var n=new I.Quaternion;n.setFromUnitVectors(this.estimatedGravity,this.measuredGravity),n.inverse();var r=new I.Quaternion;r.copy(this.filterQ),r.multiply(n),this.filterQ.slerp(r,1-this.kFilter),this.previousFilterQ.copy(this.filterQ),this.isFilterQuaternionInitialized||(this.isFilterQuaternionInitialized=!0)},$.prototype.getOrientation=function(){return this.isFilterQuaternionInitialized?this.filterQ:null};var tt=function(e){function t(){var t;return(t=e.call(this)||this).deviceMotion=new q,t.accelerometer=new I.Vector3,t.gyroscope=new I.Vector3,t._onDeviceMotionChange=t._onDeviceMotionChange.bind(h(h(t))),t._onScreenOrientationChange=t._onScreenOrientationChange.bind(h(h(t))),t.filter=new $(.98),t.posePredictor=new P(.04),t.filterToWorldQ=new I.Quaternion,t.isFirefoxAndroid=S.isFirefoxAndroid(),t.isIOS=S.isIOS(),t.isChromeUsingDegrees=66<=Y,t._isEnabled=!1,t.isIOS?t.filterToWorldQ.setFromAxisAngle(new I.Vector3(1,0,0),Math.PI/2):t.filterToWorldQ.setFromAxisAngle(new I.Vector3(1,0,0),-Math.PI/2),t.inverseWorldToScreenQ=new I.Quaternion,t.worldToScreenQ=new I.Quaternion,t.originalPoseAdjustQ=new I.Quaternion,t.originalPoseAdjustQ.setFromAxisAngle(new I.Vector3(0,0,1),-o.orientation*Math.PI/180),t._setScreenTransform(),S.isLandscapeMode()&&t.filterToWorldQ.multiply(t.inverseWorldToScreenQ),t.resetQ=new I.Quaternion,t.deviceMotion.on("devicemotion",t._onDeviceMotionChange),t.enable(),t}r(t,e);var i=t.prototype;return i.enable=function(){this.isEnabled()||(this.deviceMotion.enable(),this._isEnabled=!0,o.addEventListener("orientationchange",this._onScreenOrientationChange))},i.disable=function(){this.isEnabled()&&(this.deviceMotion.disable(),this._isEnabled=!1,o.removeEventListener("orientationchange",this._onScreenOrientationChange))},i.isEnabled=function(){return this._isEnabled},i.destroy=function(){this.disable(),this.deviceMotion=null},i._triggerChange=function(){var t=this.getOrientation();t&&(this._prevOrientation?L.equals(this._prevOrientation,t)||this.trigger("change",{quaternion:t}):this._prevOrientation=t)},i.getOrientation=function(){var t;if(this.deviceMotion.isWithoutDeviceMotion&&this._deviceOrientationQ){this.deviceOrientationFixQ=this.deviceOrientationFixQ||function(){return(new I.Quaternion).setFromAxisAngle(new I.Vector3(0,1,0),-this._alpha)}.bind(this)(),t=this._deviceOrientationQ;var e=new I.Quaternion;e.copy(t),e.multiply(this.filterToWorldQ),e.multiply(this.resetQ),e.multiply(this.worldToScreenQ),e.multiplyQuaternions(this.deviceOrientationFixQ,e);var i=L.fromValues(e.x,e.y,e.z,e.w);return L.normalize(i,i)}if(!(t=this.filter.getOrientation()))return null;var n=this._convertFusionToPredicted(t),r=L.fromValues(n.x,n.y,n.z,n.w);return L.normalize(r,r)},i._convertFusionToPredicted=function(t){this.predictedQ=this.posePredictor.getPrediction(t,this.gyroscope,this.previousTimestampS);var e=new I.Quaternion;return e.copy(this.filterToWorldQ),e.multiply(this.resetQ),e.multiply(this.predictedQ),e.multiply(this.worldToScreenQ),e},i._onDeviceMotionChange=function(t){var e=t.inputEvent,i=e.deviceorientation,n=e,r=n.accelerationIncludingGravity,o=n.adjustedRotationRate||n.rotationRate,a=n.timeStamp/1e3;i?(this._alpha||(this._alpha=i.alpha),this._deviceOrientationQ=this._deviceOrientationQ||new I.Quaternion,this._deviceOrientationQ.setFromEulerYXZ(i.beta,i.alpha,i.gamma),this._triggerChange()):(this.isFirefoxAndroid&&(a/=1e3),this.accelerometer.set(-r.x,-r.y,-r.z),this.gyroscope.set(o.alpha,o.beta,o.gamma),(this.isIOS||this.isFirefoxAndroid||this.isChromeUsingDegrees)&&this.gyroscope.multiplyScalar(Math.PI/180),this.filter.addAccelMeasurement(this.accelerometer,a),this.filter.addGyroMeasurement(this.gyroscope,a),this._triggerChange(),this.previousTimestampS=a)},i._onScreenOrientationChange=function(t){this._setScreenTransform(o.orientation)},i._setScreenTransform=function(){switch(this.worldToScreenQ.set(0,0,0,1),o.orientation){case 0:break;case 90:this.worldToScreenQ.setFromAxisAngle(new I.Vector3(0,0,1),-.5*Math.PI);break;case-90:this.worldToScreenQ.setFromAxisAngle(new I.Vector3(0,0,1),.5*Math.PI);break;case 180:this.worldToScreenQ.setFromAxisAngle(new I.Vector3(0,0,1),-1*Math.PI)}this.inverseWorldToScreenQ.copy(this.worldToScreenQ),this.inverseWorldToScreenQ.inverse()},t}(e);var et=function(n){function t(t,e){var i;return(i=n.call(this)||this).element=t,i._prevQuaternion=null,i._quaternion=null,i.fusionPoseSensor=null,i.options=c({scale:1,threshold:0},e),i._onPoseChange=i._onPoseChange.bind(h(h(i))),i}r(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 tt,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=L.clone(t.quaternion),void(this._quaternion=L.clone(t.quaternion));var n,e,i,r,o,a;L.copy(this._prevQuaternion,this._quaternion),L.copy(this._quaternion,t.quaternion),this.observer.change(this,t,(n=this.axes,[(r=this._prevQuaternion,o=this._quaternion,a=F.getRotationDelta(r,o,Q.YAW_DELTA_BY_YAW),F.getRotationDelta(r,o,Q.YAW_DELTA_BY_ROLL)*Math.sin(F.extractPitchFromQuat(o))+a),(e=this._prevQuaternion,i=this._quaternion,F.getRotationDelta(e,i,Q.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}(e),it=null,nt=0,rt=function(){function t(){if(nt++,it)return it;(it=this)._onDeviceOrientation=this._onDeviceOrientation.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._spinR=0,this._screenOrientationAngle=0,o.addEventListener("deviceorientation",this._onDeviceOrientation),o.addEventListener("orientationchange",this._onOrientationChange)}var e=t.prototype;return e._onDeviceOrientation=function(t){if(null!==t.beta&&null!==t.gamma){var e=O.toRadian(t.beta),i=O.toRadian(t.gamma);this._spinR=Math.atan2(Math.cos(e)*Math.sin(i),Math.sin(e))}},e._onOrientationChange=function(t){o.screen&&o.screen.orientation&&void 0!==o.screen.orientation.angle?this._screenOrientationAngle=screen.orientation.angle:void 0!==o.orientation&&(this._screenOrientationAngle=0<=o.orientation?o.orientation:360+o.orientation)},e.getRadian=function(){return this._spinR+O.toRadian(this._screenOrientationAngle)},e.unref=function(){0<--nt||(o.removeEventListener("deviceorientation",this._onDeviceOrientation),o.removeEventListener("orientationchange",this._onOrientationChange),this._spinR=0,this._screenOrientationAngle=0,it=null,nt=0)},t}(),ot=function(s){function t(t,e){var i;return(i=s.call(this,t,e)||this)._useRotation=!1,i._screenRotationAngle=null,i.setUseRotation(!(!e||!e.useRotation)),i._userDirection=u.DIRECTION_ALL,i}r(t,s);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 rt)},e.connect=function(t){this._userDirection=this._direction,this._useRotation&&this._direction&u.DIRECTION_ALL&&(this._direction=u.DIRECTION_ALL),s.prototype.connect.call(this,t)},e.getOffset=function(t,e){if(!1===this._useRotation)return s.prototype.getOffset.call(this,t,e);var i=s.prototype.getOffset.call(this,t,[!0,!0]),n=[0,0],r=this._screenRotationAngle.getRadian(),o=Math.cos(r),a=Math.sin(r);return n[0]=i[0]*o-i[1]*a,n[1]=i[1]*o+i[0]*a,this._userDirection&u.DIRECTION_HORIZONTAL?this._userDirection&u.DIRECTION_VERTICAL||(n[1]=0):n[0]=0,n},e.destroy=function(){this._useRotation&&this._screenRotationAngle&&this._screenRotationAngle.unref(),s.prototype.destroy.call(this)},t}(u.PanInput),at=D.fromValues(0,0,0),st=D.fromValues(1,0,0),ht=D.fromValues(0,1,0),ut=function(t){function e(){var e;return(e=t.call(this)||this)._screenRotationAngle=new rt,e._fusionPoseSensor=new tt,e._quaternion=L.create(),e._fusionPoseSensor.enable(),e._fusionPoseSensor.on("change",function(t){e._quaternion=t.quaternion,e.trigger("change",{isTrusted:!0})}),e}r(e,t);var i=e.prototype;return i.getCombinedQuaternion=function(t,e){var i=this._screenRotationAngle.getRadian(),n=D.rotateZ(D.create(),st,at,i),r=L.setAxisAngle(L.create(),ht,O.toRadian(-t)),o=L.setAxisAngle(L.create(),n,O.toRadian(-e)),a=L.conjugate(L.create(),this._quaternion),s=L.multiply(L.create(),o,a);return L.multiply(s,s,r),s},i.destroy=function(){this.off(),this._fusionPoseSensor&&(this._fusionPoseSensor.off(),this._fusionPoseSensor.destroy(),this._fusionPoseSensor=null),this._screenRotationAngle&&(this._screenRotationAngle.unref(),this._screenRotationAngle=null)},e}(e),ct="3.2.2-rc",lt=[-180,180],dt=[-90,90],ft=[-180,180],_t=function(){var t=function(n){function h(t){var e;e=n.call(this)||this;var i=c({element:null,yaw:0,pitch:0,fov:65,showPolePoint:!1,useZoom:!0,useKeyboard:!0,gyroMode:j.YAWPITCH,touchDirection:6,yawRange:lt,pitchRange:dt,fovRange:[30,110],aspectRatio:1},t);return e._element=i.element,e._initialFov=i.fov,e._enabled=!1,e._isAnimating=!1,e._deviceQuaternion=null,e._initAxes(i),e.option(i),e}r(h,n);var t=h.prototype;return t._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===j.VR;this.axesPanInput=new ot(this._element,{useRotation:r}),this.axesWheelInput=new u.WheelInput(this._element,{scale:-4}),this.axesTiltMotionInput=null,this.axesPinchInput=_?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:h.isCircular(i),bounce:[0,0]},pitch:{range:n,circular:h.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("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)},animationStart:function(t){},animationEnd:function(t){e.trigger("animationEnd",{isTrusted:t.isTrusted})}})},t.updatePanScale=function(t){void 0===t&&(t={});var e=this.axes.get().fov,i=t.height||parseInt(d(this._element).height,10),n=H[0]*e/this._initialFov*320/i;return this.axesPanInput.options.scale=[n,n],this.axes.options.deceleration=.0014*e/110,this},t.option=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var n=e.length;if(0===n)return this._getOptions();if(1===n&&"string"==typeof e[0])return this._getOptions(e[0]);var r=c({},this.options),o={},a=[];return 1===n?(a=Object.keys(e[0]),o=c({},e[0])):2<=n&&(a.push(e[0]),o[e[0]]=e[1]),this._setOptions(this._getValidatedOptions(o)),this._applyOptions(a,r),this},t._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},t._getOptions=function(t){var e;return"string"==typeof t?e=this.options[t]:0===arguments.length&&(e=this.options),e},t._setOptions=function(t){for(var e in t)this.options[e]=t[e]},t._applyOptions=function(t,e){if(t.some(function(t){return"showPolePoint"===t||"fov"===t||"aspectRatio"===t||"yawRange"===t||"pitchRange"===t})&&(this._updateControlScale(),0<=t.indexOf("fov")&&this.updatePanScale()),t.some(function(t){return"fovRange"===t})){var i=this.options.fovRange.map(function(t){return+t.toFixed(5)}),n=this.axes.get().fov,r=this.axes.get().fov;V.copy(this.axes.axis.fov.range,i),r<i[0]?r=i[0]:n>i[1]&&(r=i[1]),n!==r&&(this.axes.setTo({fov:r},0),this._updateControlScale(),this.updatePanScale())}if(t.some(function(t){return"gyroMode"===t})&&p){var o=this.options.gyroMode===j.VR,a=this.options.gyroMode===j.YAWPITCH;this.axesTiltMotionInput&&(this.axes.disconnect(this.axesTiltMotionInput),this.axesTiltMotionInput.destroy(),this.axesTiltMotionInput=null),this._deviceQuaternion&&(this._deviceQuaternion.destroy(),this._deviceQuaternion=null),o?this._initDeviceQuaternion():a&&(this.axesTiltMotionInput=new et(this._element),this.axes.connect(["yaw","pitch"],this.axesTiltMotionInput)),this.axesPanInput.setUseRotation(o)}t.some(function(t){return"useKeyboard"===t})&&(this.options.useKeyboard?this.axes.connect(["yaw","pitch"],this.axesMoveKeyInput):this.axes.disconnect(this.axesMoveKeyInput));if(t.some(function(t){return"useZoom"===t})){var s=this.options.useZoom;this.axes.disconnect(this.axesWheelInput),s&&this.axes.connect(["fov"],this.axesWheelInput)}this._togglePinchInputByOption(this.options.touchDirection,this.options.useZoom),t.some(function(t){return"touchDirection"===t})&&this._enabled&&this._enableTouch(this.options.touchDirection)},t._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))},t._enableTouch=function(t){this.axesPanInput&&this.axes.disconnect(this.axesPanInput);var e=2&t?"yaw":null,i=4&t?"pitch":null;this.axes.connect([e,i],this.axesPanInput)},t._initDeviceQuaternion=function(){var e=this;this._deviceQuaternion=new ut,this._deviceQuaternion.on("change",function(t){e._triggerChange(t)})},t._getValidYawRange=function(t,e,i){var n=h.adjustAspectRatio(i||this.options.aspectRatio||1),r=(e||this.axes.get().fov)*n;return t[1]-t[0]>=r?t:this.options.yawRange||lt},t._getValidPitchRange=function(t,e){var i=e||this.axes.get().fov;return t[1]-t[0]>=i?t:this.options.pitchRange||dt},h.isCircular=function(t){return t[1]-t[0]<360?[!1,!1]:[!0,!0]},t._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),o=this.axes.get(),a=o.yaw,s=o.pitch;return V.copy(this.axes.axis.yaw.range,r),V.copy(this.axes.axis.pitch.range,n),this.axes.axis.yaw.circular=h.isCircular(r),this.axes.axis.pitch.circular=h.isCircular(n),a<r[0]?a=r[0]:a>r[1]&&(a=r[1]),s<n[0]?s=n[0]:s>n[1]&&(s=n[1]),t&&t.set({yaw:a,pitch:s}),this.axes.setTo({yaw:a,pitch:s},0),this},t._updatePitchRange=function(t,e,i){if(this.options.gyroMode===j.VR)return ft;var n=t[1]-t[0],r=e/2;return i&&!(n<180)?t.map(function(t){return+t.toFixed(5)}):[t[0]+r,t[1]-r].map(function(t){return+t.toFixed(5)})},t._updateYawRange=function(t,e,i){if(this.options.gyroMode===j.VR)return lt;var n=t[1]-t[0];if(360<=n)return t.map(function(t){return+t.toFixed(5)});var r=1,o=e/2*h.adjustAspectRatio(i);return 290<n?r=.794:125<n&&(r=.98),[t[0]*r+o,t[1]*r-o].map(function(t){return+t.toFixed(5)})},t._triggerChange=function(t){var e=this.axes.get(),i=this.options,n={targetElement:i.element,isTrusted:t.isTrusted};n.yaw=e.yaw,n.pitch=e.pitch,n.fov=e.fov,i.gyroMode===j.VR&&this._deviceQuaternion&&(n.quaternion=this._deviceQuaternion.getCombinedQuaternion(e.yaw,e.pitch)),this.trigger("change",n)},h.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];return h.lerp(i[n],i[n+1],(t-o)/(e[n+1]-o))},h.lerp=function(t,e,i){return t+i*(e-t)},t.enable=function(){return this._enabled||(this._enabled=!0,this._applyOptions(Object.keys(this.options),this.options),this.updatePanScale()),this},t.disable=function(t){return this._enabled&&(t||this._resetOrientation(),this.axes.disconnect(),this._enabled=!1),this},t._resetOrientation=function(){var t=this.options;return this.axes.setTo({yaw:t.yaw,pitch:t.pitch,fov:t.fov},0),this},t.lookAt=function(t,e){var i=t.yaw,n=t.pitch,r=t.fov,o=this.axes.get(),a=void 0===i?0:i-o.yaw,s=void 0===n?0:n-o.pitch,h=void 0===r?0:r-o.fov;this.axes.options.maximumDuration=1/0,this.axes.setBy({yaw:a,pitch:s,fov:h},e)},t.get=function(){return this.axes.get()},t.getYaw=function(){return this.axes.get().yaw},t.getPitch=function(){return this.axes.get().pitch},t.getFov=function(){return this.axes.get().fov},t.destroy=function(){this.axes&&this.axes.destroy(),this.axisPanInput&&this.axisPanInput.destroy(),this.axesWheelInput&&this.axesWheelInput.destroy(),this.axesTiltMotionInput&&this.axesTiltMotionInput.destroy(),this.axesDeviceOrientationInput&&this.axesDeviceOrientationInput.destroy(),this.axesPinchInput&&this.axesPinchInput.destroy(),this.axesMoveKeyInput&&this.axesMoveKeyInput.destroy(),this._deviceQuaternion&&this._deviceQuaternion.destroy()},h}(e);return t.VERSION=ct,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}(),pt="undefined"==typeof Promise?n.Promise:Promise,vt={NONE:0,LOADING:1,LOADED:2,ERROR:3},gt="readystatechange",mt=function(){var t=function(i){function a(t){var e;return(e=i.call(this)||this)._image=null,e._onceHandlers=[],e._loadStatus=vt.NONE,t&&e.set(t)