-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththree.xr.js
1 lines (1 loc) · 139 KB
/
three.xr.js
1
!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.WebXRUtils=t.WebXRManager=void 0;var i=n(1),a=r(i),o=n(2),s=r(o);n(3),t.WebXRManager=a.default,t.WebXRUtils=s.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),THREE.WebXRManager=function(){function e(e){if(this.sessionActive){this.session.requestFrame(u);var t=e.getDisplayPose(e.getCoordinateSystem(XRCoordinateSystem.HEAD_MODEL));if(0===t._orientation[0]&&0===t._orientation[1]&&0===t._orientation[2]&&1===t._orientation[3]?this.poseFound&&(this.dispatchEvent({type:"poseLost"}),this.poseFound=!1):this.poseFound||(this.dispatchEvent({type:"poseFound"}),this.poseFound=!0),this.updateScene(o,e),this.renderer.autoClear=!1,this.renderer.setSize(this.session.baseLayer.framebufferWidth,this.session.baseLayer.framebufferHeight,!1),this.renderer.clear(),this.poseTarget.matrixAutoUpdate=!1,this.poseTarget.matrix.fromArray(t.poseModelMatrix),this.poseTarget.matrix.decompose(this.poseTarget.position,this.poseTarget.quaternion,this.poseTarget.scale),this.poseTarget.updateMatrixWorld(!0),this.sessionActive)for(var n=0;n<e.views.length;n++){var r=e.views[n];this.camera.matrixWorldInverse.fromArray(r.viewMatrix),this.camera.projectionMatrix.fromArray(r.projectionMatrix),this.renderer.clearDepth();var i=r.getViewport(this.session.baseLayer);this.renderer.setViewport(i.x,i.y,i.width,i.height),this.doRender()}else this.renderer.clearDepth(),this.renderer.setViewport(0,0,window.innerWidth,window.innerHeight),this.doRender()}}var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1],r=arguments[2],i=arguments[3],a=arguments[4],o=arguments[5],s={AR_AUTOSTART:!0};this.options=Object.assign({},s,t),this.displays=n,this.renderer=r,this.camera=i,this.scene=a;var u=e.bind(this);this.sessions=[],this.session=null,this.autoStarted=!1,this.matrixWorldInverse=new THREE.Matrix4,this.poseFound=!1,this.startSession=function(e,t,n){var i=this,a=!1;"vr"===t&&(a=!0);var o={exclusive:a,type:a?XRSession.REALITY:XRSession.AUGMENTATION};if(!this.sessionActive){null!==this.session&&(this.session.end(),this.session=null);var s=this;e.requestSession(o).then(function(e){i.session=e,e.realityType=t,e.depthNear=.05,e.depthFar=1e3,i.domElementOriginal=r.domElement.parentNode,i.cameraCloned=i.camera.clone(),i.camera.parent&&"Scene"!==i.camera.parent.type?i.poseTarget=i.camera.parent:i.poseTarget=i.camera,i.poseTargetCloned=i.poseTarget.clone(),e.addEventListener("focus",function(e){i.handleSessionFocus(e)}),e.addEventListener("blur",function(e){i.handleSessionBlur(e)}),e.addEventListener("end",function(e){i.handleSessionEnded(e)}),r.domElement.style.width="100%",r.domElement.style.height="100%","ar"===t&&n&&s.startPresenting()}).catch(function(e){console.error("Error requesting session",e)})}},this.startPresenting=function(){var e=this;h&&h._vrDisplay?(r.vr.enabled=!0,h._vrDisplay.isPresenting?h._vrDisplay.exitPresent():h._vrDisplay.requestPresent([{source:this.renderer.domElement}])):(this.session.baseLayer=new XRWebGLLayer(this.session,r.context),this.session.baseLayer.addEventListener("focus",function(t){e.handleLayerFocus(t)}),this.session.baseLayer.addEventListener("blur",function(t){e.handleLayerBlur(t)}),this.session.requestFrame(u),this.sessions.push(this.session),this.sessionActive=!0),document.getElementsByClassName("webxr-sessions")[0]&&(document.getElementsByClassName("webxr-sessions")[0].style.display="block"),this.dispatchEvent({type:"sessionStarted",session:this.session})},this.endSession=function(){this.session.end(),this.dispatchEvent({type:"sessionEnded",session:this.session}),this.sessionActive=!1,this.session._display._vrDisplay&&this.session._display.isPresenting&&(r.vr.enabled=!1,this.session._display._vrDisplay.exitPresent()),this.domElementOriginal.appendChild(this.session.baseLayer._context.canvas),this.poseTarget.matrixAutoUpdate=!1,this.poseTarget.matrix.copy(this.poseTargetCloned.matrix),this.poseTarget.updateMatrixWorld(!0),this.camera.matrixWorldInverse.copy(this.cameraCloned.matrixWorldInverse),this.camera.projectionMatrix.copy(this.cameraCloned.projectionMatrix),this.camera.updateProjectionMatrix(),document.getElementsByClassName("webxr-sessions")[0].style.display="none"},this.handleSessionFocus=function(e){console.log("handleSessionFocus")},this.handleSessionBlur=function(e){console.log("handleSessionBlur")},this.handleSessionEnded=function(e){console.log("handleSessionEnded")},this.handleLayerFocus=function(e){console.log("handleLayerFocus")},this.handleLayerBlur=function(e){console.log("handleLayerBlur")};var l,h,f=0,c=0;this.totalSupportedDisplays=0;for(var d=0;d<this.displays.length;d++){var _=this.displays[d];_.supportedRealities.vr&&(h=_,this.renderer.vr.setDevice(h._vrDisplay),f++),_.supportedRealities.ar&&(l=_,c++)}1===c&&0===f&&this.options.AR_AUTOSTART&&(this.autoStarted=!0,this.startSession(l,"ar",!0)),0===c&&1===f&&this.startSession(h,"vr",!1),this.totalSupportedDisplays=c+f,this.updateScene=function(e,t){e(t)},this.doRender=function(){this.renderer.render(this.scene,this.camera)}},THREE.WebXRManager.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.WebXRManager.prototype.constructor=THREE.WebXRManager,t.default=THREE.WebXRManager},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),THREE.WebXRUtils={getDisplays:function(){return new Promise(function(e,t){navigator.XR?navigator.XR.getDisplays().then(function(t){function n(){return void 0!==window.orientation||-1!==navigator.userAgent.indexOf("IEMobile")}if(0===t.length)return console.log("No displays are available"),void e(null);var r={exclusive:!1,type:XRSession.AUGMENTATION},i={exclusive:!0,type:XRSession.REALITY},a={vr:!1,ar:!1},o=!0,s=!1,u=void 0;try{for(var l,h=t[Symbol.iterator]();!(o=(l=h.next()).done);o=!0){var f=l.value;a={vr:!1,ar:!1},f.supportsSession(r)&&((f._reality._vrDisplay||!n()||function(){return-1!==navigator.userAgent.indexOf("AppleWebKit")&&-1===navigator.userAgent.indexOf("Safari")}())&&n()?a.ar=!0:a.ar=!1),f.supportsSession(i)&&-1===f._displayName.indexOf("polyfill")&&(a.vr=!0),f.supportedRealities=a}}catch(e){s=!0,u=e}finally{try{!o&&h.return&&h.return()}finally{if(s)throw u}}e(t)}).catch(function(t){console.error("Error getting XR displays",t),e(null)}):(console.log("WebXR polyfill is not found"),e(null))})}},t.default=THREE.WebXRUtils},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=22)}([function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(1),o=function(e){return e&&e.__esModule?e:{default:e}}(a),s=function(){function e(){r(this,e)}return i(e,null,[{key:"mat4_generateIdentity",value:function(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}},{key:"mat4_get_position",value:function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}},{key:"mat4_get_rotation",value:function(e,t){var n=new o.default;return n.setFromRotationMatrix(t),e[0]=n.x,e[1]=n.y,e[2]=n.z,e[3]=n.w,e}},{key:"mat4_eyeView",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Float32Array([0,0,0]);e.mat4_translate(t,n,r),e.mat4_invert(t,t)}},{key:"mat4_perspectiveFromFieldOfView",value:function(t,n,r,i){var a=Math.tan(n.upDegrees*e.PI_OVER_180),o=Math.tan(n.downDegrees*e.PI_OVER_180),s=Math.tan(n.leftDegrees*e.PI_OVER_180),u=Math.tan(n.rightDegrees*e.PI_OVER_180),l=2/(s+u),h=2/(a+o);return t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=h,t[6]=0,t[7]=0,t[8]=-(s-u)*l*.5,t[9]=(a-o)*h*.5,t[10]=i/(r-i),t[11]=-1,t[12]=0,t[13]=0,t[14]=i*r/(r-i),t[15]=0,t}},{key:"mat4_fromRotationTranslation",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0,1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[0,0,0],r=t[0],i=t[1],a=t[2],o=t[3],s=r+r,u=i+i,l=a+a,h=r*s,f=r*u,c=r*l,d=i*u,_=i*l,v=a*l,p=o*s,y=o*u,m=o*l;return e[0]=1-(d+v),e[1]=f+m,e[2]=c-y,e[3]=0,e[4]=f-m,e[5]=1-(h+v),e[6]=_+p,e[7]=0,e[8]=c+y,e[9]=_-p,e[10]=1-(h+d),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}},{key:"mat4_translate",value:function(e,t,n){var r=n[0],i=n[1],a=n[2],o=void 0,s=void 0,u=void 0,l=void 0,h=void 0,f=void 0,c=void 0,d=void 0,_=void 0,v=void 0,p=void 0,y=void 0;return t===e?(e[12]=t[0]*r+t[4]*i+t[8]*a+t[12],e[13]=t[1]*r+t[5]*i+t[9]*a+t[13],e[14]=t[2]*r+t[6]*i+t[10]*a+t[14],e[15]=t[3]*r+t[7]*i+t[11]*a+t[15]):(o=t[0],s=t[1],u=t[2],l=t[3],h=t[4],f=t[5],c=t[6],d=t[7],_=t[8],v=t[9],p=t[10],y=t[11],e[0]=o,e[1]=s,e[2]=u,e[3]=l,e[4]=h,e[5]=f,e[6]=c,e[7]=d,e[8]=_,e[9]=v,e[10]=p,e[11]=y,e[12]=o*r+h*i+_*a+t[12],e[13]=s*r+f*i+v*a+t[13],e[14]=u*r+c*i+p*a+t[14],e[15]=l*r+d*i+y*a+t[15]),e}},{key:"mat4_invert",value:function(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],h=t[8],f=t[9],c=t[10],d=t[11],_=t[12],v=t[13],p=t[14],y=t[15],m=n*s-r*o,b=n*u-i*o,w=n*l-a*o,M=r*u-i*s,g=r*l-a*s,E=i*l-a*u,A=h*v-f*_,x=h*p-c*_,T=h*y-d*_,R=f*p-c*v,O=f*y-d*v,P=c*y-d*p,k=m*P-b*O+w*R+M*T-g*x+E*A;return k?(k=1/k,e[0]=(s*P-u*O+l*R)*k,e[1]=(i*O-r*P-a*R)*k,e[2]=(v*E-p*g+y*M)*k,e[3]=(c*g-f*E-d*M)*k,e[4]=(u*T-o*P-l*x)*k,e[5]=(n*P-i*T+a*x)*k,e[6]=(p*w-_*E-y*b)*k,e[7]=(h*E-c*w+d*b)*k,e[8]=(o*O-s*T+l*A)*k,e[9]=(r*T-n*O-a*A)*k,e[10]=(_*g-v*w+y*m)*k,e[11]=(f*w-h*g-d*m)*k,e[12]=(s*x-o*R-u*A)*k,e[13]=(n*R-r*x+i*A)*k,e[14]=(v*b-_*M-p*m)*k,e[15]=(h*M-f*b+c*m)*k,e):null}},{key:"mat4_multiply",value:function(e,t,n){var r=t[0],i=t[4],a=t[8],o=t[12],s=t[1],u=t[5],l=t[9],h=t[13],f=t[2],c=t[6],d=t[10],_=t[14],v=t[3],p=t[7],y=t[11],m=t[15],b=n[0],w=n[4],M=n[8],g=n[12],E=n[1],A=n[5],x=n[9],T=n[13],R=n[2],O=n[6],P=n[10],k=n[14],I=n[3],S=n[7],C=n[11],F=n[15];return e[0]=r*b+i*E+a*R+o*I,e[4]=r*w+i*A+a*O+o*S,e[8]=r*M+i*x+a*P+o*C,e[12]=r*g+i*T+a*k+o*F,e[1]=s*b+u*E+l*R+h*I,e[5]=s*w+u*A+l*O+h*S,e[9]=s*M+u*x+l*P+h*C,e[13]=s*g+u*T+l*k+h*F,e[2]=f*b+c*E+d*R+_*I,e[6]=f*w+c*A+d*O+_*S,e[10]=f*M+c*x+d*P+_*C,e[14]=f*g+c*T+d*k+_*F,e[3]=v*b+p*E+y*R+m*I,e[7]=v*w+p*A+y*O+m*S,e[11]=v*M+p*x+y*P+m*C,e[15]=v*g+p*T+y*k+m*F,e}}]),e}();t.default=s,s.PI_OVER_180=Math.PI/180},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;r(this,e),this.x=t,this.y=n,this.z=i,this.w=a}return i(e,[{key:"set",value:function(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}},{key:"toArray",value:function(){return[this.x,this.y,this.z,this.w]}},{key:"copy",value:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}},{key:"setFromRotationMatrix",value:function(e){var t=e[0],n=e[4],r=e[8],i=e[1],a=e[5],o=e[9],s=e[2],u=e[6],l=e[10],h=t+a+l;if(h>0){var f=.5/Math.sqrt(h+1);this.w=.25/f,this.x=(u-o)*f,this.y=(r-s)*f,this.z=(i-n)*f}else if(t>a&&t>l){var f=2*Math.sqrt(1+t-a-l);this.w=(u-o)/f,this.x=.25*f,this.y=(n+i)/f,this.z=(r+s)/f}else if(a>l){var f=2*Math.sqrt(1+a-t-l);this.w=(r-s)/f,this.x=(n+i)/f,this.y=.25*f,this.z=(o+u)/f}else{var f=2*Math.sqrt(1+l-t-a);this.w=(i-n)/f,this.x=(r+s)/f,this.y=(o+u)/f,this.z=.25*f}return this}},{key:"setFromEuler",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"XYZ",i=Math.cos,a=Math.sin,o=i(e/2),s=i(t/2),u=i(n/2),l=a(e/2),h=a(t/2),f=a(n/2);"XYZ"===r?(this.x=l*s*u+o*h*f,this.y=o*h*u-l*s*f,this.z=o*s*f+l*h*u,this.w=o*s*u-l*h*f):"YXZ"===r?(this.x=l*s*u+o*h*f,this.y=o*h*u-l*s*f,this.z=o*s*f-l*h*u,this.w=o*s*u+l*h*f):"ZXY"===r?(this.x=l*s*u-o*h*f,this.y=o*h*u+l*s*f,this.z=o*s*f+l*h*u,this.w=o*s*u-l*h*f):"ZYX"===r?(this.x=l*s*u-o*h*f,this.y=o*h*u+l*s*f,this.z=o*s*f-l*h*u,this.w=o*s*u+l*h*f):"YZX"===r?(this.x=l*s*u+o*h*f,this.y=o*h*u+l*s*f,this.z=o*s*f-l*h*u,this.w=o*s*u-l*h*f):"XZY"===r&&(this.x=l*s*u-o*h*f,this.y=o*h*u-l*s*f,this.z=o*s*f+l*h*u,this.w=o*s*u+l*h*f)}},{key:"setFromAxisAngle",value:function(e,t){var n=t/2,r=Math.sin(n);return this.x=e.x*r,this.y=e.y*r,this.z=e.z*r,this.w=Math.cos(n),this}},{key:"multiply",value:function(e){return this.multiplyQuaternions(this,e)}},{key:"multiplyQuaternions",value:function(e,t){var n=e.x,r=e.y,i=e.z,a=e.w,o=t.x,s=t.y,u=t.z,l=t.w;return this.x=n*l+a*o+r*u-i*s,this.y=r*l+a*s+i*o-n*u,this.z=i*l+a*u+n*s-r*o,this.w=a*l-n*o-r*s-i*u,this}},{key:"inverse",value:function(){return this.x*=-1,this.y*=-1,this.z*=-1,this.normalize(),this}},{key:"normalize",value:function(){var e=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);return 0===e?(this.x=0,this.y=0,this.z=0,this.w=1):(e=1/e,this.x=this.x*e,this.y=this.y*e,this.z=this.z*e,this.w=this.w*e),this}},{key:"slerp",value:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var n=this.x,r=this.y,i=this.z,a=this.w,o=a*e.w+n*e.x+r*e.y+i*e.z;if(o<0?(this.w=-e.w,this.x=-e.x,this.y=-e.y,this.z=-e.z,o=-o):this.copy(e),o>=1)return this.w=a,this.x=n,this.y=r,this.z=i,this;var s=Math.acos(o),u=Math.sqrt(1-o*o);if(Math.abs(u)<.001)return this.w=.5*(a+this.w),this.x=.5*(n+this.x),this.y=.5*(r+this.y),this.z=.5*(i+this.z),this;var l=Math.sin((1-t)*s)/u,h=Math.sin(t*s)/u;return this.w=a*l+this.w*h,this.x=n*l+this.x*h,this.y=r*l+this.y*h,this.z=i*l+this.z*h,this}}]),e}();t.default=a},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e),this._listeners=new Map}return i(e,[{key:"addEventListener",value:function(e,t){var n=this._listeners.get(e);!1===Array.isArray(n)&&(n=[],this._listeners.set(e,n)),n.push(t)}},{key:"removeEventListener",value:function(e,t){var n=this._listeners.get(e);if(!1!==Array.isArray(n))for(var r=0;r<n.length;r++)if(n[r]===t)return void n.splice(r,1)}},{key:"dispatchEvent",value:function(e){var t=this._listeners.get(e.type);if(!1!==Array.isArray(t)){var n=t.slice(0),r=!0,i=!1,a=void 0;try{for(var o,s=n[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){(0,o.value)(e)}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}}}}]),e}();t.default=a},function(e,t,n){function r(e){t.ARRAY_TYPE=s=e}function i(e){return e*u}function a(e,t){return Math.abs(e-t)<=o*Math.max(1,Math.abs(e),Math.abs(t))}Object.defineProperty(t,"__esModule",{value:!0}),t.setMatrixArrayType=r,t.toRadian=i,t.equals=a;var o=t.EPSILON=1e-6,s=t.ARRAY_TYPE="undefined"!=typeof Float32Array?Float32Array:Array,u=(t.RANDOM=Math.random,Math.PI/180)},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;r(this,e),this._uid=n||e._generateUID(),this._coordinateSystem=t}return i(e,[{key:"uid",get:function(){return this._uid}},{key:"coordinateSystem",get:function(){return this._coordinateSystem}}],[{key:"_generateUID",value:function(){return"anchor-"+(new Date).getTime()+"-"+Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)}}]),e}();t.default=a},function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":r(t))&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":r(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(0),h=i(l),f=n(2),c=i(f),d=n(23),_=i(d),v=n(13),p=i(v),y=function(e){function t(e,n,r,i){a(this,t);var s=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));s._xr=e,s._displayName=n,s._isExternal=r,s._reality=i,s._headModelCoordinateSystem=new XRCoordinateSystem(s,XRCoordinateSystem.HEAD_MODEL),s._eyeLevelCoordinateSystem=new XRCoordinateSystem(s,XRCoordinateSystem.EYE_LEVEL),s._trackerCoordinateSystem=new XRCoordinateSystem(s,XRCoordinateSystem.TRACKER),s._headPose=new XRViewPose([0,XRViewPose.SITTING_EYE_HEIGHT,0]),s._eyeLevelPose=new XRViewPose([0,XRViewPose.SITTING_EYE_HEIGHT,0]),s._trackerPoseModelMatrix=h.default.mat4_generateIdentity(),s._fovy=70;var u=s._fovy/2;return s._fov=new p.default(u,u,u,u),s._depthNear=.1,s._depthFar=1e3,s._views=[],s}return s(t,e),u(t,[{key:"supportsSession",value:function(e){return this._supportedCreationParameters(e)}},{key:"requestSession",value:function(e){var t=this;return new Promise(function(n,r){if(!1===t._supportedCreationParameters(e))return void r();e.type===XRSession.REALITY&&(t._reality=new _.default,t._xr._privateRealities.push(t._reality)),n(t._createSession(e))})}},{key:"_requestVideoFrame",value:function(){}},{key:"_requestAnimationFrame",value:function(e){return window.requestAnimationFrame(e)}},{key:"_cancelAnimationFrame",value:function(e){return window.cancelAnimationFrame(e)}},{key:"_createSession",value:function(e){return new XRSession(this._xr,this,e)}},{key:"_supportedCreationParameters",value:function(e){throw"Should be implemented by extending class"}},{key:"_handleNewFrame",value:function(e){}},{key:"_handleAfterFrame",value:function(e){}},{key:"_handleNewBaseLayer",value:function(e){}},{key:"displayName",get:function(){return this._displayName}},{key:"isExternal",get:function(){return this._isExternal}}]),t}(c.default);t.default=y},function(e,t,n){function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":r(t))&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":r(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(2),l=function(e){return e&&e.__esModule?e:{default:e}}(u),h=function(e){function t(e,n,r,o){i(this,t);var s=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return s._xr=e,s._name=n,s._isShared=r,s._isPassthrough=o,s._anchors=new Map,s}return o(t,e),s(t,[{key:"getCoordinateSystem",value:function(){throw new Error("Not implemented")}},{key:"_start",value:function(e){throw new Error("Exending classes should implement _start")}},{key:"_stop",value:function(){throw new Error("Exending classes should implement _stop")}},{key:"_requestVideoFrame",value:function(){}},{key:"_stopVideoFrames",value:function(){}},{key:"_startVideoFrames",value:function(){}},{key:"_handleNewFrame",value:function(){}},{key:"_addAnchor",value:function(e,t){throw new Error("Exending classes should implement _addAnchor")}},{key:"_findAnchor",value:function(e,t,n){throw new Error("Exending classes should implement _findAnchor")}},{key:"_findFloorAnchor",value:function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1];throw new Error("Exending classes should implement _findFloorAnchor")}},{key:"_getAnchor",value:function(e){return this._anchors.get(e)||null}},{key:"_removeAnchor",value:function(e){throw new Error("Exending classes should implement _removeAnchor")}},{key:"_hitTestNoAnchor",value:function(e,t,n){throw new Error("Exending classes should implement _hitTestNoAnchor")}},{key:"_getLightAmbientIntensity",value:function(){throw new Error("Exending classes should implement _getLightAmbientIntensity")}},{key:"name",get:function(){return this._name}},{key:"isShared",get:function(){return this._isShared}},{key:"isPassthrough",get:function(){return this._isPassthrough}}]),t}(l.default);t.default=h,h.COMPUTER_VISION_DATA="cv_data",h.WINDOW_RESIZE_EVENT="window-resize"},function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":r(t))&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":r(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(2),h=i(l),f=n(0),c=i(f),d=function(e){function t(e,n,r){a(this,t);var i=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return i._xr=e,i._display=n,i._createParameters=r,i._ended=!1,i._baseLayer=null,i._stageBounds=null,i._skip=!1,i._frameAnchors=[],i._tempMatrix=c.default.mat4_generateIdentity(),i._tempMatrix2=c.default.mat4_generateIdentity(),i}return s(t,e),u(t,[{key:"requestFrame",value:function(e){if(this._ended)return null;if("function"!=typeof e)throw"Invalid callback";return this._handleRequestFrame(e)}},{key:"_handleRequestFrame",value:function(e){var t=this;return this._display._requestAnimationFrame(function(){if(t._skip)return t._skip=!1,t._handleRequestFrame(e);var n=t._createPresentationFrame();t._updateCameraAnchor(n),t._display._reality._handleNewFrame(n),t._display._handleNewFrame(n),e(n),t._display._handleAfterFrame(n)})}},{key:"cancelFrame",value:function(e){return this._display._cancelAnimationFrame(e)}},{key:"end",value:function(){if(!this._ended){for(var e=0;e<this._frameAnchors.length;e++)this._display._reality._removeAnchor(this._frameAnchors[e].uid);return this._frameAnchors=[],this._ended=!0,this._display._stop(),new Promise(function(e,t){e()})}}},{key:"_updateCameraAnchor",value:function(e){if(0==this._frameAnchors.length||this._frameAnchors[0].timestamp+6e4<e.timestamp){var t=e.getCoordinateSystem(XRCoordinateSystem.EYE_LEVEL),n=e.addAnchor(t,[0,-1,0]),r=e.getAnchor(n);if(r.timestamp=e.timestamp,this._frameAnchors.unshift(r),this._frameAnchors.length>10){var i=this._frameAnchors.pop();this._display._reality._removeAnchor(i.uid)}return r}return this._frameAnchors[0]}},{key:"_transformToCameraAnchor",value:function(e){if(0==this._frameAnchors.length)return e.viewMatrix;var t=e.viewMatrix;e._anchorUid=this._frameAnchors[0].uid;var n=this._frameAnchors[0].coordinateSystem;c.default.mat4_invert(this._tempMatrix,n._poseModelMatrix),c.default.mat4_multiply(e.viewMatrix,this._tempMatrix,t)}},{key:"setVideoFrameHandler",value:function(e){var t=this;if(e instanceof Worker){var n=e;e=function(e){t._transformToCameraAnchor(e.detail.camera),e.detail.postMessageToWorker(n,{type:"newVideoFrame"}),e.detail.release()}}else{var r=e;e=function(e){t._transformToCameraAnchor(e.detail.camera),r(e)}}this._display.addEventListener("videoFrame",e)}},{key:"getVideoFramePose",value:function(e,t){if(e.camera._anchorUid){var n=this.reality._getAnchor(e.camera._anchorUid),r=n.coordinateSystem._poseModelMatrix;c.default.mat4_multiply(t,r,e.camera.viewMatrix)}}},{key:"requestVideoFrame",value:function(){this._display._requestVideoFrame()}},{key:"stopVideoFrames",value:function(){this._display._stopVideoFrames()}},{key:"startVideoFrames",value:function(){this._display._startVideoFrames()}},{key:"_createPresentationFrame",value:function(){return new XRPresentationFrame(this)}},{key:"_getCoordinateSystem",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=!0,i=!1,a=void 0;try{for(var o,s=t[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){switch(o.value){case XRCoordinateSystem.HEAD_MODEL:return this._display._headModelCoordinateSystem;case XRCoordinateSystem.EYE_LEVEL:return this._display._eyeLevelCoordinateSystem;case XRCoordinateSystem.TRACKER:return this._display._trackerCoordinateSystem;case XRCoordinateSystem.GEOSPATIAL:default:continue}}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}return null}},{key:"display",get:function(){return this._display}},{key:"createParameters",get:function(){return this._parameters}},{key:"realities",get:function(){return this._xr._sharedRealities}},{key:"reality",get:function(){return this._display._reality}},{key:"baseLayer",get:function(){return this._baseLayer},set:function(e){this._baseLayer=e,this._display._handleNewBaseLayer(this._baseLayer)}},{key:"depthNear",get:function(){this._display._depthNear},set:function(e){this._display._depthNear=e}},{key:"depthFar",get:function(){this._display._depthFar},set:function(e){this._display._depthFar=e}},{key:"hasStageBounds",get:function(){this._stageBounds}},{key:"stageBounds",get:function(){return this._stageBounds}}]),t}(h.default);t.default=d,d.REALITY="reality",d.AUGMENTATION="augmentation",d.TYPES=[d.REALITY,d.AUGMENTATION]},function(e,t,n){function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(16),s=r(o),u=n(0),l=r(u),h=function(){function e(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;i(this,e),this._fov=t,this._depthNear=n,this._depthFar=r,this._eye=a,this._viewport=new s.default(0,0,1,1),this._projectionMatrix=new Float32Array(16),this._viewMatrix=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),l.default.mat4_perspectiveFromFieldOfView(this._projectionMatrix,this._fov,this._depthNear,this._depthFar)}return a(e,[{key:"setProjectionMatrix",value:function(e){for(var t=0;t<16;t++)this._projectionMatrix[t]=e[t]}},{key:"setViewMatrix",value:function(e){for(var t=0;t<16;t++)this._viewMatrix[t]=e[t]}},{key:"getViewport",value:function(t){return this._eye===e.LEFT?(this._viewport.x=0,this._viewport.y=0,this._viewport.width=t.framebufferWidth/2,this._viewport.height=t.framebufferHeight):this._eye===e.RIGHT?(this._viewport.x=t.framebufferWidth/2,this._viewport.y=0,this._viewport.width=t.framebufferWidth/2,this._viewport.height=t.framebufferHeight):(this._viewport.x=0,this._viewport.y=0,this._viewport.width=t.framebufferWidth,this._viewport.height=t.framebufferHeight),this._viewport}},{key:"fov",set:function(e){this._fov=e,l.default.mat4_perspectiveFromFieldOfView(this._projectionMatrix,this._fov,this._depthNear,this._depthFar)}},{key:"eye",get:function(){return this._eye}},{key:"projectionMatrix",get:function(){return this._projectionMatrix}},{key:"viewMatrix",get:function(){return this._viewMatrix}}]),e}();t.default=h,h.LEFT="left",h.RIGHT="right",h.EYES=[h.LEFT,h.RIGHT]},function(e,t,n){function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(0),s=r(o),u=n(1),l=r(u),h=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0,1];i(this,e),this._poseModelMatrix=new Float32Array(16),s.default.mat4_fromRotationTranslation(this._poseModelMatrix,n,t)}return a(e,[{key:"_setPoseModelMatrix",value:function(e){for(var t=0;t<16;t++)this._poseModelMatrix[t]=e[t]}},{key:"_translate",value:function(e){this._poseModelMatrix[12]+=e[0],this._poseModelMatrix[13]+=e[1],this._poseModelMatrix[14]+=e[2]}},{key:"getViewMatrix",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return null===t&&(t=new Float32Array(16)),s.default.mat4_eyeView(t,this._poseModelMatrix),t}},{key:"poseModelMatrix",get:function(){return this._poseModelMatrix}},{key:"_position",get:function(){return[this._poseModelMatrix[12],this._poseModelMatrix[13],this._poseModelMatrix[14]]},set:function(e){this._poseModelMatrix[12]=e[0],this._poseModelMatrix[13]=e[1],this._poseModelMatrix[14]=e[2]}},{key:"_orientation",get:function(){var e=new l.default;return e.setFromRotationMatrix(this._poseModelMatrix),e.toArray()},set:function(e){s.default.mat4_fromRotationTranslation(this._poseModelMatrix,e,this._position)}}]),e}();t.default=h,h.SITTING_EYE_HEIGHT=0},function(e,t,n){function r(){var e=new Y.ARRAY_TYPE(3);return e[0]=0,e[1]=0,e[2]=0,e}function i(e){var t=new Y.ARRAY_TYPE(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function a(e){var t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function o(e,t,n){var r=new Y.ARRAY_TYPE(3);return r[0]=e,r[1]=t,r[2]=n,r}function s(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function u(e,t,n,r){return e[0]=t,e[1]=n,e[2]=r,e}function l(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function h(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function f(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e}function c(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e}function d(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function _(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function v(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e}function p(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e}function y(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e}function m(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function b(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e}function w(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(n*n+r*r+i*i)}function M(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return n*n+r*r+i*i}function g(e){var t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r}function E(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function A(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function x(e,t){var n=t[0],r=t[1],i=t[2],a=n*n+r*r+i*i;return a>0&&(a=1/Math.sqrt(a),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a),e}function T(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function R(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[0],s=n[1],u=n[2];return e[0]=i*u-a*s,e[1]=a*o-r*u,e[2]=r*s-i*o,e}function O(e,t,n,r){var i=t[0],a=t[1],o=t[2];return e[0]=i+r*(n[0]-i),e[1]=a+r*(n[1]-a),e[2]=o+r*(n[2]-o),e}function P(e,t,n,r,i,a){var o=a*a,s=o*(2*a-3)+1,u=o*(a-2)+a,l=o*(a-1),h=o*(3-2*a);return e[0]=t[0]*s+n[0]*u+r[0]*l+i[0]*h,e[1]=t[1]*s+n[1]*u+r[1]*l+i[1]*h,e[2]=t[2]*s+n[2]*u+r[2]*l+i[2]*h,e}function k(e,t,n,r,i,a){var o=1-a,s=o*o,u=a*a,l=s*o,h=3*a*s,f=3*u*o,c=u*a;return e[0]=t[0]*l+n[0]*h+r[0]*f+i[0]*c,e[1]=t[1]*l+n[1]*h+r[1]*f+i[1]*c,e[2]=t[2]*l+n[2]*h+r[2]*f+i[2]*c,e}function I(e,t){t=t||1;var n=2*Y.RANDOM()*Math.PI,r=2*Y.RANDOM()-1,i=Math.sqrt(1-r*r)*t;return e[0]=Math.cos(n)*i,e[1]=Math.sin(n)*i,e[2]=r*t,e}function S(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/o,e[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/o,e[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/o,e}function C(e,t,n){var r=t[0],i=t[1],a=t[2];return e[0]=r*n[0]+i*n[3]+a*n[6],e[1]=r*n[1]+i*n[4]+a*n[7],e[2]=r*n[2]+i*n[5]+a*n[8],e}function F(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[0],s=n[1],u=n[2],l=n[3],h=l*r+s*a-u*i,f=l*i+u*r-o*a,c=l*a+o*i-s*r,d=-o*r-s*i-u*a;return e[0]=h*l+d*-o+f*-u-c*-s,e[1]=f*l+d*-s+c*-o-h*-u,e[2]=c*l+d*-u+h*-s-f*-o,e}function N(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0],a[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),a[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e}function D(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),a[1]=i[1],a[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e}function L(e,t,n,r){var i=[],a=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],a[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),a[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),a[2]=i[2],e[0]=a[0]+n[0],e[1]=a[1]+n[1],e[2]=a[2]+n[2],e}function j(e,t){var n=o(e[0],e[1],e[2]),r=o(t[0],t[1],t[2]);x(n,n),x(r,r);var i=T(n,r);return i>1?0:i<-1?Math.PI:Math.acos(i)}function V(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"}function W(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function G(e,t){var n=e[0],r=e[1],i=e[2],a=t[0],o=t[1],s=t[2];return Math.abs(n-a)<=Y.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(r-o)<=Y.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=Y.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))}Object.defineProperty(t,"__esModule",{value:!0}),t.forEach=t.sqrLen=t.len=t.sqrDist=t.dist=t.div=t.mul=t.sub=void 0,t.create=r,t.clone=i,t.length=a,t.fromValues=o,t.copy=s,t.set=u,t.add=l,t.subtract=h,t.multiply=f,t.divide=c,t.ceil=d,t.floor=_,t.min=v,t.max=p,t.round=y,t.scale=m,t.scaleAndAdd=b,t.distance=w,t.squaredDistance=M,t.squaredLength=g,t.negate=E,t.inverse=A,t.normalize=x,t.dot=T,t.cross=R,t.lerp=O,t.hermite=P,t.bezier=k,t.random=I,t.transformMat4=S,t.transformMat3=C,t.transformQuat=F,t.rotateX=N,t.rotateY=D,t.rotateZ=L,t.angle=j,t.str=V,t.exactEquals=W,t.equals=G;var H=n(3),Y=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(H);t.sub=h,t.mul=f,t.div=c,t.dist=w,t.sqrDist=M,t.len=a,t.sqrLen=g,t.forEach=function(){var e=r();return function(t,n,r,i,a,o){var s=void 0,u=void 0;for(n||(n=3),r||(r=0),u=i?Math.min(i*n+r,t.length):t.length,s=r;s<u;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],a(e,e,o),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2];return t}}()},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;r(this,e),this.x=t,this.y=n,this.z=i}return i(e,[{key:"set",value:function(e,t,n){return this.x=e,this.y=t,this.z=n,this}},{key:"copy",value:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}},{key:"toArray",value:function(){return[this.x,this.y,this.z]}},{key:"length",value:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}},{key:"add",value:function(e,t,n){this.x+=e,this.y+=t,this.z+=n}},{key:"normalize",value:function(){var e=this.length();return 0!==e?this.multiplyScalar(1/e):(this.x=0,this.y=0,this.z=0),this}},{key:"multiplyScalar",value:function(e){this.x*=e,this.y*=e,this.z*=e}},{key:"applyQuaternion",value:function(e){var t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,u=s*t+a*r-o*n,l=s*n+o*t-i*r,h=s*r+i*n-a*t,f=-i*t-a*n-o*r;return this.x=u*s+f*-i+l*-o-h*-a,this.y=l*s+f*-a+h*-i-u*-o,this.z=h*s+f*-o+u*-a-l*-i,this}},{key:"applyMatrix4",value:function(e){var t=this.x,n=this.y,r=this.z,i=1/(e[3]*t+e[7]*n+e[11]*r+e[15]);return this.x=(e[0]*t+e[4]*n+e[8]*r+e[12])*i,this.y=(e[1]*t+e[5]*n+e[9]*r+e[13])*i,this.z=(e[2]*t+e[6]*n+e[10]*r+e[14])*i,this}},{key:"dot",value:function(e){return this.x*e.x+this.y*e.y+this.z*e.z}},{key:"crossVectors",value:function(e,t){var n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}}]),e}();t.default=a},function(e,t,n){function i(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function a(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":r(t))&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":r(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var l="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(e){return void 0===e?"undefined":r(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":r(e)},h=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),f=n(2),c=a(f),d=n(3),_=(i(d),n(18)),v=i(_),p=n(19),y=i(p),m=n(10),b=i(m),w=n(20),M=a(w),g=n(1),E=(a(g),n(0)),A=a(E),x=function(e){function t(){function e(){return this.modelMatrix=new Float32Array(16),this}o(this,t);var n=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));if(!1===t.HasARKit())throw"ARKitWrapper will only work in Mozilla's ARDemo test app";if(void 0!==t.GLOBAL_INSTANCE)throw"ARKitWrapper is a singleton. Use ARKitWrapper.GetOrCreate() to get the global instance.";n._deviceId=null,n._isWatching=!1,n._isInitialized=!1,n._rawARData=null,n.lightIntensity=1e3,n.projectionMatrix_=new Float32Array(16),n.viewMatrix_=new Float32Array(16),n.planes_=new Map,n.anchors_=new Map,n._timeOffsets=[],n._timeOffset=0,n._timeOffsetComputed=!1,n.timestamp=0,n._globalCallbacksMap={};for(var r=["onInit","onWatch"],i=0;i<r.length;i++)n._generateGlobalCallback(r[i],i);n._defaultOptions={location:!0,camera:!0,objects:!0,light_intensity:!0,computer_vision_data:!1},n._m90=v.fromZRotation(v.create(),90*A.default.PI_OVER_180),n._m90neg=v.fromZRotation(v.create(),-90*A.default.PI_OVER_180),n._m180=v.fromZRotation(v.create(),180*A.default.PI_OVER_180),n._mTemp=v.create();for(var a=[["arkitStartRecording",t.RECORD_START_EVENT],["arkitStopRecording",t.RECORD_STOP_EVENT],["arkitDidMoveBackground",t.DID_MOVE_BACKGROUND_EVENT],["arkitWillEnterForeground",t.WILL_ENTER_FOREGROUND_EVENT],["arkitInterrupted",t.INTERRUPTED_EVENT],["arkitInterruptionEnded",t.INTERRUPTION_ENDED_EVENT],["arkitShowDebug",t.SHOW_DEBUG_EVENT],["arkitWindowResize",t.WINDOW_RESIZE_EVENT],["onError",t.ON_ERROR],["arTrackingChanged",t.AR_TRACKING_CHANGED],["userGrantedComputerVisionData",t.USER_GRANTED_COMPUTER_VISION_DATA]],u=0;u<a.length;u++)!function(e){window[a[e][0]]=function(t){t=t||null,n.dispatchEvent(new CustomEvent(a[e][1],{source:n,detail:t}))}}(u);window.onComputerVisionData=function(e){n._onComputerVisionData(e)},window.setNativeTime=function(e){n._timeOffsets.push((performance||Date).now()-e.nativeTime),n._timeOffsetComputed=!0,n._timeOffset=0;for(var t=0;t<n._timeOffsets.length;t++)n._timeOffset+=n._timeOffsets[t];n._timeOffset=n._timeOffset/n._timeOffsets.length,console.log("Native time: "+e.nativeTime+", new timeOffset: "+n._timeOffset)},n._adjustARKitTime=function(e){return this._timeOffsetComputed?e+this._timeOffset:(performance||Date).now()};var l=n;return n.getPlanes=function(){return Array.from(this.planes_.values())},n.hitTestNoAnchor=function(){var t={rayStart:b.create(),rayEnd:b.create(),cameraPosition:b.create(),cameraQuaternion:y.create(),modelViewMatrix:v.create(),projectionMatrix:v.create(),projViewMatrix:v.create(),worldRayStart:b.create(),worldRayEnd:b.create(),worldRayDir:b.create(),planeMatrix:v.create(),planeExtent:b.create(),planePosition:b.create(),planeCenter:b.create(),planeNormal:b.create(),planeIntersection:b.create(),planeIntersectionLocal:b.create(),planeHit:v.create(),planeQuaternion:y.create()},n=function(e,t){v.set(e,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},r=function(){var e=b.create();return function(t,n,r,i){var a=b.dot(t,i);return b.subtract(e,n,r),b.dot(e,t)/a}}(),i=function(e,r){n(t.planeMatrix,e.modelMatrix),v.getTranslation(t.planeIntersection,t.planeMatrix);var i=b.distance(t.planeIntersection,t.cameraPosition);return n(t.planeMatrix,r.modelMatrix),v.getTranslation(t.planeIntersection,t.planeMatrix),i<b.distance(t.planeIntersection,t.cameraPosition)?-1:1};return function(a,o){if(a<0||a>1||o<0||o>1)throw new Error("hitTest - x and y values must be normalized [0,1]!");var s=[],u=this.getPlanes();if(!u||0==u.length)return s;b.set(t.rayStart,2*a-1,2*(1-o)-1,0),b.set(t.rayEnd,2*a-1,2*(1-o)-1,1),n(t.projectionMatrix,l.projectionMatrix_),n(t.modelViewMatrix,l.viewMatrix_),v.multiply(t.projViewMatrix,t.projectionMatrix,t.modelViewMatrix),v.invert(t.projViewMatrix,t.projViewMatrix),b.transformMat4(t.worldRayStart,t.rayStart,t.projViewMatrix),b.transformMat4(t.worldRayEnd,t.rayEnd,t.projViewMatrix),b.subtract(t.worldRayDir,t.worldRayEnd,t.worldRayStart),b.normalize(t.worldRayDir,t.worldRayDir);for(var h=0;h<u.length;h++){var f=u[h];n(t.planeMatrix,f.modelMatrix),b.set(t.planeCenter,f.center.x,f.center.y,f.center.z),b.transformMat4(t.planePosition,t.planeCenter,t.planeMatrix),t.planeAlignment=f.alignment,0===t.planeAlignment?b.set(t.planeNormal,0,1,0):b.set(t.planeNormal,t.planeMatrix[4],t.planeMatrix[5],t.planeMatrix[6]);var c=r(t.planeNormal,t.planePosition,t.worldRayStart,t.worldRayDir);if(!(c<0)){b.scale(t.planeIntersection,t.worldRayDir,c),b.add(t.planeIntersection,t.worldRayStart,t.planeIntersection),b.set(t.planeExtent,f.extent[0],0,f.extent[1]),v.getRotation(t.planeQuaternion,t.planeMatrix),v.invert(t.planeMatrix,t.planeMatrix),b.transformMat4(t.planeIntersectionLocal,t.planeIntersection,t.planeMatrix);if(!(Math.abs(t.planeIntersectionLocal[0])>t.planeExtent[0]/2+.0075||Math.abs(t.planeIntersectionLocal[2])>t.planeExtent[2]/2+.0075)){v.fromRotationTranslation(t.planeHit,t.planeQuaternion,t.planeIntersection);for(var d=new e,_=0;_<16;_++)d.modelMatrix[_]=t.planeHit[_];d.i=h,s.push(d)}}}return s.sort(i),s}}(),n}return u(t,e),h(t,[{key:"waitForInit",value:function(){var e=this;return new Promise(function(n,r){if(e._isInitialized)return void n();var i=function r(){e.removeEventListener(t.INIT_EVENT,r,!1),n()};e.addEventListener(t.INIT_EVENT,i,!1)})}},{key:"getData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return null===e?this._rawARData:this._rawARData&&void 0!==this._rawARData[e]?this._rawARData[e]:null}},{key:"getObject",value:function(e){if(!this._isInitialized)return null;var t=this.getKey("objects");if(null===t)return null;var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;if(s.uuid===e)return s}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}return null}},{key:"hitTest",value:function(e,n){var r=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.HIT_TEST_TYPE_ALL;return new Promise(function(t,a){if(!r._isInitialized)return void a(new Error("ARKit is not initialized"));window.webkit.messageHandlers.hitTest.postMessage({x:e,y:n,type:i,callback:r._createPromiseCallback("hitTest",t)})})}},{key:"addAnchor",value:function(e,t){var n=this;return new Promise(function(r,i){if(!n._isInitialized)return void i(new Error("ARKit is not initialized"));window.webkit.messageHandlers.addAnchor.postMessage({uuid:e,transform:t,callback:n._createPromiseCallback("addAnchor",r)})})}},{key:"removeAnchor",value:function(e){window.webkit.messageHandlers.removeAnchors.postMessage([e])}},{key:"createImageAnchor",value:function(e,t,n,r){M.default.encode(t)}},{key:"stop",value:function(){var e=this;return new Promise(function(t,n){if(!e._isWatching)return void t();console.log("----STOP"),window.webkit.messageHandlers.stopAR.postMessage({callback:e._createPromiseCallback("stop",t)})})}},{key:"watch",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!this._isInitialized)return!1;if(this._isWatching)return!0;this._isWatching=!0;var t=Object.assign({},this._defaultOptions);null!=e&&(t=Object.assign(t,e)),t.videoFrames&&(delete t.videoFrames,t.computer_vision_data=!0);var n={options:t,callback:this._globalCallbacksMap.onWatch};return console.log("----WATCH"),window.webkit.messageHandlers.watchAR.postMessage(n),!0}},{key:"setUIOptions",value:function(e){window.webkit.messageHandlers.setUIOptions.postMessage(e)}},{key:"_sendInit",value:function(e){console.log("----INIT"),window.webkit.messageHandlers.initAR.postMessage({options:e,callback:this._globalCallbacksMap.onInit})}},{key:"_onInit",value:function(e){this._deviceId=e,this._isInitialized=!0,this.dispatchEvent(new CustomEvent(t.INIT_EVENT,{source:this}))}},{key:"_onWatch",value:function(e){if(this._rawARData=e,this.dispatchEvent(new CustomEvent(t.WATCH_EVENT,{source:this,detail:this._rawARData})),this.timestamp=this._adjustARKitTime(e.timestamp),this.lightIntensity=e.light_intensity,this.viewMatrix_=e.camera_view,this.projectionMatrix_=e.projection_camera,e.newObjects.length)for(var n=0;n<e.newObjects.length;n++){var r=e.newObjects[n];r.plane_center?this.planes_.set(r.uuid,{id:r.uuid,center:r.plane_center,extent:[r.plane_extent.x,r.plane_extent.z],modelMatrix:r.transform,alignment:r.plane_alignment}):this.anchors_.set(r.uuid,{id:r.uuid,modelMatrix:r.transform})}if(e.removedObjects.length)for(var i=0;i<e.removedObjects.length;i++){var a=e.removedObjects[i];this.planes_.get(a)?this.planes_.delete(a):this.anchors_.delete(a)}if(e.objects.length)for(var o=0;o<e.objects.length;o++){var s=e.objects[o];if(s.plane_center){var u=this.planes_.get(s.uuid);u?(u.center=s.plane_center,u.extent=[s.plane_extent.x,s.plane_extent.z],u.modelMatrix=s.transform):this.planes_.set(s.uuid,{id:s.uuid,center:s.plane_center,extent:[s.plane_extent.x,s.plane_extent.z],modelMatrix:s.transform,alignment:s.plane_alignment})}else{var l=this.anchors_.get(s.uuid);l?l.modelMatrix=s.transform:this.anchors_.set(s.uuid,{id:s.uuid,modelMatrix:s.transform})}}}},{key:"_onStop",value:function(){this._isWatching=!1}},{key:"_createPromiseCallback",value:function(e,t){var n=this,r=this._generateCallbackUID(e);return window[r]=function(i){delete window[r];var a="_on"+e[0].toUpperCase()+e.slice(1);"function"==typeof n[a]&&n[a](i),t(i)},r}},{key:"_generateCallbackUID",value:function(e){return"arkitCallback_"+e+"_"+(new Date).getTime()+"_"+Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)}},{key:"_generateGlobalCallback",value:function(e,t){var n="arkitCallback"+t;this._globalCallbacksMap[e]=n;var r=this;window[n]=function(t){r["_"+e](t)}}},{key:"_onComputerVisionData",value:function(e){if(!e)return console.error("detail passed to _onComputerVisionData is null"),void this._requestComputerVisionData();if(!e.frame||!e.frame.buffers||e.frame.buffers.length<=0)return console.error("detail passed to _onComputerVisionData is bad, no buffers"),void this._requestComputerVisionData();e.camera.arCamera=!0;var n=e.camera.interfaceOrientation;switch(e.camera.viewMatrix=e.camera.inverse_viewMatrix,n){case 1:e.camera.cameraOrientation=-90;break;case 2:e.camera.cameraOrientation=90;break;case 3:e.camera.cameraOrientation=0;break;case 4:e.camera.cameraOrientation=180}switch(e.frame.pixelFormatType){case"kCVPixelFormatType_420YpCbCr8BiPlanarFullRange":e.frame.pixelFormat="YUV420P";break;default:e.frame.pixelFormat=e.frame.pixelFormatType}var r=new XRVideoFrame(e.frame.buffers,e.frame.pixelFormat,this._adjustARKitTime(e.frame.timestamp),e.camera);this.dispatchEvent(new CustomEvent(t.COMPUTER_VISION_DATA,{source:this,detail:r}))}},{key:"_requestComputerVisionData",value:function(){window.webkit.messageHandlers.requestComputerVisionData.postMessage({})}},{key:"_startSendingComputerVisionData",value:function(){window.webkit.messageHandlers.startSendingComputerVisionData.postMessage({})}},{key:"_stopSendingComputerVisionData",value:function(){window.webkit.messageHandlers.stopSendingComputerVisionData.postMessage({})}},{key:"deviceId",get:function(){return this._deviceId}},{key:"isWatching",get:function(){return this._isWatching}},{key:"isInitialized",get:function(){return this._isInitialized}},{key:"hasData",get:function(){return null!==this._rawARData}}],[{key:"GetOrCreate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(void 0===t.GLOBAL_INSTANCE){t.GLOBAL_INSTANCE=new t,e=e&&"object"==(void 0===e?"undefined":l(e))?e:{};var n={browser:!0,points:!0,focus:!1,rec:!0,rec_time:!0,mic:!1,build:!1,plane:!0,warnings:!0,anchors:!1,debug:!0,statistics:!1},r="object"==l(e.ui)?e.ui:{};e.ui=Object.assign(n,r),t.GLOBAL_INSTANCE._sendInit(e)}return t.GLOBAL_INSTANCE}},{key:"HasARKit",value:function(){return void 0!==window.webkit}}]),t}(c.default);t.default=x,x.INIT_EVENT="arkit-init",x.WATCH_EVENT="arkit-watch",x.RECORD_START_EVENT="arkit-record-start",x.RECORD_STOP_EVENT="arkit-record-stop",x.DID_MOVE_BACKGROUND_EVENT="arkit-did-move-background",x.WILL_ENTER_FOREGROUND_EVENT="arkit-will-enter-foreground",x.INTERRUPTED_EVENT="arkit-interrupted",x.INTERRUPTION_ENDED_EVENT="arkit-interruption-ended",x.SHOW_DEBUG_EVENT="arkit-show-debug",x.WINDOW_RESIZE_EVENT="arkit-window-resize",x.ON_ERROR="on-error",x.AR_TRACKING_CHANGED="ar_tracking_changed",x.COMPUTER_VISION_DATA="cv_data",x.USER_GRANTED_COMPUTER_VISION_DATA="user-granted-cv-data",x.HIT_TEST_TYPE_FEATURE_POINT=1,x.HIT_TEST_TYPE_ESTIMATED_HORIZONTAL_PLANE=2,x.HIT_TEST_TYPE_ESTIMATED_VERTICAL_PLANE=4,x.HIT_TEST_TYPE_EXISTING_PLANE=8,x.HIT_TEST_TYPE_EXISTING_PLANE_USING_EXTENT=16,x.HIT_TEST_TYPE_EXISTING_PLANE_USING_GEOMETRY=32,x.HIT_TEST_TYPE_ALL=x.HIT_TEST_TYPE_FEATURE_POINT|x.HIT_TEST_TYPE_EXISTING_PLANE|x.HIT_TEST_TYPE_ESTIMATED_HORIZONTAL_PLANE|x.HIT_TEST_TYPE_EXISTING_PLANE_USING_EXTENT,x.HIT_TEST_TYPE_EXISTING_PLANES=x.HIT_TEST_TYPE_EXISTING_PLANE|x.HIT_TEST_TYPE_EXISTING_PLANE_USING_EXTENT},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(t,n,i,a){r(this,e),this._upDegrees=t,this._downDegrees=n,this._leftDegrees=i,this._rightDegrees=a}return i(e,[{key:"upDegrees",get:function(){return this._upDegrees}},{key:"downDegrees",get:function(){return this._downDegrees}},{key:"leftDegrees",get:function(){return this._leftDegrees}},{key:"rightDegrees",get:function(){return this._rightDegrees}}]),e}();t.default=a},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e),this._ambientLightIntensity=1}return i(e,[{key:"getAmbientColorTemperature",value:function(){throw new Error("Not implemented")}},{key:"ambientIntensity",set:function(e){this._ambientLightIntensity=e/1e3},get:function(){return this._ambientLightIntensity}}]),e}();t.default=a},function(e,t,n){function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(0),s=r(o),u=n(1),l=r(u),h=n(4),f=(r(h),function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;i(this,e),this._anchorUID=t,this._tempArray=new Float32Array(16),this._poseMatrix=n||s.default.mat4_generateIdentity()}return a(e,[{key:"setIdentityOffset",value:function(){var e=this._poseMatrix;e[0]=e[5]=e[10]=e[15]=1,e[1]=e[2]=e[3]=0,e[4]=e[6]=e[7]=0,e[8]=e[9]=e[11]=0,e[12]=e[13]=e[14]=0}},{key:"getOffsetTransform",value:function(e){return s.default.mat4_multiply(this._tempArray,this._poseMatrix,e._poseModelMatrix)}},{key:"anchorUID",get:function(){return this._anchorUID}},{key:"poseMatrix",get:function(){return this._poseMatrix},set:function(e){for(var t=0;t<16;t++)this._poseMatrix[t]=e[t]}},{key:"position",get:function(){return new Float32Array([this._poseMatrix[12],this._poseMatrix[13],this._poseMatrix[14]])}},{key:"orientation",get:function(){var e=new l.default;return e.setFromRotationMatrix(this._poseMatrix),e.toArray()}}]),e}());t.default=f},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(t,n,i,a){r(this,e),this._x=t,this._y=n,this._width=i,this._height=a}return i(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e}},{key:"y",get:function(){return this._y},set:function(e){this._y=e}},{key:"width",get:function(){return this._width},set:function(e){this._width=e}},{key:"height",get:function(){return this._height},set:function(e){this._height=e}}]),e}();t.default=a},function(e,t,n){function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":r(t))&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":r(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=n(2),u=function(e){return e&&e.__esModule?e:{default:e}}(s),l=function(e){function t(){return i(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),t}(u.default);t.default=l},function(e,t,n){function r(){var e=new q.ARRAY_TYPE(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function i(e){var t=new q.ARRAY_TYPE(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function a(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function o(e,t,n,r,i,a,o,s,u,l,h,f,c,d,_,v){var p=new q.ARRAY_TYPE(16);return p[0]=e,p[1]=t,p[2]=n,p[3]=r,p[4]=i,p[5]=a,p[6]=o,p[7]=s,p[8]=u,p[9]=l,p[10]=h,p[11]=f,p[12]=c,p[13]=d,p[14]=_,p[15]=v,p}function s(e,t,n,r,i,a,o,s,u,l,h,f,c,d,_,v,p){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=a,e[5]=o,e[6]=s,e[7]=u,e[8]=l,e[9]=h,e[10]=f,e[11]=c,e[12]=d,e[13]=_,e[14]=v,e[15]=p,e}function u(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function l(e,t){if(e===t){var n=t[1],r=t[2],i=t[3],a=t[6],o=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=a,e[11]=t[14],e[12]=i,e[13]=o,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function h(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],h=t[8],f=t[9],c=t[10],d=t[11],_=t[12],v=t[13],p=t[14],y=t[15],m=n*s-r*o,b=n*u-i*o,w=n*l-a*o,M=r*u-i*s,g=r*l-a*s,E=i*l-a*u,A=h*v-f*_,x=h*p-c*_,T=h*y-d*_,R=f*p-c*v,O=f*y-d*v,P=c*y-d*p,k=m*P-b*O+w*R+M*T-g*x+E*A;return k?(k=1/k,e[0]=(s*P-u*O+l*R)*k,e[1]=(i*O-r*P-a*R)*k,e[2]=(v*E-p*g+y*M)*k,e[3]=(c*g-f*E-d*M)*k,e[4]=(u*T-o*P-l*x)*k,e[5]=(n*P-i*T+a*x)*k,e[6]=(p*w-_*E-y*b)*k,e[7]=(h*E-c*w+d*b)*k,e[8]=(o*O-s*T+l*A)*k,e[9]=(r*T-n*O-a*A)*k,e[10]=(_*g-v*w+y*m)*k,e[11]=(f*w-h*g-d*m)*k,e[12]=(s*x-o*R-u*A)*k,e[13]=(n*R-r*x+i*A)*k,e[14]=(v*b-_*M-p*m)*k,e[15]=(h*M-f*b+c*m)*k,e):null}function f(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],h=t[8],f=t[9],c=t[10],d=t[11],_=t[12],v=t[13],p=t[14],y=t[15];return e[0]=s*(c*y-d*p)-f*(u*y-l*p)+v*(u*d-l*c),e[1]=-(r*(c*y-d*p)-f*(i*y-a*p)+v*(i*d-a*c)),e[2]=r*(u*y-l*p)-s*(i*y-a*p)+v*(i*l-a*u),e[3]=-(r*(u*d-l*c)-s*(i*d-a*c)+f*(i*l-a*u)),e[4]=-(o*(c*y-d*p)-h*(u*y-l*p)+_*(u*d-l*c)),e[5]=n*(c*y-d*p)-h*(i*y-a*p)+_*(i*d-a*c),e[6]=-(n*(u*y-l*p)-o*(i*y-a*p)+_*(i*l-a*u)),e[7]=n*(u*d-l*c)-o*(i*d-a*c)+h*(i*l-a*u),e[8]=o*(f*y-d*v)-h*(s*y-l*v)+_*(s*d-l*f),e[9]=-(n*(f*y-d*v)-h*(r*y-a*v)+_*(r*d-a*f)),e[10]=n*(s*y-l*v)-o*(r*y-a*v)+_*(r*l-a*s),e[11]=-(n*(s*d-l*f)-o*(r*d-a*f)+h*(r*l-a*s)),e[12]=-(o*(f*p-c*v)-h*(s*p-u*v)+_*(s*c-u*f)),e[13]=n*(f*p-c*v)-h*(r*p-i*v)+_*(r*c-i*f),e[14]=-(n*(s*p-u*v)-o*(r*p-i*v)+_*(r*u-i*s)),e[15]=n*(s*c-u*f)-o*(r*c-i*f)+h*(r*u-i*s),e}function c(e){var t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],l=e[8],h=e[9],f=e[10],c=e[11],d=e[12],_=e[13],v=e[14],p=e[15];return(t*o-n*a)*(f*p-c*v)-(t*s-r*a)*(h*p-c*_)+(t*u-i*a)*(h*v-f*_)+(n*s-r*o)*(l*p-c*d)-(n*u-i*o)*(l*v-f*d)+(r*u-i*s)*(l*_-h*d)}function d(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],l=t[6],h=t[7],f=t[8],c=t[9],d=t[10],_=t[11],v=t[12],p=t[13],y=t[14],m=t[15],b=n[0],w=n[1],M=n[2],g=n[3];return e[0]=b*r+w*s+M*f+g*v,e[1]=b*i+w*u+M*c+g*p,e[2]=b*a+w*l+M*d+g*y,e[3]=b*o+w*h+M*_+g*m,b=n[4],w=n[5],M=n[6],g=n[7],e[4]=b*r+w*s+M*f+g*v,e[5]=b*i+w*u+M*c+g*p,e[6]=b*a+w*l+M*d+g*y,e[7]=b*o+w*h+M*_+g*m,b=n[8],w=n[9],M=n[10],g=n[11],e[8]=b*r+w*s+M*f+g*v,e[9]=b*i+w*u+M*c+g*p,e[10]=b*a+w*l+M*d+g*y,e[11]=b*o+w*h+M*_+g*m,b=n[12],w=n[13],M=n[14],g=n[15],e[12]=b*r+w*s+M*f+g*v,e[13]=b*i+w*u+M*c+g*p,e[14]=b*a+w*l+M*d+g*y,e[15]=b*o+w*h+M*_+g*m,e}function _(e,t,n){var r=n[0],i=n[1],a=n[2],o=void 0,s=void 0,u=void 0,l=void 0,h=void 0,f=void 0,c=void 0,d=void 0,_=void 0,v=void 0,p=void 0,y=void 0;return t===e?(e[12]=t[0]*r+t[4]*i+t[8]*a+t[12],e[13]=t[1]*r+t[5]*i+t[9]*a+t[13],e[14]=t[2]*r+t[6]*i+t[10]*a+t[14],e[15]=t[3]*r+t[7]*i+t[11]*a+t[15]):(o=t[0],s=t[1],u=t[2],l=t[3],h=t[4],f=t[5],c=t[6],d=t[7],_=t[8],v=t[9],p=t[10],y=t[11],e[0]=o,e[1]=s,e[2]=u,e[3]=l,e[4]=h,e[5]=f,e[6]=c,e[7]=d,e[8]=_,e[9]=v,e[10]=p,e[11]=y,e[12]=o*r+h*i+_*a+t[12],e[13]=s*r+f*i+v*a+t[13],e[14]=u*r+c*i+p*a+t[14],e[15]=l*r+d*i+y*a+t[15]),e}function v(e,t,n){var r=n[0],i=n[1],a=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function p(e,t,n,r){var i=r[0],a=r[1],o=r[2],s=Math.sqrt(i*i+a*a+o*o),u=void 0,l=void 0,h=void 0,f=void 0,c=void 0,d=void 0,_=void 0,v=void 0,p=void 0,y=void 0,m=void 0,b=void 0,w=void 0,M=void 0,g=void 0,E=void 0,A=void 0,x=void 0,T=void 0,R=void 0,O=void 0,P=void 0,k=void 0,I=void 0;return Math.abs(s)<q.EPSILON?null:(s=1/s,i*=s,a*=s,o*=s,u=Math.sin(n),l=Math.cos(n),h=1-l,f=t[0],c=t[1],d=t[2],_=t[3],v=t[4],p=t[5],y=t[6],m=t[7],b=t[8],w=t[9],M=t[10],g=t[11],E=i*i*h+l,A=a*i*h+o*u,x=o*i*h-a*u,T=i*a*h-o*u,R=a*a*h+l,O=o*a*h+i*u,P=i*o*h+a*u,k=a*o*h-i*u,I=o*o*h+l,e[0]=f*E+v*A+b*x,e[1]=c*E+p*A+w*x,e[2]=d*E+y*A+M*x,e[3]=_*E+m*A+g*x,e[4]=f*T+v*R+b*O,e[5]=c*T+p*R+w*O,e[6]=d*T+y*R+M*O,e[7]=_*T+m*R+g*O,e[8]=f*P+v*k+b*I,e[9]=c*P+p*k+w*I,e[10]=d*P+y*k+M*I,e[11]=_*P+m*k+g*I,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function y(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[4],o=t[5],s=t[6],u=t[7],l=t[8],h=t[9],f=t[10],c=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=a*i+l*r,e[5]=o*i+h*r,e[6]=s*i+f*r,e[7]=u*i+c*r,e[8]=l*i-a*r,e[9]=h*i-o*r,e[10]=f*i-s*r,e[11]=c*i-u*r,e}function m(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],u=t[3],l=t[8],h=t[9],f=t[10],c=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*i-l*r,e[1]=o*i-h*r,e[2]=s*i-f*r,e[3]=u*i-c*r,e[8]=a*r+l*i,e[9]=o*r+h*i,e[10]=s*r+f*i,e[11]=u*r+c*i,e}function b(e,t,n){var r=Math.sin(n),i=Math.cos(n),a=t[0],o=t[1],s=t[2],u=t[3],l=t[4],h=t[5],f=t[6],c=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=a*i+l*r,e[1]=o*i+h*r,e[2]=s*i+f*r,e[3]=u*i+c*r,e[4]=l*i-a*r,e[5]=h*i-o*r,e[6]=f*i-s*r,e[7]=c*i-u*r,e}function w(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function M(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function g(e,t,n){var r=n[0],i=n[1],a=n[2],o=Math.sqrt(r*r+i*i+a*a),s=void 0,u=void 0,l=void 0;return Math.abs(o)<q.EPSILON?null:(o=1/o,r*=o,i*=o,a*=o,s=Math.sin(t),u=Math.cos(t),l=1-u,e[0]=r*r*l+u,e[1]=i*r*l+a*s,e[2]=a*r*l-i*s,e[3]=0,e[4]=r*i*l-a*s,e[5]=i*i*l+u,e[6]=a*i*l+r*s,e[7]=0,e[8]=r*a*l+i*s,e[9]=i*a*l-r*s,e[10]=a*a*l+u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function E(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r,e[6]=n,e[7]=0,e[8]=0,e[9]=-n,e[10]=r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function A(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=0,e[2]=-n,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=n,e[9]=0,e[10]=r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function x(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=0,e[3]=0,e[4]=-n,e[5]=r,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function T(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=r+r,u=i+i,l=a+a,h=r*s,f=r*u,c=r*l,d=i*u,_=i*l,v=a*l,p=o*s,y=o*u,m=o*l;return e[0]=1-(d+v),e[1]=f+m,e[2]=c-y,e[3]=0,e[4]=f-m,e[5]=1-(h+v),e[6]=_+p,e[7]=0,e[8]=c+y,e[9]=_-p,e[10]=1-(h+d),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function R(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function O(e,t){var n=t[0],r=t[1],i=t[2],a=t[4],o=t[5],s=t[6],u=t[8],l=t[9],h=t[10];return e[0]=Math.sqrt(n*n+r*r+i*i),e[1]=Math.sqrt(a*a+o*o+s*s),e[2]=Math.sqrt(u*u+l*l+h*h),e}function P(e,t){var n=t[0]+t[5]+t[10],r=0;return n>0?(r=2*Math.sqrt(n+1),e[3]=.25*r,e[0]=(t[6]-t[9])/r,e[1]=(t[8]-t[2])/r,e[2]=(t[1]-t[4])/r):t[0]>t[5]&&t[0]>t[10]?(r=2*Math.sqrt(1+t[0]-t[5]-t[10]),e[3]=(t[6]-t[9])/r,e[0]=.25*r,e[1]=(t[1]+t[4])/r,e[2]=(t[8]+t[2])/r):t[5]>t[10]?(r=2*Math.sqrt(1+t[5]-t[0]-t[10]),e[3]=(t[8]-t[2])/r,e[0]=(t[1]+t[4])/r,e[1]=.25*r,e[2]=(t[6]+t[9])/r):(r=2*Math.sqrt(1+t[10]-t[0]-t[5]),e[3]=(t[1]-t[4])/r,e[0]=(t[8]+t[2])/r,e[1]=(t[6]+t[9])/r,e[2]=.25*r),e}function k(e,t,n,r){var i=t[0],a=t[1],o=t[2],s=t[3],u=i+i,l=a+a,h=o+o,f=i*u,c=i*l,d=i*h,_=a*l,v=a*h,p=o*h,y=s*u,m=s*l,b=s*h,w=r[0],M=r[1],g=r[2];return e[0]=(1-(_+p))*w,e[1]=(c+b)*w,e[2]=(d-m)*w,e[3]=0,e[4]=(c-b)*M,e[5]=(1-(f+p))*M,e[6]=(v+y)*M,e[7]=0,e[8]=(d+m)*g,e[9]=(v-y)*g,e[10]=(1-(f+_))*g,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function I(e,t,n,r,i){var a=t[0],o=t[1],s=t[2],u=t[3],l=a+a,h=o+o,f=s+s,c=a*l,d=a*h,_=a*f,v=o*h,p=o*f,y=s*f,m=u*l,b=u*h,w=u*f,M=r[0],g=r[1],E=r[2],A=i[0],x=i[1],T=i[2],R=(1-(v+y))*M,O=(d+w)*M,P=(_-b)*M,k=(d-w)*g,I=(1-(c+y))*g,S=(p+m)*g,C=(_+b)*E,F=(p-m)*E,N=(1-(c+v))*E;return e[0]=R,e[1]=O,e[2]=P,e[3]=0,e[4]=k,e[5]=I,e[6]=S,e[7]=0,e[8]=C,e[9]=F,e[10]=N,e[11]=0,e[12]=n[0]+A-(R*A+k*x+C*T),e[13]=n[1]+x-(O*A+I*x+F*T),e[14]=n[2]+T-(P*A+S*x+N*T),e[15]=1,e}function S(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=n+n,s=r+r,u=i+i,l=n*o,h=r*o,f=r*s,c=i*o,d=i*s,_=i*u,v=a*o,p=a*s,y=a*u;return e[0]=1-f-_,e[1]=h+y,e[2]=c-p,e[3]=0,e[4]=h-y,e[5]=1-l-_,e[6]=d+v,e[7]=0,e[8]=c+p,e[9]=d-v,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function C(e,t,n,r,i,a,o){var s=1/(n-t),u=1/(i-r),l=1/(a-o);return e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*u,e[6]=0,e[7]=0,e[8]=(n+t)*s,e[9]=(i+r)*u,e[10]=(o+a)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*l,e[15]=0,e}function F(e,t,n,r,i){var a=1/Math.tan(t/2),o=1/(r-i);return e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(i+r)*o,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*i*r*o,e[15]=0,e}function N(e,t,n,r){var i=Math.tan(t.upDegrees*Math.PI/180),a=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),u=2/(o+s),l=2/(i+a);return e[0]=u,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-(o-s)*u*.5,e[9]=(i-a)*l*.5,e[10]=r/(n-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*n/(n-r),e[15]=0,e}function D(e,t,n,r,i,a,o){var s=1/(t-n),u=1/(r-i),l=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*u,e[14]=(o+a)*l,e[15]=1,e}function L(e,t,n,r){var i=void 0,a=void 0,o=void 0,s=void 0,l=void 0,h=void 0,f=void 0,c=void 0,d=void 0,_=void 0,v=t[0],p=t[1],y=t[2],m=r[0],b=r[1],w=r[2],M=n[0],g=n[1],E=n[2];return Math.abs(v-M)<q.EPSILON&&Math.abs(p-g)<q.EPSILON&&Math.abs(y-E)<q.EPSILON?u(e):(f=v-M,c=p-g,d=y-E,_=1/Math.sqrt(f*f+c*c+d*d),f*=_,c*=_,d*=_,i=b*d-w*c,a=w*f-m*d,o=m*c-b*f,_=Math.sqrt(i*i+a*a+o*o),_?(_=1/_,i*=_,a*=_,o*=_):(i=0,a=0,o=0),s=c*o-d*a,l=d*i-f*o,h=f*a-c*i,_=Math.sqrt(s*s+l*l+h*h),_?(_=1/_,s*=_,l*=_,h*=_):(s=0,l=0,h=0),e[0]=i,e[1]=s,e[2]=f,e[3]=0,e[4]=a,e[5]=l,e[6]=c,e[7]=0,e[8]=o,e[9]=h,e[10]=d,e[11]=0,e[12]=-(i*v+a*p+o*y),e[13]=-(s*v+l*p+h*y),e[14]=-(f*v+c*p+d*y),e[15]=1,e)}function j(e,t,n,r){var i=t[0],a=t[1],o=t[2],s=r[0],u=r[1],l=r[2],h=i-n[0],f=a-n[1],c=o-n[2],d=h*h+f*f+c*c;d>0&&(d=1/Math.sqrt(d),h*=d,f*=d,c*=d);var _=u*c-l*f,v=l*h-s*c,p=s*f-u*h;return d=_*_+v*v+p*p,d>0&&(d=1/Math.sqrt(d),_*=d,v*=d,p*=d),e[0]=_,e[1]=v,e[2]=p,e[3]=0,e[4]=f*p-c*v,e[5]=c*_-h*p,e[6]=h*v-f*_,e[7]=0,e[8]=h,e[9]=f,e[10]=c,e[11]=0,e[12]=i,e[13]=a,e[14]=o,e[15]=1,e}function V(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"}function W(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2)+Math.pow(e[9],2)+Math.pow(e[10],2)+Math.pow(e[11],2)+Math.pow(e[12],2)+Math.pow(e[13],2)+Math.pow(e[14],2)+Math.pow(e[15],2))}function G(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e[4]=t[4]+n[4],e[5]=t[5]+n[5],e[6]=t[6]+n[6],e[7]=t[7]+n[7],e[8]=t[8]+n[8],e[9]=t[9]+n[9],e[10]=t[10]+n[10],e[11]=t[11]+n[11],e[12]=t[12]+n[12],e[13]=t[13]+n[13],e[14]=t[14]+n[14],e[15]=t[15]+n[15],e}function H(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e[4]=t[4]-n[4],e[5]=t[5]-n[5],e[6]=t[6]-n[6],e[7]=t[7]-n[7],e[8]=t[8]-n[8],e[9]=t[9]-n[9],e[10]=t[10]-n[10],e[11]=t[11]-n[11],e[12]=t[12]-n[12],e[13]=t[13]-n[13],e[14]=t[14]-n[14],e[15]=t[15]-n[15],e}function Y(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*n,e[9]=t[9]*n,e[10]=t[10]*n,e[11]=t[11]*n,e[12]=t[12]*n,e[13]=t[13]*n,e[14]=t[14]*n,e[15]=t[15]*n,e}function U(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e[4]=t[4]+n[4]*r,e[5]=t[5]+n[5]*r,e[6]=t[6]+n[6]*r,e[7]=t[7]+n[7]*r,e[8]=t[8]+n[8]*r,e[9]=t[9]+n[9]*r,e[10]=t[10]+n[10]*r,e[11]=t[11]+n[11]*r,e[12]=t[12]+n[12]*r,e[13]=t[13]+n[13]*r,e[14]=t[14]+n[14]*r,e[15]=t[15]+n[15]*r,e}function X(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function z(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],u=e[6],l=e[7],h=e[8],f=e[9],c=e[10],d=e[11],_=e[12],v=e[13],p=e[14],y=e[15],m=t[0],b=t[1],w=t[2],M=t[3],g=t[4],E=t[5],A=t[6],x=t[7],T=t[8],R=t[9],O=t[10],P=t[11],k=t[12],I=t[13],S=t[14],C=t[15];return Math.abs(n-m)<=q.EPSILON*Math.max(1,Math.abs(n),Math.abs(m))&&Math.abs(r-b)<=q.EPSILON*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(i-w)<=q.EPSILON*Math.max(1,Math.abs(i),Math.abs(w))&&Math.abs(a-M)<=q.EPSILON*Math.max(1,Math.abs(a),Math.abs(M))&&Math.abs(o-g)<=q.EPSILON*Math.max(1,Math.abs(o),Math.abs(g))&&Math.abs(s-E)<=q.EPSILON*Math.max(1,Math.abs(s),Math.abs(E))&&Math.abs(u-A)<=q.EPSILON*Math.max(1,Math.abs(u),Math.abs(A))&&Math.abs(l-x)<=q.EPSILON*Math.max(1,Math.abs(l),Math.abs(x))&&Math.abs(h-T)<=q.EPSILON*Math.max(1,Math.abs(h),Math.abs(T))&&Math.abs(f-R)<=q.EPSILON*Math.max(1,Math.abs(f),Math.abs(R))&&Math.abs(c-O)<=q.EPSILON*Math.max(1,Math.abs(c),Math.abs(O))&&Math.abs(d-P)<=q.EPSILON*Math.max(1,Math.abs(d),Math.abs(P))&&Math.abs(_-k)<=q.EPSILON*Math.max(1,Math.abs(_),Math.abs(k))&&Math.abs(v-I)<=q.EPSILON*Math.max(1,Math.abs(v),Math.abs(I))&&Math.abs(p-S)<=q.EPSILON*Math.max(1,Math.abs(p),Math.abs(S))&&Math.abs(y-C)<=q.EPSILON*Math.max(1,Math.abs(y),Math.abs(C))}Object.defineProperty(t,"__esModule",{value:!0}),t.sub=t.mul=void 0,t.create=r,t.clone=i,t.copy=a,t.fromValues=o,t.set=s,t.identity=u,t.transpose=l,t.invert=h,t.adjoint=f,t.determinant=c,t.multiply=d,t.translate=_,t.scale=v,t.rotate=p,t.rotateX=y,t.rotateY=m,t.rotateZ=b,t.fromTranslation=w,t.fromScaling=M,t.fromRotation=g,t.fromXRotation=E,t.fromYRotation=A,t.fromZRotation=x,t.fromRotationTranslation=T,t.getTranslation=R,t.getScaling=O,t.getRotation=P,t.fromRotationTranslationScale=k,t.fromRotationTranslationScaleOrigin=I,t.fromQuat=S,t.frustum=C,t.perspective=F,t.perspectiveFromFieldOfView=N,t.ortho=D,t.lookAt=L,t.targetTo=j,t.str=V,t.frob=W,t.add=G,t.subtract=H,t.multiplyScalar=Y,t.multiplyScalarAndAdd=U,t.exactEquals=X,t.equals=z;var B=n(3),q=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(B);t.mul=d,t.sub=H},function(e,t,n){function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(){var e=new w.ARRAY_TYPE(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function a(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function o(e,t,n){n*=.5;var r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e}function s(e,t){var n=2*Math.acos(t[3]),r=Math.sin(n/2);return 0!=r?(e[0]=t[0]/r,e[1]=t[1]/r,e[2]=t[2]/r):(e[0]=1,e[1]=0,e[2]=0),n}function u(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=n[0],u=n[1],l=n[2],h=n[3];return e[0]=r*h+o*s+i*l-a*u,e[1]=i*h+o*u+a*s-r*l,e[2]=a*h+o*l+r*u-i*s,e[3]=o*h-r*s-i*u-a*l,e}function l(e,t,n){n*=.5;var r=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(n),u=Math.cos(n);return e[0]=r*u+o*s,e[1]=i*u+a*s,e[2]=a*u-i*s,e[3]=o*u-r*s,e}function h(e,t,n){n*=.5;var r=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(n),u=Math.cos(n);return e[0]=r*u-a*s,e[1]=i*u+o*s,e[2]=a*u+r*s,e[3]=o*u-i*s,e}function f(e,t,n){n*=.5;var r=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(n),u=Math.cos(n);return e[0]=r*u+i*s,e[1]=i*u-r*s,e[2]=a*u+o*s,e[3]=o*u-a*s,e}function c(e,t){var n=t[0],r=t[1],i=t[2];return e[0]=n,e[1]=r,e[2]=i,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-i*i)),e}function d(e,t,n,r){var i=t[0],a=t[1],o=t[2],s=t[3],u=n[0],l=n[1],h=n[2],f=n[3],c=void 0,d=void 0,_=void 0,v=void 0,p=void 0;return d=i*u+a*l+o*h+s*f,d<0&&(d=-d,u=-u,l=-l,h=-h,f=-f),1-d>1e-6?(c=Math.acos(d),_=Math.sin(c),v=Math.sin((1-r)*c)/_,p=Math.sin(r*c)/_):(v=1-r,p=r),e[0]=v*i+p*u,e[1]=v*a+p*l,e[2]=v*o+p*h,e[3]=v*s+p*f,e}function _(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=n*n+r*r+i*i+a*a,s=o?1/o:0;return e[0]=-n*s,e[1]=-r*s,e[2]=-i*s,e[3]=a*s,e}function v(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function p(e,t){var n=t[0]+t[4]+t[8],r=void 0;if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var a=(i+1)%3,o=(i+2)%3;r=Math.sqrt(t[3*i+i]-t[3*a+a]-t[3*o+o]+1),e[i]=.5*r,r=.5/r,e[3]=(t[3*a+o]-t[3*o+a])*r,e[a]=(t[3*a+i]+t[3*i+a])*r,e[o]=(t[3*o+i]+t[3*i+o])*r}return e}function y(e,t,n,r){var i=.5*Math.PI/180;t*=i,n*=i,r*=i;var a=Math.sin(t),o=Math.cos(t),s=Math.sin(n),u=Math.cos(n),l=Math.sin(r),h=Math.cos(r);return e[0]=a*u*h-o*s*l,e[1]=o*s*h+a*u*l,e[2]=o*u*l-a*s*h,e[3]=o*u*h+a*s*l,e}function m(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}Object.defineProperty(t,"__esModule",{value:!0}),t.setAxes=t.sqlerp=t.rotationTo=t.equals=t.exactEquals=t.normalize=t.sqrLen=t.squaredLength=t.len=t.length=t.lerp=t.dot=t.scale=t.mul=t.add=t.set=t.copy=t.fromValues=t.clone=void 0,t.create=i,t.identity=a,t.setAxisAngle=o,t.getAxisAngle=s,t.multiply=u,t.rotateX=l,t.rotateY=h,t.rotateZ=f,t.calculateW=c,t.slerp=d,t.invert=_,t.conjugate=v,t.fromMat3=p,t.fromEuler=y,t.str=m;var b=n(3),w=r(b),M=n(33),g=r(M),E=n(10),A=r(E),x=n(34),T=r(x),R=(t.clone=T.clone,t.fromValues=T.fromValues,t.copy=T.copy,t.set=T.set,t.add=T.add,t.mul=u,t.scale=T.scale,t.dot=T.dot,t.lerp=T.lerp,t.length=T.length),O=(t.len=R,t.squaredLength=T.squaredLength),P=(t.sqrLen=O,t.normalize=T.normalize);t.exactEquals=T.exactEquals,t.equals=T.equals,t.rotationTo=function(){var e=A.create(),t=A.fromValues(1,0,0),n=A.fromValues(0,1,0);return function(r,i,a){var s=A.dot(i,a);return s<-.999999?(A.cross(e,t,i),A.len(e)<1e-6&&A.cross(e,n,i),A.normalize(e,e),o(r,e,Math.PI),r):s>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(A.cross(e,i,a),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+s,P(r,r))}}(),t.sqlerp=function(){var e=i(),t=i();return function(n,r,i,a,o,s){return d(e,r,o,s),d(t,i,a,s),d(n,e,t,2*s*(1-s)),n}}(),t.setAxes=function(){var e=g.create();return function(t,n,r,i){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],P(t,p(t,e))}}()},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e)}return i(e,null,[{key:"decodeLength",value:function(e){return e.length/4*3}},{key:"decodeArrayBuffer",value:function(e,t){var n=e.length/4*3;return t&&t.byteLength==n||(t=new ArrayBuffer(n)),this.decode(e,t),t}},{key:"removePaddingChars",value:function(e){return 64==this._keyStr.indexOf(e.charAt(e.length-1))?e.substring(0,e.length-1):e}},{key:"decode",value:function(e,t){e=this.removePaddingChars(e),e=this.removePaddingChars(e);var n,r,i,a,o,s,u,l,h=parseInt(e.length/4*3,10),f=0,c=0;for(n=t?new Uint8Array(t):new Uint8Array(h),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,""),f=0;f<h;f+=3)o=this._keyStr.indexOf(e.charAt(c++)),s=this._keyStr.indexOf(e.charAt(c++)),u=this._keyStr.indexOf(e.charAt(c++)),l=this._keyStr.indexOf(e.charAt(c++)),r=o<<2|s>>4,i=(15&s)<<4|u>>2,a=(3&u)<<6|l,n[f]=r,64!=u&&(n[f+1]=i),64!=l&&(n[f+2]=a);return n}},{key:"encode",value:function(e){var t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=e;e instanceof ArrayBuffer?r=new Uint8Array(arrayBuffer):e instanceof ImageData&&(r=e.data);for(var i,a,o,s,u,l=e.length,h=l%3,f=l-h,c=0;c<f;c+=3)u=r[c]<<16|r[c+1]<<8|r[c+2],i=(16515072&u)>>18,a=(258048&u)>>12,o=(4032&u)>>6,s=63&u,t+=n[i]+n[a]+n[o]+n[s];return 1==h?(u=r[f],i=(252&u)>>2,a=(3&u)<<4,t+=n[i]+n[a]+"=="):2==h&&(u=r[f]<<8|r[f+1],i=(64512&u)>>10,a=(1008&u)>>4,o=(15&u)<<2,t+=n[i]+n[a]+n[o]+"="),t}}]),e}();t.default=a,a._keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":r(t))&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":r(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(2),h=i(l),f=n(11),c=i(f),d=n(1),_=i(d),v=n(36),p=i(v),y=function(e){function t(){a(this,t);var e=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e._deviceOrientation=null,e._windowOrientation=0,window.addEventListener("orientationchange",function(){e._windowOrientation=window.orientation||0},!1),window.addEventListener("deviceorientation",function(n){e._deviceOrientation=n,e.dispatchEvent(new CustomEvent(t.ORIENTATION_UPDATE_EVENT,{deviceOrientation:e._deviceOrientation,windowOrientation:e._windowOrientation}))},!1),e}return s(t,e),u(t,[{key:"getOrientation",value:function(e){return null===this._deviceOrientation?(e.set(0,0,0,1),!1):(t.WORKING_EULER.set(this._deviceOrientation.beta*t.DEG_TO_RAD,this._deviceOrientation.alpha*t.DEG_TO_RAD,-1*this._deviceOrientation.gamma*t.DEG_TO_RAD,"YXZ"),e.setFromEuler(t.WORKING_EULER.x,t.WORKING_EULER.y,t.WORKING_EULER.z,t.WORKING_EULER.order),e.multiply(t.HALF_PI_AROUND_X),e.multiply(t.WORKING_QUATERNION.setFromAxisAngle(t.Z_AXIS,-this._windowOrientation*t.DEG_TO_RAD)),!0)}}]),t}(h.default);t.default=y,y.ORIENTATION_UPDATE_EVENT="orientation-update",y.Z_AXIS=new c.default(0,0,1),y.WORKING_EULER=new p.default,y.WORKING_QUATERNION=new _.default,y.HALF_PI_AROUND_X=new _.default(-Math.sqrt(.5),0,0,Math.sqrt(.5)),y.DEG_TO_RAD=Math.PI/180},function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":r(t))&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":r(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(5),h=i(l),f=n(7),c=i(f),d=n(24),_=i(d),v=n(6),p=i(v),y=n(25),m=i(y),b=n(14),w=i(b),M=n(4),g=i(M),E=n(26),A=i(E),x=n(15),T=i(x),R=n(27),O=i(R),P=n(28),k=i(P),I=n(29),S=i(I),C=n(8),F=i(C),N=n(16),D=i(N),L=n(30),j=i(L),V=n(9),W=i(V),G=n(17),H=i(G),Y=n(31),U=i(Y),X=n(32),z=i(X),B=n(2),q=i(B),K=n(35),Z=i(K),Q=n(37),J=i(Q),$=n(38),ee=i($),te=function(e){function t(){a(this,t);var e=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));window.XRDisplay=h.default,window.XRSession=c.default,window.XRSessionCreateParameters=_.default,window.Reality=p.default,window.XRPointCloud=m.default,window.XRLightEstimate=w.default,window.XRAnchor=g.default,window.XRPlaneAnchor=A.default,window.XRAnchorOffset=T.default,window.XRStageBounds=O.default,window.XRStageBoundsPoint=k.default,window.XRPresentationFrame=S.default,window.XRView=F.default,window.XRViewport=D.default,window.XRCoordinateSystem=j.default,window.XRViewPose=W.default,window.XRLayer=H.default,window.XRWebGLLayer=U.default,window.XRVideoFrame=z.default,e._getVRDisplaysFinished=!1,e._sharedRealities=[new ee.default(e)],e._privateRealities=[],e._displays=[new Z.default(e,e._sharedRealities[0])],"function"==typeof navigator.getVRDisplays?navigator.getVRDisplays().then(function(t){var n=!0,r=!1,i=void 0;try{for(var a,o=t[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var s=a.value;null!==s&&(s.capabilities.canPresent&&e._displays.push(new J.default(e,e._sharedRealities[0],s)))}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}e._getVRDisplaysFinished=!0}):e._getVRDisplaysFinished=!0,e._sessionEls=document.createElement("div"),e._sessionEls.setAttribute("class","webxr-sessions"),e._realityEls=document.createElement("div"),e._realityEls.setAttribute("class","webxr-realities");for(var n=[e._sessionEls,e._realityEls],r=0;r<n.length;r++){var i=n[r];i.style.position="absolute",i.style.width="100%",i.style.height="100%"}var s=function(){document.body.style.width="100%",document.body.style.height="100%",document.body.prepend(e._sessionEls),document.body.prepend(e._realityEls)};return"loading"!==document.readyState?s():document.addEventListener("DOMContentLoaded",s),e}return s(t,e),u(t,[{key:"getDisplays",value:function(){var e=this,t=function t(n){e._getVRDisplaysFinished?n(e._displays):setTimeout(t.bind(e,n),30)};return new Promise(function(e,n){t(e)})}}]),t}(q.default);void 0===navigator.XR&&(navigator.XR=new te)},function(e,t,n){function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":r(t))&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":r(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(6),l=function(e){return e&&e.__esModule?e:{default:e}}(u),h=function(e){function t(e){return i(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Virtual",!1,!1))}return o(t,e),s(t,[{key:"_start",value:function(e){}},{key:"_stop",value:function(){}},{key:"_handleNewFrame",value:function(){}},{key:"_addAnchor",value:function(e,t){return this._anchors.set(e.uid,e),e.uid}},{key:"_findAnchor",value:function(e,t,n){return new Promise(function(e,t){e(null)})}},{key:"_removeAnchor",value:function(e){this._anchors.delete(e)}},{key:"_hitTestNoAnchor",value:function(e,t,n){return null}},{key:"_getHasLightEstimate",value:function(){return!1}},{key:"_findFloorAnchor",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=new Float32Array(e._headPose.poseModelMatrix);return new Promise(function(i,a){r[13]=0;var o=new XRCoordinateSystem(e,XRCoordinateSystem.TRACKER);o._relativeMatrix=r;var s=new XRAnchor(o,n);t._addAnchor(s,e),i(new XRAnchorOffset(s.uid))})}}]),t}(l.default);t.default=h},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e)}return i(e,[{key:"exclusive",get:function(){throw"Not implemented"}},{key:"type",get:function(){throw"Not implemented"}}]),e}();t.default=a},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e)}return i(e,[{key:"points",get:function(){throw new Error("Not implemented")}}]),e}();t.default=a},function(e,t,n){function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":r(t))&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":r(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(4),l=function(e){return e&&e.__esModule?e:{default:e}}(u),h=function(e){function t(){return i(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),s(t,[{key:"width",get:function(){throw"Not implemented"}},{key:"length",get:function(){throw"Not implemented"}}]),t}(l.default);t.default=h},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e)}return i(e,[{key:"center",get:function(){throw new Error("Not implemented")}},{key:"geometry",get:function(){throw new Error("Not implemented")}}]),e}();t.default=a},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(){r(this,e)}return i(e,[{key:"x",get:function(){throw new Error("Not implemented")}},{key:"y",get:function(){throw new Error("Not implemented")}}]),e}();t.default=a},function(e,t,n){function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(4),s=r(o),u=n(0),l=r(u),h=function(){function e(t){i(this,e),this._session=t,this._timestamp=this._session.reality._getTimeStamp()}return a(e,[{key:"addAnchor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[0,0,0,1],r=l.default.mat4_fromRotationTranslation(new Float32Array(16),n,t);l.default.mat4_multiply(r,e.getTransformTo(this._session._display._trackerCoordinateSystem),r);var i=new XRCoordinateSystem(this._session._display,XRCoordinateSystem.TRACKER);return i._relativeMatrix=r,this._session.reality._addAnchor(new s.default(i),this._session.display)}},{key:"findAnchor",value:function(e,t){return this._session.reality._findAnchor(e,t,this._session.display)}},{key:"hitTestNoAnchor",value:function(e,t){return this._session.reality._hitTestNoAnchor(e,t,this._session.display)}},{key:"findFloorAnchor",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this._session.reality._findFloorAnchor(this._session.display,e)}},{key:"removeAnchor",value:function(e){return this._session.reality._removeAnchor(e)}},{key:"getAnchor",value:function(e){return this._session.reality._getAnchor(e)}},{key:"getCoordinateSystem",value:function(){var e;return(e=this._session)._getCoordinateSystem.apply(e,arguments)}},{key:"getDisplayPose",value:function(e){switch(e._type){case XRCoordinateSystem.HEAD_MODEL:return this._session._display._headPose;case XRCoordinateSystem.EYE_LEVEL:return this._session._display._eyeLevelPose;default:return null}}},{key:"session",get:function(){return this._session}},{key:"views",get:function(){return this._session._display._views}},{key:"hasPointCloud",get:function(){return!1}},{key:"pointCloud",get:function(){return null}},{key:"hasLightEstimate",get:function(){return this._session.reality._getHasLightEstimate()}},{key:"lightEstimate",get:function(){return this._session.reality._getLightAmbientIntensity()}},{key:"timestamp",get:function(){return this._timestamp}},{key:"anchors",get:function(){var e=[],t=!0,n=!1,r=void 0;try{for(var i,a=this._session.reality._anchors.values()[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;e.push(o)}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}return e}}]),e}();t.default=h},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(0),o=function(e){return e&&e.__esModule?e:{default:e}}(a),s=function(){function e(t,n){r(this,e),this._display=t,this._type=n,this.__relativeMatrix=o.default.mat4_generateIdentity(),this._workingMatrix=o.default.mat4_generateIdentity()}return i(e,[{key:"getTransformTo",value:function(e){var t=o.default.mat4_invert(new Float32Array(16),e._poseModelMatrix),n=o.default.mat4_generateIdentity();return o.default.mat4_multiply(n,t,n),o.default.mat4_multiply(n,this._poseModelMatrix,n),n}},{key:"_relativeMatrix",get:function(){return this.__relativeMatrix},set:function(e){for(var t=0;t<16;t++)this.__relativeMatrix[t]=e[t]}},{key:"_poseModelMatrix",get:function(){switch(this._type){case e.HEAD_MODEL:return this._display._headPose.poseModelMatrix;case e.EYE_LEVEL:return this._display._eyeLevelPose.poseModelMatrix;case e.TRACKER:return o.default.mat4_multiply(this._workingMatrix,this.__relativeMatrix,this._display._trackerPoseModelMatrix),this._workingMatrix;default:throw new Error("Unknown coordinate system type: "+this._type)}}}]),e}();t.default=s,s.HEAD_MODEL="headModel",s.EYE_LEVEL="eyeLevel",s.TRACKER="tracker",s.TYPES=[s.HEAD_MODEL,s.EYE_LEVEL,s.TRACKER]},function(e,t,n){function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":r(t))&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":r(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(17),l=function(e){return e&&e.__esModule?e:{default:e}}(u),h=function(e){function t(e,n){i(this,t);var r=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r._session=e,r._context=n,r._width=r._context.canvas.width,r._height=r._context.canvas.height,r._framebuffer=null,r}return o(t,e),s(t,[{key:"requestViewportScaling",value:function(e){throw"Not implemented"}},{key:"context",get:function(){return this._context}},{key:"antialias",get:function(){throw"Not implemented"}},{key:"depth",get:function(){throw"Not implemented"}},{key:"stencil",get:function(){throw"Not implemented"}},{key:"alpha",get:function(){throw"Not implemented"}},{key:"multiview",get:function(){throw"Not implemented"}},{key:"framebuffer",get:function(){return this._framebuffer}},{key:"framebufferWidth",set:function(e){this._width=e,this._context.canvas.width=e},get:function(){return this._width}},{key:"framebufferHeight",set:function(e){this._height=e,this._context.canvas.height=e},get:function(){return this._height}}]),t}(l.default);t.default=h},function(e,t,n){function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(3),s=(r(o),n(18)),u=(r(s),n(19)),l=(r(u),n(10)),h=(r(l),n(20)),f=function(e){return e&&e.__esModule?e:{default:e}}(h),c=[],d=function(){function e(t,n,r,a){i(this,e),this._buffers=t;for(var o=0;o<t.length;o++)if(t[o]._buffer=t[o].buffer,t[o].buffer=null,t[o]._abCache||"string"!=typeof t[o]._buffer){if(!t[o]._abCache&&t[o]._buffer instanceof ImageData){for(var s=t[o]._buffer.data,u=s.length,l=0;l<c.length;l++)if(c[l].byteLength==u){t[o]._abCache=c[l],c.splice(l,1);break}var h=t[o]._abCache?t[o]._abCache:new ArrayBuffer(u);t[o]._abCache=null;for(var d=new Uint8Array(h),_=0;_<u;_++)d[_]=s[_];t[o]._buffer=h}}else for(var u=f.default.decodeLength(t[o]._buffer),l=0;l<c.length;l++)if(c[l].byteLength==u){t[o]._abCache=c[l],c.splice(l,1);break}this._pixelFormat=n,this._timestamp=r,this._camera=a}return a(e,[{key:"numBuffers",value:function(){this._buffers.length}},{key:"buffer",value:function(e){if(e>=0&&e<this._buffers.length){var t=this._buffers[e];return t.buffer||("string"==typeof t._buffer?(t._buffer=f.default.decodeArrayBuffer(t._buffer,t._abCache),t._abCache=null,t.buffer=new Uint8Array(t._buffer)):t._buffer instanceof ArrayBuffer?t.buffer=new Uint8Array(t._buffer):t._buffer instanceof ImageData&&(t.buffer=ImageData.data)),t}return null}},{key:"release",value:function(){for(var e=this._buffers,t=0;t<e.length;t++)e[t]._buffer instanceof ArrayBuffer&&e[t]._buffer.byteLength>0&&c.push(e[t]._buffer),e[t]._abCache instanceof ArrayBuffer&&e[t]._abCache.byteLength>0&&c.push(e[t]._abCache)}},{key:"postMessageToWorker",value:function(e,t){var n=Object.assign({},t||{});n.buffers=this._buffers,n.timestamp=this._timestamp,n.pixelFormat=this._pixelFormat,n.camera=this._camera;for(var r=[],i=0;i<n.buffers.length;i++)n.buffers[i].buffer=n.buffers[i]._buffer,(n.buffers[i]._buffer instanceof ArrayBuffer||n.buffers[i]._buffer instanceof ImageData)&&r.push(n.buffers[i]._buffer),n.buffers[i]._buffer=null,n.buffers[i]._abCache instanceof ArrayBuffer&&r.push(n.buffers[i]._abCache);e.postMessage(n,r)}},{key:"postReplyMessage",value:function(e){var t=Object.assign({},e);t.buffers=this._buffers,t.timestamp=this._timestamp,t.pixelFormat=this._pixelFormat,t.camera=this._camera;for(var n=[],r=0;r<t.buffers.length;r++)t.buffers[r].buffer=null,(t.buffers[r]._buffer instanceof ArrayBuffer||t.buffers[r]._buffer instanceof ImageData)&&(n.push(t.buffers[r]._buffer),t.buffers[r].buffer=t.buffers[r]._buffer),t.buffers[r]._buffer=null,t.buffers[r]._abCache instanceof ArrayBuffer&&n.push(t.buffers[r]._abCache);postMessage(t,n)}},{key:"pixelFormat",get:function(){return this._pixelFormat}},{key:"timestamp",get:function(){return this._timestamp}},{key:"camera",get:function(){return this._camera}}],[{key:"createFromMessage",value:function(e){return new this(e.data.buffers,e.data.pixelFormat,e.data.timestamp,e.data.camera)}}]),e}();t.default=d,d.IMAGEFORMAT_RGBA32="RGBA32",d.IMAGEFORMAT_BGRA32="BGRA32",d.IMAGEFORMAT_RGB24="RGB24",d.IMAGEFORMAT_BGR24="BGR24",d.IMAGEFORMAT_GRAY8="GRAY8",d.IMAGEFORMAT_YUV444P="YUV444P",d.IMAGEFORMAT_YUV422P="YUV422P",d.IMAGEFORMAT_YUV420P="YUV420P",d.IMAGEFORMAT_YUV420SP_NV12="YUV420SP_NV12",d.IMAGEFORMAT_YUV420SP_NV21="YUV420SP_NV21",d.IMAGEFORMAT_HSV="HSV",d.IMAGEFORMAT_Lab="Lab",d.IMAGEFORMAT_DEPTH="DEPTH",d.IMAGEFORMAT_NULL="",d.IMAGEFORMAT=[d.IMAGEFORMAT_RGBA32,d.IMAGEFORMAT_BGRA32,d.IMAGEFORMAT_RGB24,d.IMAGEFORMAT_BGR24,d.IMAGEFORMAT_GRAY8,d.IMAGEFORMAT_YUV444P,d.IMAGEFORMAT_YUV422P,d.IMAGEFORMAT_YUV420P,d.IMAGEFORMAT_YUV420SP_NV12,d.IMAGEFORMAT_YUV420SP_NV21,d.IMAGEFORMAT_HSV,d.IMAGEFORMAT_Lab,d.IMAGEFORMAT_DEPTH,d.IMAGEFORMAT_NULL]},function(e,t,n){function r(){var e=new F.ARRAY_TYPE(9);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function i(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e}function a(e){var t=new F.ARRAY_TYPE(9);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function o(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function s(e,t,n,r,i,a,o,s,u){var l=new F.ARRAY_TYPE(9);return l[0]=e,l[1]=t,l[2]=n,l[3]=r,l[4]=i,l[5]=a,l[6]=o,l[7]=s,l[8]=u,l}function u(e,t,n,r,i,a,o,s,u,l){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=a,e[5]=o,e[6]=s,e[7]=u,e[8]=l,e}function l(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function h(e,t){if(e===t){var n=t[1],r=t[2],i=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=r,e[7]=i}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}function f(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],h=t[8],f=h*o-s*l,c=-h*a+s*u,d=l*a-o*u,_=n*f+r*c+i*d;return _?(_=1/_,e[0]=f*_,e[1]=(-h*r+i*l)*_,e[2]=(s*r-i*o)*_,e[3]=c*_,e[4]=(h*n-i*u)*_,e[5]=(-s*n+i*a)*_,e[6]=d*_,e[7]=(-l*n+r*u)*_,e[8]=(o*n-r*a)*_,e):null}function c(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],h=t[8];return e[0]=o*h-s*l,e[1]=i*l-r*h,e[2]=r*s-i*o,e[3]=s*u-a*h,e[4]=n*h-i*u,e[5]=i*a-n*s,e[6]=a*l-o*u,e[7]=r*u-n*l,e[8]=n*o-r*a,e}function d(e){var t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],l=e[8];return t*(l*a-o*u)+n*(-l*i+o*s)+r*(u*i-a*s)}function _(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],l=t[6],h=t[7],f=t[8],c=n[0],d=n[1],_=n[2],v=n[3],p=n[4],y=n[5],m=n[6],b=n[7],w=n[8];return e[0]=c*r+d*o+_*l,e[1]=c*i+d*s+_*h,e[2]=c*a+d*u+_*f,e[3]=v*r+p*o+y*l,e[4]=v*i+p*s+y*h,e[5]=v*a+p*u+y*f,e[6]=m*r+b*o+w*l,e[7]=m*i+b*s+w*h,e[8]=m*a+b*u+w*f,e}function v(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],l=t[6],h=t[7],f=t[8],c=n[0],d=n[1];return e[0]=r,e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=u,e[6]=c*r+d*o+l,e[7]=c*i+d*s+h,e[8]=c*a+d*u+f,e}function p(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],l=t[6],h=t[7],f=t[8],c=Math.sin(n),d=Math.cos(n);return e[0]=d*r+c*o,e[1]=d*i+c*s,e[2]=d*a+c*u,e[3]=d*o-c*r,e[4]=d*s-c*i,e[5]=d*u-c*a,e[6]=l,e[7]=h,e[8]=f,e}function y(e,t,n){var r=n[0],i=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=i*t[3],e[4]=i*t[4],e[5]=i*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function m(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e}function b(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=0,e[3]=-n,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function w(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function M(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e}function g(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=n+n,s=r+r,u=i+i,l=n*o,h=r*o,f=r*s,c=i*o,d=i*s,_=i*u,v=a*o,p=a*s,y=a*u;return e[0]=1-f-_,e[3]=h-y,e[6]=c+p,e[1]=h+y,e[4]=1-l-_,e[7]=d-v,e[2]=c-p,e[5]=d+v,e[8]=1-l-f,e}function E(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],l=t[7],h=t[8],f=t[9],c=t[10],d=t[11],_=t[12],v=t[13],p=t[14],y=t[15],m=n*s-r*o,b=n*u-i*o,w=n*l-a*o,M=r*u-i*s,g=r*l-a*s,E=i*l-a*u,A=h*v-f*_,x=h*p-c*_,T=h*y-d*_,R=f*p-c*v,O=f*y-d*v,P=c*y-d*p,k=m*P-b*O+w*R+M*T-g*x+E*A;return k?(k=1/k,e[0]=(s*P-u*O+l*R)*k,e[1]=(u*T-o*P-l*x)*k,e[2]=(o*O-s*T+l*A)*k,e[3]=(i*O-r*P-a*R)*k,e[4]=(n*P-i*T+a*x)*k,e[5]=(r*T-n*O-a*A)*k,e[6]=(v*E-p*g+y*M)*k,e[7]=(p*w-_*E-y*b)*k,e[8]=(_*g-v*w+y*m)*k,e):null}function A(e,t,n){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/n,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e}function x(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"}function T(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2)+Math.pow(e[3],2)+Math.pow(e[4],2)+Math.pow(e[5],2)+Math.pow(e[6],2)+Math.pow(e[7],2)+Math.pow(e[8],2))}function R(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e[4]=t[4]+n[4],e[5]=t[5]+n[5],e[6]=t[6]+n[6],e[7]=t[7]+n[7],e[8]=t[8]+n[8],e}function O(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e[4]=t[4]-n[4],e[5]=t[5]-n[5],e[6]=t[6]-n[6],e[7]=t[7]-n[7],e[8]=t[8]-n[8],e}function P(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*n,e}function k(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e[4]=t[4]+n[4]*r,e[5]=t[5]+n[5]*r,e[6]=t[6]+n[6]*r,e[7]=t[7]+n[7]*r,e[8]=t[8]+n[8]*r,e}function I(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]}function S(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],u=e[6],l=e[7],h=e[8],f=t[0],c=t[1],d=t[2],_=t[3],v=t[4],p=t[5],y=t[6],m=t[7],b=t[8];return Math.abs(n-f)<=F.EPSILON*Math.max(1,Math.abs(n),Math.abs(f))&&Math.abs(r-c)<=F.EPSILON*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(i-d)<=F.EPSILON*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(a-_)<=F.EPSILON*Math.max(1,Math.abs(a),Math.abs(_))&&Math.abs(o-v)<=F.EPSILON*Math.max(1,Math.abs(o),Math.abs(v))&&Math.abs(s-p)<=F.EPSILON*Math.max(1,Math.abs(s),Math.abs(p))&&Math.abs(u-y)<=F.EPSILON*Math.max(1,Math.abs(u),Math.abs(y))&&Math.abs(l-m)<=F.EPSILON*Math.max(1,Math.abs(l),Math.abs(m))&&Math.abs(h-b)<=F.EPSILON*Math.max(1,Math.abs(h),Math.abs(b))}Object.defineProperty(t,"__esModule",{value:!0}),t.sub=t.mul=void 0,t.create=r,t.fromMat4=i,t.clone=a,t.copy=o,t.fromValues=s,t.set=u,t.identity=l,t.transpose=h,t.invert=f,t.adjoint=c,t.determinant=d,t.multiply=_,t.translate=v,t.rotate=p,t.scale=y,t.fromTranslation=m,t.fromRotation=b,t.fromScaling=w,t.fromMat2d=M,t.fromQuat=g,t.normalFromMat4=E,t.projection=A,t.str=x,t.frob=T,t.add=R,t.subtract=O,t.multiplyScalar=P,t.multiplyScalarAndAdd=k,t.exactEquals=I,t.equals=S;var C=n(3),F=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(C);t.mul=_,t.sub=O},function(e,t,n){function r(){var e=new N.ARRAY_TYPE(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function i(e){var t=new N.ARRAY_TYPE(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function a(e,t,n,r){var i=new N.ARRAY_TYPE(4);return i[0]=e,i[1]=t,i[2]=n,i[3]=r,i}function o(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function s(e,t,n,r,i){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e}function u(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function l(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}function h(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}function f(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e[3]=t[3]/n[3],e}function c(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e[3]=Math.ceil(t[3]),e}function d(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e[3]=Math.floor(t[3]),e}function _(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e[3]=Math.min(t[3],n[3]),e}function v(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e[3]=Math.max(t[3],n[3]),e}function p(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e[3]=Math.round(t[3]),e}function y(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function m(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e}function b(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],a=t[3]-e[3];return Math.sqrt(n*n+r*r+i*i+a*a)}function w(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],a=t[3]-e[3];return n*n+r*r+i*i+a*a}function M(e){var t=e[0],n=e[1],r=e[2],i=e[3];return Math.sqrt(t*t+n*n+r*r+i*i)}function g(e){var t=e[0],n=e[1],r=e[2],i=e[3];return t*t+n*n+r*r+i*i}function E(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e}function A(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e}function x(e,t){var n=t[0],r=t[1],i=t[2],a=t[3],o=n*n+r*r+i*i+a*a;return o>0&&(o=1/Math.sqrt(o),e[0]=n*o,e[1]=r*o,e[2]=i*o,e[3]=a*o),e}function T(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function R(e,t,n,r){var i=t[0],a=t[1],o=t[2],s=t[3];return e[0]=i+r*(n[0]-i),e[1]=a+r*(n[1]-a),e[2]=o+r*(n[2]-o),e[3]=s+r*(n[3]-s),e}function O(e,t){return t=t||1,e[0]=N.RANDOM(),e[1]=N.RANDOM(),e[2]=N.RANDOM(),e[3]=N.RANDOM(),x(e,e),y(e,e,t),e}function P(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*a+n[12]*o,e[1]=n[1]*r+n[5]*i+n[9]*a+n[13]*o,e[2]=n[2]*r+n[6]*i+n[10]*a+n[14]*o,e[3]=n[3]*r+n[7]*i+n[11]*a+n[15]*o,e}function k(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[0],s=n[1],u=n[2],l=n[3],h=l*r+s*a-u*i,f=l*i+u*r-o*a,c=l*a+o*i-s*r,d=-o*r-s*i-u*a;return e[0]=h*l+d*-o+f*-u-c*-s,e[1]=f*l+d*-s+c*-o-h*-u,e[2]=c*l+d*-u+h*-s-f*-o,e[3]=t[3],e}function I(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"}function S(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function C(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=t[0],s=t[1],u=t[2],l=t[3];return Math.abs(n-o)<=N.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-s)<=N.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-u)<=N.EPSILON*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(a-l)<=N.EPSILON*Math.max(1,Math.abs(a),Math.abs(l))}Object.defineProperty(t,"__esModule",{value:!0}),t.forEach=t.sqrLen=t.len=t.sqrDist=t.dist=t.div=t.mul=t.sub=void 0,t.create=r,t.clone=i,t.fromValues=a,t.copy=o,t.set=s,t.add=u,t.subtract=l,t.multiply=h,t.divide=f,t.ceil=c,t.floor=d,t.min=_,t.max=v,t.round=p,t.scale=y,t.scaleAndAdd=m,t.distance=b,t.squaredDistance=w,t.length=M,t.squaredLength=g,t.negate=E,t.inverse=A,t.normalize=x,t.dot=T,t.lerp=R,t.random=O,t.transformMat4=P,t.transformQuat=k,t.str=I,t.exactEquals=S,t.equals=C;var F=n(3),N=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(F);t.sub=l,t.mul=h,t.div=f,t.dist=b,t.sqrDist=w,t.len=M,t.sqrLen=g,t.forEach=function(){var e=r();return function(t,n,r,i,a,o){var s=void 0,u=void 0;for(n||(n=4),r||(r=0),u=i?Math.min(i*n+r,t.length):t.length,s=r;s<u;s+=n)e[0]=t[s],e[1]=t[s+1],e[2]=t[s+2],e[3]=t[s+3],a(e,e,o),t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3];return t}}()},function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function a(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":r(t))&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":r(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),h=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,n,r)}if("value"in i)return i.value;var o=i.get;if(void 0!==o)return o.call(r)},f=n(5),c=i(f),d=n(8),_=i(d),v=n(7),p=i(v),y=n(13),m=i(y),b=n(0),w=i(b),M=n(1),g=i(M),E=n(11),A=i(E),x=n(21),T=i(x),R=n(12),O=i(R),P=function(e){function t(e,n){o(this,t);var r=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Flat",!1,n));return r._started=!1,r._initialized=!1,r._arKitWrapper=null,r._vrFrameData=null,r._deviceOrientationTracker=null,r._deviceOrientation=null,r._devicePosition=null,r._deviceWorldMatrix=null,r._views.push(new _.default(r._fov,r._depthNear,r._depthFar)),r}return u(t,e),l(t,[{key:"_start",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._reality._vrDisplay?null===this._vrFrameData&&(this._vrFrameData=new VRFrameData,this._views[0]._depthNear=this._reality._vrDisplay.depthNear,this._views[0]._depthFar=this._reality._vrDisplay.depthFar,this._deviceOrientation=new g.default,this._devicePosition=new A.default,this._deviceWorldMatrix=new Float32Array(16)):O.default.HasARKit()?!1===this._initialized&&(this._initialized=!0,this._arKitWrapper=O.default.GetOrCreate(),this._arKitWrapper.addEventListener(O.default.INIT_EVENT,this._handleARKitInit.bind(this)),this._arKitWrapper.addEventListener(O.default.WATCH_EVENT,this._handleARKitUpdate.bind(this)),this._arKitWrapper.addEventListener(O.default.WINDOW_RESIZE_EVENT,this._handleARKitWindowResize.bind(this)),this._arKitWrapper.addEventListener(O.default.ON_ERROR,this._handleOnError.bind(this)),this._arKitWrapper.addEventListener(O.default.AR_TRACKING_CHANGED,this._handleArTrackingChanged.bind(this)),this._arKitWrapper.addEventListener(O.default.COMPUTER_VISION_DATA,this._handleComputerVisionData.bind(this)),this._arKitWrapper.waitForInit().then(function(){})):!1===this._initialized&&(this._initialized=!0,this._deviceOrientation=new g.default,this._devicePosition=new A.default,this._deviceWorldMatrix=new Float32Array(16),this._deviceOrientationTracker=new T.default,this._deviceOrientationTracker.addEventListener(T.default.ORIENTATION_UPDATE_EVENT,this._updateFromDeviceOrientationTracker.bind(this)),this._reality.addEventListener(Reality.COMPUTER_VISION_DATA,this._handleComputerVisionData.bind(this)),this._reality.addEventListener(Reality.WINDOW_RESIZE_EVENT,this._handleWindowResize.bind(this))),this.running=!0,this._reality._start(e)}},{key:"_stop",value:function(){!1!==this.running&&(this.running=!1,this._reality._stop())}},{key:"_fixFov",value:function(e,t,n){if(this.baseLayer){n/=e/this.baseLayer._context.canvas.clientWidth;var r=.5*this.baseLayer._context.canvas.clientWidth/n,i=180/Math.PI*2*Math.atan(r),a=.5*this.baseLayer._context.canvas.clientHeight/n,o=180/Math.PI*2*Math.atan(a);this._fov=new m.default(o/2,o/2,i/2,i/2),this._views[0].fov=this._fov}}},{key:"_handleWindowResize",value:function(e){this._fixFov(e.detail.width,e.detail.height,e.detail.focalLength)}},{key:"_handleNewBaseLayer",value:function(e){this.baseLayer=e,e._context.canvas.style.width="100%",e._context.canvas.style.height="100%",e.framebufferWidth=this._xr._sessionEls.clientWidth,e.framebufferHeight=this._xr._sessionEls.clientHeight,null===this._arKitWrapper&&window.addEventListener("resize",function(){e.framebufferWidth=e._context.canvas.clientWidth,e.framebufferHeight=e._context.canvas.clientHeight},!1),this._xr._sessionEls.appendChild(e._context.canvas)}},{key:"_handleNewFrame",value:function(e){null!==this._vrFrameData&&this._updateFromVRDevice()}},{key:"_updateFromVRDevice",value:function(){var e,t;this._reality._vrDisplay.getFrameData(this._vrFrameData),this._views[0].setProjectionMatrix(this._vrFrameData.leftProjectionMatrix),(e=this._deviceOrientation).set.apply(e,a(this._vrFrameData.pose.orientation)),(t=this._devicePosition).set.apply(t,a(this._vrFrameData.pose.position)),this._devicePosition.add(0,XRViewPose.SITTING_EYE_HEIGHT,0),w.default.mat4_fromRotationTranslation(this._deviceWorldMatrix,this._deviceOrientation.toArray(),this._devicePosition.toArray()),this._views[0].setViewMatrix(this._deviceWorldMatrix),this._headPose._setPoseModelMatrix(this._deviceWorldMatrix),this._eyeLevelPose._position=this._devicePosition.toArray()}},{key:"_updateFromDeviceOrientationTracker",value:function(){this._deviceOrientationTracker.getOrientation(this._deviceOrientation),this._devicePosition.set(this._headPose.poseModelMatrix[12],this._headPose.poseModelMatrix[13],this._headPose.poseModelMatrix[14]),this._devicePosition.add(0,XRViewPose.SITTING_EYE_HEIGHT,0),w.default.mat4_fromRotationTranslation(this._deviceWorldMatrix,this._deviceOrientation.toArray(),this._devicePosition.toArray()),this._headPose._setPoseModelMatrix(this._deviceWorldMatrix),this._views[0].setViewMatrix(this._deviceWorldMatrix),this._eyeLevelPose._position=this._devicePosition.toArray()}},{key:"_handleARKitUpdate",value:function(){var e=this._arKitWrapper.getData("camera_transform");e?(this._headPose._setPoseModelMatrix(e),this._views[0].setViewMatrix(e),this._headPose._poseModelMatrix[13]+=XRViewPose.SITTING_EYE_HEIGHT,this._eyeLevelPose._position=this._headPose._position):console.log("no camera transform",this._arKitWrapper.rawARData);var t=this._arKitWrapper.getData("projection_camera");t?this._views[0].setProjectionMatrix(t):console.log("no projection camera",this._arKitWrapper.rawARData)}},{key:"_handleARKitInit",value:function(e){}},{key:"_handleARKitWindowResize",value:function(e){this.baseLayer.framebufferWidth=e.detail.width,this.baseLayer.framebufferHeight=e.detail.height}},{key:"_handleOnError",value:function(e){}},{key:"_handleArTrackingChanged",value:function(e){}},{key:"_handleComputerVisionData",value:function(e){try{this.dispatchEvent(new CustomEvent("videoFrame",{source:this,detail:e.detail}))}catch(e){console.error("computer vision callback error",e)}}},{key:"_requestVideoFrame",value:function(){this._arKitWrapper?this._arKitWrapper._requestComputerVisionData():this._reality._requestVideoFrame()}},{key:"_stopVideoFrames",value:function(){this._arKitWrapper?this._arKitWrapper._stopSendingComputerVisionData():this._reality._stopVideoFrames()}},{key:"_startVideoFrames",value:function(){this._arKitWrapper?this._arKitWrapper._startSendingComputerVisionData():this._reality._startVideoFrames()}},{key:"_createSession",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this._start(n),O.default.HasARKit()?this._arKitWrapper.waitForInit().then(function(){return h(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_createSession",e).call(e,n)}):h(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_createSession",this).call(this,n)}},{key:"_supportedCreationParameters",value:function(e){return e.type===p.default.AUGMENTATION&&!1===e.exclusive}}]),t}(c.default);t.default=P},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){function e(t,n,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.DefaultOrder;r(this,e),this.x=t,this.y=n,this.z=i,this.order=a}return i(e,[{key:"set",value:function(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.DefaultOrder;this.x=t,this.y=n,this.z=r,this.order=i}},{key:"toArray",value:function(){return[this.x,this.y,this.z]}}]),e}();t.default=a,a.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],a.DefaultOrder="XYZ"},function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function a(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":r(t))&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":r(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),h=n(5),f=i(h),c=n(8),d=i(c),_=n(7),v=i(_),p=n(9),y=(i(p),n(0)),m=i(y),b=n(1),w=i(b),M=n(11),g=i(M),E=n(21),A=(i(E),n(12)),x=(i(A),function(e){function t(e,n,r){o(this,t);var i=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r.displayName,r.capabilities.hasExternalDisplay,n));return i._vrDisplay=r,i._vrFrameData=new VRFrameData,i._leftView=new d.default(i._fov,i._depthNear,i._depthFar,d.default.LEFT),i._rightView=new d.default(i._fov,i._depthNear,i._depthFar,d.default.RIGHT),i._views=[i._leftView,i._rightView],i._deviceOrientation=new w.default,i._devicePosition=new g.default,i._deviceWorldMatrix=new Float32Array(16),i}return u(t,e),l(t,[{key:"_requestAnimationFrame",value:function(e){this._vrDisplay.isPresenting?this._vrDisplay.requestAnimationFrame(e):window.requestAnimationFrame(e)}},{key:"_handleNewBaseLayer",value:function(e){var t=this;this._vrDisplay.requestPresent([{source:e._context.canvas}]).then(function(){var n=t._vrDisplay.getEyeParameters("left"),r=t._vrDisplay.getEyeParameters("right");e.framebufferWidth=2*Math.max(n.renderWidth,r.renderWidth),e.framebufferHeight=Math.max(n.renderHeight,r.renderHeight),e._context.canvas.style.position="absolute",e._context.canvas.style.bottom="1px",e._context.canvas.style.right="1px",e._context.canvas.style.width="100%",e._context.canvas.style.height="100%",document.body.appendChild(e._context.canvas)}).catch(function(e){console.error("Unable to init WebVR 1.1 display",e)})}},{key:"_stop",value:function(){!1!==this.running&&(this.running=!1,this._reality._stop())}},{key:"_handleNewFrame",value:function(e){this._vrDisplay.isPresenting&&this._updateFromVRFrameData()}},{key:"_handleAfterFrame",value:function(e){this._vrDisplay.isPresenting&&this._vrDisplay.submitFrame()}},{key:"_supportedCreationParameters",value:function(e){return e.type===v.default.REALITY&&!0===e.exclusive}},{key:"_updateFromVRFrameData",value:function(){if(this._vrDisplay.getFrameData(this._vrFrameData),this._leftView.setViewMatrix(this._vrFrameData.leftViewMatrix),this._rightView.setViewMatrix(this._vrFrameData.rightViewMatrix),this._leftView.setProjectionMatrix(this._vrFrameData.leftProjectionMatrix),this._rightView.setProjectionMatrix(this._vrFrameData.rightProjectionMatrix),this._vrFrameData.pose){if(this._vrFrameData.pose.orientation){var e;(e=this._deviceOrientation).set.apply(e,a(this._vrFrameData.pose.orientation))}if(this._vrFrameData.pose.position){var t;(t=this._devicePosition).set.apply(t,a(this._vrFrameData.pose.position))}m.default.mat4_fromRotationTranslation(this._deviceWorldMatrix,this._deviceOrientation.toArray(),this._devicePosition.toArray()),this._vrDisplay.stageParameters&&this._vrDisplay.stageParameters.sittingToStandingTransform&&m.default.mat4_multiply(this._deviceWorldMatrix,this._vrDisplay.stageParameters.sittingToStandingTransform,this._deviceWorldMatrix),this._headPose._setPoseModelMatrix(this._deviceWorldMatrix),this._eyeLevelPose.position=this._devicePosition.toArray()}}}]),t}(f.default));t.default=x},function(e,t,n){function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":r(t))&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":r(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(6),h=i(l),f=n(4),c=i(f),d=n(9),_=i(d),v=n(15),p=i(v),y=n(14),m=i(y),b=n(0),w=i(b),M=n(1),g=i(M),E=n(12),A=i(E),x=n(39),T=i(x),R=function(e){function t(e){a(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,"Camera",!0,!0));return n._initialized=!1,n._running=!1,n._cameraFov=70*Math.PI/180,n._focalLength=160/Math.tan(n._cameraFov/2),n._cameraIntrinsics=[n._focalLength,0,0,0,n._focalLength,0,160,120,1],n._arKitWrapper=null,n._mediaStream=null,n._videoEl=null,n._arCoreCameraRenderer=null,n._arCoreCanvas=null,n._elContext=null,n._vrDisplay=null,n._vrFrameData=null,n._sendingVideo=!1,n._videoFramesPaused=!1,n._sendVideoFrame=!1,n._videoProjectionMatrix=w.default.mat4_generateIdentity(),n._videoViewMatrix=w.default.mat4_generateIdentity(),n._lightEstimate=new m.default,"function"==typeof navigator.getVRDisplays&&navigator.getVRDisplays().then(function(e){var t=!0,r=!1,i=void 0;try{for(var a,o=e[Symbol.iterator]();!(t=(a=o.next()).done);t=!0){var s=a.value;if(null!==s&&s.capabilities.hasPassThroughCamera){if(n._vrDisplay=s,n._vrFrameData=new VRFrameData,!window.WebARonARKitSetData&&(n._arCoreCanvas=document.createElement("canvas"),n._xr._realityEls.appendChild(n._arCoreCanvas),n._arCoreCanvas.width=window.innerWidth,n._arCoreCanvas.height=window.innerHeight,n._elContext=n._arCoreCanvas.getContext("webgl"),null===n._elContext))throw"Could not create CameraReality GL context";break}}}catch(e){r=!0,i=e}finally{try{!t&&o.return&&o.return()}finally{if(r)throw i}}}),window.addEventListener("resize",function(){n._arCoreCanvas&&(n._arCoreCanvas.width=window.innerWidth,n._arCoreCanvas.height=window.innerHeight),n._videoEl&&setTimeout(function(){n._adjustVideoSize()},10)},!1),n}return s(t,e),u(t,[{key:"_setFovy",value:function(e){if(this._cameraFov=e*Math.PI/180,!this._videoEl)return void(this._focalLength=0);this._videoRenderWidth>this._videoRenderHeight?this._focalLength=this._videoRenderWidth/2/Math.tan(this._cameraFov/2):this._focalLength=this._videoRenderHeight/2/Math.tan(this._cameraFov/2),this._cameraIntrinsics=[this._focalLength,0,0,0,this._focalLength,0,this._videoRenderWidth/2,this._videoRenderHeight/2,1]}},{key:"_adjustVideoSize",value:function(){var e=this._videoRenderWidth,t=this._videoRenderHeight,n=e/t,r=this._videoEl.videoWidth,i=this._videoEl.videoHeight;if(r/i!=n){for(;r>512||i>512;)r/=2,i/=2;e=this._videoRenderWidth=r,t=this._videoRenderHeight=i;var n=e/t;this._videoFrameCanvas.width=r,this._videoFrameCanvas.height=i}this._setFovy(this._cameraFov/(Math.PI/180));var a=this._xr._realityEls.clientWidth,o=this._xr._realityEls.clientHeight,s=a/o,u=0,l=0;n>s?(e=t*s,a=o*n,u=-(a-this._xr._realityEls.clientWidth)/2):(t=e/s,o=a/n,l=-(o-this._xr._realityEls.clientHeight)/2),this._videoEl.style.width=a.toFixed(2)+"px",this._videoEl.style.height=o.toFixed(2)+"px",this._videoEl.style.transform="translate("+u.toFixed(2)+"px, "+l.toFixed(2)+"px)",this.dispatchEvent(new CustomEvent(h.default.WINDOW_RESIZE_EVENT,{source:this,detail:{width:e,height:t,focalLength:this._focalLength}}))}},{key:"_handleNewFrame",value:function(e){if(this._vrDisplay&&(this._arCoreCameraRenderer&&this._arCoreCameraRenderer.render(),this._vrDisplay.getFrameData(this._vrFrameData)),this._videoEl&&this._sendVideoFrame&&!this._videoFramesPaused){this._sendVideoFrame=!1;var t=this._videoRenderWidth,n=this._videoRenderHeight;this._videoCtx.drawImage(this._videoEl,0,0,t,n);var r=this._videoCtx.getImageData(0,0,t,n),i=(r.data,r.data.length,[{size:{width:t,height:n,bytesPerRow:4*t,bytesPerPixel:4},buffer:r}]),a=XRVideoFrame.IMAGEFORMAT_RGBA32,o=e.timestamp,s=e.views[0];w.default.mat4_invert(this._videoViewMatrix,s.viewMatrix),this._videoProjectionMatrix.set(s.projectionMatrix);var u={arCamera:!1,cameraOrientation:0,cameraIntrinsics:this._cameraIntrinsics.slice(0),cameraImageResolution:{width:this._videoEl.videoWidth,height:this._videoEl.videoHeight},viewMatrix:this._videoViewMatrix,projectionMatrix:this._videoProjectionMatrix},l=new XRVideoFrame(i,a,o,u);this.dispatchEvent(new CustomEvent(h.default.COMPUTER_VISION_DATA,{source:this,detail:l}))}}},{key:"_start",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._running||(this._running=!0,null!==this._vrDisplay?(window.WebARonARKitSetData||(this._arCoreCameraRenderer=new T.default(this._vrDisplay,this._elContext)),this._initialized=!0):A.default.HasARKit()?!1===this._initialized?(this._initialized=!0,this._arKitWrapper=A.default.GetOrCreate(),this._arKitWrapper.addEventListener(A.default.WATCH_EVENT,this._handleARKitWatch.bind(this)),this._arKitWrapper.waitForInit().then(function(){e._arKitWrapper.watch(t)})):this._arKitWrapper.watch(t):!1===this._initialized?(this._initialized=!0,navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:"environment"}}).then(function(n){e._videoEl=document.createElement("video"),e._xr._realityEls.appendChild(e._videoEl),e._videoEl.setAttribute("class","camera-reality-video"),e._videoEl.setAttribute("playsinline",!0),e._videoEl.style.width="100%",e._videoEl.style.height="100%",e._videoEl.srcObject=n,e._videoEl.play(),e._setupWebRTC(t)}).catch(function(t){console.error("Could not set up video stream",t),e._initialized=!1,e._running=!1})):this._videoEl&&(this._xr._realityEls.appendChild(this._videoEl),this._videoEl.play(),this._setupWebRTC(t)))}},{key:"_setupWebRTC",value:function(e){var t=this;e.videoFrames&&(this._sendingVideo=!0,this._videoEl.addEventListener("loadedmetadata",function(){for(var e=t._videoEl.videoWidth,n=t._videoEl.videoHeight;e>256||n>256;)e/=2,n/=2;t._videoRenderWidth=e,t._videoRenderHeight=n,t._videoFrameCanvas=document.createElement("canvas"),t._videoFrameCanvas.width=e,t._videoFrameCanvas.height=n,t._videoCtx=t._videoFrameCanvas.getContext("2d"),t._adjustVideoSize(),t._sendVideoFrame=!0}))}},{key:"_requestVideoFrame",value:function(){this._sendVideoFrame=!0}},{key:"_stopVideoFrames",value:function(){this._videoFramesPaused=!0}},{key:"_startVideoFrames",value:function(){this._videoFramesPaused=!1}},{key:"_stop",value:function(){if(!1!==this._running)if(this._running=!1,A.default.HasARKit()){if(null===this._arKitWrapper)return;this._arKitWrapper.stop()}else this._arCoreCanvas?(this._xr._realityEls.removeChild(this._arCoreCanvas),this._arCoreCanvas=null):null!==this._videoEl&&(this._videoEl.pause(),this._xr._realityEls.removeChild(this._videoEl))}},{key:"_handleARKitWatch",value:function(e){if(e.detail&&e.detail.objects){var t=!0,n=!1,r=void 0;try{for(var i,a=e.detail.objects[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var o=i.value;this._updateAnchorFromARKitUpdate(o.uuid,o)}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}}if(e.detail&&e.detail.removedObjects){var s=!0,u=!1,l=void 0;try{for(var h,f=e.detail.removedObjects[Symbol.iterator]();!(s=(h=f.next()).done);s=!0){var c=h.value;this._deleteAnchorFromARKitUpdate(c)}}catch(e){u=!0,l=e}finally{try{!s&&f.return&&f.return()}finally{if(u)throw l}}}}},{key:"_deleteAnchorFromARKitUpdate",value:function(e){this._anchors.delete(e)}},{key:"_handleARKitAddObject",value:function(e){this._updateAnchorFromARKitUpdate(e.uuid,e)}},{key:"_updateAnchorFromARKitUpdate",value:function(e,t){var n=this._anchors.get(e)||null;null!==n&&(n.coordinateSystem._relativeMatrix=t.transform)}},{key:"_addAnchor",value:function(e,t){var n=this;return null!==this._arKitWrapper&&this._arKitWrapper.addAnchor(e.uid,e.coordinateSystem._poseModelMatrix).then(function(e){return n._handleARKitAddObject(e)}),this._anchors.set(e.uid,e),e.uid}},{key:"_findAnchor",value:function(e,t,n){var r=this;return new Promise(function(i,a){if(null!==r._arKitWrapper)r._arKitWrapper.hitTest(e,t,A.default.HIT_TEST_TYPE_EXISTING_PLANES).then(function(e){if(0===e.length)return void i(null);var t=r._pickARKitHit(e);t.anchor_transform[13]+=_.default.SITTING_EYE_HEIGHT,t.world_transform[13]+=_.default.SITTING_EYE_HEIGHT;var a=r._getAnchor(t.uuid);if(null===a){var o=new XRCoordinateSystem(n,XRCoordinateSystem.TRACKER);o._relativeMatrix=t.anchor_transform,a=new c.default(o,t.uuid),r._anchors.set(a.uid,a)}var s=[t.world_transform[12]-t.anchor_transform[12],t.world_transform[13]-t.anchor_transform[13],t.world_transform[14]-t.anchor_transform[14]],u=(new g.default).setFromRotationMatrix(t.world_transform),l=(new g.default).setFromRotationMatrix(t.anchor_transform).inverse(),h=(new g.default).multiplyQuaternions(u,l),f=new p.default(a.uid);f.poseMatrix=w.default.mat4_fromRotationTranslation(new Float32Array(16),h.toArray(),s),i(f)});else if(null!==r._vrDisplay){var o=r._vrDisplay.hitTest(e,t);if(0==o.length)return void i(null);o.sort(function(e,t){return e.distance-t.distance});var s=r._getAnchor(o[0].uuid);if(null===s){var u=new XRCoordinateSystem(n,XRCoordinateSystem.TRACKER);u._relativeMatrix=o[0].modelMatrix,u._relativeMatrix[13]+=_.default.SITTING_EYE_HEIGHT,s=new c.default(u),r._anchors.set(s.uid,s)}i(new p.default(s.uid))}else i(null)})}},{key:"_removeAnchor",value:function(e){this._arKitWrapper?this._arKitWrapper.removeAnchor(e):this._getAnchor(e)&&this._anchors.delete(e)}},{key:"_pickARKitHit",value:function(e){if(0===e.length)return null;var t=null,n=e.filter(function(e){return e.type!=A.default.HIT_TEST_TYPE_FEATURE_POINT}),r=n.filter(function(e){return e.type==A.default.HIT_TEST_TYPE_EXISTING_PLANE_USING_EXTENT}),i=n.filter(function(e){return e.type==A.default.HIT_TEST_TYPE_EXISTING_PLANE});return r.length?(r=r.sort(function(e,t){return e.distance-t.distance}),t=r[0]):i.length?(i=i.sort(function(e,t){return e.distance-t.distance}),t=i[0]):n.length?(n=n.sort(function(e,t){return e.distance-t.distance}),t=n[0]):t=e[0],t}},{key:"_hitTestNoAnchor",value:function(e,t,n){if(null!==this._arKitWrapper){for(var r=this._arKitWrapper.hitTestNoAnchor(e,t),i=0;i<r.length;i++)r[i].modelMatrix[13]+=_.default.SITTING_EYE_HEIGHT;return 0==r.length?null:r}if(null!==this._vrDisplay){for(var a=this._vrDisplay.hitTest(e,t),o=0;o<a.length;o++)a[o].modelMatrix[13]+=_.default.SITTING_EYE_HEIGHT;return 0==a.length?null:a}return null}},{key:"_getHasLightEstimate",value:function(){return null!==this._arKitWrapper}},{key:"_getLightAmbientIntensity",value:function(){return null!==this._arKitWrapper?(this._lightEstimate.ambientIntensity=this._arKitWrapper.lightIntensity,this._lightEstimate.ambientIntensity):null}},{key:"_getTimeStamp",value:function(){return null!==this._arKitWrapper?this._arKitWrapper.timestamp:(performance||Date).now()}},{key:"_findFloorAnchor",value:function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise(function(e,t){e(null)})}}]),t}(h.default);t.default=R},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,n){if("fragment"==n)var r=e.createShader(e.FRAGMENT_SHADER);else{if("vertex"!=n)return null;var r=e.createShader(e.VERTEX_SHADER)}return e.shaderSource(r,t),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(console.error(e.getShaderInfoLog(r)),null)}function a(e,t,n){var r=i(e,t,"vertex"),a=i(e,n,"fragment");if(!a)return null;var o=e.createProgram();return e.attachShader(o,r),e.attachShader(o,a),e.linkProgram(o),e.getProgramParameter(o,e.LINK_STATUS)||console.error("Could not initialise arview shaders"),o}function o(e,t){var n=0;switch(t){case 90:n=1;break;case 180:n=2;break;case 270:n=3;break;default:n=0}var r=0;switch(e){case 90:r=1;break;case 180:r=2;break;case 270:r=3;break;default:r=0}var i=r-n;return i<0&&(i+=4),i%4}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u="#extension GL_OES_EGL_image_external : require\n\nprecision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform samplerExternalOES uSampler;\n\nvoid main(void) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n}",l="attribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void) {\n gl_Position = vec4(aVertexPosition, 1.0);\n vTextureCoord = aTextureCoord;\n}",h=function(){function e(t,n){r(this,e),this.vrDisplay=t,this.gl=n,this.passThroughCamera=t.getPassThroughCamera(),this.program=a(n,l,u),n.useProgram(this.program),this.vertexPositionAttribute=n.getAttribLocation(this.program,"aVertexPosition"),this.textureCoordAttribute=n.getAttribLocation(this.program,"aTextureCoord"),this.samplerUniform=n.getUniformLocation(this.program,"uSampler"),this.vertexPositionBuffer=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,this.vertexPositionBuffer);var i=[-1,1,0,-1,-1,0,1,1,0,1,-1,0],s=new Float32Array(i);n.bufferData(n.ARRAY_BUFFER,s,n.STATIC_DRAW),this.vertexPositionBuffer.itemSize=3,this.vertexPositionBuffer.numItems=12,this.textureCoordBuffer=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,this.textureCoordBuffer);var h=null;if(this.vrDisplay){var f=this.passThroughCamera.width/this.passThroughCamera.textureWidth,c=this.passThroughCamera.height/this.passThroughCamera.textureHeight;h=[[0,0,0,c,f,0,f,c],[f,0,0,0,f,c,0,c],[f,c,f,0,0,c,0,0],[0,c,f,c,0,0,f,0]]}else h=[[0,0,0,1,1,0,1,1],[1,0,0,0,1,1,0,1],[1,1,1,0,0,1,0,0],[0,1,1,1,0,0,1,0]];this.f32TextureCoords=[];for(var d=0;d<h.length;d++)this.f32TextureCoords.push(new Float32Array(h[d]));this.combinedOrientation=o(screen.orientation.angle,this.passThroughCamera.orientation),n.bufferData(n.ARRAY_BUFFER,this.f32TextureCoords[this.combinedOrientation],n.STATIC_DRAW),this.textureCoordBuffer.itemSize=2,this.textureCoordBuffer.numItems=8,n.bindBuffer(n.ARRAY_BUFFER,null),this.indexBuffer=n.createBuffer(),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var _=[0,1,2,2,1,3],v=new Uint16Array(_);return n.bufferData(n.ELEMENT_ARRAY_BUFFER,v,n.STATIC_DRAW),this.indexBuffer.itemSize=1,this.indexBuffer.numItems=6,n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),this.texture=n.createTexture(),n.useProgram(null),this.projectionMatrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this.mvMatrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this}return s(e,[{key:"render",value:function(){var e=this.gl;e.useProgram(this.program),e.bindBuffer(e.ARRAY_BUFFER,this.vertexPositionBuffer),e.enableVertexAttribArray(this.vertexPositionAttribute),e.vertexAttribPointer(this.vertexPositionAttribute,this.vertexPositionBuffer.itemSize,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.textureCoordBuffer);var t=o(screen.orientation.angle,this.passThroughCamera.orientation);t!==this.combinedOrientation&&(this.combinedOrientation=t,e.bufferData(e.ARRAY_BUFFER,this.f32TextureCoords[this.combinedOrientation],e.STATIC_DRAW)),e.enableVertexAttribArray(this.textureCoordAttribute),e.vertexAttribPointer(this.textureCoordAttribute,this.textureCoordBuffer.itemSize,e.FLOAT,!1,0,0),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_EXTERNAL_OES,this.texture),e.texImage2D(e.TEXTURE_EXTERNAL_OES,0,e.RGB,e.RGB,e.UNSIGNED_BYTE,this.passThroughCamera),e.uniform1i(this.samplerUniform,0),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer),e.drawElements(e.TRIANGLES,this.indexBuffer.numItems,e.UNSIGNED_SHORT,0),e.bindTexture(e.TEXTURE_EXTERNAL_OES,null),e.disableVertexAttribArray(this.vertexPositionAttribute),e.disableVertexAttribArray(this.textureCoordAttribute),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),e.useProgram(null)}}]),e}(),f=function(){function e(t,n){r(this,e),this.vrDisplay=t,this.gl=n,this.videoRenderer=new h(t,this.gl),this.width=window.innerWidth,this.height=window.innerHeight,window.addEventListener("resize",this.onWindowResize.bind(this),!1)}return s(e,[{key:"onWindowResize",value:function(){this.width=window.innerWidth,this.height=window.innerHeight}},{key:"render",value:function(){var e=this.gl,t=1*this.width,n=1*this.height;e.viewportWidth!==t&&(e.viewportWidth=t),e.viewportHeight!==n&&(e.viewportHeight=n),this.gl.viewport(0,0,e.viewportWidth,e.viewportHeight),this.videoRenderer.render()}}]),e}();t.default=f}])}]);