diff --git "a/static/3d/vendor/lookingglass/webxr.js" "b/static/3d/vendor/lookingglass/webxr.js" new file mode 100644--- /dev/null +++ "b/static/3d/vendor/lookingglass/webxr.js" @@ -0,0 +1,419 @@ +/* esm.sh - @lookingglass/webxr@0.6.0 */ +var Tn=Object.create;var Cr=Object.defineProperty;var Pn=Object.getOwnPropertyDescriptor;var Cn=Object.getOwnPropertyNames;var Fn=Object.getPrototypeOf,In=Object.prototype.hasOwnProperty;var di=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ln=(t,e)=>{for(var r in e)Cr(t,r,{get:e[r],enumerable:!0})},Dn=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Cn(e))!In.call(t,a)&&a!==r&&Cr(t,a,{get:()=>e[a],enumerable:!(n=Pn(e,a))||n.enumerable});return t};var Bn=(t,e,r)=>(r=t!=null?Tn(Fn(t)):{},Dn(e||!t||!t.__esModule?Cr(r,"default",{value:t,enumerable:!0}):r,t));var Ci=di((Qr,Xr)=>{(function(t,e){typeof Qr=="object"&&typeof Xr<"u"?Xr.exports=e():typeof define=="function"&&define.amd?define(e):t.CardboardVRDisplay=e()})(Qr,(function(){"use strict";var t=(function(){function i(l){this.value=l}function s(l){var c,f;function u(P,x){return new Promise(function(E,O){var V={key:P,arg:x,resolve:E,reject:O,next:null};f?f=f.next=V:(c=f=V,g(P,x))})}function g(P,x){try{var E=l[P](x),O=E.value;O instanceof i?Promise.resolve(O.value).then(function(V){g("next",V)},function(V){g("throw",V)}):D(E.done?"return":"normal",E.value)}catch(V){D("throw",V)}}function D(P,x){switch(P){case"return":c.resolve({value:x,done:!0});break;case"throw":c.reject(x);break;default:c.resolve({value:x,done:!1});break}c=c.next,c?g(c.key,c.arg):f=null}this._invoke=u,typeof l.return!="function"&&(this.return=void 0)}return typeof Symbol=="function"&&Symbol.asyncIterator&&(s.prototype[Symbol.asyncIterator]=function(){return this}),s.prototype.next=function(l){return this._invoke("next",l)},s.prototype.throw=function(l){return this._invoke("throw",l)},s.prototype.return=function(l){return this._invoke("return",l)},{wrap:function(l){return function(){return new s(l.apply(this,arguments))}},await:function(l){return new i(l)}}})(),e=function(i,s){if(!(i instanceof s))throw new TypeError("Cannot call a class as a function")},r=(function(){function i(s,l){for(var c=0;co)},F=function(){return Math.max(window.screen.width,window.screen.height)*window.devicePixelRatio},R=function(){return Math.min(window.screen.width,window.screen.height)*window.devicePixelRatio},I=function(s){if(p())return!1;if(s.requestFullscreen)s.requestFullscreen();else if(s.webkitRequestFullscreen)s.webkitRequestFullscreen();else if(s.mozRequestFullScreen)s.mozRequestFullScreen();else if(s.msRequestFullscreen)s.msRequestFullscreen();else return!1;return!0},B=function(){if(document.exitFullscreen)document.exitFullscreen();else if(document.webkitExitFullscreen)document.webkitExitFullscreen();else if(document.mozCancelFullScreen)document.mozCancelFullScreen();else if(document.msExitFullscreen)document.msExitFullscreen();else return!1;return!0},L=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},z=function(s,l,c,f){var u=s.createShader(s.VERTEX_SHADER);s.shaderSource(u,l),s.compileShader(u);var g=s.createShader(s.FRAGMENT_SHADER);s.shaderSource(g,c),s.compileShader(g);var D=s.createProgram();s.attachShader(D,u),s.attachShader(D,g);for(var P in f)s.bindAttribLocation(D,f[P],P);return s.linkProgram(D),s.deleteShader(u),s.deleteShader(g),D},U=function(s,l){for(var c={},f=s.getProgramParameter(l,s.ACTIVE_UNIFORMS),u="",g=0;g1)return console.warn("getQuaternionAngle: w > 1"),0;var l=2*Math.acos(s.w);return l},q=(function(){var i={};return function(s,l){i[s]===void 0&&(console.warn("webvr-polyfill: "+l),i[s]=!0)}})(),$=function(s,l){var c=l?"Please use "+l+" instead.":"";q(s,s+" has been deprecated. This may not work on native WebVR displays. "+c)};function xe(i,s,l){if(!s){l(i);return}for(var c=[],f=null,u=0;ui.TEXTURE31){console.error("TEXTURE_BINDING_2D or TEXTURE_BINDING_CUBE_MAP must be followed by a valid texture unit"),c.push(null,null);break}f||(f=i.getParameter(i.ACTIVE_TEXTURE)),i.activeTexture(D),c.push(i.getParameter(g),null);break;case i.ACTIVE_TEXTURE:f=i.getParameter(i.ACTIVE_TEXTURE),c.push(null);break;default:c.push(i.getParameter(g));break}}l(i);for(var u=0;ui.TEXTURE31)break;i.activeTexture(D),i.bindTexture(i.TEXTURE_2D,P);break;case i.TEXTURE_BINDING_CUBE_MAP:var D=s[++u];if(Di.TEXTURE31)break;i.activeTexture(D),i.bindTexture(i.TEXTURE_CUBE_MAP,P);break;case i.VIEWPORT:i.viewport(P[0],P[1],P[2],P[3]);break;case i.BLEND:case i.CULL_FACE:case i.DEPTH_TEST:case i.SCISSOR_TEST:case i.STENCIL_TEST:P?i.enable(g):i.disable(g);break;default:console.log("No GL restore behavior for 0x"+g.toString(16));break}f&&i.activeTexture(f)}}var Me=xe,We=["attribute vec2 position;","attribute vec3 texCoord;","varying vec2 vTexCoord;","uniform vec4 viewportOffsetScale[2];","void main() {"," vec4 viewport = viewportOffsetScale[int(texCoord.z)];"," vTexCoord = (texCoord.xy * viewport.zw) + viewport.xy;"," gl_Position = vec4( position, 1.0, 1.0 );","}"].join(` +`),et=["precision mediump float;","uniform sampler2D diffuse;","varying vec2 vTexCoord;","void main() {"," gl_FragColor = texture2D(diffuse, vTexCoord);","}"].join(` +`);function de(i,s,l,c){this.gl=i,this.cardboardUI=s,this.bufferScale=l,this.dirtySubmitFrameBindings=c,this.ctxAttribs=i.getContextAttributes(),this.instanceExt=i.getExtension("ANGLE_instanced_arrays"),this.meshWidth=20,this.meshHeight=20,this.bufferWidth=i.drawingBufferWidth,this.bufferHeight=i.drawingBufferHeight,this.realBindFramebuffer=i.bindFramebuffer,this.realEnable=i.enable,this.realDisable=i.disable,this.realColorMask=i.colorMask,this.realClearColor=i.clearColor,this.realViewport=i.viewport,A()||(this.realCanvasWidth=Object.getOwnPropertyDescriptor(i.canvas.__proto__,"width"),this.realCanvasHeight=Object.getOwnPropertyDescriptor(i.canvas.__proto__,"height")),this.isPatched=!1,this.lastBoundFramebuffer=null,this.cullFace=!1,this.depthTest=!1,this.blend=!1,this.scissorTest=!1,this.stencilTest=!1,this.viewport=[0,0,0,0],this.colorMask=[!0,!0,!0,!0],this.clearColor=[0,0,0,0],this.attribs={position:0,texCoord:1},this.program=z(i,We,et,this.attribs),this.uniforms=U(i,this.program),this.viewportOffsetScale=new Float32Array(8),this.setTextureBounds(),this.vertexBuffer=i.createBuffer(),this.indexBuffer=i.createBuffer(),this.indexCount=0,this.renderTarget=i.createTexture(),this.framebuffer=i.createFramebuffer(),this.depthStencilBuffer=null,this.depthBuffer=null,this.stencilBuffer=null,this.ctxAttribs.depth&&this.ctxAttribs.stencil?this.depthStencilBuffer=i.createRenderbuffer():this.ctxAttribs.depth?this.depthBuffer=i.createRenderbuffer():this.ctxAttribs.stencil&&(this.stencilBuffer=i.createRenderbuffer()),this.patch(),this.onResize()}de.prototype.destroy=function(){var i=this.gl;this.unpatch(),i.deleteProgram(this.program),i.deleteBuffer(this.vertexBuffer),i.deleteBuffer(this.indexBuffer),i.deleteTexture(this.renderTarget),i.deleteFramebuffer(this.framebuffer),this.depthStencilBuffer&&i.deleteRenderbuffer(this.depthStencilBuffer),this.depthBuffer&&i.deleteRenderbuffer(this.depthBuffer),this.stencilBuffer&&i.deleteRenderbuffer(this.stencilBuffer),this.cardboardUI&&this.cardboardUI.destroy()},de.prototype.onResize=function(){var i=this.gl,s=this,l=[i.RENDERBUFFER_BINDING,i.TEXTURE_BINDING_2D,i.TEXTURE0];Me(i,l,function(c){s.realBindFramebuffer.call(c,c.FRAMEBUFFER,null),s.scissorTest&&s.realDisable.call(c,c.SCISSOR_TEST),s.realColorMask.call(c,!0,!0,!0,!0),s.realViewport.call(c,0,0,c.drawingBufferWidth,c.drawingBufferHeight),s.realClearColor.call(c,0,0,0,1),c.clear(c.COLOR_BUFFER_BIT),s.realBindFramebuffer.call(c,c.FRAMEBUFFER,s.framebuffer),c.bindTexture(c.TEXTURE_2D,s.renderTarget),c.texImage2D(c.TEXTURE_2D,0,s.ctxAttribs.alpha?c.RGBA:c.RGB,s.bufferWidth,s.bufferHeight,0,s.ctxAttribs.alpha?c.RGBA:c.RGB,c.UNSIGNED_BYTE,null),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,s.renderTarget,0),s.ctxAttribs.depth&&s.ctxAttribs.stencil?(c.bindRenderbuffer(c.RENDERBUFFER,s.depthStencilBuffer),c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_STENCIL,s.bufferWidth,s.bufferHeight),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,s.depthStencilBuffer)):s.ctxAttribs.depth?(c.bindRenderbuffer(c.RENDERBUFFER,s.depthBuffer),c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,s.bufferWidth,s.bufferHeight),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,s.depthBuffer)):s.ctxAttribs.stencil&&(c.bindRenderbuffer(c.RENDERBUFFER,s.stencilBuffer),c.renderbufferStorage(c.RENDERBUFFER,c.STENCIL_INDEX8,s.bufferWidth,s.bufferHeight),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.STENCIL_ATTACHMENT,c.RENDERBUFFER,s.stencilBuffer)),!c.checkFramebufferStatus(c.FRAMEBUFFER)===c.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer incomplete!"),s.realBindFramebuffer.call(c,c.FRAMEBUFFER,s.lastBoundFramebuffer),s.scissorTest&&s.realEnable.call(c,c.SCISSOR_TEST),s.realColorMask.apply(c,s.colorMask),s.realViewport.apply(c,s.viewport),s.realClearColor.apply(c,s.clearColor)}),this.cardboardUI&&this.cardboardUI.onResize()},de.prototype.patch=function(){if(!this.isPatched){var i=this,s=this.gl.canvas,l=this.gl;A()||(s.width=F()*this.bufferScale,s.height=R()*this.bufferScale,Object.defineProperty(s,"width",{configurable:!0,enumerable:!0,get:function(){return i.bufferWidth},set:function(f){i.bufferWidth=f,i.realCanvasWidth.set.call(s,f),i.onResize()}}),Object.defineProperty(s,"height",{configurable:!0,enumerable:!0,get:function(){return i.bufferHeight},set:function(f){i.bufferHeight=f,i.realCanvasHeight.set.call(s,f),i.onResize()}})),this.lastBoundFramebuffer=l.getParameter(l.FRAMEBUFFER_BINDING),this.lastBoundFramebuffer==null&&(this.lastBoundFramebuffer=this.framebuffer,this.gl.bindFramebuffer(l.FRAMEBUFFER,this.framebuffer)),this.gl.bindFramebuffer=function(c,f){i.lastBoundFramebuffer=f||i.framebuffer,i.realBindFramebuffer.call(l,c,i.lastBoundFramebuffer)},this.cullFace=l.getParameter(l.CULL_FACE),this.depthTest=l.getParameter(l.DEPTH_TEST),this.blend=l.getParameter(l.BLEND),this.scissorTest=l.getParameter(l.SCISSOR_TEST),this.stencilTest=l.getParameter(l.STENCIL_TEST),l.enable=function(c){switch(c){case l.CULL_FACE:i.cullFace=!0;break;case l.DEPTH_TEST:i.depthTest=!0;break;case l.BLEND:i.blend=!0;break;case l.SCISSOR_TEST:i.scissorTest=!0;break;case l.STENCIL_TEST:i.stencilTest=!0;break}i.realEnable.call(l,c)},l.disable=function(c){switch(c){case l.CULL_FACE:i.cullFace=!1;break;case l.DEPTH_TEST:i.depthTest=!1;break;case l.BLEND:i.blend=!1;break;case l.SCISSOR_TEST:i.scissorTest=!1;break;case l.STENCIL_TEST:i.stencilTest=!1;break}i.realDisable.call(l,c)},this.colorMask=l.getParameter(l.COLOR_WRITEMASK),l.colorMask=function(c,f,u,g){i.colorMask[0]=c,i.colorMask[1]=f,i.colorMask[2]=u,i.colorMask[3]=g,i.realColorMask.call(l,c,f,u,g)},this.clearColor=l.getParameter(l.COLOR_CLEAR_VALUE),l.clearColor=function(c,f,u,g){i.clearColor[0]=c,i.clearColor[1]=f,i.clearColor[2]=u,i.clearColor[3]=g,i.realClearColor.call(l,c,f,u,g)},this.viewport=l.getParameter(l.VIEWPORT),l.viewport=function(c,f,u,g){i.viewport[0]=c,i.viewport[1]=f,i.viewport[2]=u,i.viewport[3]=g,i.realViewport.call(l,c,f,u,g)},this.isPatched=!0,k(s)}},de.prototype.unpatch=function(){if(this.isPatched){var i=this.gl,s=this.gl.canvas;A()||(Object.defineProperty(s,"width",this.realCanvasWidth),Object.defineProperty(s,"height",this.realCanvasHeight)),s.width=this.bufferWidth,s.height=this.bufferHeight,i.bindFramebuffer=this.realBindFramebuffer,i.enable=this.realEnable,i.disable=this.realDisable,i.colorMask=this.realColorMask,i.clearColor=this.realClearColor,i.viewport=this.realViewport,this.lastBoundFramebuffer==this.framebuffer&&i.bindFramebuffer(i.FRAMEBUFFER,null),this.isPatched=!1,setTimeout(function(){k(s)},1)}},de.prototype.setTextureBounds=function(i,s){i||(i=[0,0,.5,1]),s||(s=[.5,0,.5,1]),this.viewportOffsetScale[0]=i[0],this.viewportOffsetScale[1]=i[1],this.viewportOffsetScale[2]=i[2],this.viewportOffsetScale[3]=i[3],this.viewportOffsetScale[4]=s[0],this.viewportOffsetScale[5]=s[1],this.viewportOffsetScale[6]=s[2],this.viewportOffsetScale[7]=s[3]},de.prototype.submitFrame=function(){var i=this.gl,s=this,l=[];if(this.dirtySubmitFrameBindings||l.push(i.CURRENT_PROGRAM,i.ARRAY_BUFFER_BINDING,i.ELEMENT_ARRAY_BUFFER_BINDING,i.TEXTURE_BINDING_2D,i.TEXTURE0),Me(i,l,function(f){s.realBindFramebuffer.call(f,f.FRAMEBUFFER,null);var u=0,g=0;s.instanceExt&&(u=f.getVertexAttrib(s.attribs.position,s.instanceExt.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE),g=f.getVertexAttrib(s.attribs.texCoord,s.instanceExt.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE)),s.cullFace&&s.realDisable.call(f,f.CULL_FACE),s.depthTest&&s.realDisable.call(f,f.DEPTH_TEST),s.blend&&s.realDisable.call(f,f.BLEND),s.scissorTest&&s.realDisable.call(f,f.SCISSOR_TEST),s.stencilTest&&s.realDisable.call(f,f.STENCIL_TEST),s.realColorMask.call(f,!0,!0,!0,!0),s.realViewport.call(f,0,0,f.drawingBufferWidth,f.drawingBufferHeight),(s.ctxAttribs.alpha||A())&&(s.realClearColor.call(f,0,0,0,1),f.clear(f.COLOR_BUFFER_BIT)),f.useProgram(s.program),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,s.indexBuffer),f.bindBuffer(f.ARRAY_BUFFER,s.vertexBuffer),f.enableVertexAttribArray(s.attribs.position),f.enableVertexAttribArray(s.attribs.texCoord),f.vertexAttribPointer(s.attribs.position,2,f.FLOAT,!1,20,0),f.vertexAttribPointer(s.attribs.texCoord,3,f.FLOAT,!1,20,8),s.instanceExt&&(u!=0&&s.instanceExt.vertexAttribDivisorANGLE(s.attribs.position,0),g!=0&&s.instanceExt.vertexAttribDivisorANGLE(s.attribs.texCoord,0)),f.activeTexture(f.TEXTURE0),f.uniform1i(s.uniforms.diffuse,0),f.bindTexture(f.TEXTURE_2D,s.renderTarget),f.uniform4fv(s.uniforms.viewportOffsetScale,s.viewportOffsetScale),f.drawElements(f.TRIANGLES,s.indexCount,f.UNSIGNED_SHORT,0),s.cardboardUI&&s.cardboardUI.renderNoState(),s.realBindFramebuffer.call(s.gl,f.FRAMEBUFFER,s.framebuffer),s.ctxAttribs.preserveDrawingBuffer||(s.realClearColor.call(f,0,0,0,0),f.clear(f.COLOR_BUFFER_BIT)),s.dirtySubmitFrameBindings||s.realBindFramebuffer.call(f,f.FRAMEBUFFER,s.lastBoundFramebuffer),s.cullFace&&s.realEnable.call(f,f.CULL_FACE),s.depthTest&&s.realEnable.call(f,f.DEPTH_TEST),s.blend&&s.realEnable.call(f,f.BLEND),s.scissorTest&&s.realEnable.call(f,f.SCISSOR_TEST),s.stencilTest&&s.realEnable.call(f,f.STENCIL_TEST),s.realColorMask.apply(f,s.colorMask),s.realViewport.apply(f,s.viewport),(s.ctxAttribs.alpha||!s.ctxAttribs.preserveDrawingBuffer)&&s.realClearColor.apply(f,s.clearColor),s.instanceExt&&(u!=0&&s.instanceExt.vertexAttribDivisorANGLE(s.attribs.position,u),g!=0&&s.instanceExt.vertexAttribDivisorANGLE(s.attribs.texCoord,g))}),A()){var c=i.canvas;(c.width!=s.bufferWidth||c.height!=s.bufferHeight)&&(s.bufferWidth=c.width,s.bufferHeight=c.height,s.onResize())}},de.prototype.updateDeviceInfo=function(i){var s=this.gl,l=this,c=[s.ARRAY_BUFFER_BINDING,s.ELEMENT_ARRAY_BUFFER_BINDING];Me(s,c,function(f){var u=l.computeMeshVertices_(l.meshWidth,l.meshHeight,i);if(f.bindBuffer(f.ARRAY_BUFFER,l.vertexBuffer),f.bufferData(f.ARRAY_BUFFER,u,f.STATIC_DRAW),!l.indexCount){var g=l.computeMeshIndices_(l.meshWidth,l.meshHeight);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,l.indexBuffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,g,f.STATIC_DRAW),l.indexCount=g.length}})},de.prototype.computeMeshVertices_=function(i,s,l){for(var c=new Float32Array(2*i*s*5),f=l.getLeftEyeVisibleTanAngles(),u=l.getLeftEyeNoLensTanAngles(),g=l.getLeftEyeVisibleScreenRect(u),D=0,P=0;P<2;P++){for(var x=0;xf-u&&c.clientXl.clientHeight-u?i(c):c.clientX1e-4;){var f=i-this.distort(l),u=l-f*((l-s)/(f-c));s=l,l=u,c=f}return l},ar.prototype.distort=function(i){for(var s=i*i,l=0,c=0;c=1)return this.w=g,this.x=c,this.y=f,this.z=u,this;var P=Math.acos(D),x=Math.sqrt(1-D*D);if(Math.abs(x)<.001)return this.w=.5*(g+this.w),this.x=.5*(c+this.x),this.y=.5*(f+this.y),this.z=.5*(u+this.z),this;var E=Math.sin((1-l)*P)/x,O=Math.sin(l*P)/x;return this.w=g*E+this.w*O,this.x=c*E+this.x*O,this.y=f*E+this.y*O,this.z=u*E+this.z*O,this},setFromUnitVectors:(function(){var i,s,l=1e-6;return function(c,f){return i===void 0&&(i=new ne),s=c.dot(f)+1,sMath.abs(c.z)?i.set(-c.y,c.x,0):i.set(0,-c.z,c.y)):i.crossVectors(c,f),this.x=i.x,this.y=i.y,this.z=i.z,this.w=s,this.normalize(),this}})()};function Rr(i){this.width=i.width||F(),this.height=i.height||R(),this.widthMeters=i.widthMeters,this.heightMeters=i.heightMeters,this.bevelMeters=i.bevelMeters}var tn=new Rr({widthMeters:.11,heightMeters:.062,bevelMeters:.004}),rn=new Rr({widthMeters:.1038,heightMeters:.0584,bevelMeters:.004}),_r={CardboardV1:new Tr({id:"CardboardV1",label:"Cardboard I/O 2014",fov:40,interLensDistance:.06,baselineLensDistance:.035,screenLensDistance:.042,distortionCoefficients:[.441,.156],inverseCoefficients:[-.4410035,.42756155,-.4804439,.5460139,-.58821183,.5733938,-.48303202,.33299083,-.17573841,.0651772,-.01488963,.001559834]}),CardboardV2:new Tr({id:"CardboardV2",label:"Cardboard I/O 2015",fov:60,interLensDistance:.064,baselineLensDistance:.035,screenLensDistance:.039,distortionCoefficients:[.34,.55],inverseCoefficients:[-.33836704,-.18162185,.862655,-1.2462051,1.0560602,-.58208317,.21609078,-.05444823,.009177956,-.0009904169,6183535e-11,-16981803e-13]})};function fe(i,s){this.viewer=_r.CardboardV2,this.updateDeviceParams(i),this.distortion=new ar(this.viewer.distortionCoefficients);for(var l=0;l=200&&l.status<=299?(c.dpdb=JSON.parse(l.response),c.recalculateDeviceParams_()):console.error("Error loading online DPDB!")}),l.send()}}_t.prototype.getDeviceParams=function(){return this.deviceParams},_t.prototype.recalculateDeviceParams_=function(){var i=this.calcDeviceParams_();i?(this.deviceParams=i,this.onDeviceParamsUpdated&&this.onDeviceParamsUpdated(this.deviceParams)):console.error("Failed to recalculate device parameters.")},_t.prototype.calcDeviceParams_=function(){var i=this.dpdb;if(!i)return console.error("DPDB not available."),null;if(i.format!=1)return console.error("DPDB has unexpected format version."),null;if(!i.devices||!i.devices.length)return console.error("DPDB does not have a devices section."),null;var s=navigator.userAgent||navigator.vendor||window.opera,l=F(),c=R();if(!i.devices)return console.error("DPDB has no devices section."),null;for(var f=0;fo){q("fusion-pose-sensor:invalid:outside-threshold","Invalid timestamps detected: Timestamp from devicemotion outside expected range."),this.previousTimestampS=c;return}this.accelerometer.set(-s.x,-s.y,-s.z),l&&(M()?this.gyroscope.set(-l.beta,l.alpha,l.gamma):this.gyroscope.set(l.alpha,l.beta,l.gamma),this.isDeviceMotionInRadians||this.gyroscope.multiplyScalar(Math.PI/180),this.filter.addGyroMeasurement(this.gyroscope,c)),this.filter.addAccelMeasurement(this.accelerometer,c),this.previousTimestampS=c},Le.prototype.onOrientationChange_=function(i){this.setScreenTransform_()},Le.prototype.onMessage_=function(i){var s=i.data;if(!(!s||!s.type)){var l=s.type.toLowerCase();l==="devicemotion"&&this.updateDeviceMotion_(s.deviceMotionEvent)}},Le.prototype.setScreenTransform_=function(){switch(this.worldToScreenQ.set(0,0,0,1),window.orientation){case 0:break;case 90:this.worldToScreenQ.setFromAxisAngle(new ne(0,0,1),-Math.PI/2);break;case-90:this.worldToScreenQ.setFromAxisAngle(new ne(0,0,1),Math.PI/2);break;case 180:break}this.inverseWorldToScreenQ.copy(this.worldToScreenQ),this.inverseWorldToScreenQ.inverse()},Le.prototype.start=function(){this.onDeviceMotionCallback_=this.onDeviceMotion_.bind(this),this.onOrientationChangeCallback_=this.onOrientationChange_.bind(this),this.onMessageCallback_=this.onMessage_.bind(this),this.onDeviceOrientationCallback_=this.onDeviceOrientation_.bind(this),A()&&C()&&window.addEventListener("message",this.onMessageCallback_),window.addEventListener("orientationchange",this.onOrientationChangeCallback_),this.isWithoutDeviceMotion?window.addEventListener("deviceorientation",this.onDeviceOrientationCallback_):window.addEventListener("devicemotion",this.onDeviceMotionCallback_)},Le.prototype.stop=function(){window.removeEventListener("devicemotion",this.onDeviceMotionCallback_),window.removeEventListener("deviceorientation",this.onDeviceOrientationCallback_),window.removeEventListener("orientationchange",this.onOrientationChangeCallback_),window.removeEventListener("message",this.onMessageCallback_)};var cn=60,hn=new ne(1,0,0),dn=new ne(0,0,1),Pr=new ee;Pr.setFromAxisAngle(hn,-Math.PI/2),Pr.multiply(new ee().setFromAxisAngle(dn,Math.PI/2));var fn=(function(){function i(s){e(this,i),this.config=s,this.sensor=null,this.fusionSensor=null,this._out=new Float32Array(4),this.api=null,this.errors=[],this._sensorQ=new ee,this._outQ=new ee,this._onSensorRead=this._onSensorRead.bind(this),this._onSensorError=this._onSensorError.bind(this),this.init()}return r(i,[{key:"init",value:function(){var l=null;try{l=new RelativeOrientationSensor({frequency:cn,referenceFrame:"screen"}),l.addEventListener("error",this._onSensorError)}catch(c){this.errors.push(c),c.name==="SecurityError"?(console.error("Cannot construct sensors due to the Feature Policy"),console.warn('Attempting to fall back using "devicemotion"; however this will fail in the future without correct permissions.'),this.useDeviceMotion()):c.name==="ReferenceError"?this.useDeviceMotion():console.error(c)}l&&(this.api="sensor",this.sensor=l,this.sensor.addEventListener("reading",this._onSensorRead),this.sensor.start())}},{key:"useDeviceMotion",value:function(){this.api="devicemotion",this.fusionSensor=new Le(this.config.K_FILTER,this.config.PREDICTION_TIME_S,this.config.YAW_ONLY,this.config.DEBUG),this.sensor&&(this.sensor.removeEventListener("reading",this._onSensorRead),this.sensor.removeEventListener("error",this._onSensorError),this.sensor=null)}},{key:"getOrientation",value:function(){if(this.fusionSensor)return this.fusionSensor.getOrientation();if(!this.sensor||!this.sensor.quaternion)return this._out[0]=this._out[1]=this._out[2]=0,this._out[3]=1,this._out;var l=this.sensor.quaternion;this._sensorQ.set(l[0],l[1],l[2],l[3]);var c=this._outQ;return c.copy(Pr),c.multiply(this._sensorQ),this.config.YAW_ONLY&&(c.x=c.z=0,c.normalize()),this._out[0]=c.x,this._out[1]=c.y,this._out[2]=c.z,this._out[3]=c.w,this._out}},{key:"_onSensorError",value:function(l){this.errors.push(l.error),l.error.name==="NotAllowedError"?console.error("Permission to access sensor was denied"):l.error.name==="NotReadableError"?console.error("Sensor could not be read"):console.error(l.error),this.useDeviceMotion()}},{key:"_onSensorRead",value:function(){}}]),i})(),An="";function nt(){this.loadIcon_();var i=document.createElement("div"),g=i.style;g.position="fixed",g.top=0,g.right=0,g.bottom=0,g.left=0,g.backgroundColor="gray",g.fontFamily="sans-serif",g.zIndex=1e6;var s=document.createElement("img");s.src=this.icon;var g=s.style;g.marginLeft="25%",g.marginTop="25%",g.width="50%",i.appendChild(s);var l=document.createElement("div"),g=l.style;g.textAlign="center",g.fontSize="16px",g.lineHeight="24px",g.margin="24px 25%",g.width="50%",l.innerHTML="Place your phone into your Cardboard viewer.",i.appendChild(l);var c=document.createElement("div"),g=c.style;g.backgroundColor="#CFD8DC",g.position="fixed",g.bottom=0,g.width="100%",g.height="48px",g.padding="14px 24px",g.boxSizing="border-box",g.color="#656A6B",i.appendChild(c);var f=document.createElement("div");f.style.float="left",f.innerHTML="No Cardboard viewer?";var u=document.createElement("a");u.href="https://www.google.com/get/cardboard/get-cardboard/",u.innerHTML="get one",u.target="_blank";var g=u.style;g.float="right",g.fontWeight=600,g.textTransform="uppercase",g.borderLeft="1px solid gray",g.paddingLeft="24px",g.textDecoration="none",g.color="#656A6B",c.appendChild(f),c.appendChild(u),this.overlay=i,this.text=l,this.hide()}nt.prototype.show=function(i){!i&&!this.overlay.parentElement?document.body.appendChild(this.overlay):i&&(this.overlay.parentElement&&this.overlay.parentElement!=i&&this.overlay.parentElement.removeChild(this.overlay),i.appendChild(this.overlay)),this.overlay.style.display="block";var s=this.overlay.querySelector("img"),l=s.style;v()?(l.width="20%",l.marginLeft="40%",l.marginTop="3%"):(l.width="50%",l.marginLeft="25%",l.marginTop="25%")},nt.prototype.hide=function(){this.overlay.style.display="none"},nt.prototype.showTemporarily=function(i,s){this.show(s),this.timer=setTimeout(this.hide.bind(this),i)},nt.prototype.disableShowTemporarily=function(){clearTimeout(this.timer)},nt.prototype.update=function(){this.disableShowTemporarily(),!v()&&H()?this.show():this.hide()},nt.prototype.loadIcon_=function(){this.icon=h("image/svg+xml",An)};var pn="CardboardV1",ci="WEBVR_CARDBOARD_VIEWER",un="webvr-polyfill-viewer-selector";function De(i){try{this.selectedKey=localStorage.getItem(ci)}catch(s){console.error("Failed to load viewer profile: %s",s)}this.selectedKey||(this.selectedKey=i||pn),this.dialog=this.createDialog_(fe.Viewers),this.root=null,this.onChangeCallbacks_=[]}De.prototype.show=function(i){this.root=i,i.appendChild(this.dialog);var s=this.dialog.querySelector("#"+this.selectedKey);s.checked=!0,this.dialog.style.display="block"},De.prototype.hide=function(){this.root&&this.root.contains(this.dialog)&&this.root.removeChild(this.dialog),this.dialog.style.display="none"},De.prototype.getCurrentViewer=function(){return fe.Viewers[this.selectedKey]},De.prototype.getSelectedKey_=function(){var i=this.dialog.querySelector("input[name=field]:checked");return i?i.id:null},De.prototype.onChange=function(i){this.onChangeCallbacks_.push(i)},De.prototype.fireOnChange_=function(i){for(var s=0;s.5&&(this.noSleepVideo.currentTime=Math.random())}.bind(this)))}return u(E,[{key:"enable",value:function(){P?(this.disable(),this.noSleepTimer=window.setInterval(function(){window.location.href="/",window.setTimeout(window.stop,0)},15e3)):this.noSleepVideo.play()}},{key:"disable",value:function(){P?this.noSleepTimer&&(window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause()}}]),E})();l.exports=x}),(function(l,c,f){"use strict";l.exports="data:video/mp4;base64,AAAAIGZ0eXBtcDQyAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAACKBtZGF0AAAC8wYF///v3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE0MiByMjQ3OSBkZDc5YTYxIC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAxNCAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTEgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweDExMSBtZT1oZXggc3VibWU9MiBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0wIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MCA4eDhkY3Q9MCBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0wIHRocmVhZHM9NiBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVzPTMgYl9weXJhbWlkPTIgYl9hZGFwdD0xIGJfYmlhcz0wIGRpcmVjdD0xIHdlaWdodGI9MSBvcGVuX2dvcD0wIHdlaWdodHA9MSBrZXlpbnQ9MzAwIGtleWludF9taW49MzAgc2NlbmVjdXQ9NDAgaW50cmFfcmVmcmVzaD0wIHJjX2xvb2thaGVhZD0xMCByYz1jcmYgbWJ0cmVlPTEgY3JmPTIwLjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IHZidl9tYXhyYXRlPTIwMDAwIHZidl9idWZzaXplPTI1MDAwIGNyZl9tYXg9MC4wIG5hbF9ocmQ9bm9uZSBmaWxsZXI9MCBpcF9yYXRpbz0xLjQwIGFxPTE6MS4wMACAAAAAOWWIhAA3//p+C7v8tDDSTjf97w55i3SbRPO4ZY+hkjD5hbkAkL3zpJ6h/LR1CAABzgB1kqqzUorlhQAAAAxBmiQYhn/+qZYADLgAAAAJQZ5CQhX/AAj5IQADQGgcIQADQGgcAAAACQGeYUQn/wALKCEAA0BoHAAAAAkBnmNEJ/8ACykhAANAaBwhAANAaBwAAAANQZpoNExDP/6plgAMuSEAA0BoHAAAAAtBnoZFESwr/wAI+SEAA0BoHCEAA0BoHAAAAAkBnqVEJ/8ACykhAANAaBwAAAAJAZ6nRCf/AAsoIQADQGgcIQADQGgcAAAADUGarDRMQz/+qZYADLghAANAaBwAAAALQZ7KRRUsK/8ACPkhAANAaBwAAAAJAZ7pRCf/AAsoIQADQGgcIQADQGgcAAAACQGe60Qn/wALKCEAA0BoHAAAAA1BmvA0TEM//qmWAAy5IQADQGgcIQADQGgcAAAAC0GfDkUVLCv/AAj5IQADQGgcAAAACQGfLUQn/wALKSEAA0BoHCEAA0BoHAAAAAkBny9EJ/8ACyghAANAaBwAAAANQZs0NExDP/6plgAMuCEAA0BoHAAAAAtBn1JFFSwr/wAI+SEAA0BoHCEAA0BoHAAAAAkBn3FEJ/8ACyghAANAaBwAAAAJAZ9zRCf/AAsoIQADQGgcIQADQGgcAAAADUGbeDRMQz/+qZYADLkhAANAaBwAAAALQZ+WRRUsK/8ACPghAANAaBwhAANAaBwAAAAJAZ+1RCf/AAspIQADQGgcAAAACQGft0Qn/wALKSEAA0BoHCEAA0BoHAAAAA1Bm7w0TEM//qmWAAy4IQADQGgcAAAAC0Gf2kUVLCv/AAj5IQADQGgcAAAACQGf+UQn/wALKCEAA0BoHCEAA0BoHAAAAAkBn/tEJ/8ACykhAANAaBwAAAANQZvgNExDP/6plgAMuSEAA0BoHCEAA0BoHAAAAAtBnh5FFSwr/wAI+CEAA0BoHAAAAAkBnj1EJ/8ACyghAANAaBwhAANAaBwAAAAJAZ4/RCf/AAspIQADQGgcAAAADUGaJDRMQz/+qZYADLghAANAaBwAAAALQZ5CRRUsK/8ACPkhAANAaBwhAANAaBwAAAAJAZ5hRCf/AAsoIQADQGgcAAAACQGeY0Qn/wALKSEAA0BoHCEAA0BoHAAAAA1Bmmg0TEM//qmWAAy5IQADQGgcAAAAC0GehkUVLCv/AAj5IQADQGgcIQADQGgcAAAACQGepUQn/wALKSEAA0BoHAAAAAkBnqdEJ/8ACyghAANAaBwAAAANQZqsNExDP/6plgAMuCEAA0BoHCEAA0BoHAAAAAtBnspFFSwr/wAI+SEAA0BoHAAAAAkBnulEJ/8ACyghAANAaBwhAANAaBwAAAAJAZ7rRCf/AAsoIQADQGgcAAAADUGa8DRMQz/+qZYADLkhAANAaBwhAANAaBwAAAALQZ8ORRUsK/8ACPkhAANAaBwAAAAJAZ8tRCf/AAspIQADQGgcIQADQGgcAAAACQGfL0Qn/wALKCEAA0BoHAAAAA1BmzQ0TEM//qmWAAy4IQADQGgcAAAAC0GfUkUVLCv/AAj5IQADQGgcIQADQGgcAAAACQGfcUQn/wALKCEAA0BoHAAAAAkBn3NEJ/8ACyghAANAaBwhAANAaBwAAAANQZt4NExC//6plgAMuSEAA0BoHAAAAAtBn5ZFFSwr/wAI+CEAA0BoHCEAA0BoHAAAAAkBn7VEJ/8ACykhAANAaBwAAAAJAZ+3RCf/AAspIQADQGgcAAAADUGbuzRMQn/+nhAAYsAhAANAaBwhAANAaBwAAAAJQZ/aQhP/AAspIQADQGgcAAAACQGf+UQn/wALKCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHAAACiFtb292AAAAbG12aGQAAAAA1YCCX9WAgl8AAAPoAAAH/AABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAGGlvZHMAAAAAEICAgAcAT////v7/AAAF+XRyYWsAAABcdGtoZAAAAAPVgIJf1YCCXwAAAAEAAAAAAAAH0AAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAygAAAMoAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAB9AAABdwAAEAAAAABXFtZGlhAAAAIG1kaGQAAAAA1YCCX9WAgl8AAV+QAAK/IFXEAAAAAAAtaGRscgAAAAAAAAAAdmlkZQAAAAAAAAAAAAAAAFZpZGVvSGFuZGxlcgAAAAUcbWluZgAAABR2bWhkAAAAAQAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAAE3HN0YmwAAACYc3RzZAAAAAAAAAABAAAAiGF2YzEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAygDKAEgAAABIAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY//8AAAAyYXZjQwFNQCj/4QAbZ01AKOyho3ySTUBAQFAAAAMAEAAr8gDxgxlgAQAEaO+G8gAAABhzdHRzAAAAAAAAAAEAAAA8AAALuAAAABRzdHNzAAAAAAAAAAEAAAABAAAB8GN0dHMAAAAAAAAAPAAAAAEAABdwAAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAAC7gAAAAAQAAF3AAAAABAAAAAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAEEc3RzegAAAAAAAAAAAAAAPAAAAzQAAAAQAAAADQAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAANAAAADQAAAQBzdGNvAAAAAAAAADwAAAAwAAADZAAAA3QAAAONAAADoAAAA7kAAAPQAAAD6wAAA/4AAAQXAAAELgAABEMAAARcAAAEbwAABIwAAAShAAAEugAABM0AAATkAAAE/wAABRIAAAUrAAAFQgAABV0AAAVwAAAFiQAABaAAAAW1AAAFzgAABeEAAAX+AAAGEwAABiwAAAY/AAAGVgAABnEAAAaEAAAGnQAABrQAAAbPAAAG4gAABvUAAAcSAAAHJwAAB0AAAAdTAAAHcAAAB4UAAAeeAAAHsQAAB8gAAAfjAAAH9gAACA8AAAgmAAAIQQAACFQAAAhnAAAIhAAACJcAAAMsdHJhawAAAFx0a2hkAAAAA9WAgl/VgIJfAAAAAgAAAAAAAAf8AAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAACsm1kaWEAAAAgbWRoZAAAAADVgIJf1YCCXwAArEQAAWAAVcQAAAAAACdoZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU3RlcmVvAAAAAmNtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAidzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAIABICAgBRAFQAAAAADDUAAAAAABYCAgAISEAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAABYAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAAUc3RzegAAAAAAAAAGAAAAWAAAAXBzdGNvAAAAAAAAAFgAAAOBAAADhwAAA5oAAAOtAAADswAAA8oAAAPfAAAD5QAAA/gAAAQLAAAEEQAABCgAAAQ9AAAEUAAABFYAAARpAAAEgAAABIYAAASbAAAErgAABLQAAATHAAAE3gAABPMAAAT5AAAFDAAABR8AAAUlAAAFPAAABVEAAAVXAAAFagAABX0AAAWDAAAFmgAABa8AAAXCAAAFyAAABdsAAAXyAAAF+AAABg0AAAYgAAAGJgAABjkAAAZQAAAGZQAABmsAAAZ+AAAGkQAABpcAAAauAAAGwwAABskAAAbcAAAG7wAABwYAAAcMAAAHIQAABzQAAAc6AAAHTQAAB2QAAAdqAAAHfwAAB5IAAAeYAAAHqwAAB8IAAAfXAAAH3QAAB/AAAAgDAAAICQAACCAAAAg1AAAIOwAACE4AAAhhAAAIeAAACH4AAAiRAAAIpAAACKoAAAiwAAAItgAACLwAAAjCAAAAFnVkdGEAAAAObmFtZVN0ZXJlbwAAAHB1ZHRhAAAAaG1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAAO2lsc3QAAAAzqXRvbwAAACtkYXRhAAAAAQAAAABIYW5kQnJha2UgMC4xMC4yIDIwMTUwNjExMDA="})])})}),xn=vn(gn),yn=1e3,bn=[0,0,.5,1],Mn=[.5,0,.5,1],En=window.requestAnimationFrame,Sn=window.cancelAnimationFrame;function Rn(){this.leftProjectionMatrix=new Float32Array(16),this.leftViewMatrix=new Float32Array(16),this.rightProjectionMatrix=new Float32Array(16),this.rightViewMatrix=new Float32Array(16),this.pose=null}function hi(i){Object.defineProperties(this,{hasPosition:{writable:!1,enumerable:!0,value:i.hasPosition},hasExternalDisplay:{writable:!1,enumerable:!0,value:i.hasExternalDisplay},canPresent:{writable:!1,enumerable:!0,value:i.canPresent},maxLayers:{writable:!1,enumerable:!0,value:i.maxLayers},hasOrientation:{enumerable:!0,get:function(){return $("VRDisplayCapabilities.prototype.hasOrientation","VRDisplay.prototype.getFrameData"),i.hasOrientation}}})}function ie(i){i=i||{};var s="wakelock"in i?i.wakelock:!0;this.isPolyfilled=!0,this.displayId=yn++,this.displayName="",this.depthNear=.01,this.depthFar=1e4,this.isPresenting=!1,Object.defineProperty(this,"isConnected",{get:function(){return $("VRDisplay.prototype.isConnected","VRDisplayCapabilities.prototype.hasExternalDisplay"),!1}}),this.capabilities=new hi({hasPosition:!1,hasOrientation:!1,hasExternalDisplay:!1,canPresent:!1,maxLayers:1}),this.stageParameters=null,this.waitingForPresent_=!1,this.layer_=null,this.originalParent_=null,this.fullscreenElement_=null,this.fullscreenWrapper_=null,this.fullscreenElementCachedStyle_=null,this.fullscreenEventTarget_=null,this.fullscreenChangeHandler_=null,this.fullscreenErrorHandler_=null,s&&H()&&(this.wakelock_=new xn)}ie.prototype.getFrameData=function(i){return G(i,this._getPose(),this)},ie.prototype.getPose=function(){return $("VRDisplay.prototype.getPose","VRDisplay.prototype.getFrameData"),this._getPose()},ie.prototype.resetPose=function(){return $("VRDisplay.prototype.resetPose"),this._resetPose()},ie.prototype.getImmediatePose=function(){return $("VRDisplay.prototype.getImmediatePose","VRDisplay.prototype.getFrameData"),this._getPose()},ie.prototype.requestAnimationFrame=function(i){return En(i)},ie.prototype.cancelAnimationFrame=function(i){return Sn(i)},ie.prototype.wrapForFullscreen=function(i){if(A())return i;if(!this.fullscreenWrapper_){this.fullscreenWrapper_=document.createElement("div");var s=["height: "+Math.min(screen.height,screen.width)+"px !important","top: 0 !important","left: 0 !important","right: 0 !important","border: 0","margin: 0","padding: 0","z-index: 999999 !important","position: fixed"];this.fullscreenWrapper_.setAttribute("style",s.join("; ")+";"),this.fullscreenWrapper_.classList.add("webvr-polyfill-fullscreen-wrapper")}if(this.fullscreenElement_==i)return this.fullscreenWrapper_;if(this.fullscreenElement_&&(this.originalParent_?this.originalParent_.appendChild(this.fullscreenElement_):this.fullscreenElement_.parentElement.removeChild(this.fullscreenElement_)),this.fullscreenElement_=i,this.originalParent_=i.parentElement,this.originalParent_||document.body.appendChild(i),!this.fullscreenWrapper_.parentElement){var l=this.fullscreenElement_.parentElement;l.insertBefore(this.fullscreenWrapper_,this.fullscreenElement_),l.removeChild(this.fullscreenElement_)}this.fullscreenWrapper_.insertBefore(this.fullscreenElement_,this.fullscreenWrapper_.firstChild),this.fullscreenElementCachedStyle_=this.fullscreenElement_.getAttribute("style");var c=this;function f(){if(c.fullscreenElement_){var u=["position: absolute","top: 0","left: 0","width: "+Math.max(screen.width,screen.height)+"px","height: "+Math.min(screen.height,screen.width)+"px","border: 0","margin: 0","padding: 0"];c.fullscreenElement_.setAttribute("style",u.join("; ")+";")}}return f(),this.fullscreenWrapper_},ie.prototype.removeFullscreenWrapper=function(){if(this.fullscreenElement_){var i=this.fullscreenElement_;this.fullscreenElementCachedStyle_?i.setAttribute("style",this.fullscreenElementCachedStyle_):i.removeAttribute("style"),this.fullscreenElement_=null,this.fullscreenElementCachedStyle_=null;var s=this.fullscreenWrapper_.parentElement;return this.fullscreenWrapper_.removeChild(i),this.originalParent_===s?s.insertBefore(i,this.fullscreenWrapper_):this.originalParent_&&this.originalParent_.appendChild(i),s.removeChild(this.fullscreenWrapper_),i}},ie.prototype.requestPresent=function(i){var s=this.isPresenting,l=this;return i instanceof Array||($("VRDisplay.prototype.requestPresent with non-array argument","an array of VRLayers as the first argument"),i=[i]),new Promise(function(c,f){if(!l.capabilities.canPresent){f(new Error("VRDisplay is not capable of presenting."));return}if(i.length==0||i.length>l.capabilities.maxLayers){f(new Error("Invalid number of layers."));return}var u=i[0];if(!u.source){c();return}var g=u.leftBounds||bn,D=u.rightBounds||Mn;if(s){var P=l.layer_;P.source!==u.source&&(P.source=u.source);for(var x=0;x<4;x++)P.leftBounds[x]=g[x],P.rightBounds[x]=D[x];l.wrapForFullscreen(l.layer_.source),l.updatePresent_(),c();return}if(l.layer_={predistorted:u.predistorted,source:u.source,leftBounds:g.slice(0),rightBounds:D.slice(0)},l.waitingForPresent_=!1,l.layer_&&l.layer_.source){var E=l.wrapForFullscreen(l.layer_.source),O=function(){var X=L();l.isPresenting=E===X,l.isPresenting?(screen.orientation&&screen.orientation.lock&&screen.orientation.lock("landscape-primary").catch(function(J){console.error("screen.orientation.lock() failed due to",J.message)}),l.waitingForPresent_=!1,l.beginPresent_(),c()):(screen.orientation&&screen.orientation.unlock&&screen.orientation.unlock(),l.removeFullscreenWrapper(),l.disableWakeLock(),l.endPresent_(),l.removeFullscreenListeners_()),l.fireVRDisplayPresentChange_()},V=function(){l.waitingForPresent_&&(l.removeFullscreenWrapper(),l.removeFullscreenListeners_(),l.disableWakeLock(),l.waitingForPresent_=!1,l.isPresenting=!1,f(new Error("Unable to present.")))};l.addFullscreenListeners_(E,O,V),I(E)?(l.enableWakeLock(),l.waitingForPresent_=!0):(A()||p())&&(l.enableWakeLock(),l.isPresenting=!0,l.beginPresent_(),l.fireVRDisplayPresentChange_(),c())}!l.waitingForPresent_&&!A()&&(B(),f(new Error("Unable to present.")))})},ie.prototype.exitPresent=function(){var i=this.isPresenting,s=this;return this.isPresenting=!1,this.layer_=null,this.disableWakeLock(),new Promise(function(l,c){i?(!B()&&A()&&(s.endPresent_(),s.fireVRDisplayPresentChange_()),p()&&(s.removeFullscreenWrapper(),s.removeFullscreenListeners_(),s.endPresent_(),s.fireVRDisplayPresentChange_()),l()):c(new Error("Was not presenting to VRDisplay."))})},ie.prototype.getLayers=function(){return this.layer_?[this.layer_]:[]},ie.prototype.fireVRDisplayPresentChange_=function(){var i=new CustomEvent("vrdisplaypresentchange",{detail:{display:this}});window.dispatchEvent(i)},ie.prototype.fireVRDisplayConnect_=function(){var i=new CustomEvent("vrdisplayconnect",{detail:{display:this}});window.dispatchEvent(i)},ie.prototype.addFullscreenListeners_=function(i,s,l){this.removeFullscreenListeners_(),this.fullscreenEventTarget_=i,this.fullscreenChangeHandler_=s,this.fullscreenErrorHandler_=l,s&&(document.fullscreenEnabled?i.addEventListener("fullscreenchange",s,!1):document.webkitFullscreenEnabled?i.addEventListener("webkitfullscreenchange",s,!1):document.mozFullScreenEnabled?document.addEventListener("mozfullscreenchange",s,!1):document.msFullscreenEnabled&&i.addEventListener("msfullscreenchange",s,!1)),l&&(document.fullscreenEnabled?i.addEventListener("fullscreenerror",l,!1):document.webkitFullscreenEnabled?i.addEventListener("webkitfullscreenerror",l,!1):document.mozFullScreenEnabled?document.addEventListener("mozfullscreenerror",l,!1):document.msFullscreenEnabled&&i.addEventListener("msfullscreenerror",l,!1))},ie.prototype.removeFullscreenListeners_=function(){if(this.fullscreenEventTarget_){var i=this.fullscreenEventTarget_;if(this.fullscreenChangeHandler_){var s=this.fullscreenChangeHandler_;i.removeEventListener("fullscreenchange",s,!1),i.removeEventListener("webkitfullscreenchange",s,!1),document.removeEventListener("mozfullscreenchange",s,!1),i.removeEventListener("msfullscreenchange",s,!1)}if(this.fullscreenErrorHandler_){var l=this.fullscreenErrorHandler_;i.removeEventListener("fullscreenerror",l,!1),i.removeEventListener("webkitfullscreenerror",l,!1),document.removeEventListener("mozfullscreenerror",l,!1),i.removeEventListener("msfullscreenerror",l,!1)}this.fullscreenEventTarget_=null,this.fullscreenChangeHandler_=null,this.fullscreenErrorHandler_=null}},ie.prototype.enableWakeLock=function(){this.wakelock_&&this.wakelock_.enable()},ie.prototype.disableWakeLock=function(){this.wakelock_&&this.wakelock_.disable()},ie.prototype.beginPresent_=function(){},ie.prototype.endPresent_=function(){},ie.prototype.submitFrame=function(i){},ie.prototype.getEyeParameters=function(i){return null};var _n={ADDITIONAL_VIEWERS:[],DEFAULT_VIEWER:"",MOBILE_WAKE_LOCK:!0,DEBUG:!1,DPDB_URL:"https://dpdb.webvr.rocks/dpdb.json",K_FILTER:.98,PREDICTION_TIME_S:.04,CARDBOARD_UI_DISABLED:!1,ROTATE_INSTRUCTIONS_DISABLED:!1,YAW_ONLY:!1,BUFFER_SCALE:.5,DIRTY_SUBMIT_FRAME_BINDINGS:!1},or={LEFT:"left",RIGHT:"right"};function Ae(i){var s=N({},_n);i=N(s,i||{}),ie.call(this,{wakelock:i.MOBILE_WAKE_LOCK}),this.config=i,this.displayName="Cardboard VRDisplay",this.capabilities=new hi({hasPosition:!1,hasOrientation:!0,hasExternalDisplay:!1,canPresent:!0,maxLayers:1}),this.stageParameters=null,this.bufferScale_=this.config.BUFFER_SCALE,this.poseSensor_=new fn(this.config),this.distorter_=null,this.cardboardUI_=null,this.dpdb_=new _t(this.config.DPDB_URL,this.onDeviceParamsUpdated_.bind(this)),this.deviceInfo_=new fe(this.dpdb_.getDeviceParams(),i.ADDITIONAL_VIEWERS),this.viewerSelector_=new De(i.DEFAULT_VIEWER),this.viewerSelector_.onChange(this.onViewerChanged_.bind(this)),this.deviceInfo_.setViewer(this.viewerSelector_.getCurrentViewer()),this.config.ROTATE_INSTRUCTIONS_DISABLED||(this.rotateInstructions_=new nt),A()&&window.addEventListener("resize",this.onResize_.bind(this))}return Ae.prototype=Object.create(ie.prototype),Ae.prototype._getPose=function(){return{position:null,orientation:this.poseSensor_.getOrientation(),linearVelocity:null,linearAcceleration:null,angularVelocity:null,angularAcceleration:null}},Ae.prototype._resetPose=function(){this.poseSensor_.resetPose&&this.poseSensor_.resetPose()},Ae.prototype._getFieldOfView=function(i){var s;if(i==or.LEFT)s=this.deviceInfo_.getFieldOfViewLeftEye();else if(i==or.RIGHT)s=this.deviceInfo_.getFieldOfViewRightEye();else return console.error("Invalid eye provided: %s",i),null;return s},Ae.prototype._getEyeOffset=function(i){var s;if(i==or.LEFT)s=[-this.deviceInfo_.viewer.interLensDistance*.5,0,0];else if(i==or.RIGHT)s=[this.deviceInfo_.viewer.interLensDistance*.5,0,0];else return console.error("Invalid eye provided: %s",i),null;return s},Ae.prototype.getEyeParameters=function(i){var s=this._getEyeOffset(i),l=this._getFieldOfView(i),c={offset:s,renderWidth:this.deviceInfo_.device.width*.5*this.bufferScale_,renderHeight:this.deviceInfo_.device.height*this.bufferScale_};return Object.defineProperty(c,"fieldOfView",{enumerable:!0,get:function(){return $("VRFieldOfView","VRFrameData's projection matrices"),l}}),c},Ae.prototype.onDeviceParamsUpdated_=function(i){this.config.DEBUG&&console.log("DPDB reported that device params were updated."),this.deviceInfo_.updateDeviceParams(i),this.distorter_&&this.distorter_.updateDeviceInfo(this.deviceInfo_)},Ae.prototype.updateBounds_=function(){this.layer_&&this.distorter_&&(this.layer_.leftBounds||this.layer_.rightBounds)&&this.distorter_.setTextureBounds(this.layer_.leftBounds,this.layer_.rightBounds)},Ae.prototype.beginPresent_=function(){var i=this.layer_.source.getContext("webgl");i||(i=this.layer_.source.getContext("experimental-webgl")),i||(i=this.layer_.source.getContext("webgl2")),i&&(this.layer_.predistorted?this.config.CARDBOARD_UI_DISABLED||(i.canvas.width=F()*this.bufferScale_,i.canvas.height=R()*this.bufferScale_,this.cardboardUI_=new rt(i)):(this.config.CARDBOARD_UI_DISABLED||(this.cardboardUI_=new rt(i)),this.distorter_=new de(i,this.cardboardUI_,this.config.BUFFER_SCALE,this.config.DIRTY_SUBMIT_FRAME_BINDINGS),this.distorter_.updateDeviceInfo(this.deviceInfo_)),this.cardboardUI_&&this.cardboardUI_.listen(function(s){this.viewerSelector_.show(this.layer_.source.parentElement),s.stopPropagation(),s.preventDefault()}.bind(this),function(s){this.exitPresent(),s.stopPropagation(),s.preventDefault()}.bind(this)),this.rotateInstructions_&&(v()&&H()?this.rotateInstructions_.showTemporarily(3e3,this.layer_.source.parentElement):this.rotateInstructions_.update()),this.orientationHandler=this.onOrientationChange_.bind(this),window.addEventListener("orientationchange",this.orientationHandler),this.vrdisplaypresentchangeHandler=this.updateBounds_.bind(this),window.addEventListener("vrdisplaypresentchange",this.vrdisplaypresentchangeHandler),this.fireVRDisplayDeviceParamsChange_())},Ae.prototype.endPresent_=function(){this.distorter_&&(this.distorter_.destroy(),this.distorter_=null),this.cardboardUI_&&(this.cardboardUI_.destroy(),this.cardboardUI_=null),this.rotateInstructions_&&this.rotateInstructions_.hide(),this.viewerSelector_.hide(),window.removeEventListener("orientationchange",this.orientationHandler),window.removeEventListener("vrdisplaypresentchange",this.vrdisplaypresentchangeHandler)},Ae.prototype.updatePresent_=function(){this.endPresent_(),this.beginPresent_()},Ae.prototype.submitFrame=function(i){if(this.distorter_)this.updateBounds_(),this.distorter_.submitFrame();else if(this.cardboardUI_&&this.layer_){var s=this.layer_.source.getContext("webgl");s||(s=this.layer_.source.getContext("experimental-webgl")),s||(s=this.layer_.source.getContext("webgl2"));var l=s.canvas;(l.width!=this.lastWidth||l.height!=this.lastHeight)&&this.cardboardUI_.onResize(),this.lastWidth=l.width,this.lastHeight=l.height,this.cardboardUI_.render()}},Ae.prototype.onOrientationChange_=function(i){this.viewerSelector_.hide(),this.rotateInstructions_&&this.rotateInstructions_.update(),this.onResize_()},Ae.prototype.onResize_=function(i){if(this.layer_){var s=this.layer_.source.getContext("webgl");s||(s=this.layer_.source.getContext("experimental-webgl")),s||(s=this.layer_.source.getContext("webgl2"));var l=["position: absolute","top: 0","left: 0","width: 100vw","height: 100vh","border: 0","margin: 0","padding: 0px","box-sizing: content-box"];s.canvas.setAttribute("style",l.join("; ")+";"),k(s.canvas)}},Ae.prototype.onViewerChanged_=function(i){this.deviceInfo_.setViewer(i),this.distorter_&&this.distorter_.updateDeviceInfo(this.deviceInfo_),this.fireVRDisplayDeviceParamsChange_()},Ae.prototype.fireVRDisplayDeviceParamsChange_=function(){var i=new CustomEvent("vrdisplaydeviceparamschange",{detail:{vrdisplay:this,deviceInfo:this.deviceInfo_}});window.dispatchEvent(i)},Ae.VRFrameData=Rn,Ae.VRDisplay=ie,Ae}))});var Wi=di((Dl,Ui)=>{"use strict";Ui.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var Vt=Symbol("@@webxr-polyfill/EventTarget"),Ve=class{constructor(){this[Vt]={listeners:new Map}}addEventListener(e,r){if(typeof e!="string")throw new Error("`type` must be a string");if(typeof r!="function")throw new Error("`listener` must be a function");let n=this[Vt].listeners.get(e)||[];n.push(r),this[Vt].listeners.set(e,n)}removeEventListener(e,r){if(typeof e!="string")throw new Error("`type` must be a string");if(typeof r!="function")throw new Error("`listener` must be a function");let n=this[Vt].listeners.get(e)||[];for(let a=n.length;a>=0;a--)n[a]===r&&n.pop()}dispatchEvent(e,r){let n=this[Vt].listeners.get(e)||[],a=[];for(let o=0;o0?(n=Math.sqrt(r+1)*2,t[3]=.25*n,t[0]=(e[6]-e[9])/n,t[1]=(e[8]-e[2])/n,t[2]=(e[1]-e[4])/n):e[0]>e[5]&&e[0]>e[10]?(n=Math.sqrt(1+e[0]-e[5]-e[10])*2,t[3]=(e[6]-e[9])/n,t[0]=.25*n,t[1]=(e[1]+e[4])/n,t[2]=(e[8]+e[2])/n):e[5]>e[10]?(n=Math.sqrt(1+e[5]-e[0]-e[10])*2,t[3]=(e[8]-e[2])/n,t[0]=(e[1]+e[4])/n,t[1]=.25*n,t[2]=(e[6]+e[9])/n):(n=Math.sqrt(1+e[10]-e[0]-e[5])*2,t[3]=(e[1]-e[4])/n,t[0]=(e[8]+e[2])/n,t[1]=(e[6]+e[9])/n,t[2]=.25*n),t}function hr(t,e,r,n,a){let o=1/Math.tan(e/2),h;return t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,a!=null&&a!==1/0?(h=1/(n-a),t[10]=(a+n)*h,t[14]=2*a*n*h):(t[10]=-1,t[14]=-2*n),t}function Ce(){let t=new ue(3);return ue!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Fr(t){var e=new ue(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function On(t){let e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function Ee(t,e,r){let n=new ue(3);return n[0]=t,n[1]=e,n[2]=r,n}function Ir(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function bt(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function Lr(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function dr(t,e){let r=e[0],n=e[1],a=e[2],o=r*r+n*n+a*a;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o),t}function Wt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function fr(t,e,r){let n=e[0],a=e[1],o=e[2],h=r[0],d=r[1],A=r[2];return t[0]=a*A-o*d,t[1]=o*h-n*A,t[2]=n*d-a*h,t}function ot(t,e,r){let n=r[0],a=r[1],o=r[2],h=r[3],d=e[0],A=e[1],p=e[2],m=a*p-o*A,w=o*d-n*p,b=n*A-a*d,y=a*b-o*w,_=o*m-n*b,M=n*w-a*m,v=h*2;return m*=v,w*=v,b*=v,y*=2,_*=2,M*=2,t[0]=d+m+y,t[1]=A+w+_,t[2]=p+b+M,t}function pi(t,e){let r=Ee(t[0],t[1],t[2]),n=Ee(e[0],e[1],e[2]);dr(r,r),dr(n,n);let a=Wt(r,n);return a>1?0:a<-1?Math.PI:Math.acos(a)}var ui=On;var Ta=(function(){let t=Ce();return function(e,r,n,a,o,h){let d,A;for(r||(r=3),n||(n=0),a?A=Math.min(a*r+n,e.length):A=e.length,d=n;d0&&(h=1/Math.sqrt(h),t[0]=r*h,t[1]=n*h,t[2]=a*h,t[3]=o*h),t}var Pa=(function(){let t=Gn();return function(e,r,n,a,o,h){let d,A;for(r||(r=4),n||(n=0),a?A=Math.min(a*r+n,e.length):A=e.length,d=n;d1e-6?(b=Math.acos(y),_=Math.sin(b),M=Math.sin((1-n)*b)/_,v=Math.sin(n*b)/_):(M=1-n,v=n),t[0]=M*a+v*A,t[1]=M*o+v*p,t[2]=M*h+v*m,t[3]=M*d+v*w,t}function Br(t,e){let r=e[0],n=e[1],a=e[2],o=e[3],h=r*r+n*n+a*a+o*o,d=h?1/h:0;return t[0]=-r*d,t[1]=-n*d,t[2]=-a*d,t[3]=o*d,t}function zn(t,e){let r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{let a=0;e[4]>e[0]&&(a=1),e[8]>e[a*3+a]&&(a=2);let o=(a+1)%3,h=(a+2)%3;n=Math.sqrt(e[a*3+a]-e[o*3+o]-e[h*3+h]+1),t[a]=.5*n,n=.5/n,t[3]=(e[o*3+h]-e[h*3+o])*n,t[o]=(e[o*3+a]+e[a*3+o])*n,t[h]=(e[h*3+a]+e[a*3+h])*n}return t}function yi(t,e,r,n){let a=.5*Math.PI/180;e*=a,r*=a,n*=a;let o=Math.sin(e),h=Math.cos(e),d=Math.sin(r),A=Math.cos(r),p=Math.sin(n),m=Math.cos(n);return t[0]=o*A*m-h*d*p,t[1]=h*d*m+o*A*p,t[2]=h*A*p-o*d*m,t[3]=h*A*m+o*d*p,t}var Or=vi,bi=wi,pr=gi;var Qt=xi;var ka=(function(){let t=Ce(),e=Ee(1,0,0),r=Ee(0,1,0);return function(n,a,o){let h=Wt(a,o);return h<-.999999?(fr(t,e,a),ui(t)<1e-6&&fr(t,r,a),dr(t,t),Vn(n,t,Math.PI),n):h>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(fr(t,a,o),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+h,Qt(n,n))}})(),Va=(function(){let t=Fe(),e=Fe();return function(r,n,a,o,h,d){return Mt(t,n,h,d),Mt(e,a,o,d),Mt(r,t,e,2*d*(1-d)),r}})(),za=(function(){let t=mi();return function(e,r,n,a){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=a[0],t[4]=a[1],t[7]=a[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],Qt(e,zn(e,t))}})();var te=Symbol("@@webxr-polyfill/XRRigidTransform"),lt=class t{constructor(){if(this[te]={matrix:null,position:null,orientation:null,inverse:null},arguments.length===0)this[te].matrix=Xe(new Float32Array(16));else if(arguments.length===1)arguments[0]instanceof Float32Array?this[te].matrix=arguments[0]:(this[te].position=this._getPoint(arguments[0]),this[te].orientation=DOMPointReadOnly.fromPoint({x:0,y:0,z:0,w:1}));else if(arguments.length===2)this[te].position=this._getPoint(arguments[0]),this[te].orientation=this._getPoint(arguments[1]);else throw new Error("Too many arguments!");if(this[te].matrix){let e=Ce();lr(e,this[te].matrix),this[te].position=DOMPointReadOnly.fromPoint({x:e[0],y:e[1],z:e[2]});let r=Fe();cr(r,this[te].matrix),this[te].orientation=DOMPointReadOnly.fromPoint({x:r[0],y:r[1],z:r[2],w:r[3]})}else this[te].matrix=Xe(new Float32Array(16)),He(this[te].matrix,bi(this[te].orientation.x,this[te].orientation.y,this[te].orientation.z,this[te].orientation.w),Ee(this[te].position.x,this[te].position.y,this[te].position.z))}_getPoint(e){return e instanceof DOMPointReadOnly?e:DOMPointReadOnly.fromPoint(e)}get matrix(){return this[te].matrix}get position(){return this[te].position}get orientation(){return this[te].orientation}get inverse(){if(this[te].inverse===null){let e=Xe(new Float32Array(16));st(e,this[te].matrix),this[te].inverse=new t(e),this[te].inverse[te].inverse=this}return this[te].inverse}};var ae=Symbol("@@webxr-polyfill/XRSpace");var Se=class{constructor(e=null,r=null){this[ae]={specialType:e,inputSource:r,baseMatrix:null,inverseBaseMatrix:null,lastFrameId:-1}}get _specialType(){return this[ae].specialType}get _inputSource(){return this[ae].inputSource}_ensurePoseUpdated(e,r){r!=this[ae].lastFrameId&&(this[ae].lastFrameId=r,this._onPoseUpdate(e))}_onPoseUpdate(e){this[ae].specialType=="viewer"&&(this._baseMatrix=e.getBasePoseMatrix())}set _baseMatrix(e){this[ae].baseMatrix=e,this[ae].inverseBaseMatrix=null}get _baseMatrix(){return this[ae].baseMatrix||this[ae].inverseBaseMatrix&&(this[ae].baseMatrix=new Float32Array(16),st(this[ae].baseMatrix,this[ae].inverseBaseMatrix)),this[ae].baseMatrix}set _inverseBaseMatrix(e){this[ae].inverseBaseMatrix=e,this[ae].baseMatrix=null}get _inverseBaseMatrix(){return this[ae].inverseBaseMatrix||this[ae].baseMatrix&&(this[ae].inverseBaseMatrix=new Float32Array(16),st(this[ae].inverseBaseMatrix,this[ae].baseMatrix)),this[ae].inverseBaseMatrix}_getSpaceRelativeTransform(e){if(!this._inverseBaseMatrix||!e._baseMatrix)return null;let r=new Float32Array(16);return ze(r,this._inverseBaseMatrix,e._baseMatrix),new lt(r)}};var Un=1.6,Ye=Symbol("@@webxr-polyfill/XRReferenceSpace"),Xt=["viewer","local","local-floor","bounded-floor","unbounded"];function Wn(t){return t==="bounded-floor"||t==="local-floor"}var qe=class t extends Se{constructor(e,r=null){if(!Xt.includes(e))throw new Error(`XRReferenceSpaceType must be one of ${Xt}`);if(super(e),e==="bounded-floor"&&!r)throw new Error("XRReferenceSpace cannot use 'bounded-floor' type if the platform does not provide the floor level");Wn(e)&&!r&&(r=Xe(new Float32Array(16)),r[13]=Un),this._inverseBaseMatrix=r||Xe(new Float32Array(16)),this[Ye]={type:e,transform:r,originOffset:Xe(new Float32Array(16))}}_transformBasePoseMatrix(e,r){ze(e,this._inverseBaseMatrix,r)}_originOffsetMatrix(){return this[Ye].originOffset}_adjustForOriginOffset(e){let r=new Float32Array(16);st(r,this[Ye].originOffset),ze(e,r,e)}_getSpaceRelativeTransform(e){let r=super._getSpaceRelativeTransform(e);return this._adjustForOriginOffset(r.matrix),new XRRigidTransform(r.matrix)}getOffsetReferenceSpace(e){let r=new t(this[Ye].type,this[Ye].transform,this[Ye].bounds);return ze(r[Ye].originOffset,this[Ye].originOffset,e.matrix),r}};var ye=Symbol("@@webxr-polyfill/XR"),Qn=["inline","immersive-vr","immersive-ar"],Xn={inline:{requiredFeatures:["viewer"],optionalFeatures:[]},"immersive-vr":{requiredFeatures:["viewer","local"],optionalFeatures:[]},"immersive-ar":{requiredFeatures:["viewer","local"],optionalFeatures:[]}},Hn=`Polyfill Error: Must call navigator.xr.isSessionSupported() with any XRSessionMode +or navigator.xr.requestSession('inline') prior to requesting an immersive +session. This is a limitation specific to the WebXR Polyfill and does not apply +to native implementations of the API.`,ct=class extends Ve{constructor(e){super(),this[ye]={device:null,devicePromise:e,immersiveSession:null,inlineSessions:new Set},e.then(r=>{this[ye].device=r})}async isSessionSupported(e){return this[ye].device||await this[ye].devicePromise,e!="inline"?Promise.resolve(this[ye].device.isSessionSupported(e)):Promise.resolve(!0)}async requestSession(e,r){if(!this[ye].device){if(e!="inline")throw new Error(Hn);await this[ye].devicePromise}if(!Qn.includes(e))throw new TypeError(`The provided value '${e}' is not a valid enum value of type XRSessionMode`);let n=Xn[e],a=n.requiredFeatures.concat(r&&r.requiredFeatures?r.requiredFeatures:[]),o=n.optionalFeatures.concat(r&&r.optionalFeatures?r.optionalFeatures:[]),h=new Set,d=!1;for(let w of a)this[ye].device.isFeatureSupported(w)?h.add(w):(console.error(`The required feature '${w}' is not supported`),d=!0);if(d)throw new DOMException("Session does not support some required features","NotSupportedError");for(let w of o)this[ye].device.isFeatureSupported(w)?h.add(w):console.log(`The optional feature '${w}' is not supported`);let A=await this[ye].device.requestSession(e,h),p=new XRSession(this[ye].device,e,A);e=="inline"?this[ye].inlineSessions.add(p):this[ye].immersiveSession=p;let m=()=>{e=="inline"?this[ye].inlineSessions.delete(p):this[ye].immersiveSession=null,p.removeEventListener("end",m)};return p.addEventListener("end",m),p}};var Yn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:{},ur=Yn;var Gr;if("performance"in ur)Gr=()=>performance.now();else{let t=Date.now();Gr=()=>Date.now()-t}var mr=Gr;var kr=Symbol("@@webxr-polyfill/XRPose"),ht=class{constructor(e,r){this[kr]={transform:e,emulatedPosition:r}}get transform(){return this[kr].transform}get emulatedPosition(){return this[kr].emulatedPosition}};var Mi=Symbol("@@webxr-polyfill/XRViewerPose"),dt=class extends ht{constructor(e,r,n=!1){super(e,n),this[Mi]={views:r}}get views(){return this[Mi].views}};var Ht=Symbol("@@webxr-polyfill/XRViewport"),ft=class{constructor(e){this[Ht]={target:e}}get x(){return this[Ht].target.x}get y(){return this[Ht].target.y}get width(){return this[Ht].target.width}get height(){return this[Ht].target.height}};var Ei=["left","right","none"],ke=Symbol("@@webxr-polyfill/XRView"),At=class{constructor(e,r,n,a,o){if(!Ei.includes(n))throw new Error(`XREye must be one of: ${Ei}`);let h=Object.create(null),d=new ft(h);this[ke]={device:e,eye:n,viewport:d,temp:h,sessionId:a,transform:r,viewIndex:o}}get eye(){return this[ke].eye}get projectionMatrix(){return this[ke].device.getProjectionMatrix(this.eye,this[ke].viewIndex)}get transform(){return this[ke].transform}_getViewport(e){if(this[ke].device.getViewport(this[ke].sessionId,this.eye,e,this[ke].temp,this[ke].viewIndex))return this[ke].viewport}};var he=Symbol("@@webxr-polyfill/XRFrame"),Si="XRFrame access outside the callback that produced it is invalid.",qn="getViewerPose can only be called on XRFrame objects passed to XRSession.requestAnimationFrame callbacks.",jn=0,je=class{constructor(e,r,n){this[he]={id:++jn,active:!1,animationFrame:!1,device:e,session:r,sessionId:n}}get session(){return this[he].session}getViewerPose(e){if(!this[he].animationFrame)throw new DOMException(qn,"InvalidStateError");if(!this[he].active)throw new DOMException(Si,"InvalidStateError");let r=this[he].device,n=this[he].session;n[T].viewerSpace._ensurePoseUpdated(r,this[he].id),e._ensurePoseUpdated(r,this[he].id);let a=e._getSpaceRelativeTransform(n[T].viewerSpace),o=[];for(let d of n[T].viewSpaces){d._ensurePoseUpdated(r,this[he].id);let A=e._getSpaceRelativeTransform(d),p=new At(r,A,d.eye,this[he].sessionId,d.viewIndex);o.push(p)}return new dt(a,o,!1)}getPose(e,r){if(!this[he].active)throw new DOMException(Si,"InvalidStateError");let n=this[he].device;if(e._specialType==="target-ray"||e._specialType==="grip")return n.getInputPose(e._inputSource,r,e._specialType);{e._ensurePoseUpdated(n,this[he].id),r._ensurePoseUpdated(n,this[he].id);let a=r._getSpaceRelativeTransform(e);return a?new XRPose(a,!1):null}return null}};var Yt=Symbol("@@webxr-polyfill/XRRenderState"),Zn=Object.freeze({depthNear:.1,depthFar:1e3,inlineVerticalFieldOfView:null,baseLayer:null}),Ze=class{constructor(e={}){let r=Object.assign({},Zn,e);this[Yt]={config:r}}get depthNear(){return this[Yt].config.depthNear}get depthFar(){return this[Yt].config.depthFar}get inlineVerticalFieldOfView(){return this[Yt].config.inlineVerticalFieldOfView}get baseLayer(){return this[Yt].config.baseLayer}};var Vr=Symbol("@@webxr-polyfill/XRInputSourceEvent"),pt=class t extends Event{constructor(e,r){super(e,r),this[Vr]={frame:r.frame,inputSource:r.inputSource},Object.setPrototypeOf(this,t.prototype)}get frame(){return this[Vr].frame}get inputSource(){return this[Vr].inputSource}};var Ri=Symbol("@@webxr-polyfill/XRSessionEvent"),Ke=class t extends Event{constructor(e,r){super(e,r),this[Ri]={session:r.session},Object.setPrototypeOf(this,t.prototype)}get session(){return this[Ri].session}};var vr=Symbol("@@webxr-polyfill/XRInputSourcesChangeEvent"),ut=class t extends Event{constructor(e,r){super(e,r),this[vr]={session:r.session,added:r.added,removed:r.removed},Object.setPrototypeOf(this,t.prototype)}get session(){return this[vr].session}get added(){return this[vr].added}get removed(){return this[vr].removed}};var T=Symbol("@@webxr-polyfill/XRSession"),qt=class extends Se{constructor(e){super(e)}get eye(){return this._specialType}_onPoseUpdate(e){this._inverseBaseMatrix=e.getBaseViewMatrix(this._specialType)}},mt=class extends Ve{constructor(e,r,n){super();let a=r!="inline",o=new Ze({inlineVerticalFieldOfView:a?null:Math.PI*.5}),h=a?[new qt("left"),new qt("right")]:[new qt("none")];Object.freeze(h),this[T]={device:e,mode:r,immersive:a,ended:!1,suspended:!1,frameCallbacks:[],currentFrameCallbacks:null,frameHandle:0,deviceFrameHandle:null,id:n,activeRenderState:o,pendingRenderState:null,viewerSpace:new qe("viewer"),get viewSpaces(){return e.getViewSpaces(r)||h},currentInputSources:[]},this[T].onDeviceFrame=()=>{if(this[T].ended||this[T].suspended||(this[T].deviceFrameHandle=null,this[T].startDeviceFrameLoop(),this[T].pendingRenderState!==null&&(this[T].activeRenderState=new Ze(this[T].pendingRenderState),this[T].pendingRenderState=null,this[T].activeRenderState.baseLayer&&this[T].device.onBaseLayerSet(this[T].id,this[T].activeRenderState.baseLayer)),this[T].activeRenderState.baseLayer===null))return;let d=new je(e,this,this[T].id),A=this[T].currentFrameCallbacks=this[T].frameCallbacks;this[T].frameCallbacks=[],d[he].active=!0,d[he].animationFrame=!0,this[T].device.onFrameStart(this[T].id,this[T].activeRenderState),this._checkInputSourcesChange();let p=mr();for(let m=0;m{this[T].deviceFrameHandle===null&&(this[T].deviceFrameHandle=this[T].device.requestAnimationFrame(this[T].onDeviceFrame))},this[T].stopDeviceFrameLoop=()=>{let d=this[T].deviceFrameHandle;d!==null&&(this[T].device.cancelAnimationFrame(d),this[T].deviceFrameHandle=null)},this[T].onPresentationEnd=d=>{if(d!==this[T].id){this[T].suspended=!1,this[T].startDeviceFrameLoop(),this.dispatchEvent("focus",{session:this});return}this[T].ended=!0,this[T].stopDeviceFrameLoop(),e.removeEventListener("@@webxr-polyfill/vr-present-end",this[T].onPresentationEnd),e.removeEventListener("@@webxr-polyfill/vr-present-start",this[T].onPresentationStart),e.removeEventListener("@@webxr-polyfill/input-select-start",this[T].onSelectStart),e.removeEventListener("@@webxr-polyfill/input-select-end",this[T].onSelectEnd),this.dispatchEvent("end",new Ke("end",{session:this}))},e.addEventListener("@@webxr-polyfill/vr-present-end",this[T].onPresentationEnd),this[T].onPresentationStart=d=>{d!==this[T].id&&(this[T].suspended=!0,this[T].stopDeviceFrameLoop(),this.dispatchEvent("blur",{session:this}))},e.addEventListener("@@webxr-polyfill/vr-present-start",this[T].onPresentationStart),this[T].onSelectStart=d=>{d.sessionId===this[T].id&&this[T].dispatchInputSourceEvent("selectstart",d.inputSource)},e.addEventListener("@@webxr-polyfill/input-select-start",this[T].onSelectStart),this[T].onSelectEnd=d=>{d.sessionId===this[T].id&&(this[T].dispatchInputSourceEvent("selectend",d.inputSource),this[T].dispatchInputSourceEvent("select",d.inputSource))},e.addEventListener("@@webxr-polyfill/input-select-end",this[T].onSelectEnd),this[T].onSqueezeStart=d=>{d.sessionId===this[T].id&&this[T].dispatchInputSourceEvent("squeezestart",d.inputSource)},e.addEventListener("@@webxr-polyfill/input-squeeze-start",this[T].onSqueezeStart),this[T].onSqueezeEnd=d=>{d.sessionId===this[T].id&&(this[T].dispatchInputSourceEvent("squeezeend",d.inputSource),this[T].dispatchInputSourceEvent("squeeze",d.inputSource))},e.addEventListener("@@webxr-polyfill/input-squeeze-end",this[T].onSqueezeEnd),this[T].dispatchInputSourceEvent=(d,A)=>{let p=new je(e,this,this[T].id),m=new pt(d,{frame:p,inputSource:A});p[he].active=!0,this.dispatchEvent(d,m),p[he].active=!1},this[T].startDeviceFrameLoop(),this.onblur=void 0,this.onfocus=void 0,this.onresetpose=void 0,this.onend=void 0,this.onselect=void 0,this.onselectstart=void 0,this.onselectend=void 0}get renderState(){return this[T].activeRenderState}get environmentBlendMode(){return this[T].device.environmentBlendMode||"opaque"}async requestReferenceSpace(e){if(this[T].ended)return;if(!Xt.includes(e))throw new TypeError(`XRReferenceSpaceType must be one of ${Xt}`);if(!this[T].device.doesSessionSupportReferenceSpace(this[T].id,e))throw new DOMException(`The ${e} reference space is not supported by this session.`,"NotSupportedError");if(e==="viewer")return this[T].viewerSpace;let r=await this[T].device.requestFrameOfReferenceTransform(e);if(e==="bounded-floor")throw r?this[T].device.requestStageBounds()?new DOMException(`The WebXR polyfill does not support the ${e} reference space yet.`,"NotSupportedError"):new DOMException(`${e} XRReferenceSpace not supported by this device.`,"NotSupportedError"):new DOMException(`${e} XRReferenceSpace not supported by this device.`,"NotSupportedError");return new qe(e,r)}requestAnimationFrame(e){if(this[T].ended)return;let r=++this[T].frameHandle;return this[T].frameCallbacks.push({handle:r,callback:e,cancelled:!1}),r}cancelAnimationFrame(e){let r=this[T].frameCallbacks,n=r.findIndex(a=>a&&a.handle===e);n>-1&&(r[n].cancelled=!0,r.splice(n,1)),r=this[T].currentFrameCallbacks,r&&(n=r.findIndex(a=>a&&a.handle===e),n>-1&&(r[n].cancelled=!0))}get inputSources(){return this[T].device.getInputSources()}async end(){if(!this[T].ended)return this[T].immersive&&(this[T].ended=!0,this[T].device.removeEventListener("@@webxr-polyfill/vr-present-start",this[T].onPresentationStart),this[T].device.removeEventListener("@@webxr-polyfill/vr-present-end",this[T].onPresentationEnd),this[T].device.removeEventListener("@@webxr-polyfill/input-select-start",this[T].onSelectStart),this[T].device.removeEventListener("@@webxr-polyfill/input-select-end",this[T].onSelectEnd),this.dispatchEvent("end",new Ke("end",{session:this}))),this[T].stopDeviceFrameLoop(),this[T].device.endSession(this[T].id)}updateRenderState(e){if(this[T].ended){let n="Can't call updateRenderState on an XRSession that has already ended.";throw new Error(n)}if(e.baseLayer&&e.baseLayer._session!==this){let n="Called updateRenderState with a base layer that was created by a different session.";throw new Error(n)}if(e.inlineVerticalFieldOfView!==null&&e.inlineVerticalFieldOfView!==void 0)if(this[T].immersive){let n="inlineVerticalFieldOfView must not be set for an XRRenderState passed to updateRenderState for an immersive session.";throw new Error(n)}else e.inlineVerticalFieldOfView=Math.min(3.13,Math.max(.01,e.inlineVerticalFieldOfView));if(this[T].pendingRenderState===null){let n=this[T].activeRenderState;this[T].pendingRenderState={depthNear:n.depthNear,depthFar:n.depthFar,inlineVerticalFieldOfView:n.inlineVerticalFieldOfView,baseLayer:n.baseLayer}}Object.assign(this[T].pendingRenderState,e)}_checkInputSourcesChange(){let e=[],r=[],n=this.inputSources,a=this[T].currentInputSources;for(let o of n)a.includes(o)||e.push(o);for(let o of a)n.includes(o)||r.push(o);(e.length>0||r.length>0)&&this.dispatchEvent("inputsourceschange",new ut("inputsourceschange",{session:this,added:e,removed:r})),this[T].currentInputSources.length=0;for(let o of n)this[T].currentInputSources.push(o)}};var Je=Symbol("@@webxr-polyfill/XRInputSource"),vt=class{constructor(e){this[Je]={impl:e,gripSpace:new Se("grip",this),targetRaySpace:new Se("target-ray",this)}}get handedness(){return this[Je].impl.handedness}get targetRayMode(){return this[Je].impl.targetRayMode}get gripSpace(){let e=this[Je].impl.targetRayMode;return e==="gaze"||e==="screen"?null:this[Je].gripSpace}get targetRaySpace(){return this[Je].targetRaySpace}get profiles(){return this[Je].impl.profiles}get gamepad(){return this[Je].impl.gamepad}};var wr=Symbol("@@webxr-polyfill/polyfilled-xr-compatible"),jt=Symbol("@@webxr-polyfill/xr-compatible");var $e=Symbol("@@webxr-polyfill/XRWebGLLayer"),Kn=Object.freeze({antialias:!0,depth:!0,stencil:!1,alpha:!0,multiview:!1,ignoreDepthValues:!1,framebufferScaleFactor:1}),wt=class{constructor(e,r,n={}){let a=Object.assign({},Kn,n);if(!(e instanceof mt))throw new Error("session must be a XRSession");if(e.ended)throw new Error("InvalidStateError");if(r[wr]&&r[jt]!==!0)throw new Error("InvalidStateError");this[$e]={context:r,config:a,session:e}}get context(){return this[$e].context}get antialias(){return this[$e].config.antialias}get ignoreDepthValues(){return!0}get framebuffer(){return null}get framebufferWidth(){return this[$e].context.drawingBufferWidth}get framebufferHeight(){return this[$e].context.drawingBufferHeight}get _session(){return this[$e].session}getViewport(e){return e._getViewport(this)}static getNativeFramebufferScaleFactor(e){if(!e)throw new TypeError("getNativeFramebufferScaleFactor must be passed a session.");return e[T].ended?0:1}};var zr=Symbol("@@webxr-polyfill/XRReferenceSpaceEvent"),Zt=class t extends Event{constructor(e,r){super(e,r),this[zr]={referenceSpace:r.referenceSpace,transform:r.transform||null},Object.setPrototypeOf(this,t.prototype)}get referenceSpace(){return this[zr].referenceSpace}get transform(){return this[zr].transform}};var gt={XRSystem:ct,XRSession:mt,XRSessionEvent:Ke,XRFrame:je,XRView:At,XRViewport:ft,XRViewerPose:dt,XRWebGLLayer:wt,XRSpace:Se,XRReferenceSpace:qe,XRReferenceSpaceEvent:Zt,XRInputSource:vt,XRInputSourceEvent:pt,XRInputSourcesChangeEvent:ut,XRRenderState:Ze,XRRigidTransform:lt,XRPose:ht};var Ur=t=>(t.prototype.makeXRCompatible,t.prototype.makeXRCompatible=function(){return this[jt]=!0,Promise.resolve()},!0),Wr=t=>{let e=t.prototype.getContext;t.prototype.getContext=function(r,n){let a=e.call(this,r,n);return a&&(a[wr]=!0,n&&"xrCompatible"in n&&(a[jt]=n.xrCompatible)),a}};var _i=t=>!!(t.ImageBitmapRenderingContext&&t.createImageBitmap),Ti=t=>{var e=!1;return(function(r){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(r)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(r.substr(0,4)))&&(e=!0)})(t.navigator.userAgent||t.navigator.vendor||t.opera),e},Pi=t=>{t.style.display="block",t.style.position="absolute",t.style.width=t.style.height="1px",t.style.top=t.style.left="0px"};var Vi=Bn(Ci());var Ue=class extends Ve{constructor(e){super(),this.global=e,this.onWindowResize=this.onWindowResize.bind(this),this.global.window.addEventListener("resize",this.onWindowResize),this.environmentBlendMode="opaque"}onBaseLayerSet(e,r){throw new Error("Not implemented")}isSessionSupported(e){throw new Error("Not implemented")}isFeatureSupported(e){throw new Error("Not implemented")}async requestSession(e,r){throw new Error("Not implemented")}requestAnimationFrame(e){throw new Error("Not implemented")}onFrameStart(e){throw new Error("Not implemented")}onFrameEnd(e){throw new Error("Not implemented")}doesSessionSupportReferenceSpace(e,r){throw new Error("Not implemented")}requestStageBounds(){throw new Error("Not implemented")}async requestFrameOfReferenceTransform(e,r){}cancelAnimationFrame(e){throw new Error("Not implemented")}endSession(e){throw new Error("Not implemented")}getViewSpaces(e){}getViewport(e,r,n,a,o){throw new Error("Not implemented")}getProjectionMatrix(e,r){throw new Error("Not implemented")}getBasePoseMatrix(){throw new Error("Not implemented")}getBaseViewMatrix(e){throw new Error("Not implemented")}getInputSources(){throw new Error("Not implemented")}getInputPose(e,r,n){throw new Error("Not implemented")}onWindowResize(){this.onWindowResize()}};var Jn={mapping:"",profiles:["google-daydream","generic-trigger-touchpad"],buttons:{length:3,0:null,1:null,2:0}},$n={mapping:"xr-standard",profiles:["htc-vive-focus","generic-trigger-touchpad"],buttons:{length:3,0:1,1:null,2:0}},es={mapping:"xr-standard",profiles:["oculus-go","generic-trigger-touchpad"],buttons:{length:3,0:1,1:null,2:0},gripTransform:{orientation:[Math.PI*.11,0,0,1]}},Fi={mapping:"xr-standard",displayProfiles:{"Oculus Quest":["oculus-touch-v2","oculus-touch","generic-trigger-squeeze-thumbstick"]},profiles:["oculus-touch","generic-trigger-squeeze-thumbstick"],axes:{length:4,0:null,1:null,2:0,3:1},buttons:{length:7,0:1,1:2,2:null,3:0,4:3,5:4,6:null},gripTransform:{position:[0,-.02,.04,1],orientation:[Math.PI*.11,0,0,1]}},ts={mapping:"xr-standard",profiles:["htc-vive","generic-trigger-squeeze-touchpad"],displayProfiles:{"HTC Vive":["htc-vive","generic-trigger-squeeze-touchpad"],"HTC Vive DVT":["htc-vive","generic-trigger-squeeze-touchpad"],"Valve Index":["valve-index","generic-trigger-squeeze-touchpad-thumbstick"]},buttons:{length:3,0:1,1:2,2:0},gripTransform:{position:[0,0,.05,1]},targetRayTransform:{orientation:[Math.PI*-.08,0,0,1]},userAgentOverrides:{Firefox:{axes:{invert:[1,3]}}}},rs={mapping:"xr-standard",profiles:["samsung-gearvr","generic-trigger-touchpad"],buttons:{length:3,0:1,1:null,2:0},gripTransform:{orientation:[Math.PI*.11,0,0,1]}},is={mapping:"xr-standard",profiles:["samsung-odyssey","microsoft-mixed-reality","generic-trigger-squeeze-touchpad-thumbstick"],buttons:{length:4,0:1,1:0,2:2,3:4},gripTransform:{position:[0,-.02,.04,1],orientation:[Math.PI*.11,0,0,1]}},Hr={mapping:"xr-standard",profiles:["microsoft-mixed-reality","generic-trigger-squeeze-touchpad-thumbstick"],buttons:{length:4,0:1,1:0,2:2,3:4},gripTransform:{position:[0,-.02,.04,1],orientation:[Math.PI*.11,0,0,1]}},ns={"Daydream Controller":Jn,"Gear VR Controller":rs,"HTC Vive Focus Controller":$n,"Oculus Go Controller":es,"Oculus Touch (Right)":Fi,"Oculus Touch (Left)":Fi,"OpenVR Gamepad":ts,"Spatial Controller (Spatial Interaction Source) 045E-065A":Hr,"Spatial Controller (Spatial Interaction Source) 045E-065D":is,"Windows Mixed Reality (Right)":Hr,"Windows Mixed Reality (Left)":Hr},Ii=ns;var Li=Ee(.155,-.465,-.15),ss=Ee(-.155,-.465,-.15),as=Ee(0,0,-.25),os=Ee(0,0,.05),Di=Ee(-.08,.14,.08),Bi=.4,ls=.4,cs=.61,hs=.175,ds=.12,fs=.87,Oi=180/Math.PI;function As(t,e,r){function n(A,p,m){return Am?m:A}var a=e[0]*e[0],o=e[1]*e[1],h=e[2]*e[2],d=e[3]*e[3];if(r==="XYZ")t[0]=Math.atan2(2*(e[0]*e[3]-e[1]*e[2]),d-a-o+h),t[1]=Math.asin(n(2*(e[0]*e[2]+e[1]*e[3]),-1,1)),t[2]=Math.atan2(2*(e[2]*e[3]-e[0]*e[1]),d+a-o-h);else if(r==="YXZ")t[0]=Math.asin(n(2*(e[0]*e[3]-e[1]*e[2]),-1,1)),t[1]=Math.atan2(2*(e[0]*e[2]+e[1]*e[3]),d-a-o+h),t[2]=Math.atan2(2*(e[0]*e[1]+e[2]*e[3]),d-a+o-h);else if(r==="ZXY")t[0]=Math.asin(n(2*(e[0]*e[3]+e[1]*e[2]),-1,1)),t[1]=Math.atan2(2*(e[1]*e[3]-e[2]*e[0]),d-a-o+h),t[2]=Math.atan2(2*(e[2]*e[3]-e[0]*e[1]),d-a+o-h);else if(r==="ZYX")t[0]=Math.atan2(2*(e[0]*e[3]+e[2]*e[1]),d-a-o+h),t[1]=Math.asin(n(2*(e[1]*e[3]-e[0]*e[2]),-1,1)),t[2]=Math.atan2(2*(e[0]*e[1]+e[2]*e[3]),d+a-o-h);else if(r==="YZX")t[0]=Math.atan2(2*(e[0]*e[3]-e[2]*e[1]),d-a+o-h),t[1]=Math.atan2(2*(e[1]*e[3]-e[0]*e[2]),d+a-o-h),t[2]=Math.asin(n(2*(e[0]*e[1]+e[2]*e[3]),-1,1));else if(r==="XZY")t[0]=Math.atan2(2*(e[0]*e[3]+e[1]*e[2]),d-a+o-h),t[1]=Math.atan2(2*(e[0]*e[2]+e[1]*e[3]),d+a-o-h),t[2]=Math.asin(n(2*(e[2]*e[3]-e[0]*e[1]),-1,1));else{console.log("No order given for quaternion to euler conversion.");return}}var Kt=class{constructor(){this.hand="right",this.headElbowOffset=Li,this.controllerQ=Fe(),this.lastControllerQ=Fe(),this.headQ=Fe(),this.headPos=Ce(),this.elbowPos=Ce(),this.wristPos=Ce(),this.time=null,this.lastTime=null,this.rootQ=Fe(),this.position=Ce()}setHandedness(e){this.hand!=e&&(this.hand=e,this.hand=="left"?this.headElbowOffset=ss:this.headElbowOffset=Li)}update(e,r){this.time=mr(),e&&(pr(this.lastControllerQ,this.controllerQ),pr(this.controllerQ,e)),r&&(lr(this.headPos,r),cr(this.headQ,r));let n=this.getHeadYawOrientation_(),a=this.quatAngle_(this.lastControllerQ,this.controllerQ),o=(this.time-this.lastTime)/1e3;a/o>cs?Mt(this.rootQ,this.rootQ,n,Math.min(a/hs,1)):pr(this.rootQ,n);let d=Ee(0,0,-1);ot(d,d,this.controllerQ);let A=Wt(d,[0,1,0]),p=this.clamp_((A-ds)/fs,0,1),m=Or(this.rootQ);Br(m,m),Dr(m,m,this.controllerQ);let w=this.elbowPos;Ir(w,this.headPos),bt(w,w,this.headElbowOffset);let b=Fr(Di);Lr(b,b,p),bt(w,w,b);let _=this.quatAngle_(m,Fe())*Oi,M=1-Math.pow(_/180,4);sssss;let v=Bi,S=1-Bi,F=M*(v+S*p*ls),R=Fe();Mt(R,R,m,F);let I=Br(Fe(),R),B=Or(m);Dr(B,B,I);let L=this.wristPos;Ir(L,os),ot(L,L,R),bt(L,L,as),ot(L,L,B),bt(L,L,w);let z=Fr(Di);Lr(z,z,p),bt(this.position,this.wristPos,z),ot(this.position,this.position,this.rootQ),this.lastTime=this.time}getPosition(){return this.position}getHeadYawOrientation_(){let e=Ce();return As(e,this.headQ,"YXZ"),yi(Fe(),0,e[1]*Oi,0)}clamp_(e,r,n){return Math.min(Math.max(e,r),n)}quatAngle_(e,r){let n=[0,0,-1],a=[0,0,-1];return ot(n,n,e),ot(a,a,r),pi(n,a)}};var we=Symbol("@@webxr-polyfill/XRRemappedGamepad"),Ni={pressed:!1,touched:!1,value:0};Object.freeze(Ni);var Yr=class{constructor(e,r,n){if(n||(n={}),n.userAgentOverrides){for(let p in n.userAgentOverrides)if(navigator.userAgent.includes(p)){let m=n.userAgentOverrides[p];for(let w in m)w in n?Object.assign(n[w],m[w]):n[w]=m[w];break}}let a=new Array(n.axes&&n.axes.length?n.axes.length:e.axes.length),o=new Array(n.buttons&&n.buttons.length?n.buttons.length:e.buttons.length),h=null;if(n.gripTransform){let p=n.gripTransform.orientation||[0,0,0,1];h=Ge(),He(h,Qt(p,p),n.gripTransform.position||[0,0,0])}let d=null;if(n.targetRayTransform){let p=n.targetRayTransform.orientation||[0,0,0,1];d=Ge(),He(d,Qt(p,p),n.targetRayTransform.position||[0,0,0])}let A=n.profiles;n.displayProfiles&&r.displayName in n.displayProfiles&&(A=n.displayProfiles[r.displayName]),this[we]={gamepad:e,map:n,profiles:A||[e.id],mapping:n.mapping||e.mapping,axes:a,buttons:o,gripTransform:h,targetRayTransform:d},this._update()}_update(){let e=this[we].gamepad,r=this[we].map,n=this[we].axes;for(let o=0;o{!$t&&!this.global.document.body.contains(a)&&(n.modifiedCanvasLayer=!0,this.global.document.body.appendChild(a),Pi(a)),n.baseLayer=r})}else n.baseLayer=r}isSessionSupported(e){return!(e=="immersive-ar"||e=="immersive-vr"&&this.canPresent===!1)}isFeatureSupported(e){switch(e){case"viewer":return!0;case"local":return!0;case"local-floor":return!0;case"bounded":return!1;case"unbounded":return!1;default:return!1}}async requestSession(e,r){if(!this.isSessionSupported(e))return Promise.reject();let n=e=="immersive-vr";if(n){let o=this.global.document.createElement("canvas");if(!$t){let h=o.getContext("webgl")}await this.display.requestPresent([{source:o,attributes:Gi}])}let a=new qr(e,r,{renderContextType:this.HAS_BITMAP_SUPPORT?"bitmaprenderer":"2d"});return this.sessions.set(a.id,a),n&&(this.immersiveSession=a,this.dispatchEvent("@@webxr-polyfill/vr-present-start",a.id)),Promise.resolve(a.id)}requestAnimationFrame(e){return this.display.requestAnimationFrame(e)}getPrimaryButtonIndex(e){let r=0,n=e.id.toLowerCase();for(let a in ki)if(n.includes(a)){r=ki[a];break}return Math.min(r,e.buttons.length-1)}onFrameStart(e,r){this.display.depthNear=r.depthNear,this.display.depthFar=r.depthFar,this.display.getFrameData(this.frame);let n=this.sessions.get(e);if(n.immersive&&this.CAN_USE_GAMEPAD){let a=this.gamepadInputSources;this.gamepadInputSources={};let o=this.global.navigator.getGamepads();for(let h=0;h0){let A=a[h];if(A||(A=new Jt(this,this.display,this.getPrimaryButtonIndex(d))),A.updateFromGamepad(d),this.gamepadInputSources[h]=A,A.primaryButtonIndex!=-1){let p=d.buttons[A.primaryButtonIndex].pressed;p&&!A.primaryActionPressed?this.dispatchEvent("@@webxr-polyfill/input-select-start",{sessionId:n.id,inputSource:A.inputSource}):!p&&A.primaryActionPressed&&this.dispatchEvent("@@webxr-polyfill/input-select-end",{sessionId:n.id,inputSource:A.inputSource}),A.primaryActionPressed=p}if(A.primarySqueezeButtonIndex!=-1){let p=d.buttons[A.primarySqueezeButtonIndex].pressed;p&&!A.primarySqueezeActionPressed?this.dispatchEvent("@@webxr-polyfill/input-squeeze-start",{sessionId:n.id,inputSource:A.inputSource}):!p&&A.primarySqueezeActionPressed&&this.dispatchEvent("@@webxr-polyfill/input-squeeze-end",{sessionId:n.id,inputSource:A.inputSource}),A.primarySqueezeActionPressed=p}}}}if(!$t&&!n.immersive&&n.baseLayer){let a=n.baseLayer.context.canvas;hr(this.frame.leftProjectionMatrix,r.inlineVerticalFieldOfView,a.width/a.height,r.depthNear,r.depthFar)}}onFrameEnd(e){let r=this.sessions.get(e);if(!(r.ended||!r.baseLayer)){if(r.outputContext&&!(r.immersive&&!this.display.capabilities.hasExternalDisplay)){let n=r.immersive&&this.display.capabilities.hasExternalDisplay,a=r.baseLayer.context.canvas,o=n?a.width/2:a.width,h=a.height;if(!$t){let d=r.outputContext.canvas,A=d.width,p=d.height,m=r.renderContext;this.HAS_BITMAP_SUPPORT?a.transferToImageBitmap?m.transferFromImageBitmap(a.transferToImageBitmap()):this.global.createImageBitmap(a,0,0,o,h,{resizeWidth:A,resizeHeight:p}).then(w=>m.transferFromImageBitmap(w)):m.drawImage(a,0,0,o,h,0,0,A,p)}}r.immersive&&r.baseLayer&&this.display.submitFrame()}}cancelAnimationFrame(e){this.display.cancelAnimationFrame(e)}async endSession(e){let r=this.sessions.get(e);if(!r.ended){if(r.immersive)return this.display.exitPresent();r.ended=!0}}doesSessionSupportReferenceSpace(e,r){let n=this.sessions.get(e);return n.ended?!1:n.enabledFeatures.has(r)}requestStageBounds(){if(this.display.stageParameters){let e=this.display.stageParameters.sizeX,r=this.display.stageParameters.sizeZ,n=[];return n.push(-e/2),n.push(-r/2),n.push(e/2),n.push(-r/2),n.push(e/2),n.push(r/2),n.push(-e/2),n.push(r/2),n}return null}async requestFrameOfReferenceTransform(e,r){return(e==="local-floor"||e==="bounded-floor")&&this.display.stageParameters&&this.display.stageParameters.sittingToStandingTransform?this.display.stageParameters.sittingToStandingTransform:null}getProjectionMatrix(e){if(e==="left")return this.frame.leftProjectionMatrix;if(e==="right")return this.frame.rightProjectionMatrix;if(e==="none")return this.frame.leftProjectionMatrix;throw new Error("eye must be of type 'left' or 'right'")}getViewport(e,r,n,a){let o=this.sessions.get(e),{width:h,height:d}=n.context.canvas;if(!o.immersive)return a.x=a.y=0,a.width=h,a.height=d,!0;if(r==="left"||r==="none")a.x=0;else if(r==="right")a.x=h/2;else return!1;return a.y=0,a.width=h/2,a.height=d,!0}getBasePoseMatrix(){let{position:e,orientation:r}=this.frame.pose;return!e&&!r?this.baseModelMatrix:(e||(e=this.tempVec3,e[0]=e[1]=e[2]=0),He(this.baseModelMatrix,r,e),this.baseModelMatrix)}getBaseViewMatrix(e){if(e==="left"||e==="none")return this.frame.leftViewMatrix;if(e==="right")return this.frame.rightViewMatrix;throw new Error("eye must be of type 'left' or 'right'")}getInputSources(){let e=[];for(let r in this.gamepadInputSources)e.push(this.gamepadInputSources[r].inputSource);return e}getInputPose(e,r,n){if(!r)return null;for(let a in this.gamepadInputSources){let o=this.gamepadInputSources[a];if(o.inputSource===e)return o.getXRPose(r,n)}return null}onWindowResize(){}onVRDisplayPresentChange(e){this.display.isPresenting||this.sessions.forEach(r=>{if(r.immersive&&!r.ended){if(r.modifiedCanvasLayer){let n=r.baseLayer.context.canvas;document.body.removeChild(n),n.setAttribute("style","")}this.immersiveSession===r&&(this.immersiveSession=null),this.dispatchEvent("@@webxr-polyfill/vr-present-end",r.id)}})}};var er=class extends xt{constructor(e,r){let n=new Vi.default(r||{});super(e,n),this.display=n,this.frame={rightViewMatrix:new Float32Array(16),leftViewMatrix:new Float32Array(16),rightProjectionMatrix:new Float32Array(16),leftProjectionMatrix:new Float32Array(16),pose:null,timestamp:null}}};var us=!1,ms=0,jr=class{constructor(e,r){this.mode=e,this.enabledFeatures=r,this.ended=null,this.baseLayer=null,this.id=++ms}},tr=class extends Ue{constructor(e){super(e),this.sessions=new Map,this.projectionMatrix=Ge(),this.identityMatrix=Ge()}onBaseLayerSet(e,r){let n=this.sessions.get(e);n.baseLayer=r}isSessionSupported(e){return e=="inline"}isFeatureSupported(e){switch(e){case"viewer":return!0;default:return!1}}async requestSession(e,r){if(!this.isSessionSupported(e))return Promise.reject();let n=new jr(e,r);return this.sessions.set(n.id,n),Promise.resolve(n.id)}requestAnimationFrame(e){return window.requestAnimationFrame(e)}cancelAnimationFrame(e){window.cancelAnimationFrame(e)}onFrameStart(e,r){if(us)return;let n=this.sessions.get(e);if(n.baseLayer){let a=n.baseLayer.context.canvas;hr(this.projectionMatrix,r.inlineVerticalFieldOfView,a.width/a.height,r.depthNear,r.depthFar)}}onFrameEnd(e){}async endSession(e){let r=this.sessions.get(e);r.ended=!0}doesSessionSupportReferenceSpace(e,r){let n=this.sessions.get(e);return n.ended?!1:n.enabledFeatures.has(r)}requestStageBounds(){return null}async requestFrameOfReferenceTransform(e,r){return null}getProjectionMatrix(e){return this.projectionMatrix}getViewport(e,r,n,a){let o=this.sessions.get(e),{width:h,height:d}=n.context.canvas;return a.x=a.y=0,a.width=h,a.height=d,!0}getBasePoseMatrix(){return this.identityMatrix}getBaseViewMatrix(e){return this.identityMatrix}getInputSources(){return[]}getInputPose(e,r,n){return null}onWindowResize(){}};var vs=async function(t){let e=null;if("getVRDisplays"in t.navigator)try{let r=await t.navigator.getVRDisplays();r&&r.length&&(e=new xt(t,r[0]))}catch{}return e},zi=async function(t,e){if(e.webvr){let n=await vs(t);if(n)return n}let r=Ti(t);return r&&e.cardboard||!r&&e.allowCardboardOnDesktop?(t.VRFrameData||(t.VRFrameData=function(){this.rightViewMatrix=new Float32Array(16),this.leftViewMatrix=new Float32Array(16),this.rightProjectionMatrix=new Float32Array(16),this.leftProjectionMatrix=new Float32Array(16),this.pose=null}),new er(t,e.cardboardConfig)):new tr(t)};var ws={global:ur,webvr:!0,cardboard:!0,cardboardConfig:null,allowCardboardOnDesktop:!1},gr=["navigator","HTMLCanvasElement","WebGLRenderingContext"],rr=class{constructor(e={}){this.config=Object.freeze(Object.assign({},ws,e)),this.global=this.config.global,this.nativeWebXR="xr"in this.global.navigator,this.injected=!1,this._injectPolyfill(this.global)}_injectPolyfill(e){if(!gr.every(r=>!!e[r]))throw new Error(`Global must have the following attributes : ${gr}`);for(let r of Object.keys(gt))e[r]!==void 0?console.warn(`${r} already defined on global.`):e[r]=gt[r];Ur(e.WebGLRenderingContext)&&(Wr(e.HTMLCanvasElement),e.OffscreenCanvas&&Wr(e.OffscreenCanvas),e.WebGL2RenderingContext&&Ur(e.WebGL2RenderingContext),window.isSecureContext||console.warn(`WebXR Polyfill Warning: +This page is not running in a secure context (https:// or localhost)! +This means that although the page may be able to use the WebXR Polyfill it will +not be able to use native WebXR implementations, and as such will not be able to +access dedicated VR or AR hardware, and will not be able to take advantage of +any performance improvements a native WebXR implementation may offer. Please +host this content on a secure origin for the best user experience. +`)),this.injected=!0,this._patchNavigatorXR()}_patchNavigatorXR(){let e=zi(this.global,this.config);this.xr=new gt.XRSystem(e),Object.defineProperty(this.global.navigator,"xr",{value:this.xr,configurable:!0})}_injectCompatibilityShims(e){if(!gr.every(r=>!!e[r]))throw new Error(`Global must have the following attributes : ${gr}`);if(e.navigator.xr&&"supportsSession"in e.navigator.xr&&!("isSessionSupported"in e.navigator.xr)){let r=e.navigator.xr.supportsSession;e.navigator.xr.isSessionSupported=function(n){return r.call(this,n).then(()=>!0).catch(()=>!1)},e.navigator.xr.supportsSession=function(n){return console.warn("navigator.xr.supportsSession() is deprecated. Please call navigator.xr.isSessionSupported() instead and check the boolean value returned when the promise resolves."),r.call(this,n)}}}};var gs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};function xs(t,e){return e={exports:{}},t(e,e.exports),e.exports}var Qi=xs(function(t){(function(e,r){var n=Math.pow(2,-24),a=Math.pow(2,32),o=Math.pow(2,53);function h(p){var m=new ArrayBuffer(256),w=new DataView(m),b,y=0;function _(N){for(var k=m.byteLength,G=y+N;k>2,Q=0;Q>6),G.push(128|C&63)):C<55296?(G.push(224|C>>12),G.push(128|C>>6&63),G.push(128|C&63)):(C=(C&1023)<<10,C|=N.charCodeAt(++k)&1023,C+=65536,G.push(240|C>>18),G.push(128|C>>12&63),G.push(128|C>>6&63),G.push(128|C&63))}return L(3,G.length),F(G);default:var Y;if(Array.isArray(N))for(Y=N.length,L(4,Y),k=0;k>5!==G)throw"Invalid indefinite length element";return Y}function H(G,C){for(var Y=0;Y>10),G.push(56320|Q&1023))}}function N(){var G=R(),C=G>>5,Y=G&31,Q,q;if(C===7)switch(Y){case 25:return v();case 26:return S();case 27:return F()}if(q=U(Y),q<0&&(C<2||6=0;)xe+=q,$.push(M(q));var Me=new Uint8Array(xe),We=0;for(Q=0;Q<$.length;++Q)Me.set($[Q],We),We+=$[Q].length;return Me}return M(q);case 3:var et=[];if(q<0)for(;(q=K(C))>=0;)H(et,q);else H(et,q);return String.fromCharCode.apply(null,et);case 4:var de;if(q<0)for(de=[];!z();)de.push(N());else for(de=new Array(q),Q=0;Q"u"?Wi():window.WebSocket,xr=class{constructor(e,r,n,a=!1,o,h,d){this.reqs=[],this.reps=[],this.requestId=this.getRequestId(),this.debug=a,this.isGreedy=h,this.errCallback=r,this.closeCallback=n,this.alwaysdebug=!1,this.isConnected=!1;let A=null;o||h||d?A=new Zr(o,h,d,this.debug):(a&&(this.alwaysdebug=!0),typeof e=="function"&&(A=new Kr)),this.openWebsocket(A,e)}sendMessage(e,r=60){this.alwaysdebug&&(e.cmd.debug=!0);let n=e.toCbor();return this.sendRequestObj(n,r)}disconnect(){this.ws.close()}openWebsocket(e=null,r=null){this.ws=new ys("ws://localhost:11222/driver",["rep.sp.nanomsg.org"]),this.ws.parent=this,this.ws.binaryType="arraybuffer",this.ws.onmessage=this.messageHandler,this.ws.onopen=(()=>{this.isConnected=!0,this.debug&&console.log("socket open"),e!=null&&this.sendMessage(e).then(r)}),this.ws.onerror=this.onSocketError,this.ws.onclose=this.onClose}sendRequestObj(e,r){return new Promise((n,a)=>{let o={id:this.requestId++,parent:this,payload:e,success:n,error:a,send:function(){this.debug&&console.log("attemtping to send request with ID "+this.id),this.timeout=setTimeout(o.send.bind(this),r*1e3);let h=new Uint8Array(e.byteLength+4);new DataView(h.buffer).setUint32(0,this.id),h.set(new Uint8Array(this.payload),4),this.parent.ws.send(h.buffer)}};this.reqs.push(o),o.send()})}messageHandler(e){let r=e.data;if(r.byteLength<4)return;let a=new DataView(r).getUint32(0);if(a<2147483648){this.parent.err("bad nng header");return}let o=this.parent.findReqIndex(a);if(o==-1){this.parent.err("got reply that doesn't match known request!");return}let h={id:a,payload:Qi.decode(r.slice(4))};h.payload.error==0?this.parent.reqs[o].success(h.payload):this.parent.reqs[o].error(h.payload),clearTimeout(this.parent.reqs[o].timeout),this.parent.reqs.splice(o,1),this.parent.reps.push(h),this.debug&&console.log(h.payload)}getRequestId(){return Math.floor(this.prng()*2147483647)+2147483648}onClose(e){this.parent.isConnected=!1,this.parent.debug&&console.log("socket closed"),typeof this.parent.closeCallback=="function"&&this.parent.closeCallback(e)}onSocketError(e){this.parent.debug&&console.log(e),typeof this.parent.errCallback=="function"&&this.parent.errCallback(e)}err(e){this.debug&&console.log("[DRIVER ERROR]"+e)}findReqIndex(e){let r=0;for(;r>>19;return function(){return h=Math.imul(h^h>>>16,2246822507),h=Math.imul(h^h>>>13,3266489909),(h^=h>>>16)>>>0}}function e(a,o,h,d){return(()=>{var A=o<<9,p=a*5;return p=(p<<7|p>>>25)*9,h^=a,d^=o,o^=h,a^=d,h^=A,d=d<<11|d>>>21,(p>>>0)/4294967296})}var r=Date.now(),n=t(r.toString());return e(n(),n(),n(),n())}function ge(t,...e){let r=t[0];for(let n=1;noa,adjoint:()=>Is,clone:()=>Rs,copy:()=>_s,create:()=>Ss,determinant:()=>Ls,equals:()=>da,exactEquals:()=>ha,frob:()=>aa,fromQuat:()=>Js,fromQuat2:()=>Hs,fromRotation:()=>Us,fromRotationTranslation:()=>qi,fromRotationTranslationScale:()=>Zs,fromRotationTranslationScaleOrigin:()=>Ks,fromScaling:()=>zs,fromTranslation:()=>Vs,fromValues:()=>Ts,fromXRotation:()=>Ws,fromYRotation:()=>Qs,fromZRotation:()=>Xs,frustum:()=>$s,getRotation:()=>js,getScaling:()=>qs,getTranslation:()=>Ys,identity:()=>Hi,invert:()=>Fs,lookAt:()=>ia,mul:()=>fa,multiply:()=>Yi,multiplyScalar:()=>la,multiplyScalarAndAdd:()=>ca,ortho:()=>ra,perspective:()=>ea,perspectiveFromFieldOfView:()=>ta,rotate:()=>Os,rotateX:()=>Ns,rotateY:()=>Gs,rotateZ:()=>ks,scale:()=>Bs,set:()=>Ps,str:()=>sa,sub:()=>Aa,subtract:()=>ji,targetTo:()=>na,translate:()=>Ds,transpose:()=>Cs});function Ss(){var t=new Et(16);return Et!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function Rs(t){var e=new Et(16);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 _s(t,e){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 Ts(t,e,r,n,a,o,h,d,A,p,m,w,b,y,_,M){var v=new Et(16);return v[0]=t,v[1]=e,v[2]=r,v[3]=n,v[4]=a,v[5]=o,v[6]=h,v[7]=d,v[8]=A,v[9]=p,v[10]=m,v[11]=w,v[12]=b,v[13]=y,v[14]=_,v[15]=M,v}function Ps(t,e,r,n,a,o,h,d,A,p,m,w,b,y,_,M,v){return t[0]=e,t[1]=r,t[2]=n,t[3]=a,t[4]=o,t[5]=h,t[6]=d,t[7]=A,t[8]=p,t[9]=m,t[10]=w,t[11]=b,t[12]=y,t[13]=_,t[14]=M,t[15]=v,t}function Hi(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Cs(t,e){if(t===e){var r=e[1],n=e[2],a=e[3],o=e[6],h=e[7],d=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=o,t[11]=e[14],t[12]=a,t[13]=h,t[14]=d}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Fs(t,e){var r=e[0],n=e[1],a=e[2],o=e[3],h=e[4],d=e[5],A=e[6],p=e[7],m=e[8],w=e[9],b=e[10],y=e[11],_=e[12],M=e[13],v=e[14],S=e[15],F=r*d-n*h,R=r*A-a*h,I=r*p-o*h,B=n*A-a*d,L=n*p-o*d,z=a*p-o*A,U=m*M-w*_,K=m*v-b*_,H=m*S-y*_,N=w*v-b*M,k=w*S-y*M,G=b*S-y*v,C=F*G-R*k+I*N+B*H-L*K+z*U;return C?(C=1/C,t[0]=(d*G-A*k+p*N)*C,t[1]=(a*k-n*G-o*N)*C,t[2]=(M*z-v*L+S*B)*C,t[3]=(b*L-w*z-y*B)*C,t[4]=(A*H-h*G-p*K)*C,t[5]=(r*G-a*H+o*K)*C,t[6]=(v*I-_*z-S*R)*C,t[7]=(m*z-b*I+y*R)*C,t[8]=(h*k-d*H+p*U)*C,t[9]=(n*H-r*k-o*U)*C,t[10]=(_*L-M*I+S*F)*C,t[11]=(w*I-m*L-y*F)*C,t[12]=(d*K-h*N-A*U)*C,t[13]=(r*N-n*K+a*U)*C,t[14]=(M*R-_*B-v*F)*C,t[15]=(m*B-w*R+b*F)*C,t):null}function Is(t,e){var r=e[0],n=e[1],a=e[2],o=e[3],h=e[4],d=e[5],A=e[6],p=e[7],m=e[8],w=e[9],b=e[10],y=e[11],_=e[12],M=e[13],v=e[14],S=e[15];return t[0]=d*(b*S-y*v)-w*(A*S-p*v)+M*(A*y-p*b),t[1]=-(n*(b*S-y*v)-w*(a*S-o*v)+M*(a*y-o*b)),t[2]=n*(A*S-p*v)-d*(a*S-o*v)+M*(a*p-o*A),t[3]=-(n*(A*y-p*b)-d*(a*y-o*b)+w*(a*p-o*A)),t[4]=-(h*(b*S-y*v)-m*(A*S-p*v)+_*(A*y-p*b)),t[5]=r*(b*S-y*v)-m*(a*S-o*v)+_*(a*y-o*b),t[6]=-(r*(A*S-p*v)-h*(a*S-o*v)+_*(a*p-o*A)),t[7]=r*(A*y-p*b)-h*(a*y-o*b)+m*(a*p-o*A),t[8]=h*(w*S-y*M)-m*(d*S-p*M)+_*(d*y-p*w),t[9]=-(r*(w*S-y*M)-m*(n*S-o*M)+_*(n*y-o*w)),t[10]=r*(d*S-p*M)-h*(n*S-o*M)+_*(n*p-o*d),t[11]=-(r*(d*y-p*w)-h*(n*y-o*w)+m*(n*p-o*d)),t[12]=-(h*(w*v-b*M)-m*(d*v-A*M)+_*(d*b-A*w)),t[13]=r*(w*v-b*M)-m*(n*v-a*M)+_*(n*b-a*w),t[14]=-(r*(d*v-A*M)-h*(n*v-a*M)+_*(n*A-a*d)),t[15]=r*(d*b-A*w)-h*(n*b-a*w)+m*(n*A-a*d),t}function Ls(t){var e=t[0],r=t[1],n=t[2],a=t[3],o=t[4],h=t[5],d=t[6],A=t[7],p=t[8],m=t[9],w=t[10],b=t[11],y=t[12],_=t[13],M=t[14],v=t[15],S=e*h-r*o,F=e*d-n*o,R=e*A-a*o,I=r*d-n*h,B=r*A-a*h,L=n*A-a*d,z=p*_-m*y,U=p*M-w*y,K=p*v-b*y,H=m*M-w*_,N=m*v-b*_,k=w*v-b*M;return S*k-F*N+R*H+I*K-B*U+L*z}function Yi(t,e,r){var n=e[0],a=e[1],o=e[2],h=e[3],d=e[4],A=e[5],p=e[6],m=e[7],w=e[8],b=e[9],y=e[10],_=e[11],M=e[12],v=e[13],S=e[14],F=e[15],R=r[0],I=r[1],B=r[2],L=r[3];return t[0]=R*n+I*d+B*w+L*M,t[1]=R*a+I*A+B*b+L*v,t[2]=R*o+I*p+B*y+L*S,t[3]=R*h+I*m+B*_+L*F,R=r[4],I=r[5],B=r[6],L=r[7],t[4]=R*n+I*d+B*w+L*M,t[5]=R*a+I*A+B*b+L*v,t[6]=R*o+I*p+B*y+L*S,t[7]=R*h+I*m+B*_+L*F,R=r[8],I=r[9],B=r[10],L=r[11],t[8]=R*n+I*d+B*w+L*M,t[9]=R*a+I*A+B*b+L*v,t[10]=R*o+I*p+B*y+L*S,t[11]=R*h+I*m+B*_+L*F,R=r[12],I=r[13],B=r[14],L=r[15],t[12]=R*n+I*d+B*w+L*M,t[13]=R*a+I*A+B*b+L*v,t[14]=R*o+I*p+B*y+L*S,t[15]=R*h+I*m+B*_+L*F,t}function Ds(t,e,r){var n=r[0],a=r[1],o=r[2],h=void 0,d=void 0,A=void 0,p=void 0,m=void 0,w=void 0,b=void 0,y=void 0,_=void 0,M=void 0,v=void 0,S=void 0;return e===t?(t[12]=e[0]*n+e[4]*a+e[8]*o+e[12],t[13]=e[1]*n+e[5]*a+e[9]*o+e[13],t[14]=e[2]*n+e[6]*a+e[10]*o+e[14],t[15]=e[3]*n+e[7]*a+e[11]*o+e[15]):(h=e[0],d=e[1],A=e[2],p=e[3],m=e[4],w=e[5],b=e[6],y=e[7],_=e[8],M=e[9],v=e[10],S=e[11],t[0]=h,t[1]=d,t[2]=A,t[3]=p,t[4]=m,t[5]=w,t[6]=b,t[7]=y,t[8]=_,t[9]=M,t[10]=v,t[11]=S,t[12]=h*n+m*a+_*o+e[12],t[13]=d*n+w*a+M*o+e[13],t[14]=A*n+b*a+v*o+e[14],t[15]=p*n+y*a+S*o+e[15]),t}function Bs(t,e,r){var n=r[0],a=r[1],o=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*a,t[5]=e[5]*a,t[6]=e[6]*a,t[7]=e[7]*a,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Os(t,e,r,n){var a=n[0],o=n[1],h=n[2],d=Math.sqrt(a*a+o*o+h*h),A=void 0,p=void 0,m=void 0,w=void 0,b=void 0,y=void 0,_=void 0,M=void 0,v=void 0,S=void 0,F=void 0,R=void 0,I=void 0,B=void 0,L=void 0,z=void 0,U=void 0,K=void 0,H=void 0,N=void 0,k=void 0,G=void 0,C=void 0,Y=void 0;return d0?(r[0]=(d*h+m*n+A*o-p*a)*2/w,r[1]=(A*h+m*a+p*n-d*o)*2/w,r[2]=(p*h+m*o+d*a-A*n)*2/w):(r[0]=(d*h+m*n+A*o-p*a)*2,r[1]=(A*h+m*a+p*n-d*o)*2,r[2]=(p*h+m*o+d*a-A*n)*2),qi(t,e,r),t}function Ys(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function qs(t,e){var r=e[0],n=e[1],a=e[2],o=e[4],h=e[5],d=e[6],A=e[8],p=e[9],m=e[10];return t[0]=Math.sqrt(r*r+n*n+a*a),t[1]=Math.sqrt(o*o+h*h+d*d),t[2]=Math.sqrt(A*A+p*p+m*m),t}function js(t,e){var r=e[0]+e[5]+e[10],n=0;return r>0?(n=Math.sqrt(r+1)*2,t[3]=.25*n,t[0]=(e[6]-e[9])/n,t[1]=(e[8]-e[2])/n,t[2]=(e[1]-e[4])/n):e[0]>e[5]&&e[0]>e[10]?(n=Math.sqrt(1+e[0]-e[5]-e[10])*2,t[3]=(e[6]-e[9])/n,t[0]=.25*n,t[1]=(e[1]+e[4])/n,t[2]=(e[8]+e[2])/n):e[5]>e[10]?(n=Math.sqrt(1+e[5]-e[0]-e[10])*2,t[3]=(e[8]-e[2])/n,t[0]=(e[1]+e[4])/n,t[1]=.25*n,t[2]=(e[6]+e[9])/n):(n=Math.sqrt(1+e[10]-e[0]-e[5])*2,t[3]=(e[1]-e[4])/n,t[0]=(e[8]+e[2])/n,t[1]=(e[6]+e[9])/n,t[2]=.25*n),t}function Zs(t,e,r,n){var a=e[0],o=e[1],h=e[2],d=e[3],A=a+a,p=o+o,m=h+h,w=a*A,b=a*p,y=a*m,_=o*p,M=o*m,v=h*m,S=d*A,F=d*p,R=d*m,I=n[0],B=n[1],L=n[2];return t[0]=(1-(_+v))*I,t[1]=(b+R)*I,t[2]=(y-F)*I,t[3]=0,t[4]=(b-R)*B,t[5]=(1-(w+v))*B,t[6]=(M+S)*B,t[7]=0,t[8]=(y+F)*L,t[9]=(M-S)*L,t[10]=(1-(w+_))*L,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function Ks(t,e,r,n,a){var o=e[0],h=e[1],d=e[2],A=e[3],p=o+o,m=h+h,w=d+d,b=o*p,y=o*m,_=o*w,M=h*m,v=h*w,S=d*w,F=A*p,R=A*m,I=A*w,B=n[0],L=n[1],z=n[2],U=a[0],K=a[1],H=a[2],N=(1-(M+S))*B,k=(y+I)*B,G=(_-R)*B,C=(y-I)*L,Y=(1-(b+S))*L,Q=(v+F)*L,q=(_+R)*z,$=(v-F)*z,xe=(1-(b+M))*z;return t[0]=N,t[1]=k,t[2]=G,t[3]=0,t[4]=C,t[5]=Y,t[6]=Q,t[7]=0,t[8]=q,t[9]=$,t[10]=xe,t[11]=0,t[12]=r[0]+U-(N*U+C*K+q*H),t[13]=r[1]+K-(k*U+Y*K+$*H),t[14]=r[2]+H-(G*U+Q*K+xe*H),t[15]=1,t}function Js(t,e){var r=e[0],n=e[1],a=e[2],o=e[3],h=r+r,d=n+n,A=a+a,p=r*h,m=n*h,w=n*d,b=a*h,y=a*d,_=a*A,M=o*h,v=o*d,S=o*A;return t[0]=1-w-_,t[1]=m+S,t[2]=b-v,t[3]=0,t[4]=m-S,t[5]=1-p-_,t[6]=y+M,t[7]=0,t[8]=b+v,t[9]=y-M,t[10]=1-p-w,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function $s(t,e,r,n,a,o,h){var d=1/(r-e),A=1/(a-n),p=1/(o-h);return t[0]=o*2*d,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o*2*A,t[6]=0,t[7]=0,t[8]=(r+e)*d,t[9]=(a+n)*A,t[10]=(h+o)*p,t[11]=-1,t[12]=0,t[13]=0,t[14]=h*o*2*p,t[15]=0,t}function ea(t,e,r,n,a){var o=1/Math.tan(e/2),h=void 0;return t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,a!=null&&a!==1/0?(h=1/(n-a),t[10]=(a+n)*h,t[14]=2*a*n*h):(t[10]=-1,t[14]=-2*n),t}function ta(t,e,r,n){var a=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),h=Math.tan(e.leftDegrees*Math.PI/180),d=Math.tan(e.rightDegrees*Math.PI/180),A=2/(h+d),p=2/(a+o);return t[0]=A,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=p,t[6]=0,t[7]=0,t[8]=-((h-d)*A*.5),t[9]=(a-o)*p*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t}function ra(t,e,r,n,a,o,h){var d=1/(e-r),A=1/(n-a),p=1/(o-h);return t[0]=-2*d,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*A,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*p,t[11]=0,t[12]=(e+r)*d,t[13]=(a+n)*A,t[14]=(h+o)*p,t[15]=1,t}function ia(t,e,r,n){var a=void 0,o=void 0,h=void 0,d=void 0,A=void 0,p=void 0,m=void 0,w=void 0,b=void 0,y=void 0,_=e[0],M=e[1],v=e[2],S=n[0],F=n[1],R=n[2],I=r[0],B=r[1],L=r[2];return Math.abs(_-I)0&&(y=1/Math.sqrt(y),m*=y,w*=y,b*=y);var _=A*b-p*w,M=p*m-d*b,v=d*w-A*m;return y=_*_+M*M+v*v,y>0&&(y=1/Math.sqrt(y),_*=y,M*=y,v*=y),t[0]=_,t[1]=M,t[2]=v,t[3]=0,t[4]=w*v-b*M,t[5]=b*_-m*v,t[6]=m*M-w*_,t[7]=0,t[8]=m,t[9]=w,t[10]=b,t[11]=0,t[12]=a,t[13]=o,t[14]=h,t[15]=1,t}function sa(t){return"mat4("+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]+")"}function aa(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2)+Math.pow(t[9],2)+Math.pow(t[10],2)+Math.pow(t[11],2)+Math.pow(t[12],2)+Math.pow(t[13],2)+Math.pow(t[14],2)+Math.pow(t[15],2))}function oa(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function ji(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function la(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function ca(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t}function ha(t,e){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]}function da(t,e){var r=t[0],n=t[1],a=t[2],o=t[3],h=t[4],d=t[5],A=t[6],p=t[7],m=t[8],w=t[9],b=t[10],y=t[11],_=t[12],M=t[13],v=t[14],S=t[15],F=e[0],R=e[1],I=e[2],B=e[3],L=e[4],z=e[5],U=e[6],K=e[7],H=e[8],N=e[9],k=e[10],G=e[11],C=e[12],Y=e[13],Q=e[14],q=e[15];return Math.abs(r-F)<=oe*Math.max(1,Math.abs(r),Math.abs(F))&&Math.abs(n-R)<=oe*Math.max(1,Math.abs(n),Math.abs(R))&&Math.abs(a-I)<=oe*Math.max(1,Math.abs(a),Math.abs(I))&&Math.abs(o-B)<=oe*Math.max(1,Math.abs(o),Math.abs(B))&&Math.abs(h-L)<=oe*Math.max(1,Math.abs(h),Math.abs(L))&&Math.abs(d-z)<=oe*Math.max(1,Math.abs(d),Math.abs(z))&&Math.abs(A-U)<=oe*Math.max(1,Math.abs(A),Math.abs(U))&&Math.abs(p-K)<=oe*Math.max(1,Math.abs(p),Math.abs(K))&&Math.abs(m-H)<=oe*Math.max(1,Math.abs(m),Math.abs(H))&&Math.abs(w-N)<=oe*Math.max(1,Math.abs(w),Math.abs(N))&&Math.abs(b-k)<=oe*Math.max(1,Math.abs(b),Math.abs(k))&&Math.abs(y-G)<=oe*Math.max(1,Math.abs(y),Math.abs(G))&&Math.abs(_-C)<=oe*Math.max(1,Math.abs(_),Math.abs(C))&&Math.abs(M-Y)<=oe*Math.max(1,Math.abs(M),Math.abs(Y))&&Math.abs(v-Q)<=oe*Math.max(1,Math.abs(v),Math.abs(Q))&&Math.abs(S-q)<=oe*Math.max(1,Math.abs(S),Math.abs(q))}var fa=Yi,Aa=ji;var pa=Object.defineProperty,ua=(t,e,r)=>e in t?pa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,be=(t,e,r)=>(ua(t,typeof e!="symbol"?e+"":e,r),r),$r=1.6,ei;(function(t){t[t.Swizzled=0]="Swizzled",t[t.Center=1]="Center",t[t.Quilt=2]="Quilt"})(ei||(ei={}));var ti=class extends EventTarget{constructor(e){super(),be(this,"_calibration",{configVersion:"1.0",pitch:{value:45},slope:{value:-5},center:{value:-.5},viewCone:{value:40},invView:{value:1},verticalAngle:{value:0},DPI:{value:338},screenW:{value:3840},screenH:{value:2160},flipImageX:{value:0},flipImageY:{value:0},flipSubp:{value:0},serial:"",subpixelCells:[],CellPatternMode:{value:0}}),be(this,"_viewControls",{tileHeight:512,numViews:48,trackballX:0,trackballY:0,targetX:0,targetY:$r,targetZ:-.5,targetDiam:2,fovy:14/180*Math.PI,depthiness:1.25,inlineView:ei.Center,capturing:!1,quiltResolution:null,columns:null,rows:null,popup:null,XRSession:null,lkgCanvas:null,appCanvas:null,subpixelMode:1,filterMode:1,gaussianSigma:.01}),be(this,"LookingGlassDetected"),this._viewControls={...this._viewControls,...e},this.syncCalibration()}syncCalibration(){new xr(e=>{if(e.devices.length<1){console.log("No Looking Glass devices found");return}e.devices.length>1&&console.log("More than one Looking Glass device found... using the first one"),this.calibration=e.devices[0].calibration})}addEventListener(e,r,n){super.addEventListener(e,r,n)}onConfigChange(){this.dispatchEvent(new Event("on-config-changed"))}get calibration(){return this._calibration}set calibration(e){this._calibration={...this._calibration,...e},this.onConfigChange()}updateViewControls(e){e!=null&&(this._viewControls={...this._viewControls,...e},this.onConfigChange())}get tileHeight(){return Math.round(this.framebufferHeight/this.quiltHeight)}get quiltResolution(){if(this._viewControls.quiltResolution!=null)return{width:this._viewControls.quiltResolution.width,height:this._viewControls.quiltResolution.height};{let e=this._calibration.serial;switch(!0){case e.startsWith("LKG-2K"):return{width:4096,height:4096};case e.startsWith("LKG-4K"):return{width:4096,height:4096};case e.startsWith("LKG-8K"):return{width:8192,height:8192};case e.startsWith("LKG-P"):return{width:3360,height:3360};case e.startsWith("LKG-A"):return{width:4096,height:4096};case e.startsWith("LKG-B"):return{width:8192,height:8192};case e.startsWith("LKG-D"):return{width:8192,height:8192};case e.startsWith("LKG-F"):return{width:3360,height:3360};case e.startsWith("LKG-E"):return{width:4092,height:4092};case e.startsWith("LKG-H"):return{width:5995,height:6e3};case e.startsWith("LKG-J"):return{width:5999,height:5999};case e.startsWith("LKG-K"):return{width:8184,height:8184};case e.startsWith("LKG-L"):return{width:8190,height:8190};default:return{width:4096,height:4096}}}}set quiltResolution(e){this.updateViewControls({quiltResolution:e})}get numViews(){return this.quiltWidth*this.quiltHeight}get targetX(){return this._viewControls.targetX}set targetX(e){this.updateViewControls({targetX:e})}get targetY(){return this._viewControls.targetY}set targetY(e){this.updateViewControls({targetY:e})}get targetZ(){return this._viewControls.targetZ}set targetZ(e){this.updateViewControls({targetZ:e})}get trackballX(){return this._viewControls.trackballX}set trackballX(e){this.updateViewControls({trackballX:e})}get trackballY(){return this._viewControls.trackballY}set trackballY(e){this.updateViewControls({trackballY:e})}get targetDiam(){return this._viewControls.targetDiam}set targetDiam(e){this.updateViewControls({targetDiam:e})}get fovy(){return this._viewControls.fovy}set fovy(e){this.updateViewControls({fovy:e})}get depthiness(){return this._viewControls.depthiness}set depthiness(e){this.updateViewControls({depthiness:e})}get inlineView(){return this._viewControls.inlineView}set inlineView(e){this.updateViewControls({inlineView:e})}get capturing(){return this._viewControls.capturing}set capturing(e){this.updateViewControls({capturing:e})}get subpixelMode(){return this._viewControls.subpixelMode}set subpixelMode(e){this.updateViewControls({subpixelMode:e})}get filterMode(){return this._viewControls.filterMode}set filterMode(e){this.updateViewControls({filterMode:e})}get gaussianSigma(){return this._viewControls.gaussianSigma}set gaussianSigma(e){this.updateViewControls({gaussianSigma:e})}get popup(){return this._viewControls.popup}set popup(e){this.updateViewControls({popup:e})}get XRSession(){return this._viewControls.XRSession}set XRSession(e){this.updateViewControls({XRSession:e})}get lkgCanvas(){return this._viewControls.lkgCanvas}set lkgCanvas(e){this.updateViewControls({lkgCanvas:e})}get appCanvas(){return this._viewControls.appCanvas}set appCanvas(e){this.updateViewControls({appCanvas:e})}get columns(){return this._viewControls.columns}set columns(e){this.updateViewControls({columns:e})}get rows(){return this._viewControls.rows}set rows(e){this.updateViewControls({rows:e})}get aspect(){return this._calibration.screenW.value/this._calibration.screenH.value}get tileWidth(){return Math.round(this.framebufferWidth/this.quiltWidth)}get framebufferWidth(){return this.quiltResolution.width}get quiltWidth(){if(this._viewControls.columns!=null)return this._viewControls.columns;let e=this._calibration.serial;switch(!0){case e.startsWith("LKG-2K"):return 5;case e.startsWith("LKG-4K"):return 5;case e.startsWith("LKG-8K"):return 5;case e.startsWith("LKG-P"):return 8;case e.startsWith("LKG-A"):return 5;case e.startsWith("LKG-B"):return 5;case e.startsWith("LKG-D"):return 8;case e.startsWith("LKG-F"):return 8;case e.startsWith("LKG-E"):return 11;case e.startsWith("LKG-H"):return 11;case e.startsWith("LKG-J"):return 7;case e.startsWith("LKG-K"):return 11;case e.startsWith("LKG-L"):return 7;default:return 1}}get quiltHeight(){if(this._viewControls.rows!=null)return this._viewControls.rows;let e=this._calibration.serial;switch(!0){case e.startsWith("LKG-2K"):return 9;case e.startsWith("LKG-4K"):return 9;case e.startsWith("LKG-8K"):return 9;case e.startsWith("LKG-P"):return 6;case e.startsWith("LKG-A"):return 9;case e.startsWith("LKG-B"):return 9;case e.startsWith("LKG-D"):return 9;case e.startsWith("LKG-F"):return 6;case e.startsWith("LKG-E"):return 6;case e.startsWith("LKG-H"):return 6;case e.startsWith("LKG-J"):return 7;case e.startsWith("LKG-K"):return 6;case e.startsWith("LKG-L"):return 7;default:return 1}}get framebufferHeight(){return this.quiltResolution.height}get viewCone(){return this._calibration.viewCone.value*this.depthiness/180*Math.PI}get tilt(){return this._calibration.screenH.value/(this._calibration.screenW.value*this._calibration.slope.value)*(this._calibration.flipImageX.value?-1:1)}get subp(){return 1/(this._calibration.screenW.value*3)*(this._calibration.flipImageX.value?-1:1)}get pitch(){return this._calibration.pitch.value*this._calibration.screenW.value/this._calibration.DPI.value*Math.cos(Math.atan(1/this._calibration.slope.value))}get subpixelCells(){let e=new Float32Array(6*this._calibration.subpixelCells.length);return this._calibration.subpixelCells.forEach((r,n)=>{r.ROffsetX/=this.calibration.screenW.value,r.ROffsetY/=this.calibration.screenH.value,r.GOffsetX/=this.calibration.screenW.value,r.GOffsetY/=this.calibration.screenH.value,r.BOffsetX/=this.calibration.screenW.value,r.BOffsetY/=this.calibration.screenH.value,e[n*6+0]=r.ROffsetX,e[n*6+1]=r.ROffsetY,e[n*6+2]=r.GOffsetX,e[n*6+3]=r.GOffsetY,e[n*6+4]=r.BOffsetX,e[n*6+5]=r.BOffsetY}),e}},Jr=null;function Ie(){return Jr==null&&(Jr=new ti),Jr}function Zi(t){let e=Ie();t!=null&&e.updateViewControls(t)}async function ma(){let t=Ie(),e=2;async function r(){if(t.appCanvas!=null)try{t.capturing=!0,await new Promise(h=>{requestAnimationFrame(h)}),t.appCanvas.width=t.quiltResolution.width,t.appCanvas.height=t.quiltResolution.height;let a=t.appCanvas.toDataURL(),o=document.createElement("a");o.style.display="none",o.href=a,o.download=`hologram_qs${t.quiltWidth}x${t.quiltHeight}a${t.aspect}.png`,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(a)}catch(a){console.error("Error while capturing canvas data:",a),t.capturing=!1}finally{t.inlineView=e,t.capturing=!1,t.appCanvas.width=t.calibration.screenW.value,t.appCanvas.height=t.calibration.screenH.value}}let n=document.getElementById("screenshotbutton");n&&n.addEventListener("click",()=>{e=t.inlineView;let a=si.getInstance();if(!a){console.warn("LookingGlassXRDevice not initialized");return}t.inlineView=2,a.captureScreenshot=!0,setTimeout(()=>{a.screenshotCallback=r},100)})}function va(){var t,e,r,n,a;let o=Ie();if(o.lkgCanvas==null)console.warn("window placement called without a valid XR Session!");else{let h=function(){let v=M.d-M.a,S=M.w-M.s;v&&S&&(v*=Math.sqrt(.5),S*=Math.sqrt(.5));let F=o.trackballX,R=o.trackballY,I=Math.cos(F)*v-Math.sin(F)*Math.cos(R)*S,B=-Math.sin(R)*S,L=-Math.sin(F)*v-Math.cos(F)*Math.cos(R)*S;o.targetX=o.targetX+I*o.targetDiam*.03,o.targetY=o.targetY+B*o.targetDiam*.03,o.targetZ=o.targetZ+L*o.targetDiam*.03,requestAnimationFrame(h)},d=document.createElement("style");document.head.appendChild(d),(t=d.sheet)==null||t.insertRule("#LookingGlassWebXRControls * { all: revert; font-family: sans-serif }");let A=document.createElement("div");A.id="LookingGlassWebXRControls",A.style.position="fixed",A.style.zIndex="1000",A.style.padding="15px",A.style.width="320px",A.style.maxWidth="calc(100vw - 18px)",A.style.maxHeight="calc(100vh - 18px)",A.style.whiteSpace="nowrap",A.style.background="rgba(0, 0, 0, 0.6)",A.style.color="white",A.style.borderRadius="10px",A.style.right="15px",A.style.bottom="15px",A.style.flex="row";let p=document.createElement("div");A.appendChild(p),p.style.width="100%",p.style.textAlign="center",p.style.fontWeight="bold",p.style.marginBottom="8px",p.innerText="Looking Glass Controls";let m=document.createElement("button");m.style.display="block",m.style.margin="auto",m.style.width="100%",m.style.height="35px",m.style.padding="4px",m.style.marginBottom="8px",m.style.borderRadius="8px",m.id="screenshotbutton",A.appendChild(m),m.innerText="Save Hologram",o.quiltResolution.height*o.quiltResolution.width>33177600?(m.style.backgroundColor="#ccc",m.style.color="#999",m.style.cursor="not-allowed",m.title="Button is disabled because the quilt resolution is too large."):(m.style.backgroundColor="",m.style.color="",m.style.cursor="",m.title="");let w=document.createElement("button");w.style.display="block",w.style.margin="auto",w.style.width="100%",w.style.height="35px",w.style.padding="4px",w.style.marginBottom="8px",w.style.borderRadius="8px",w.id="copybutton",A.appendChild(w),w.innerText="Copy Config",w.addEventListener("click",()=>{wa(o)});let b=document.createElement("div");A.appendChild(b),b.style.width="290px",b.style.whiteSpace="normal",b.style.color="rgba(255,255,255,0.7)",b.style.fontSize="14px",b.style.margin="5px 0",b.innerHTML="Click the popup and use WASD, mouse left/right drag, and scroll.";let y=document.createElement("div");A.appendChild(y);let _=(v,S,F)=>{let R=F.stringify,I=document.createElement("div");I.style.marginBottom="8px",y.appendChild(I);let B=v,L=o[v],z=document.createElement("label");I.appendChild(z),z.innerText=F.label,z.setAttribute("for",B),z.style.width="100px",z.style.display="inline-block",z.style.textDecoration="dotted underline 1px",z.style.fontFamily='"Courier New"',z.style.fontSize="13px",z.style.fontWeight="bold",z.title=F.title;let U=document.createElement("input");I.appendChild(U),Object.assign(U,S),U.id=B,U.title=F.title,U.value=S.value!==void 0?S.value:L;let K=k=>{o[v]=k,N(k)};U.oninput=()=>{let k=S.type==="range"?parseFloat(U.value):S.type==="checkbox"?U.checked:U.value;K(k)};let H=k=>{let G=k(o[v]);F.fixRange&&(G=F.fixRange(G),U.max=Math.max(parseFloat(U.max),G).toString(),U.min=Math.min(parseFloat(U.min),G).toString()),U.value=G,K(G)};S.type==="range"&&(U.style.width="110px",U.style.height="8px",U.onwheel=k=>{H(G=>G+Math.sign(k.deltaX-k.deltaY)*S.step)});let N=k=>{};if(R){let k=document.createElement("span");k.style.fontFamily='"Courier New"',k.style.fontSize="13px",k.style.marginLeft="3px",I.appendChild(k),N=G=>{k.innerHTML=R(G)},N(L)}return H};_("fovy",{type:"range",min:1/180*Math.PI,max:120.1/180*Math.PI,step:1/180*Math.PI},{label:"fov",title:"perspective fov (degrades stereo effect)",fixRange:v=>Math.max(1/180*Math.PI,Math.min(v,120.1/180*Math.PI)),stringify:v=>{let S=v/Math.PI*180,F=Math.atan(Math.tan(v/2)*o.aspect)*2/Math.PI*180;return`${S.toFixed()}°×${F.toFixed()}°`}}),_("depthiness",{type:"range",min:0,max:2,step:.01},{label:"depthiness",title:"exaggerates depth by multiplying the width of the view cone (as reported by the firmware) - can somewhat compensate for depthiness lost using higher fov.",fixRange:v=>Math.max(0,v),stringify:v=>`${v.toFixed(2)}x`}),_("inlineView",{type:"range",min:0,max:2,step:1},{label:"inline view",title:"what to show inline on the original canvas (swizzled = no overwrite)",fixRange:v=>Math.max(0,Math.min(v,2)),stringify:v=>v===0?"swizzled":v===1?"center":v===2?"quilt":"?"}),_("filterMode",{type:"range",min:0,max:3,step:1},{label:"view filtering mode",title:"controls the method used for view blending",fixRange:v=>Math.max(0,Math.min(v,2)),stringify:v=>v===0?"old, studio style":v===1?"2 view":v===2?"gaussian":v===3?"10 view gaussian":"?"}),_("gaussianSigma",{type:"range",min:-1,max:1,step:.01},{label:"gaussian sigma",title:"control view blending",fixRange:v=>Math.max(-1,Math.min(v,1)),stringify:v=>v}),o.lkgCanvas.oncontextmenu=v=>{v.preventDefault()},o.lkgCanvas.addEventListener("wheel",v=>{let S=o.targetDiam,F=1.1,R=Math.log(S)/Math.log(F);return o.targetDiam=Math.pow(F,R+v.deltaY*.01)},{passive:!1}),o.lkgCanvas.addEventListener("mousemove",v=>{let S=v.movementX,F=-v.movementY;if(v.buttons&2||v.buttons&1&&(v.shiftKey||v.ctrlKey)){let R=o.trackballX,I=o.trackballY,B=-Math.cos(R)*S+Math.sin(R)*Math.sin(I)*F,L=-Math.cos(I)*F,z=Math.sin(R)*S+Math.cos(R)*Math.sin(I)*F;o.targetX=o.targetX+B*o.targetDiam*.001,o.targetY=o.targetY+L*o.targetDiam*.001,o.targetZ=o.targetZ+z*o.targetDiam*.001}else v.buttons&1&&(o.trackballX=o.trackballX-S*.01,o.trackballY=o.trackballY-F*.01)});let M={w:0,a:0,s:0,d:0};return o.lkgCanvas.addEventListener("keydown",v=>{switch(v.code){case"KeyW":M.w=1;break;case"KeyA":M.a=1;break;case"KeyS":M.s=1;break;case"KeyD":M.d=1;break}}),o.lkgCanvas.addEventListener("keyup",v=>{switch(v.code){case"KeyW":M.w=0;break;case"KeyA":M.a=0;break;case"KeyS":M.s=0;break;case"KeyD":M.d=0;break}}),(e=o.appCanvas)==null||e.addEventListener("wheel",v=>{let S=o.targetDiam,F=1.1,R=Math.log(S)/Math.log(F);return o.targetDiam=Math.pow(F,R+v.deltaY*.01)},{passive:!1}),(r=o.appCanvas)==null||r.addEventListener("mousemove",v=>{let S=v.movementX,F=-v.movementY;if(v.buttons&2||v.buttons&1&&(v.shiftKey||v.ctrlKey)){let R=o.trackballX,I=o.trackballY,B=-Math.cos(R)*S+Math.sin(R)*Math.sin(I)*F,L=-Math.cos(I)*F,z=Math.sin(R)*S+Math.cos(R)*Math.sin(I)*F;o.targetX=o.targetX+B*o.targetDiam*.001,o.targetY=o.targetY+L*o.targetDiam*.001,o.targetZ=o.targetZ+z*o.targetDiam*.001}else v.buttons&1&&(o.trackballX=o.trackballX-S*.01,o.trackballY=o.trackballY-F*.01)}),(n=o.appCanvas)==null||n.addEventListener("keydown",v=>{switch(v.code){case"KeyW":M.w=1;break;case"KeyA":M.a=1;break;case"KeyS":M.s=1;break;case"KeyD":M.d=1;break}}),(a=o.appCanvas)==null||a.addEventListener("keyup",v=>{switch(v.code){case"KeyW":M.w=0;break;case"KeyA":M.a=0;break;case"KeyS":M.s=0;break;case"KeyD":M.d=0;break}}),requestAnimationFrame(h),setTimeout(()=>{ma()},1e3),A}}function wa(t){let e={targetX:t.targetX,targetY:t.targetY,targetZ:t.targetZ,fovy:`${Math.round(t.fovy/Math.PI*180)} * Math.PI / 180`,targetDiam:t.targetDiam,trackballX:t.trackballX,trackballY:t.trackballY,depthiness:t.depthiness},r=JSON.stringify(e,null,4).replace(/"/g,"").replace(/{/g,"").replace(/}/g,"");navigator.clipboard.writeText(r)}var br,ga=(t,e)=>{let r=Ie();if(r.lkgCanvas==null){console.warn("window placement called without a valid XR Session!");return}else t==!1?ya(r,br):(br==null&&(br=va()),r.lkgCanvas.style.position="fixed",r.lkgCanvas.style.bottom="0",r.lkgCanvas.style.left="0",r.lkgCanvas.width=r.calibration.screenW.value,r.lkgCanvas.height=r.calibration.screenH.value,document.body.appendChild(br),"getScreenDetails"in window?xa(r.lkgCanvas,r,e):Ji(r,r.lkgCanvas,e))};async function xa(t,e,r){let n=(await window.getScreenDetails()).screens.filter(a=>a.label.includes("LKG"))[0];if(n===void 0){console.log("no Looking Glass monitor detected - manually opening popup window"),Ji(e,t,r);return}else{let a=[`left=${n.left}`,`top=${n.top}`,`width=${n.width}`,`height=${n.height}`,"menubar=no","toolbar=no","location=no","status=no","resizable=yes","scrollbars=no","fullscreenEnabled=true"].join(",");e.popup=window.open("","new",a),e.popup&&(e.popup.document.body.style.background="black",e.popup.document.body.style.transform="1.0",$i(e),e.popup.document.body.appendChild(t),console.assert(r),e.popup.onbeforeunload=r)}}function Ji(t,e,r){t.popup=window.open("",void 0,"width=640,height=360"),t.popup&&(t.popup.document.title="Looking Glass Window (fullscreen me on Looking Glass!)",t.popup.document.body.style.background="black",t.popup.document.body.style.transform="1.0",$i(t),t.popup.document.body.appendChild(e),console.assert(r),t.popup.onbeforeunload=r)}function ya(t,e){var r;(r=e.parentElement)==null||r.removeChild(e),t.popup&&(t.popup.onbeforeunload=null,t.popup.close(),t.popup=null)}function $i(t){t.popup&&t.popup.document.addEventListener("keydown",e=>{e.ctrlKey&&(e.key==="="||e.key==="-"||e.key==="+")&&e.preventDefault()})}var Be=Symbol("LookingGlassXRWebGLLayer"),ri=class extends wt{constructor(e,r,n){super(e,r,n);let a=Ie();a.appCanvas=r.canvas,a.lkgCanvas=document.createElement("canvas"),a.lkgCanvas.tabIndex=0;let o=a.lkgCanvas.getContext("2d",{alpha:!1});a.lkgCanvas.addEventListener("dblclick",function(){this.requestFullscreen()});let h=this[$e].config,d=r.createTexture(),A,p,m=r.createFramebuffer(),w=r.enable.bind(r),b=r.disable.bind(r),y=r.getExtension("OES_vertex_array_object"),_=34229,M=y?y.bindVertexArrayOES.bind(y):r.bindVertexArray.bind(r),v=()=>{let $=r.getParameter(r.TEXTURE_BINDING_2D);if(r.bindTexture(r.TEXTURE_2D,d),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,a.framebufferWidth,a.framebufferHeight,0,r.RGBA,r.UNSIGNED_BYTE,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_BASE_LEVEL,0),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAX_LEVEL,0),r.bindTexture(r.TEXTURE_2D,$),A){let xe=r.getParameter(r.RENDERBUFFER_BINDING);r.bindRenderbuffer(r.RENDERBUFFER,A),r.renderbufferStorage(r.RENDERBUFFER,p.format,a.framebufferWidth,a.framebufferHeight),r.bindRenderbuffer(r.RENDERBUFFER,xe)}};(h.depth||h.stencil)&&(h.depth&&h.stencil?p={format:r.DEPTH_STENCIL,attachment:r.DEPTH_STENCIL_ATTACHMENT}:h.depth?p={format:r.DEPTH_COMPONENT16,attachment:r.DEPTH_ATTACHMENT}:h.stencil&&(p={format:r.STENCIL_INDEX8,attachment:r.STENCIL_ATTACHMENT}),A=r.createRenderbuffer()),v(),a.addEventListener("on-config-changed",v);let S=r.getParameter(r.FRAMEBUFFER_BINDING);r.bindFramebuffer(r.FRAMEBUFFER,m),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,d,0),(h.depth||h.stencil)&&r.framebufferRenderbuffer(r.FRAMEBUFFER,p.attachment,r.RENDERBUFFER,A),r.bindFramebuffer(r.FRAMEBUFFER,S);let F=r.createProgram();if(!F)return;let R=r.createShader(r.VERTEX_SHADER);if(!R)return;r.attachShader(F,R);let I=r.createShader(r.FRAGMENT_SHADER);if(!I)return;r.attachShader(F,I),r.shaderSource(R,`#version 300 es + in vec2 a_position; + out vec2 v_texcoord; + void main() { + gl_Position = vec4(a_position * 2.0 - 1.0, 0.0, 1.0); + v_texcoord = a_position; + } + `),r.compileShader(R),r.getShaderParameter(R,r.COMPILE_STATUS)||console.warn(r.getShaderInfoLog(R));let B,L,z,U=()=>{let $=Xi(a);if($===B||(B=$,!I))return;if(r.shaderSource(I,$),r.compileShader(I),!r.getShaderParameter(I,r.COMPILE_STATUS)){console.warn(r.getShaderInfoLog(I));return}if(!F)return;if(r.linkProgram(F),!r.getProgramParameter(F,r.LINK_STATUS)){console.warn(r.getProgramInfoLog(F));return}L=r.getAttribLocation(F,"a_position"),z=r.getUniformLocation(F,"u_viewType");let xe=r.getUniformLocation(F,"u_texture"),Me=r.getUniformLocation(F,"subpixelData"),We=r.getParameter(r.CURRENT_PROGRAM);r.useProgram(F),r.uniform1i(xe,0),r.uniform1fv(Me,a.subpixelCells),r.useProgram(We)};a.addEventListener("on-config-changed",U);let K=y?y.createVertexArrayOES():r.createVertexArray(),H=r.createBuffer(),N=r.getParameter(r.ARRAY_BUFFER_BINDING),k=r.getParameter(_);M(K),r.bindBuffer(r.ARRAY_BUFFER,H),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),r.STATIC_DRAW),r.enableVertexAttribArray(L),r.vertexAttribPointer(L,2,r.FLOAT,!1,0,0),M(k),r.bindBuffer(r.ARRAY_BUFFER,N);let G=()=>{console.assert(this[Be].LookingGlassEnabled),r.bindFramebuffer(r.FRAMEBUFFER,m);let $=r.getParameter(r.COLOR_CLEAR_VALUE),xe=r.getParameter(r.DEPTH_CLEAR_VALUE),Me=r.getParameter(r.STENCIL_CLEAR_VALUE);r.clearColor(0,0,0,0),r.clearDepth(1),r.clearStencil(0),r.clear(r.DEPTH_BUFFER_BIT|r.COLOR_BUFFER_BIT|r.STENCIL_BUFFER_BIT),r.clearColor($[0],$[1],$[2],$[3]),r.clearDepth(xe),r.clearStencil(Me)},C=r.canvas,Y,Q,q=()=>{if(!this[Be].LookingGlassEnabled)return;(C.width!==a.calibration.screenW.value||C.height!==a.calibration.screenH.value)&&a.capturing===!1?(Y=C.width,Q=C.height,C.width=a.calibration.screenW.value,C.height=a.calibration.screenH.value):a.capturing===!0&&(Y=C.width,Q=C.height,C.width=a.framebufferWidth,C.height=a.framebufferHeight);let $=r.getParameter(_),xe=r.getParameter(r.CULL_FACE),Me=r.getParameter(r.BLEND),We=r.getParameter(r.DEPTH_TEST),et=r.getParameter(r.STENCIL_TEST),de=r.getParameter(r.SCISSOR_TEST),yt=r.getParameter(r.VIEWPORT),St=r.getParameter(r.FRAMEBUFFER_BINDING),ir=r.getParameter(r.RENDERBUFFER_BINDING),Rt=r.getParameter(r.CURRENT_PROGRAM),nr=r.getParameter(r.ACTIVE_TEXTURE);{let sr=r.getParameter(r.TEXTURE_BINDING_2D);r.bindFramebuffer(r.FRAMEBUFFER,null),r.useProgram(F),M(K),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,d),r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.STENCIL_TEST),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight),r.uniform1i(z,0),r.drawArrays(r.TRIANGLES,0,6),o?.clearRect(0,0,a.calibration.screenW.value,a.calibration.screenH.value),o?.drawImage(C,0,0),a.inlineView!==0&&(r.uniform1i(z,a.inlineView),r.drawArrays(r.TRIANGLES,0,6)),r.bindTexture(r.TEXTURE_2D,sr)}r.activeTexture(nr),r.useProgram(Rt),r.bindRenderbuffer(r.RENDERBUFFER,ir),r.bindFramebuffer(r.FRAMEBUFFER,St),r.viewport(...yt),(de?w:b)(r.SCISSOR_TEST),(et?w:b)(r.STENCIL_TEST),(We?w:b)(r.DEPTH_TEST),(Me?w:b)(r.BLEND),(xe?w:b)(r.CULL_FACE),M($)};this[Be]={LookingGlassEnabled:!1,framebuffer:m,clearFramebuffer:G,blitTextureToDefaultFramebufferIfNeeded:q,moveCanvasToWindow:ga,restoreOriginalCanvasDimensions:()=>{Y&&Q&&(C.width=Y,C.height=Q,Y=Q=void 0)}}}get framebuffer(){return this[Be].LookingGlassEnabled?this[Be].framebuffer:null}get framebufferWidth(){return Ie().framebufferWidth}get framebufferHeight(){return Ie().framebufferHeight}},Mr=class extends Ue{constructor(t){super(t),this.sessions=new Map,this.viewSpaces=[],this.basePoseMatrix=le.create(),this.inlineProjectionMatrix=le.create(),this.inlineInverseViewMatrix=le.create(),this.LookingGlassProjectionMatrices=[],this.LookingGlassInverseViewMatrices=[],this.captureScreenshot=!1,this.screenshotCallback=null,Mr.instance||(Mr.instance=this)}static getInstance(){return Mr.instance}onBaseLayerSet(t,e){let r=this.sessions.get(t);r.baseLayer=e;let n=Ie(),a=e[Be];a.LookingGlassEnabled=r.immersive,r.immersive&&(n.XRSession=this.sessions.get(t),n.popup==null?a.moveCanvasToWindow(!0,()=>{this.endSession(t)}):console.warn("attempted to assign baselayer twice?"))}isSessionSupported(t){return t==="inline"||t==="immersive-vr"}isFeatureSupported(t){switch(t){case"viewer":return!0;case"local":return!0;case"local-floor":return!0;case"bounded-floor":return!1;case"unbounded":return!1;default:return console.warn("LookingGlassXRDevice.isFeatureSupported: feature not understood:",t),!1}}async requestSession(t,e){if(!this.isSessionSupported(t))return Promise.reject();let r=t!=="inline",n=new ii(t,e),a=Ie();return this.sessions.set(n.id,n),r&&(this.dispatchEvent("@@webxr-polyfill/vr-present-start",n.id),window.addEventListener("unload",()=>{a.popup&&a.popup.close(),a.popup=null})),Promise.resolve(n.id)}requestAnimationFrame(t){return this.global.requestAnimationFrame(t)}cancelAnimationFrame(t){this.global.cancelAnimationFrame(t)}onFrameStart(t,e){let r=this.sessions.get(t),n=Ie();if(r.immersive){let a=Math.tan(.5*n.fovy),o=.5*n.targetDiam/a,h=o-n.targetDiam,d=this.basePoseMatrix;le.fromTranslation(d,[n.targetX,n.targetY,n.targetZ]),le.rotate(d,d,n.trackballX,[0,1,0]),le.rotate(d,d,-n.trackballY,[1,0,0]),le.translate(d,d,[0,0,o]);for(let A=0;A{this.isPresenting=!0,this.updateVRButtonUI()}),this.device.addEventListener("@@webxr-polyfill/vr-present-end",()=>{this.isPresenting=!1,this.updateVRButtonUI()}),this.vrButton.addEventListener("click",e=>{this.updateVRButtonUI()}),this.updateVRButtonUI()):console.warn("Unable to find VRButton")}async updateVRButtonUI(){if(this.vrButton){await Ea(100),this.isPresenting?this.vrButton.innerHTML="EXIT LOOKING GLASS":this.vrButton.innerHTML="ENTER LOOKING GLASS";let e=220;this.vrButton.style.width=`${e}px`,this.vrButton.style.left=`calc(50% - ${e/2}px)`}}update(e){Zi(e)}};async function Ma(t){return new Promise(e=>{let r=new MutationObserver(function(n){n.forEach(function(a){a.addedNodes.forEach(function(o){let h=o;h.id===t&&(e(h),r.disconnect())})})});r.observe(document.body,{subtree:!1,childList:!0}),setTimeout(()=>{r.disconnect(),e(null)},5e3)})}function Ea(t){return new Promise(e=>setTimeout(e,t))}var Xl=Ie();export{Xl as LookingGlassConfig,Ki as LookingGlassWebXRPolyfill}; +/*! Bundled license information: + +cardboard-vr-display/dist/cardboard-vr-display.js: + (** + * @license + * cardboard-vr-display + * Copyright (c) 2015-2017 Google + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *) + (** + * @license + * gl-preserve-state + * Copyright (c) 2016, Brandon Jones. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + (** + * @license + * webvr-polyfill-dpdb + * Copyright (c) 2015-2017 Google + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *) + (** + * @license + * nosleep.js + * Copyright (c) 2017, Rich Tibbett + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +holoplay-core/dist/holoplaycore.module.js: + (** + * This files defines the HoloPlayClient class and Message class. + * + * Copyright (c) [2024] [Looking Glass Factory] + * + * @link https://lookingglassfactory.com/ + * @file This files defines the HoloPlayClient class and Message class. + * @author Looking Glass Factory. + * @version 0.0.11 + * @license SEE LICENSE IN LICENSE.txt + *) +*/ +//# sourceMappingURL=webxr.bundle.mjs.map \ No newline at end of file