UNPKG

@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 96.3 kB
/* 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,h,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 d(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}function u(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 h(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,u="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 _,g,p,v,m=void 0;function y(t,e){var i=this,n=new this.constructor(E);void 0===n[x]&&U(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 w(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=new this(E);return P(e,t),e}m=u?function(){return process.nextTick(f)}:a?(g=0,p=new a(f),v=document.createTextNode(""),p.observe(v,{characterData:!0}),function(){v.data=g=++g%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 x=Math.random().toString(36).substring(2);function E(){}var T=void 0,R=1,I=2,A={error:null};function C(t){try{return t.then}catch(t){return A.error=t,A}}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===w?(o=t,(a=e)._state===R?M(o,a._result):a._state===I?D(o,a._result):V(a,void 0,function(t){return P(o,t)},function(t){return D(o,t)})):i===A?(D(t,A.error),A.error=null):void 0===i?M(t,e):h(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=I,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+I]=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=h(i),o=void 0,a=void 0,s=void 0,u=void 0;if(r){if((o=function(t,e){try{return t(e)}catch(t){return A.error=t,A}}(i,n))===A?(u=!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):u?D(e,a):t===R?M(e,o):t===I&&D(e,o))}var F=0;function U(t){t[x]=F++,t._state=void 0,t._result=void 0,t._subscribers=[]}var Q=function(){function t(t,e){this._instanceConstructor=t,this.promise=new t(E),this.promise[x]||U(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===w){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===I?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(I,e,t)})},t}(),z=function(){function e(t){this[x]=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 h(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 Q(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=w,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),r="undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")(),o=r.document,a=r.navigator.userAgent,l=-1!==a.indexOf("Safari")&&-1===a.indexOf("Chrome")&&-1!==a.indexOf("Mac OS X");r.Float32Array=void 0!==r.Float32Array?r.Float32Array:r.Array;r.Float32Array;var s=r.getComputedStyle,f=r.navigator.userAgent,_="ontouchstart"in r,g="ondevicemotion"in r,p=r.DeviceMotionEvent,v=r.devicePixelRatio,m=function(){for(var t=o.documentElement.style,e=["transform","webkitTransform","msTransform","mozTransform"],i=0,n=e.length;i<n;i++)if(e[i]in t)return e[i];return""}(),y=r.CSS&&r.CSS.supports&&r.CSS.supports("will-change","transform");var w,x,E=window.MathUtil||{};E.degToRad=Math.PI/180,E.radToDeg=180/Math.PI,E.Vector2=function(t,e){this.x=t||0,this.y=e||0},E.Vector2.prototype={constructor:E.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}},E.Vector3=function(t,e,i){this.x=t||0,this.y=e||0,this.z=i||0},E.Vector3.prototype={constructor:E.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,u=s*e+o*n-a*i,h=s*i+a*e-r*n,c=s*n+r*i-o*e,l=-r*e-o*i-a*n;return this.x=u*s+l*-r+h*-a-c*-o,this.y=h*s+l*-o+c*-r-u*-a,this.z=c*s+l*-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,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}},E.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},E.Quaternion.prototype={constructor:E.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),u=Math.sin(i/2);return this.x=a*r*o+n*s*u,this.y=n*s*o-a*r*u,this.z=n*r*u+a*s*o,this.w=n*r*o-a*s*u,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),u=Math.sin(i/2);return this.x=a*r*o+n*s*u,this.y=n*s*o-a*r*u,this.z=n*r*u-a*s*o,this.w=n*r*o+a*s*u,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,u=e.z,h=e.w;return this.x=i*h+o*a+n*u-r*s,this.y=n*h+o*s+r*a-i*u,this.z=r*h+o*u+i*s-n*a,this.w=o*h-i*a-n*s-r*u,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),u=Math.sqrt(1-a*a);if(Math.abs(u)<.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 h=Math.sin((1-e)*s)/u,c=Math.sin(e*s)/u;return this.w=o*h+this.w*c,this.x=i*h+this.x*c,this.y=n*h+this.y*c,this.z=r*h+this.z*c,this},setFromUnitVectors:function(t,e){return void 0===w&&(w=new E.Vector3),(x=t.dot(e)+1)<1e-6?(x=0,Math.abs(t.x)>Math.abs(t.z)?w.set(-t.y,t.x,0):w.set(0,-t.z,t.y)):w.crossVectors(t,e),this.x=w.x,this.y=w.y,this.z=w.z,this.w=x,this.normalize(),this}};var T,R,I,A,C,S=E,b=(S.MathUtil,window.Util||{});b.MIN_TIMESTEP=.001,b.MAX_TIMESTEP=1,b.base64=function(t,e){return"data:"+t+";base64,"+e},b.clamp=function(t,e,i){return Math.min(Math.max(e,t),i)},b.lerp=function(t,e,i){return t+(e-t)*i},b.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)})},b.isIOS=(T=/iPad|iPhone|iPod/.test(navigator.platform),function(){return T}),b.isWebViewAndroid=(R=-1!==navigator.userAgent.indexOf("Version")&&-1!==navigator.userAgent.indexOf("Android")&&-1!==navigator.userAgent.indexOf("Chrome"),function(){return R}),b.isSafari=(I=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),function(){return I}),b.isFirefoxAndroid=(A=-1!==navigator.userAgent.indexOf("Firefox")&&-1!==navigator.userAgent.indexOf("Android"),function(){return A}),b.isR7=(C=-1!==navigator.userAgent.indexOf("R7 Build"),function(){return C}),b.isLandscapeMode=function(){var t=90==window.orientation||-90==window.orientation;return b.isR7()?!t:t},b.isTimestampDeltaValid=function(t){return!isNaN(t)&&(!(t<=b.MIN_TIMESTEP)&&!(t>b.MAX_TIMESTEP))},b.getScreenWidth=function(){return Math.max(window.screen.width,window.screen.height)*window.devicePixelRatio},b.getScreenHeight=function(){return Math.min(window.screen.width,window.screen.height)*window.devicePixelRatio},b.requestFullscreen=function(t){if(b.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},b.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},b.getFullscreenElement=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},b.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},b.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},b.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},b.copyArray=function(t,e){for(var i=0,n=t.length;i<n;i++)e[i]=t[i]},b.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},b.extend=function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t},b.safariCssSizeWorkaround=function(t){if(b.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=b,window.canvas=t},b.isDebug=function(){return b.getQueryParameter("debug")},b.getQueryParameter=function(t){t=t.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var e=new RegExp("[\\?&]"+t+"=([^&#]*)").exec(location.search);return null===e?"":decodeURIComponent(e[1].replace(/\+/g," "))},b.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,u,h,c,l,d,f,_;o=t,a=n?n.fieldOfView:null,s=r.depthNear,u=r.depthFar,h=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/(h+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]=(h-c)*_*.5,o[10]=u/(s-u),o[11]=-1,o[12]=0,o[13]=0,o[14]=u*s/(s-u),o[15]=0;var g,p,v,m,y,w,x,E,T,R,I,A,C,S,b,P,O,M,D,V,L,N,F,U,Q,z,G,W,X,Y,B,k,H,j,q,K,Z,J,$,tt,et,it,nt,rt,ot,at,st,ut,ht,ct,lt,dt,ft,_t,gt,pt,vt,mt,yt,wt,xt,Et,Tt,Rt,It,At,Ct,St,bt=i.orientation||Dt,Pt=i.position||Vt;g=e,v=Pt,m=(p=bt)[0],y=p[1],w=p[2],x=p[3],I=m*(E=m+m),A=m*(T=y+y),C=m*(R=w+w),S=y*T,b=y*R,P=w*R,O=x*E,M=x*T,D=x*R,g[0]=1-(S+P),g[1]=A+D,g[2]=C-M,g[3]=0,g[4]=A-D,g[5]=1-(I+P),g[6]=b+O,g[7]=0,g[8]=C+M,g[9]=b-O,g[10]=1-(I+S),g[11]=0,g[12]=v[0],g[13]=v[1],g[14]=v[2],g[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],U=L[1],Q=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]=U,V[2]=Q,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]=U*q+W*K+k*Z+L[13],V[14]=Q*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],ut=$[8],ht=$[9],ct=$[10],lt=$[11],dt=$[12],ft=$[13],_t=$[14],gt=$[15],(St=(pt=tt*ot-et*rt)*(Ct=ct*gt-lt*_t)-(vt=tt*at-it*rt)*(At=ht*gt-lt*ft)+(mt=tt*st-nt*rt)*(It=ht*_t-ct*ft)+(yt=et*at-it*ot)*(Rt=ut*gt-lt*dt)-(wt=et*st-nt*ot)*(Tt=ut*_t-ct*dt)+(xt=it*st-nt*at)*(Et=ut*ft-ht*dt))&&(St=1/St,J[0]=(ot*Ct-at*At+st*It)*St,J[1]=(it*At-et*Ct-nt*It)*St,J[2]=(ft*xt-_t*wt+gt*yt)*St,J[3]=(ct*wt-ht*xt-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*xt-gt*vt)*St,J[7]=(ut*xt-ct*mt+lt*vt)*St,J[8]=(rt*At-ot*Rt+st*Et)*St,J[9]=(et*Rt-tt*At-nt*Et)*St,J[10]=(dt*wt-ft*mt+gt*pt)*St,J[11]=(ht*mt-ut*wt-lt*pt)*St,J[12]=(ot*Tt-rt*It-at*Et)*St,J[13]=(tt*It-et*Tt+it*Et)*St,J[14]=(ft*vt-dt*yt-_t*pt)*St,J[15]=(ut*yt-ht*vt+ct*pt)*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)}}(),b.isInsideCrossDomainIFrame=function(){var t=window.self!==window.top,e=b.getDomainFromUrl(document.referrer),i=b.getDomainFromUrl(window.location.href);return t&&e!==i},b.getDomainFromUrl=function(t){return(-1<t.indexOf("://")?t.split("/")[2]:t.split("/")[0]).split(":")[0]};var P=b;function O(t){this.predictionTimeS=t,this.previousQ=new S.Quaternion,this.previousTimestampS=null,this.deltaQ=new S.Quaternion,this.outQ=new S.Quaternion}O.prototype.getPrediction=function(t,e,i){if(!this.previousTimestampS)return this.previousQ.copy(t),this.previousTimestampS=i,t;var n=new S.Vector3;n.copy(e),n.normalize();var r=e.length();if(r<20*S.degToRad)return P.isDebug()&&console.log("Moving slowly, at %s deg/s: no prediction",(S.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 M=O,D={};D.ARRAY_TYPE="undefined"!=typeof Float32Array?Float32Array:Array;var V=Math.PI/180;D.toRadian=function(t){return t*V},D.toDegree=function(t){return t/V},D.EPSILON=1e-4;var L={create:function(){var t=new D.ARRAY_TYPE(3);return t[0]=0,t[1]=0,t[2]=0,t},fromValues:function(t,e,i){var n=new D.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],u=i[2];return t[0]=r*u-o*s,t[1]=o*a-n*u,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],u=i[2],h=i[3],c=h*n+s*o-u*r,l=h*r+u*n-a*o,d=h*o+a*r-s*n,f=-a*n-s*r-u*o;return t[0]=c*h+f*-a+l*-u-d*-s,t[1]=l*h+f*-s+d*-a-c*-u,t[2]=d*h+f*-u+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}},N={copy:function(t,e){return t[0]=e[0],t[1]=e[1],t}},F={create:function(){var t=new D.ARRAY_TYPE(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},clone:function(t){var e=new D.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 D.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],u=i[1],h=i[2],c=i[3];return t[0]=n*c+a*s+r*h-o*u,t[1]=r*c+a*u+o*s-n*h,t[2]=o*c+a*h+n*u-r*s,t[3]=a*c-n*s-r*u-o*h,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),u=Math.cos(i);return t[0]=n*u+a*s,t[1]=r*u+o*s,t[2]=o*u-r*s,t[3]=a*u-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),u=Math.cos(i);return t[0]=n*u-o*s,t[1]=r*u+a*s,t[2]=o*u+n*s,t[3]=a*u-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],u=e[2],h=e[3];return Math.abs(i-a)<=D.EPSILON*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(n-s)<=D.EPSILON*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(r-u)<=D.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(o-h)<=D.EPSILON*Math.max(1,Math.abs(o),Math.abs(h))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}},U={};U.create=function(){var t=new D.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},U.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},U.rotateX=function(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[4],a=e[5],s=e[6],u=e[7],h=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+h*n,t[5]=a*r+c*n,t[6]=s*r+l*n,t[7]=u*r+d*n,t[8]=h*r-o*n,t[9]=c*r-a*n,t[10]=l*r-s*n,t[11]=d*r-u*n,t},U.rotateY=function(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[0],a=e[1],s=e[2],u=e[3],h=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-h*n,t[1]=a*r-c*n,t[2]=s*r-l*n,t[3]=u*r-d*n,t[8]=o*n+h*r,t[9]=a*n+c*r,t[10]=s*n+l*r,t[11]=u*n+d*r,t},U.fromQuat=function(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],a=i+i,s=n+n,u=r+r,h=i*a,c=n*a,l=n*s,d=r*a,f=r*s,_=r*u,g=o*a,p=o*s,v=o*u;return t[0]=1-l-_,t[1]=c+v,t[2]=d-p,t[3]=0,t[4]=c-v,t[5]=1-h-_,t[6]=f+g,t[7]=0,t[8]=d+p,t[9]=f-g,t[10]=1-h-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},U.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 Q={isPowerOfTwo:function(t){return t&&0==(t&t-1)}};Q.extractPitchFromQuat=function(t){var e,i,n=(e=t,i=L.fromValues(0,0,1),L.transformQuat(i,i,e),i);return-1*Math.atan2(n[1],Math.sqrt(Math.pow(n[0],2)+Math.pow(n[2],2)))};var z={PITCH_DELTA:1,YAW_DELTA_BY_ROLL:2,YAW_DELTA_BY_YAW:3};z[z.PITCH_DELTA]={targetAxis:[0,1,0],meshPoint:[0,0,1]},z[z.YAW_DELTA_BY_ROLL]={targetAxis:[0,1,0],meshPoint:[1,0,0]},z[z.YAW_DELTA_BY_YAW]={targetAxis:[1,0,0],meshPoint:[0,0,1]},Q.getRotationDelta=function(t,e,i){var n=L.fromValues(z[i].targetAxis[0],z[i].targetAxis[1],z[i].targetAxis[2]),r=z[i].meshPoint,o=F.clone(t),a=F.clone(e);F.normalize(o,o),F.normalize(a,a);var s=L.fromValues(0,0,1),u=L.fromValues(0,0,1);L.transformQuat(s,s,o),L.transformQuat(u,u,a),L.transformQuat(n,n,a);var h,c=0<L.dot(n,L.cross(L.create(),s,u))?1:-1,l=L.fromValues(r[0],r[1],r[2]);h=i!==z.YAW_DELTA_BY_YAW?L.fromValues(0,c,0):L.fromValues(c,0,0),L.transformQuat(l,l,a),L.transformQuat(h,h,a);var d=l,f=h,_=L.create();L.cross(_,d,f),L.normalize(_,_);var g=_[0],p=_[1],v=_[2];u=L.fromValues(r[0],r[1],r[2]),L.transformQuat(u,u,a),s=L.fromValues(r[0],r[1],r[2]),L.transformQuat(s,s,o);var m=Math.abs(s[0]*g+s[1]*p+s[2]*v),y=L.create();L.subtract(y,s,L.scale(L.create(),_,m));var w=(y[0]*u[0]+y[1]*u[1]+y[2]*u[2])/(L.length(y)*L.length(u));1<w&&(w=1);var x=Math.acos(w),E=L.cross(L.create(),u,y);m=g*E[0]+p*E[1]+v*E[2];var T=x*(i!==z.YAW_DELTA_BY_YAW?0<m?1:-1:m<0?1:-1)*c;return D.toDegree(T)};var W=-1,X=null,Y=null,B=/Chrome\/([0-9]+)\.(?:[0-9]*)\.([0-9]*)\.([0-9]*)/i.exec(f);B&&(W=parseInt(B[1],10),X=B[2],Y=B[3]);var k=W,H=65===W&&"3325"===X&&parseInt(Y,10)<148,j=/Android/i.test(f),q=[.2,.2],K={NONE:"none",YAWPITCH:"yawPitch",VR:"VR"},Z=function(e){function t(){var t;return(t=e.call(this)||this)._onDeviceMotion=t._onDeviceMotion.bind(u(u(t))),t._onDeviceOrientation=t._onDeviceOrientation.bind(u(u(t))),t._onChromeWithoutDeviceMotion=t._onChromeWithoutDeviceMotion.bind(u(u(t))),t.isWithoutDeviceMotion=H,t.isAndroid=j,t.stillGyroVec=L.create(),t.rawGyroVec=L.create(),t.adjustedGyroVec=L.create(),t._timer=null,t.lastDevicemotionTimestamp=0,t._isEnabled=!1,t.enable(),t}d(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&&L.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&&(L.set(this.rawGyroVec,t.rotationRate.alpha||0,t.rotationRate.beta||0,t.rotationRate.gamma||0),L.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&&r.addEventListener("deviceorientation",this._onDeviceOrientation),this.isWithoutDeviceMotion?r.addEventListener("deviceorientation",this._onChromeWithoutDeviceMotion):r.addEventListener("devicemotion",this._onDeviceMotion),this._isEnabled=!0},i.disable=function(){r.removeEventListener("deviceorientation",this._onDeviceOrientation),r.removeEventListener("deviceorientation",this._onChromeWithoutDeviceMotion),r.removeEventListener("devicemotion",this._onDeviceMotion),this._isEnabled=!1},t}(e);function J(t,e){this.set(t,e)}J.prototype.set=function(t,e){this.sample=t,this.timestampS=e},J.prototype.copy=function(t){this.set(t.sample,t.timestampS)};var $=J;function tt(t){this.kFilter=t,this.currentAccelMeasurement=new $,this.currentGyroMeasurement=new $,this.previousGyroMeasurement=new $,P.isIOS()?this.filterQ=new S.Quaternion(-1,0,0,1):this.filterQ=new S.Quaternion(1,0,0,1),this.previousFilterQ=new S.Quaternion,this.previousFilterQ.copy(this.filterQ),this.accelQ=new S.Quaternion,this.isOrientationInitialized=!1,this.estimatedGravity=new S.Vector3,this.measuredGravity=new S.Vector3,this.gyroIntegralQ=new S.Quaternion}tt.prototype.addAccelMeasurement=function(t,e){this.currentAccelMeasurement.set(t,e)},tt.prototype.addGyroMeasurement=function(t,e){this.currentGyroMeasurement.set(t,e);var i=e-this.previousGyroMeasurement.timestampS;P.isTimestampDeltaValid(i)&&this.run_(),this.previousGyroMeasurement.copy(this.currentGyroMeasurement)},tt.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 S.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 S.Quaternion;n.setFromUnitVectors(this.estimatedGravity,this.measuredGravity),n.inverse(),P.isDebug()&&console.log("Delta: %d deg, G_est: (%s, %s, %s), G_meas: (%s, %s, %s)",S.radToDeg*P.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 S.Quaternion;r.copy(this.filterQ),r.multiply(n),this.filterQ.slerp(r,1-this.kFilter),this.previousFilterQ.copy(this.filterQ)},tt.prototype.getOrientation=function(){return this.filterQ},tt.prototype.accelToQuaternion_=function(t){var e=new S.Vector3;e.copy(t),e.normalize();var i=new S.Quaternion;return i.setFromUnitVectors(new S.Vector3(0,0,-1),e),i.inverse(),i},tt.prototype.gyroToQuaternionDelta_=function(t,e){var i=new S.Quaternion,n=new S.Vector3;return n.copy(t),n.normalize(),i.setFromAxisAngle(n,t.length()*e),i};var et=tt;et.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 S.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 S.Quaternion;n.setFromUnitVectors(this.estimatedGravity,this.measuredGravity),n.inverse();var r=new S.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)},et.prototype.getOrientation=function(){return this.isFilterQuaternionInitialized?this.filterQ:null};var it=function(e){function t(){var t;return(t=e.call(this)||this).deviceMotion=new Z,t.accelerometer=new S.Vector3,t.gyroscope=new S.Vector3,t._onDeviceMotionChange=t._onDeviceMotionChange.bind(u(u(t))),t._onScreenOrientationChange=t._onScreenOrientationChange.bind(u(u(t))),t.filter=new et(.98),t.posePredictor=new M(.04),t.filterToWorldQ=new S.Quaternion,t.isFirefoxAndroid=P.isFirefoxAndroid(),t.isIOS=P.isIOS(),t.isChromeUsingDegrees=66<=k,t._isEnabled=!1,t.isIOS?t.filterToWorldQ.setFromAxisAngle(new S.Vector3(1,0,0),Math.PI/2):t.filterToWorldQ.setFromAxisAngle(new S.Vector3(1,0,0),-Math.PI/2),t.inverseWorldToScreenQ=new S.Quaternion,t.worldToScreenQ=new S.Quaternion,t.originalPoseAdjustQ=new S.Quaternion,t.originalPoseAdjustQ.setFromAxisAngle(new S.Vector3(0,0,1),-r.orientation*Math.PI/180),t._setScreenTransform(),P.isLandscapeMode()&&t.filterToWorldQ.multiply(t.inverseWorldToScreenQ),t.resetQ=new S.Quaternion,t.deviceMotion.on("devicemotion",t._onDeviceMotionChange),t.enable(),t}d(t,e);var i=t.prototype;return i.enable=function(){this.isEnabled()||(this.deviceMotion.enable(),this._isEnabled=!0,r.addEventListener("orientationchange",this._onScreenOrientationChange))},i.disable=function(){this.isEnabled()&&(this.deviceMotion.disable(),this._isEnabled=!1,r.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?F.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 S.Quaternion).setFromAxisAngle(new S.Vector3(0,1,0),-this._alpha)}.bind(this)(),t=this._deviceOrientationQ;var e=new S.Quaternion;e.copy(t),e.multiply(this.filterToWorldQ),e.multiply(this.resetQ),e.multiply(this.worldToScreenQ),e.multiplyQuaternions(this.deviceOrientationFixQ,e);var i=F.fromValues(e.x,e.y,e.z,e.w);return F.normalize(i,i)}if(!(t=this.filter.getOrientation()))return null;var n=this._convertFusionToPredicted(t),r=F.fromValues(n.x,n.y,n.z,n.w);return F.normalize(r,r)},i._convertFusionToPredicted=function(t){this.predictedQ=this.posePredictor.getPrediction(t,this.gyroscope,this.previousTimestampS);var e=new S.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 S.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(r.orientation)},i._setScreenTransform=function(){switch(this.worldToScreenQ.set(0,0,0,1),r.orientation){case 0:break;case 90:this.worldToScreenQ.setFromAxisAngle(new S.Vector3(0,0,1),-.5*Math.PI);break;case-90:this.worldToScreenQ.setFromAxisAngle(new S.Vector3(0,0,1),.5*Math.PI);break;case 180:this.worldToScreenQ.setFromAxisAngle(new S.Vector3(0,0,1),-1*Math.PI)}this.inverseWorldToScreenQ.copy(this.worldToScreenQ),this.inverseWorldToScreenQ.inverse()},t}(e);var nt=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(u(u(i))),i}d(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 it,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=F.clone(t.quaternion),void(this._quaternion=F.clone(t.quaternion));var n,e,i,r,o,a;F.copy(this._prevQuaternion,this._quaternion),F.copy(this._quaternion,t.quaternion),this.observer.change(this,t,(n=this.axes,[(r=this._prevQuaternion,o=this._quaternion,a=Q.getRotationDelta(r,o,z.YAW_DELTA_BY_YAW),Q.getRotationDelta(r,o,z.YAW_DELTA_BY_ROLL)*Math.sin(Q.extractPitchFromQuat(o))+a),(e=this._prevQuaternion,i=this._quaternion,Q.getRotationDelta(e,i,z.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),rt=null,ot=0,at=function(){function t(){if(ot++,rt)return rt;(rt=this)._onDeviceOrientation=this._onDeviceOrientation.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._spinR=0,this._screenOrientationAngle=0,r.addEventListener("deviceorientation",this._onDeviceOrientation),r.addEventListener("orientationchange",this._onOrientationChange)}var e=t.prototype;return e._onDeviceOrientation=function(t){if(null!==t.beta&&null!==t.gamma){var e=D.toRadian(t.beta),i=D.toRadian(t.gamma);this._spinR=Math.atan2(Math.cos(e)*Math.sin(i),Math.sin(e))}},e._onOrientationChange=function(t){r.screen&&r.screen.orientation&&void 0!==r.screen.orientation.angle?this._screenOrientationAngle=screen.orientation.angle:void 0!==r.orientation&&(this._screenOrientationAngle=0<=r.orientation?r.orientation:360+r.orientation)},e.getRadian=function(){return this._spinR+D.toRadian(this._screenOrientationAngle)},e.unref=function(){0<--ot||(r.removeEventListener("deviceorientation",this._onDeviceOrientation),r.removeEventListener("orientationchange",this._onOrientationChange),this._spinR=0,this._screenOrientationAngle=0,rt=null,ot=0)},t}(),st=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=h.DIRECTION_ALL,i}d(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 at)},e.connect=function(t){this._userDirection=this._direction,this._useRotation&&this._direction&h.DIRECTION_ALL&&(this._direction=h.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&h.DIRECTION_HORIZONTAL?this._userDirection&h.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}(h.PanInput),ut=L.fromValues(0,0,0),ht=L.fromValues(1,0,0),ct=L.fromValues(0,1,0),lt=function(t){function e(){var e;return(e=t.call(this)||this)._screenRotationAngle=new at,e._fusionPoseSensor=new it,e._quaternion=F.create(),e._fusionPoseSensor.enable(),e._fusionPoseSensor.on("change",function(t){e._quaternion=t.quaternion,e.trigger("change",{isTrusted:!0})}),e}d(e,t);var i=e.prototype;return i.getCombinedQuaternion=function(t,e){var i=this._screenRotationAngle.getRadian(),n=L.rotateZ(L.create(),ht,ut,i),r=F.setAxisAngle(F.create(),ct,D.toRadian(-t)),o=F.setAxisAngle(F.create(),n,D.toRadian(-e)),a=F.conjugate(F.create(),this._quaternion),s=F.multiply(F.create(),o,a);return F.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),dt="3.2.2-rc",ft=[-180,180],_t=[-90,90],gt=[-180,180],pt=function(){var t=function(n){function u(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:K.YAWPITCH,touchDirection:6,yawRange:ft,pitchRange:_t,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}d(u,n);var t=u.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===K.VR;this.axesPanInput=new st(this._element,{useRotation:r}),this.axesWheelInput=new h.WheelInput(this._element,{scale:-4}),this.axesTiltMotionInput=null,this.axesPinchInput=_?new h.PinchInput(this._element,{scale:-1}):null,this.axesMoveKeyInput=new h.MoveKeyInput(this._element,{scale:[-6,6]}),this.axes=new h({yaw:{range:i,circular:u.isCircular(i),bounce:[0,0]},pitch:{range:n,circular:u.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(s(this._element).height,10),n=q[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;N.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})&&g){var o=this.options.gyroMode===K.VR,a=this.options.gyroMode===K.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 nt(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 lt,this._deviceQuaternion.on("change",function(t){e._triggerChange(t)})},t._getValidYawRange=function(t,e,i){var n=u.adjustAspectRatio(i||this.options.aspectRatio||1),r=(e||this.axes.get().fov)*n;return t[1]-t[0]>=r?t:this.options.yawRange||ft},t._getValidPitchRange=function(t,e){var i=e||this.axes.get().fov;return t[1]-t[0]>=i?t:this.options.pitchRange||_t},u.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 N.copy(this.axes.axis.yaw.range,r),N.copy(this.axes.axis.pitch.range,n),this.axes.axis.yaw.circular=u.isCircular(r),this.axes.axis.pitch.circular=u.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===K.VR)return gt;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===K.VR)return ft;var n=t[1]-t[0];if(360<=n)return t.map(function(t){return+t.toFixed(5)});var r=1,o=e/2*u.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===K.VR&&this._deviceQuaternion&&(n.quaternion=this._deviceQuaternion.getCombinedQuaternion(e.yaw,e.pitch)),this.trigger("change",n)},u.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 u.lerp(i[n],i[n+1],(t-o)/(e[n+1]-o))},u.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,u=void 0===r?0:r-o.fov;this.axes.options.maximumDuration=1/0,this.axes.setBy({yaw:a,pitch:s,fov:u},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()},u}(e);return t.VERSION=dt,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}(),vt="undefined"==typeof Promise?n.Promise:Promise,mt={NONE:0,LOADING:1,LOADED:2,ERROR:3},yt="readystatechange",wt=function(){var t=function(i){function a(t){var e;return(e=i.call(this)||this)._image=null,e._onceHandlers=[],e._lo