@qispace/vue3-player 0.4.59 → 0.4.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3464,7 +3464,7 @@ void main() {
|
|
|
3464
3464
|
squared_mean = squared_mean / samples;
|
|
3465
3465
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3466
3466
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3467
|
-
}`}),w=p.clone();w.defines.HORIZONTAL_PASS=1;const k=new bn;k.setAttribute("position",new Vi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const R=new UA(k,p),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=f;let N=this.type;function L(ne,Ae){const te=e.update(R);p.defines.VSM_SAMPLES!==ne.blurSamples&&(p.defines.VSM_SAMPLES=ne.blurSamples,w.defines.VSM_SAMPLES=ne.blurSamples,p.needsUpdate=!0,w.needsUpdate=!0),ne.mapPass===null&&(ne.mapPass=new ei(n.x,n.y)),p.uniforms.shadow_pass.value=ne.map.texture,p.uniforms.resolution.value=ne.mapSize,p.uniforms.radius.value=ne.radius,o.setRenderTarget(ne.mapPass),o.clear(),o.renderBufferDirect(Ae,null,te,p,R,null),w.uniforms.shadow_pass.value=ne.mapPass.texture,w.uniforms.resolution.value=ne.mapSize,w.uniforms.radius.value=ne.radius,o.setRenderTarget(ne.map),o.clear(),o.renderBufferDirect(Ae,null,te,w,R,null)}function G(ne,Ae,te,ye){let ge=null;const Me=te.isPointLight===!0?ne.customDistanceMaterial:ne.customDepthMaterial;if(Me!==void 0)ge=Me;else if(ge=te.isPointLight===!0?u:h,o.localClippingEnabled&&Ae.clipShadows===!0&&Array.isArray(Ae.clippingPlanes)&&Ae.clippingPlanes.length!==0||Ae.displacementMap&&Ae.displacementScale!==0||Ae.alphaMap&&Ae.alphaTest>0||Ae.map&&Ae.alphaTest>0){const pe=ge.uuid,Ze=Ae.uuid;let Ct=c[pe];Ct===void 0&&(Ct={},c[pe]=Ct);let Qt=Ct[Ze];Qt===void 0&&(Qt=ge.clone(),Ct[Ze]=Qt),ge=Qt}return ge.visible=Ae.visible,ge.wireframe=Ae.wireframe,ge.side=ye===Q?Ae.shadowSide!==null?Ae.shadowSide:Ae.side:Ae.shadowSide!==null?Ae.shadowSide:B[Ae.side],ge.alphaMap=Ae.alphaMap,ge.alphaTest=Ae.alphaTest,ge.map=Ae.map,ge.clipShadows=Ae.clipShadows,ge.clippingPlanes=Ae.clippingPlanes,ge.clipIntersection=Ae.clipIntersection,ge.displacementMap=Ae.displacementMap,ge.displacementScale=Ae.displacementScale,ge.displacementBias=Ae.displacementBias,ge.wireframeLinewidth=Ae.wireframeLinewidth,ge.linewidth=Ae.linewidth,te.isPointLight===!0&&ge.isMeshDistanceMaterial===!0&&(o.properties.get(ge).light=te),ge}function le(ne,Ae,te,ye,ge){if(ne.visible===!1)return;if(ne.layers.test(Ae.layers)&&(ne.isMesh||ne.isLine||ne.isPoints)&&(ne.castShadow||ne.receiveShadow&&ge===Q)&&(!ne.frustumCulled||A.intersectsObject(ne))){ne.modelViewMatrix.multiplyMatrices(te.matrixWorldInverse,ne.matrixWorld);const pe=e.update(ne),Ze=ne.material;if(Array.isArray(Ze)){const Ct=pe.groups;for(let Qt=0,Wt=Ct.length;Qt<Wt;Qt++){const ft=Ct[Qt],Mt=Ze[ft.materialIndex];if(Mt&&Mt.visible){const Rt=G(ne,Mt,ye,ge);o.renderBufferDirect(te,null,pe,Rt,ne,ft)}}}else if(Ze.visible){const Ct=G(ne,Ze,ye,ge);o.renderBufferDirect(te,null,pe,Ct,ne,null)}}const Me=ne.children;for(let pe=0,Ze=Me.length;pe<Ze;pe++)le(Me[pe],Ae,te,ye,ge)}this.render=function(ne,Ae,te){if(_.enabled===!1||_.autoUpdate===!1&&_.needsUpdate===!1||ne.length===0)return;const ye=o.getRenderTarget(),ge=o.getActiveCubeFace(),Me=o.getActiveMipmapLevel(),pe=o.state;pe.setBlending(0),pe.buffers.color.setClear(1,1,1,1),pe.buffers.depth.setTest(!0),pe.setScissorTest(!1);const Ze=N!==Q&&this.type===Q,Ct=N===Q&&this.type!==Q;for(let Qt=0,Wt=ne.length;Qt<Wt;Qt++){const ft=ne[Qt],Mt=ft.shadow;if(Mt===void 0||Mt.autoUpdate===!1&&Mt.needsUpdate===!1)continue;n.copy(Mt.mapSize);const Rt=Mt.getFrameExtents();if(n.multiply(Rt),r.copy(Mt.mapSize),(n.x>C||n.y>C)&&(n.x>C&&(r.x=Math.floor(C/Rt.x),n.x=r.x*Rt.x,Mt.mapSize.x=r.x),n.y>C&&(r.y=Math.floor(C/Rt.y),n.y=r.y*Rt.y,Mt.mapSize.y=r.y)),Mt.map===null||Ze===!0||Ct===!0){const Ye=this.type!==Q?{minFilter:Be,magFilter:Be}:{};Mt.map!==null&&Mt.map.dispose(),Mt.map=new ei(n.x,n.y,Ye),Mt.map.texture.name=ft.name+".shadowMap",Mt.camera.updateProjectionMatrix()}o.setRenderTarget(Mt.map),o.clear();const Ft=Mt.getViewportCount();for(let Ye=0;Ye<Ft;Ye++){const dt=Mt.getViewport(Ye);g.set(r.x*dt.x,r.y*dt.y,r.x*dt.z,r.y*dt.w),pe.viewport(g),Mt.updateMatrices(ft,Ye),A=Mt.getFrustum(),le(Ae,te,Mt.camera,ft,this.type)}Mt.isPointLightShadow!==!0&&this.type===Q&&L(Mt,te),Mt.needsUpdate=!1}N=this.type,_.needsUpdate=!1,o.setRenderTarget(ye,ge,Me)}}function SS(o,e,t){const A=t.isWebGL2,n=new function(){let oe=!1;const Te=new zA;let ct=null;const St=new zA(0,0,0,0);return{setMask:function(ht){ct===ht||oe||(o.colorMask(ht,ht,ht,ht),ct=ht)},setLocked:function(ht){oe=ht},setClear:function(ht,Kt,Ht,_t,CA){CA===!0&&(ht*=_t,Kt*=_t,Ht*=_t),Te.set(ht,Kt,Ht,_t),St.equals(Te)===!1&&(o.clearColor(ht,Kt,Ht,_t),St.copy(Te))},reset:function(){oe=!1,ct=null,St.set(-1,0,0,0)}}},r=new function(){let oe=!1,Te=null,ct=null,St=null;return{setTest:function(ht){ht?Xt(o.DEPTH_TEST):ce(o.DEPTH_TEST)},setMask:function(ht){Te===ht||oe||(o.depthMask(ht),Te=ht)},setFunc:function(ht){if(ct!==ht){switch(ht){case 0:o.depthFunc(o.NEVER);break;case 1:o.depthFunc(o.ALWAYS);break;case 2:o.depthFunc(o.LESS);break;case 3:default:o.depthFunc(o.LEQUAL);break;case 4:o.depthFunc(o.EQUAL);break;case 5:o.depthFunc(o.GEQUAL);break;case 6:o.depthFunc(o.GREATER);break;case 7:o.depthFunc(o.NOTEQUAL)}ct=ht}},setLocked:function(ht){oe=ht},setClear:function(ht){St!==ht&&(o.clearDepth(ht),St=ht)},reset:function(){oe=!1,Te=null,ct=null,St=null}}},g=new function(){let oe=!1,Te=null,ct=null,St=null,ht=null,Kt=null,Ht=null,_t=null,CA=null;return{setTest:function(hA){oe||(hA?Xt(o.STENCIL_TEST):ce(o.STENCIL_TEST))},setMask:function(hA){Te===hA||oe||(o.stencilMask(hA),Te=hA)},setFunc:function(hA,J,$){ct===hA&&St===J&&ht===$||(o.stencilFunc(hA,J,$),ct=hA,St=J,ht=$)},setOp:function(hA,J,$){Kt===hA&&Ht===J&&_t===$||(o.stencilOp(hA,J,$),Kt=hA,Ht=J,_t=$)},setLocked:function(hA){oe=hA},setClear:function(hA){CA!==hA&&(o.clearStencil(hA),CA=hA)},reset:function(){oe=!1,Te=null,ct=null,St=null,ht=null,Kt=null,Ht=null,_t=null,CA=null}}},h=new WeakMap,u=new WeakMap;let c={},C={},B=new WeakMap,p=[],w=null,k=!1,R=null,_=null,N=null,L=null,G=null,le=null,ne=null,Ae=!1,te=null,ye=null,ge=null,Me=null,pe=null;const Ze=o.getParameter(o.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Ct=!1,Qt=0;const Wt=o.getParameter(o.VERSION);Wt.indexOf("WebGL")!==-1?(Qt=parseFloat(/^WebGL (\d)/.exec(Wt)[1]),Ct=Qt>=1):Wt.indexOf("OpenGL ES")!==-1&&(Qt=parseFloat(/^OpenGL ES (\d)/.exec(Wt)[1]),Ct=Qt>=2);let ft=null,Mt={};const Rt=o.getParameter(o.SCISSOR_BOX),Ft=o.getParameter(o.VIEWPORT),Ye=new zA().fromArray(Rt),dt=new zA().fromArray(Ft);function bt(oe,Te,ct,St){const ht=new Uint8Array(4),Kt=o.createTexture();o.bindTexture(oe,Kt),o.texParameteri(oe,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(oe,o.TEXTURE_MAG_FILTER,o.NEAREST);for(let Ht=0;Ht<ct;Ht++)!A||oe!==o.TEXTURE_3D&&oe!==o.TEXTURE_2D_ARRAY?o.texImage2D(Te+Ht,0,o.RGBA,1,1,0,o.RGBA,o.UNSIGNED_BYTE,ht):o.texImage3D(Te,0,o.RGBA,1,1,St,0,o.RGBA,o.UNSIGNED_BYTE,ht);return Kt}const gt={};function Xt(oe){c[oe]!==!0&&(o.enable(oe),c[oe]=!0)}function ce(oe){c[oe]!==!1&&(o.disable(oe),c[oe]=!1)}gt[o.TEXTURE_2D]=bt(o.TEXTURE_2D,o.TEXTURE_2D,1),gt[o.TEXTURE_CUBE_MAP]=bt(o.TEXTURE_CUBE_MAP,o.TEXTURE_CUBE_MAP_POSITIVE_X,6),A&&(gt[o.TEXTURE_2D_ARRAY]=bt(o.TEXTURE_2D_ARRAY,o.TEXTURE_2D_ARRAY,1,1),gt[o.TEXTURE_3D]=bt(o.TEXTURE_3D,o.TEXTURE_3D,1,1)),n.setClear(0,0,0,1),r.setClear(1),g.setClear(0),Xt(o.DEPTH_TEST),r.setFunc(3),_e(!1),Et(1),Xt(o.CULL_FACE),je(0);const Ie={[S]:o.FUNC_ADD,101:o.FUNC_SUBTRACT,102:o.FUNC_REVERSE_SUBTRACT};if(A)Ie[103]=o.MIN,Ie[104]=o.MAX;else{const oe=e.get("EXT_blend_minmax");oe!==null&&(Ie[103]=oe.MIN_EXT,Ie[104]=oe.MAX_EXT)}const Se={200:o.ZERO,201:o.ONE,202:o.SRC_COLOR,204:o.SRC_ALPHA,210:o.SRC_ALPHA_SATURATE,208:o.DST_COLOR,206:o.DST_ALPHA,203:o.ONE_MINUS_SRC_COLOR,205:o.ONE_MINUS_SRC_ALPHA,209:o.ONE_MINUS_DST_COLOR,207:o.ONE_MINUS_DST_ALPHA};function je(oe,Te,ct,St,ht,Kt,Ht,_t){if(oe!==0){if(k===!1&&(Xt(o.BLEND),k=!0),oe===5)ht=ht||Te,Kt=Kt||ct,Ht=Ht||St,Te===_&&ht===G||(o.blendEquationSeparate(Ie[Te],Ie[ht]),_=Te,G=ht),ct===N&&St===L&&Kt===le&&Ht===ne||(o.blendFuncSeparate(Se[ct],Se[St],Se[Kt],Se[Ht]),N=ct,L=St,le=Kt,ne=Ht),R=oe,Ae=!1;else if(oe!==R||_t!==Ae){if(_===S&&G===S||(o.blendEquation(o.FUNC_ADD),_=S,G=S),_t)switch(oe){case 1:o.blendFuncSeparate(o.ONE,o.ONE_MINUS_SRC_ALPHA,o.ONE,o.ONE_MINUS_SRC_ALPHA);break;case 2:o.blendFunc(o.ONE,o.ONE);break;case 3:o.blendFuncSeparate(o.ZERO,o.ONE_MINUS_SRC_COLOR,o.ZERO,o.ONE);break;case 4:o.blendFuncSeparate(o.ZERO,o.SRC_COLOR,o.ZERO,o.SRC_ALPHA)}else switch(oe){case 1:o.blendFuncSeparate(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA,o.ONE,o.ONE_MINUS_SRC_ALPHA);break;case 2:o.blendFunc(o.SRC_ALPHA,o.ONE);break;case 3:o.blendFuncSeparate(o.ZERO,o.ONE_MINUS_SRC_COLOR,o.ZERO,o.ONE);break;case 4:o.blendFunc(o.ZERO,o.SRC_COLOR)}N=null,L=null,le=null,ne=null,R=oe,Ae=_t}}else k===!0&&(ce(o.BLEND),k=!1)}function _e(oe){te!==oe&&(oe?o.frontFace(o.CW):o.frontFace(o.CCW),te=oe)}function Et(oe){oe!==0?(Xt(o.CULL_FACE),oe!==ye&&(oe===1?o.cullFace(o.BACK):oe===2?o.cullFace(o.FRONT):o.cullFace(o.FRONT_AND_BACK))):ce(o.CULL_FACE),ye=oe}function ke(oe,Te,ct){oe?(Xt(o.POLYGON_OFFSET_FILL),Me===Te&&pe===ct||(o.polygonOffset(Te,ct),Me=Te,pe=ct)):ce(o.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:r,stencil:g},enable:Xt,disable:ce,bindFramebuffer:function(oe,Te){return C[oe]!==Te&&(o.bindFramebuffer(oe,Te),C[oe]=Te,A&&(oe===o.DRAW_FRAMEBUFFER&&(C[o.FRAMEBUFFER]=Te),oe===o.FRAMEBUFFER&&(C[o.DRAW_FRAMEBUFFER]=Te)),!0)},drawBuffers:function(oe,Te){let ct=p,St=!1;if(oe)if(ct=B.get(Te),ct===void 0&&(ct=[],B.set(Te,ct)),oe.isWebGLMultipleRenderTargets){const ht=oe.texture;if(ct.length!==ht.length||ct[0]!==o.COLOR_ATTACHMENT0){for(let Kt=0,Ht=ht.length;Kt<Ht;Kt++)ct[Kt]=o.COLOR_ATTACHMENT0+Kt;ct.length=ht.length,St=!0}}else ct[0]!==o.COLOR_ATTACHMENT0&&(ct[0]=o.COLOR_ATTACHMENT0,St=!0);else ct[0]!==o.BACK&&(ct[0]=o.BACK,St=!0);St&&(t.isWebGL2?o.drawBuffers(ct):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(ct))},useProgram:function(oe){return w!==oe&&(o.useProgram(oe),w=oe,!0)},setBlending:je,setMaterial:function(oe,Te){oe.side===2?ce(o.CULL_FACE):Xt(o.CULL_FACE);let ct=oe.side===v;Te&&(ct=!ct),_e(ct),oe.blending===1&&oe.transparent===!1?je(0):je(oe.blending,oe.blendEquation,oe.blendSrc,oe.blendDst,oe.blendEquationAlpha,oe.blendSrcAlpha,oe.blendDstAlpha,oe.premultipliedAlpha),r.setFunc(oe.depthFunc),r.setTest(oe.depthTest),r.setMask(oe.depthWrite),n.setMask(oe.colorWrite);const St=oe.stencilWrite;g.setTest(St),St&&(g.setMask(oe.stencilWriteMask),g.setFunc(oe.stencilFunc,oe.stencilRef,oe.stencilFuncMask),g.setOp(oe.stencilFail,oe.stencilZFail,oe.stencilZPass)),ke(oe.polygonOffset,oe.polygonOffsetFactor,oe.polygonOffsetUnits),oe.alphaToCoverage===!0?Xt(o.SAMPLE_ALPHA_TO_COVERAGE):ce(o.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:_e,setCullFace:Et,setLineWidth:function(oe){oe!==ge&&(Ct&&o.lineWidth(oe),ge=oe)},setPolygonOffset:ke,setScissorTest:function(oe){oe?Xt(o.SCISSOR_TEST):ce(o.SCISSOR_TEST)},activeTexture:function(oe){oe===void 0&&(oe=o.TEXTURE0+Ze-1),ft!==oe&&(o.activeTexture(oe),ft=oe)},bindTexture:function(oe,Te,ct){ct===void 0&&(ct=ft===null?o.TEXTURE0+Ze-1:ft);let St=Mt[ct];St===void 0&&(St={type:void 0,texture:void 0},Mt[ct]=St),St.type===oe&&St.texture===Te||(ft!==ct&&(o.activeTexture(ct),ft=ct),o.bindTexture(oe,Te||gt[oe]),St.type=oe,St.texture=Te)},unbindTexture:function(){const oe=Mt[ft];oe!==void 0&&oe.type!==void 0&&(o.bindTexture(oe.type,null),oe.type=void 0,oe.texture=void 0)},compressedTexImage2D:function(){try{o.compressedTexImage2D.apply(o,arguments)}catch{}},compressedTexImage3D:function(){try{o.compressedTexImage3D.apply(o,arguments)}catch{}},texImage2D:function(){try{o.texImage2D.apply(o,arguments)}catch{}},texImage3D:function(){try{o.texImage3D.apply(o,arguments)}catch{}},updateUBOMapping:function(oe,Te){let ct=u.get(Te);ct===void 0&&(ct=new WeakMap,u.set(Te,ct));let St=ct.get(oe);St===void 0&&(St=o.getUniformBlockIndex(Te,oe.name),ct.set(oe,St))},uniformBlockBinding:function(oe,Te){const ct=u.get(Te).get(oe);h.get(Te)!==ct&&(o.uniformBlockBinding(Te,ct,oe.__bindingPointIndex),h.set(Te,ct))},texStorage2D:function(){try{o.texStorage2D.apply(o,arguments)}catch{}},texStorage3D:function(){try{o.texStorage3D.apply(o,arguments)}catch{}},texSubImage2D:function(){try{o.texSubImage2D.apply(o,arguments)}catch{}},texSubImage3D:function(){try{o.texSubImage3D.apply(o,arguments)}catch{}},compressedTexSubImage2D:function(){try{o.compressedTexSubImage2D.apply(o,arguments)}catch{}},compressedTexSubImage3D:function(){try{o.compressedTexSubImage3D.apply(o,arguments)}catch{}},scissor:function(oe){Ye.equals(oe)===!1&&(o.scissor(oe.x,oe.y,oe.z,oe.w),Ye.copy(oe))},viewport:function(oe){dt.equals(oe)===!1&&(o.viewport(oe.x,oe.y,oe.z,oe.w),dt.copy(oe))},reset:function(){o.disable(o.BLEND),o.disable(o.CULL_FACE),o.disable(o.DEPTH_TEST),o.disable(o.POLYGON_OFFSET_FILL),o.disable(o.SCISSOR_TEST),o.disable(o.STENCIL_TEST),o.disable(o.SAMPLE_ALPHA_TO_COVERAGE),o.blendEquation(o.FUNC_ADD),o.blendFunc(o.ONE,o.ZERO),o.blendFuncSeparate(o.ONE,o.ZERO,o.ONE,o.ZERO),o.colorMask(!0,!0,!0,!0),o.clearColor(0,0,0,0),o.depthMask(!0),o.depthFunc(o.LESS),o.clearDepth(1),o.stencilMask(4294967295),o.stencilFunc(o.ALWAYS,0,4294967295),o.stencilOp(o.KEEP,o.KEEP,o.KEEP),o.clearStencil(0),o.cullFace(o.BACK),o.frontFace(o.CCW),o.polygonOffset(0,0),o.activeTexture(o.TEXTURE0),o.bindFramebuffer(o.FRAMEBUFFER,null),A===!0&&(o.bindFramebuffer(o.DRAW_FRAMEBUFFER,null),o.bindFramebuffer(o.READ_FRAMEBUFFER,null)),o.useProgram(null),o.lineWidth(1),o.scissor(0,0,o.canvas.width,o.canvas.height),o.viewport(0,0,o.canvas.width,o.canvas.height),c={},ft=null,Mt={},C={},B=new WeakMap,p=[],w=null,k=!1,R=null,_=null,N=null,L=null,G=null,le=null,ne=null,Ae=!1,te=null,ye=null,ge=null,Me=null,pe=null,Ye.set(0,0,o.canvas.width,o.canvas.height),dt.set(0,0,o.canvas.width,o.canvas.height),n.reset(),r.reset(),g.reset()}}}function xS(o,e,t,A,n,r,g){const h=n.isWebGL2,u=(n.maxTextures,n.maxCubemapSize),c=n.maxTextureSize,C=n.maxSamples,B=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator<"u"&&/OculusBrowser/g.test(navigator.userAgent),w=new WeakMap;let k;const R=new WeakMap;let _=!1;try{_=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function N(ce,Ie){return _?new OffscreenCanvas(ce,Ie):wn("canvas")}function L(ce,Ie,Se,je){let _e=1;if((ce.width>je||ce.height>je)&&(_e=je/Math.max(ce.width,ce.height)),_e<1||Ie===!0){if(typeof HTMLImageElement<"u"&&ce instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&ce instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&ce instanceof ImageBitmap){const Et=Ie?Fr:Math.floor,ke=Et(_e*ce.width),oe=Et(_e*ce.height);k===void 0&&(k=N(ke,oe));const Te=Se?N(ke,oe):k;return Te.width=ke,Te.height=oe,Te.getContext("2d").drawImage(ce,0,0,ke,oe),ce.width,ce.height,Te}return"data"in ce&&(ce.width,ce.height),ce}return ce}function G(ce){return $n(ce.width)&&$n(ce.height)}function le(ce,Ie){return ce.generateMipmaps&&Ie&&ce.minFilter!==Be&&ce.minFilter!==Qe}function ne(ce){o.generateMipmap(ce)}function Ae(ce,Ie,Se,je,_e=!1){if(h===!1)return Ie;if(ce!==null&&o[ce]!==void 0)return o[ce];let Et=Ie;return Ie===o.RED&&(Se===o.FLOAT&&(Et=o.R32F),Se===o.HALF_FLOAT&&(Et=o.R16F),Se===o.UNSIGNED_BYTE&&(Et=o.R8)),Ie===o.RG&&(Se===o.FLOAT&&(Et=o.RG32F),Se===o.HALF_FLOAT&&(Et=o.RG16F),Se===o.UNSIGNED_BYTE&&(Et=o.RG8)),Ie===o.RGBA&&(Se===o.FLOAT&&(Et=o.RGBA32F),Se===o.HALF_FLOAT&&(Et=o.RGBA16F),Se===o.UNSIGNED_BYTE&&(Et=je===ie&&_e===!1?o.SRGB8_ALPHA8:o.RGBA8),Se===o.UNSIGNED_SHORT_4_4_4_4&&(Et=o.RGBA4),Se===o.UNSIGNED_SHORT_5_5_5_1&&(Et=o.RGB5_A1)),Et!==o.R16F&&Et!==o.R32F&&Et!==o.RG16F&&Et!==o.RG32F&&Et!==o.RGBA16F&&Et!==o.RGBA32F||e.get("EXT_color_buffer_float"),Et}function te(ce,Ie,Se){return le(ce,Se)===!0||ce.isFramebufferTexture&&ce.minFilter!==Be&&ce.minFilter!==Qe?Math.log2(Math.max(Ie.width,Ie.height))+1:ce.mipmaps!==void 0&&ce.mipmaps.length>0?ce.mipmaps.length:ce.isCompressedTexture&&Array.isArray(ce.image)?Ie.mipmaps.length:1}function ye(ce){return ce===Be||ce===qe||ce===me?o.NEAREST:o.LINEAR}function ge(ce){const Ie=ce.target;Ie.removeEventListener("dispose",ge),(function(Se){const je=A.get(Se);if(je.__webglInit===void 0)return;const _e=Se.source,Et=R.get(_e);if(Et){const ke=Et[je.__cacheKey];ke.usedTimes--,ke.usedTimes===0&&pe(Se),Object.keys(Et).length===0&&R.delete(_e)}A.remove(Se)})(Ie),Ie.isVideoTexture&&w.delete(Ie)}function Me(ce){const Ie=ce.target;Ie.removeEventListener("dispose",Me),(function(Se){const je=Se.texture,_e=A.get(Se),Et=A.get(je);if(Et.__webglTexture!==void 0&&(o.deleteTexture(Et.__webglTexture),g.memory.textures--),Se.depthTexture&&Se.depthTexture.dispose(),Se.isWebGLCubeRenderTarget)for(let ke=0;ke<6;ke++)o.deleteFramebuffer(_e.__webglFramebuffer[ke]),_e.__webglDepthbuffer&&o.deleteRenderbuffer(_e.__webglDepthbuffer[ke]);else{if(o.deleteFramebuffer(_e.__webglFramebuffer),_e.__webglDepthbuffer&&o.deleteRenderbuffer(_e.__webglDepthbuffer),_e.__webglMultisampledFramebuffer&&o.deleteFramebuffer(_e.__webglMultisampledFramebuffer),_e.__webglColorRenderbuffer)for(let ke=0;ke<_e.__webglColorRenderbuffer.length;ke++)_e.__webglColorRenderbuffer[ke]&&o.deleteRenderbuffer(_e.__webglColorRenderbuffer[ke]);_e.__webglDepthRenderbuffer&&o.deleteRenderbuffer(_e.__webglDepthRenderbuffer)}if(Se.isWebGLMultipleRenderTargets)for(let ke=0,oe=je.length;ke<oe;ke++){const Te=A.get(je[ke]);Te.__webglTexture&&(o.deleteTexture(Te.__webglTexture),g.memory.textures--),A.remove(je[ke])}A.remove(je),A.remove(Se)})(Ie)}function pe(ce){const Ie=A.get(ce);o.deleteTexture(Ie.__webglTexture);const Se=ce.source;delete R.get(Se)[Ie.__cacheKey],g.memory.textures--}let Ze=0;function Ct(ce,Ie){const Se=A.get(ce);if(ce.isVideoTexture&&(function(je){const _e=g.render.frame;w.get(je)!==_e&&(w.set(je,_e),je.update())})(ce),ce.isRenderTargetTexture===!1&&ce.version>0&&Se.__version!==ce.version){const je=ce.image;if(je!==null){if(je.complete!==!1)return void Rt(Se,ce,Ie)}}t.bindTexture(o.TEXTURE_2D,Se.__webglTexture,o.TEXTURE0+Ie)}const Qt={[Ce]:o.REPEAT,[ee]:o.CLAMP_TO_EDGE,[Fe]:o.MIRRORED_REPEAT},Wt={[Be]:o.NEAREST,[qe]:o.NEAREST_MIPMAP_NEAREST,[me]:o.NEAREST_MIPMAP_LINEAR,[Qe]:o.LINEAR,[tt]:o.LINEAR_MIPMAP_NEAREST,[se]:o.LINEAR_MIPMAP_LINEAR};function ft(ce,Ie,Se){if(Se?(o.texParameteri(ce,o.TEXTURE_WRAP_S,Qt[Ie.wrapS]),o.texParameteri(ce,o.TEXTURE_WRAP_T,Qt[Ie.wrapT]),ce!==o.TEXTURE_3D&&ce!==o.TEXTURE_2D_ARRAY||o.texParameteri(ce,o.TEXTURE_WRAP_R,Qt[Ie.wrapR]),o.texParameteri(ce,o.TEXTURE_MAG_FILTER,Wt[Ie.magFilter]),o.texParameteri(ce,o.TEXTURE_MIN_FILTER,Wt[Ie.minFilter])):(o.texParameteri(ce,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(ce,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),ce!==o.TEXTURE_3D&&ce!==o.TEXTURE_2D_ARRAY||o.texParameteri(ce,o.TEXTURE_WRAP_R,o.CLAMP_TO_EDGE),Ie.wrapS!==ee||Ie.wrapT,o.texParameteri(ce,o.TEXTURE_MAG_FILTER,ye(Ie.magFilter)),o.texParameteri(ce,o.TEXTURE_MIN_FILTER,ye(Ie.minFilter)),Ie.minFilter!==Be&&Ie.minFilter),e.has("EXT_texture_filter_anisotropic")===!0){const je=e.get("EXT_texture_filter_anisotropic");if(Ie.magFilter===Be||Ie.minFilter!==me&&Ie.minFilter!==se||Ie.type===De&&e.has("OES_texture_float_linear")===!1||h===!1&&Ie.type===mt&&e.has("OES_texture_half_float_linear")===!1)return;(Ie.anisotropy>1||A.get(Ie).__currentAnisotropy)&&(o.texParameterf(ce,je.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(Ie.anisotropy,n.getMaxAnisotropy())),A.get(Ie).__currentAnisotropy=Ie.anisotropy)}}function Mt(ce,Ie){let Se=!1;ce.__webglInit===void 0&&(ce.__webglInit=!0,Ie.addEventListener("dispose",ge));const je=Ie.source;let _e=R.get(je);_e===void 0&&(_e={},R.set(je,_e));const Et=(function(ke){const oe=[];return oe.push(ke.wrapS),oe.push(ke.wrapT),oe.push(ke.wrapR||0),oe.push(ke.magFilter),oe.push(ke.minFilter),oe.push(ke.anisotropy),oe.push(ke.internalFormat),oe.push(ke.format),oe.push(ke.type),oe.push(ke.generateMipmaps),oe.push(ke.premultiplyAlpha),oe.push(ke.flipY),oe.push(ke.unpackAlignment),oe.push(ke.colorSpace),oe.join()})(Ie);if(Et!==ce.__cacheKey){_e[Et]===void 0&&(_e[Et]={texture:o.createTexture(),usedTimes:0},g.memory.textures++,Se=!0),_e[Et].usedTimes++;const ke=_e[ce.__cacheKey];ke!==void 0&&(_e[ce.__cacheKey].usedTimes--,ke.usedTimes===0&&pe(Ie)),ce.__cacheKey=Et,ce.__webglTexture=_e[Et].texture}return Se}function Rt(ce,Ie,Se){let je=o.TEXTURE_2D;(Ie.isDataArrayTexture||Ie.isCompressedArrayTexture)&&(je=o.TEXTURE_2D_ARRAY),Ie.isData3DTexture&&(je=o.TEXTURE_3D);const _e=Mt(ce,Ie),Et=Ie.source;t.bindTexture(je,ce.__webglTexture,o.TEXTURE0+Se);const ke=A.get(Et);if(Et.version!==ke.__version||_e===!0){t.activeTexture(o.TEXTURE0+Se),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,Ie.flipY),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ie.premultiplyAlpha),o.pixelStorei(o.UNPACK_ALIGNMENT,Ie.unpackAlignment),o.pixelStorei(o.UNPACK_COLORSPACE_CONVERSION_WEBGL,o.NONE);const oe=(function($){return!h&&($.wrapS!==ee||$.wrapT!==ee||$.minFilter!==Be&&$.minFilter!==Qe)})(Ie)&&G(Ie.image)===!1;let Te=L(Ie.image,oe,!1,c);Te=Xt(Ie,Te);const ct=G(Te)||h,St=r.convert(Ie.format,Ie.colorSpace);let ht,Kt=r.convert(Ie.type),Ht=Ae(Ie.internalFormat,St,Kt,Ie.colorSpace);ft(je,Ie,ct);const _t=Ie.mipmaps,CA=h&&Ie.isVideoTexture!==!0,hA=ke.__version===void 0||_e===!0,J=te(Ie,Te,ct);if(Ie.isDepthTexture)Ht=o.DEPTH_COMPONENT,h?Ht=Ie.type===De?o.DEPTH_COMPONENT32F:Ie.type===U?o.DEPTH_COMPONENT24:Ie.type===He?o.DEPTH24_STENCIL8:o.DEPTH_COMPONENT16:Ie.type,Ie.format===st&&Ht===o.DEPTH_COMPONENT&&Ie.type!==1012&&Ie.type!==U&&(Ie.type=U,Kt=r.convert(Ie.type)),Ie.format===Tt&&Ht===o.DEPTH_COMPONENT&&(Ht=o.DEPTH_STENCIL,Ie.type!==He&&(Ie.type=He,Kt=r.convert(Ie.type))),hA&&(CA?t.texStorage2D(o.TEXTURE_2D,1,Ht,Te.width,Te.height):t.texImage2D(o.TEXTURE_2D,0,Ht,Te.width,Te.height,0,St,Kt,null));else if(Ie.isDataTexture)if(_t.length>0&&ct){CA&&hA&&t.texStorage2D(o.TEXTURE_2D,J,Ht,_t[0].width,_t[0].height);for(let $=0,xe=_t.length;$<xe;$++)ht=_t[$],CA?t.texSubImage2D(o.TEXTURE_2D,$,0,0,ht.width,ht.height,St,Kt,ht.data):t.texImage2D(o.TEXTURE_2D,$,Ht,ht.width,ht.height,0,St,Kt,ht.data);Ie.generateMipmaps=!1}else CA?(hA&&t.texStorage2D(o.TEXTURE_2D,J,Ht,Te.width,Te.height),t.texSubImage2D(o.TEXTURE_2D,0,0,0,Te.width,Te.height,St,Kt,Te.data)):t.texImage2D(o.TEXTURE_2D,0,Ht,Te.width,Te.height,0,St,Kt,Te.data);else if(Ie.isCompressedTexture)if(Ie.isCompressedArrayTexture){CA&&hA&&t.texStorage3D(o.TEXTURE_2D_ARRAY,J,Ht,_t[0].width,_t[0].height,Te.depth);for(let $=0,xe=_t.length;$<xe;$++)ht=_t[$],Ie.format!==kt?St!==null&&(CA?t.compressedTexSubImage3D(o.TEXTURE_2D_ARRAY,$,0,0,0,ht.width,ht.height,Te.depth,St,ht.data,0,0):t.compressedTexImage3D(o.TEXTURE_2D_ARRAY,$,Ht,ht.width,ht.height,Te.depth,0,ht.data,0,0)):CA?t.texSubImage3D(o.TEXTURE_2D_ARRAY,$,0,0,0,ht.width,ht.height,Te.depth,St,Kt,ht.data):t.texImage3D(o.TEXTURE_2D_ARRAY,$,Ht,ht.width,ht.height,Te.depth,0,St,Kt,ht.data)}else{CA&&hA&&t.texStorage2D(o.TEXTURE_2D,J,Ht,_t[0].width,_t[0].height);for(let $=0,xe=_t.length;$<xe;$++)ht=_t[$],Ie.format!==kt?St!==null&&(CA?t.compressedTexSubImage2D(o.TEXTURE_2D,$,0,0,ht.width,ht.height,St,ht.data):t.compressedTexImage2D(o.TEXTURE_2D,$,Ht,ht.width,ht.height,0,ht.data)):CA?t.texSubImage2D(o.TEXTURE_2D,$,0,0,ht.width,ht.height,St,Kt,ht.data):t.texImage2D(o.TEXTURE_2D,$,Ht,ht.width,ht.height,0,St,Kt,ht.data)}else if(Ie.isDataArrayTexture)CA?(hA&&t.texStorage3D(o.TEXTURE_2D_ARRAY,J,Ht,Te.width,Te.height,Te.depth),t.texSubImage3D(o.TEXTURE_2D_ARRAY,0,0,0,0,Te.width,Te.height,Te.depth,St,Kt,Te.data)):t.texImage3D(o.TEXTURE_2D_ARRAY,0,Ht,Te.width,Te.height,Te.depth,0,St,Kt,Te.data);else if(Ie.isData3DTexture)CA?(hA&&t.texStorage3D(o.TEXTURE_3D,J,Ht,Te.width,Te.height,Te.depth),t.texSubImage3D(o.TEXTURE_3D,0,0,0,0,Te.width,Te.height,Te.depth,St,Kt,Te.data)):t.texImage3D(o.TEXTURE_3D,0,Ht,Te.width,Te.height,Te.depth,0,St,Kt,Te.data);else if(Ie.isFramebufferTexture){if(hA)if(CA)t.texStorage2D(o.TEXTURE_2D,J,Ht,Te.width,Te.height);else{let $=Te.width,xe=Te.height;for(let rt=0;rt<J;rt++)t.texImage2D(o.TEXTURE_2D,rt,Ht,$,xe,0,St,Kt,null),$>>=1,xe>>=1}}else if(_t.length>0&&ct){CA&&hA&&t.texStorage2D(o.TEXTURE_2D,J,Ht,_t[0].width,_t[0].height);for(let $=0,xe=_t.length;$<xe;$++)ht=_t[$],CA?t.texSubImage2D(o.TEXTURE_2D,$,0,0,St,Kt,ht):t.texImage2D(o.TEXTURE_2D,$,Ht,St,Kt,ht);Ie.generateMipmaps=!1}else CA?(hA&&t.texStorage2D(o.TEXTURE_2D,J,Ht,Te.width,Te.height),t.texSubImage2D(o.TEXTURE_2D,0,0,0,St,Kt,Te)):t.texImage2D(o.TEXTURE_2D,0,Ht,St,Kt,Te);le(Ie,ct)&&ne(je),ke.__version=Et.version,Ie.onUpdate&&Ie.onUpdate(Ie)}ce.__version=Ie.version}function Ft(ce,Ie,Se,je,_e){const Et=r.convert(Se.format,Se.colorSpace),ke=r.convert(Se.type),oe=Ae(Se.internalFormat,Et,ke,Se.colorSpace);A.get(Ie).__hasExternalTextures||(_e===o.TEXTURE_3D||_e===o.TEXTURE_2D_ARRAY?t.texImage3D(_e,0,oe,Ie.width,Ie.height,Ie.depth,0,Et,ke,null):t.texImage2D(_e,0,oe,Ie.width,Ie.height,0,Et,ke,null)),t.bindFramebuffer(o.FRAMEBUFFER,ce),gt(Ie)?B.framebufferTexture2DMultisampleEXT(o.FRAMEBUFFER,je,_e,A.get(Se).__webglTexture,0,bt(Ie)):(_e===o.TEXTURE_2D||_e>=o.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=o.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&o.framebufferTexture2D(o.FRAMEBUFFER,je,_e,A.get(Se).__webglTexture,0),t.bindFramebuffer(o.FRAMEBUFFER,null)}function Ye(ce,Ie,Se){if(o.bindRenderbuffer(o.RENDERBUFFER,ce),Ie.depthBuffer&&!Ie.stencilBuffer){let je=o.DEPTH_COMPONENT16;if(Se||gt(Ie)){const _e=Ie.depthTexture;_e&&_e.isDepthTexture&&(_e.type===De?je=o.DEPTH_COMPONENT32F:_e.type===U&&(je=o.DEPTH_COMPONENT24));const Et=bt(Ie);gt(Ie)?B.renderbufferStorageMultisampleEXT(o.RENDERBUFFER,Et,je,Ie.width,Ie.height):o.renderbufferStorageMultisample(o.RENDERBUFFER,Et,je,Ie.width,Ie.height)}else o.renderbufferStorage(o.RENDERBUFFER,je,Ie.width,Ie.height);o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,ce)}else if(Ie.depthBuffer&&Ie.stencilBuffer){const je=bt(Ie);Se&>(Ie)===!1?o.renderbufferStorageMultisample(o.RENDERBUFFER,je,o.DEPTH24_STENCIL8,Ie.width,Ie.height):gt(Ie)?B.renderbufferStorageMultisampleEXT(o.RENDERBUFFER,je,o.DEPTH24_STENCIL8,Ie.width,Ie.height):o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,Ie.width,Ie.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,ce)}else{const je=Ie.isWebGLMultipleRenderTargets===!0?Ie.texture:[Ie.texture];for(let _e=0;_e<je.length;_e++){const Et=je[_e],ke=r.convert(Et.format,Et.colorSpace),oe=r.convert(Et.type),Te=Ae(Et.internalFormat,ke,oe,Et.colorSpace),ct=bt(Ie);Se&>(Ie)===!1?o.renderbufferStorageMultisample(o.RENDERBUFFER,ct,Te,Ie.width,Ie.height):gt(Ie)?B.renderbufferStorageMultisampleEXT(o.RENDERBUFFER,ct,Te,Ie.width,Ie.height):o.renderbufferStorage(o.RENDERBUFFER,Te,Ie.width,Ie.height)}}o.bindRenderbuffer(o.RENDERBUFFER,null)}function dt(ce){const Ie=A.get(ce),Se=ce.isWebGLCubeRenderTarget===!0;if(ce.depthTexture&&!Ie.__autoAllocateDepthBuffer){if(Se)throw new Error("target.depthTexture not supported in Cube render targets");(function(je,_e){if(_e&&_e.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(o.FRAMEBUFFER,je),!_e.depthTexture||!_e.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");A.get(_e.depthTexture).__webglTexture&&_e.depthTexture.image.width===_e.width&&_e.depthTexture.image.height===_e.height||(_e.depthTexture.image.width=_e.width,_e.depthTexture.image.height=_e.height,_e.depthTexture.needsUpdate=!0),Ct(_e.depthTexture,0);const Et=A.get(_e.depthTexture).__webglTexture,ke=bt(_e);if(_e.depthTexture.format===st)gt(_e)?B.framebufferTexture2DMultisampleEXT(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.TEXTURE_2D,Et,0,ke):o.framebufferTexture2D(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.TEXTURE_2D,Et,0);else{if(_e.depthTexture.format!==Tt)throw new Error("Unknown depthTexture format");gt(_e)?B.framebufferTexture2DMultisampleEXT(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.TEXTURE_2D,Et,0,ke):o.framebufferTexture2D(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.TEXTURE_2D,Et,0)}})(Ie.__webglFramebuffer,ce)}else if(Se){Ie.__webglDepthbuffer=[];for(let je=0;je<6;je++)t.bindFramebuffer(o.FRAMEBUFFER,Ie.__webglFramebuffer[je]),Ie.__webglDepthbuffer[je]=o.createRenderbuffer(),Ye(Ie.__webglDepthbuffer[je],ce,!1)}else t.bindFramebuffer(o.FRAMEBUFFER,Ie.__webglFramebuffer),Ie.__webglDepthbuffer=o.createRenderbuffer(),Ye(Ie.__webglDepthbuffer,ce,!1);t.bindFramebuffer(o.FRAMEBUFFER,null)}function bt(ce){return Math.min(C,ce.samples)}function gt(ce){const Ie=A.get(ce);return h&&ce.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&Ie.__useRenderToTexture!==!1}function Xt(ce,Ie){const Se=ce.colorSpace,je=ce.format;return ce.type,ce.isCompressedTexture===!0||ce.format===Ne||Se!==W&&Se!==Ee&&Se===ie&&h===!1&&(e.has("EXT_sRGB")===!0&&je===kt?(ce.format=Ne,ce.minFilter=Qe,ce.generateMipmaps=!1):Ie=ul.sRGBToLinear(Ie)),Ie}this.allocateTextureUnit=function(){const ce=Ze;return Ze+=1,ce},this.resetTextureUnits=function(){Ze=0},this.setTexture2D=Ct,this.setTexture2DArray=function(ce,Ie){const Se=A.get(ce);ce.version>0&&Se.__version!==ce.version?Rt(Se,ce,Ie):t.bindTexture(o.TEXTURE_2D_ARRAY,Se.__webglTexture,o.TEXTURE0+Ie)},this.setTexture3D=function(ce,Ie){const Se=A.get(ce);ce.version>0&&Se.__version!==ce.version?Rt(Se,ce,Ie):t.bindTexture(o.TEXTURE_3D,Se.__webglTexture,o.TEXTURE0+Ie)},this.setTextureCube=function(ce,Ie){const Se=A.get(ce);ce.version>0&&Se.__version!==ce.version?(function(je,_e,Et){if(_e.image.length!==6)return;const ke=Mt(je,_e),oe=_e.source;t.bindTexture(o.TEXTURE_CUBE_MAP,je.__webglTexture,o.TEXTURE0+Et);const Te=A.get(oe);if(oe.version!==Te.__version||ke===!0){t.activeTexture(o.TEXTURE0+Et),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,_e.flipY),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_e.premultiplyAlpha),o.pixelStorei(o.UNPACK_ALIGNMENT,_e.unpackAlignment),o.pixelStorei(o.UNPACK_COLORSPACE_CONVERSION_WEBGL,o.NONE);const ct=_e.isCompressedTexture||_e.image[0].isCompressedTexture,St=_e.image[0]&&_e.image[0].isDataTexture,ht=[];for(let $e=0;$e<6;$e++)ht[$e]=ct||St?St?_e.image[$e].image:_e.image[$e]:L(_e.image[$e],!1,!0,u),ht[$e]=Xt(_e,ht[$e]);const Kt=ht[0],Ht=G(Kt)||h,_t=r.convert(_e.format,_e.colorSpace),CA=r.convert(_e.type),hA=Ae(_e.internalFormat,_t,CA,_e.colorSpace),J=h&&_e.isVideoTexture!==!0,$=Te.__version===void 0||ke===!0;let xe,rt=te(_e,Kt,Ht);if(ft(o.TEXTURE_CUBE_MAP,_e,Ht),ct){J&&$&&t.texStorage2D(o.TEXTURE_CUBE_MAP,rt,hA,Kt.width,Kt.height);for(let $e=0;$e<6;$e++){xe=ht[$e].mipmaps;for(let Re=0;Re<xe.length;Re++){const Pe=xe[Re];_e.format!==kt?_t!==null&&(J?t.compressedTexSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,0,0,Pe.width,Pe.height,_t,Pe.data):t.compressedTexImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,hA,Pe.width,Pe.height,0,Pe.data)):J?t.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,0,0,Pe.width,Pe.height,_t,CA,Pe.data):t.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,hA,Pe.width,Pe.height,0,_t,CA,Pe.data)}}}else{xe=_e.mipmaps,J&&$&&(xe.length>0&&rt++,t.texStorage2D(o.TEXTURE_CUBE_MAP,rt,hA,ht[0].width,ht[0].height));for(let $e=0;$e<6;$e++)if(St){J?t.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,0,0,ht[$e].width,ht[$e].height,_t,CA,ht[$e].data):t.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,hA,ht[$e].width,ht[$e].height,0,_t,CA,ht[$e].data);for(let Re=0;Re<xe.length;Re++){const Pe=xe[Re].image[$e].image;J?t.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,0,0,Pe.width,Pe.height,_t,CA,Pe.data):t.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,hA,Pe.width,Pe.height,0,_t,CA,Pe.data)}}else{J?t.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,0,0,_t,CA,ht[$e]):t.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,hA,_t,CA,ht[$e]);for(let Re=0;Re<xe.length;Re++){const Pe=xe[Re];J?t.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,0,0,_t,CA,Pe.image[$e]):t.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,hA,_t,CA,Pe.image[$e])}}}le(_e,Ht)&&ne(o.TEXTURE_CUBE_MAP),Te.__version=oe.version,_e.onUpdate&&_e.onUpdate(_e)}je.__version=_e.version})(Se,ce,Ie):t.bindTexture(o.TEXTURE_CUBE_MAP,Se.__webglTexture,o.TEXTURE0+Ie)},this.rebindTextures=function(ce,Ie,Se){const je=A.get(ce);Ie!==void 0&&Ft(je.__webglFramebuffer,ce,ce.texture,o.COLOR_ATTACHMENT0,o.TEXTURE_2D),Se!==void 0&&dt(ce)},this.setupRenderTarget=function(ce){const Ie=ce.texture,Se=A.get(ce),je=A.get(Ie);ce.addEventListener("dispose",Me),ce.isWebGLMultipleRenderTargets!==!0&&(je.__webglTexture===void 0&&(je.__webglTexture=o.createTexture()),je.__version=Ie.version,g.memory.textures++);const _e=ce.isWebGLCubeRenderTarget===!0,Et=ce.isWebGLMultipleRenderTargets===!0,ke=G(ce)||h;if(_e){Se.__webglFramebuffer=[];for(let oe=0;oe<6;oe++)Se.__webglFramebuffer[oe]=o.createFramebuffer()}else{if(Se.__webglFramebuffer=o.createFramebuffer(),Et&&n.drawBuffers){const oe=ce.texture;for(let Te=0,ct=oe.length;Te<ct;Te++){const St=A.get(oe[Te]);St.__webglTexture===void 0&&(St.__webglTexture=o.createTexture(),g.memory.textures++)}}if(h&&ce.samples>0&>(ce)===!1){const oe=Et?Ie:[Ie];Se.__webglMultisampledFramebuffer=o.createFramebuffer(),Se.__webglColorRenderbuffer=[],t.bindFramebuffer(o.FRAMEBUFFER,Se.__webglMultisampledFramebuffer);for(let Te=0;Te<oe.length;Te++){const ct=oe[Te];Se.__webglColorRenderbuffer[Te]=o.createRenderbuffer(),o.bindRenderbuffer(o.RENDERBUFFER,Se.__webglColorRenderbuffer[Te]);const St=r.convert(ct.format,ct.colorSpace),ht=r.convert(ct.type),Kt=Ae(ct.internalFormat,St,ht,ct.colorSpace,ce.isXRRenderTarget===!0),Ht=bt(ce);o.renderbufferStorageMultisample(o.RENDERBUFFER,Ht,Kt,ce.width,ce.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0+Te,o.RENDERBUFFER,Se.__webglColorRenderbuffer[Te])}o.bindRenderbuffer(o.RENDERBUFFER,null),ce.depthBuffer&&(Se.__webglDepthRenderbuffer=o.createRenderbuffer(),Ye(Se.__webglDepthRenderbuffer,ce,!0)),t.bindFramebuffer(o.FRAMEBUFFER,null)}}if(_e){t.bindTexture(o.TEXTURE_CUBE_MAP,je.__webglTexture),ft(o.TEXTURE_CUBE_MAP,Ie,ke);for(let oe=0;oe<6;oe++)Ft(Se.__webglFramebuffer[oe],ce,Ie,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+oe);le(Ie,ke)&&ne(o.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Et){const oe=ce.texture;for(let Te=0,ct=oe.length;Te<ct;Te++){const St=oe[Te],ht=A.get(St);t.bindTexture(o.TEXTURE_2D,ht.__webglTexture),ft(o.TEXTURE_2D,St,ke),Ft(Se.__webglFramebuffer,ce,St,o.COLOR_ATTACHMENT0+Te,o.TEXTURE_2D),le(St,ke)&&ne(o.TEXTURE_2D)}t.unbindTexture()}else{let oe=o.TEXTURE_2D;(ce.isWebGL3DRenderTarget||ce.isWebGLArrayRenderTarget)&&h&&(oe=ce.isWebGL3DRenderTarget?o.TEXTURE_3D:o.TEXTURE_2D_ARRAY),t.bindTexture(oe,je.__webglTexture),ft(oe,Ie,ke),Ft(Se.__webglFramebuffer,ce,Ie,o.COLOR_ATTACHMENT0,oe),le(Ie,ke)&&ne(oe),t.unbindTexture()}ce.depthBuffer&&dt(ce)},this.updateRenderTargetMipmap=function(ce){const Ie=G(ce)||h,Se=ce.isWebGLMultipleRenderTargets===!0?ce.texture:[ce.texture];for(let je=0,_e=Se.length;je<_e;je++){const Et=Se[je];if(le(Et,Ie)){const ke=ce.isWebGLCubeRenderTarget?o.TEXTURE_CUBE_MAP:o.TEXTURE_2D,oe=A.get(Et).__webglTexture;t.bindTexture(ke,oe),ne(ke),t.unbindTexture()}}},this.updateMultisampleRenderTarget=function(ce){if(h&&ce.samples>0&>(ce)===!1){const Ie=ce.isWebGLMultipleRenderTargets?ce.texture:[ce.texture],Se=ce.width,je=ce.height;let _e=o.COLOR_BUFFER_BIT;const Et=[],ke=ce.stencilBuffer?o.DEPTH_STENCIL_ATTACHMENT:o.DEPTH_ATTACHMENT,oe=A.get(ce),Te=ce.isWebGLMultipleRenderTargets===!0;if(Te)for(let ct=0;ct<Ie.length;ct++)t.bindFramebuffer(o.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0+ct,o.RENDERBUFFER,null),t.bindFramebuffer(o.FRAMEBUFFER,oe.__webglFramebuffer),o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0+ct,o.TEXTURE_2D,null,0);t.bindFramebuffer(o.READ_FRAMEBUFFER,oe.__webglMultisampledFramebuffer),t.bindFramebuffer(o.DRAW_FRAMEBUFFER,oe.__webglFramebuffer);for(let ct=0;ct<Ie.length;ct++){Et.push(o.COLOR_ATTACHMENT0+ct),ce.depthBuffer&&Et.push(ke);const St=oe.__ignoreDepthValues!==void 0&&oe.__ignoreDepthValues;if(St===!1&&(ce.depthBuffer&&(_e|=o.DEPTH_BUFFER_BIT),ce.stencilBuffer&&(_e|=o.STENCIL_BUFFER_BIT)),Te&&o.framebufferRenderbuffer(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.RENDERBUFFER,oe.__webglColorRenderbuffer[ct]),St===!0&&(o.invalidateFramebuffer(o.READ_FRAMEBUFFER,[ke]),o.invalidateFramebuffer(o.DRAW_FRAMEBUFFER,[ke])),Te){const ht=A.get(Ie[ct]).__webglTexture;o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,ht,0)}o.blitFramebuffer(0,0,Se,je,0,0,Se,je,_e,o.NEAREST),p&&o.invalidateFramebuffer(o.READ_FRAMEBUFFER,Et)}if(t.bindFramebuffer(o.READ_FRAMEBUFFER,null),t.bindFramebuffer(o.DRAW_FRAMEBUFFER,null),Te)for(let ct=0;ct<Ie.length;ct++){t.bindFramebuffer(o.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0+ct,o.RENDERBUFFER,oe.__webglColorRenderbuffer[ct]);const St=A.get(Ie[ct]).__webglTexture;t.bindFramebuffer(o.FRAMEBUFFER,oe.__webglFramebuffer),o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0+ct,o.TEXTURE_2D,St,0)}t.bindFramebuffer(o.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=dt,this.setupFrameBufferTexture=Ft,this.useMultisampledRTT=gt}function bS(o,e,t){const A=t.isWebGL2;return{convert:function(n,r=""){let g;if(n===be)return o.UNSIGNED_BYTE;if(n===1017)return o.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return o.UNSIGNED_SHORT_5_5_5_1;if(n===1010)return o.BYTE;if(n===1011)return o.SHORT;if(n===1012)return o.UNSIGNED_SHORT;if(n===1013)return o.INT;if(n===U)return o.UNSIGNED_INT;if(n===De)return o.FLOAT;if(n===mt)return A?o.HALF_FLOAT:(g=e.get("OES_texture_half_float"),g!==null?g.HALF_FLOAT_OES:null);if(n===1021)return o.ALPHA;if(n===kt)return o.RGBA;if(n===1024)return o.LUMINANCE;if(n===1025)return o.LUMINANCE_ALPHA;if(n===st)return o.DEPTH_COMPONENT;if(n===Tt)return o.DEPTH_STENCIL;if(n===Ne)return g=e.get("EXT_sRGB"),g!==null?g.SRGB_ALPHA_EXT:null;if(n===Ge)return o.RED;if(n===1029)return o.RED_INTEGER;if(n===1030)return o.RG;if(n===1031)return o.RG_INTEGER;if(n===1033)return o.RGBA_INTEGER;if(n===Le||n===jt||n===Nt||n===V)if(r===ie){if(g=e.get("WEBGL_compressed_texture_s3tc_srgb"),g===null)return null;if(n===Le)return g.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===jt)return g.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Nt)return g.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===V)return g.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(g=e.get("WEBGL_compressed_texture_s3tc"),g===null)return null;if(n===Le)return g.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===jt)return g.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Nt)return g.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===V)return g.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===35840||n===35841||n===35842||n===35843){if(g=e.get("WEBGL_compressed_texture_pvrtc"),g===null)return null;if(n===35840)return g.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return g.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return g.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return g.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===36196)return g=e.get("WEBGL_compressed_texture_etc1"),g!==null?g.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===37492||n===37496){if(g=e.get("WEBGL_compressed_texture_etc"),g===null)return null;if(n===37492)return r===ie?g.COMPRESSED_SRGB8_ETC2:g.COMPRESSED_RGB8_ETC2;if(n===37496)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:g.COMPRESSED_RGBA8_ETC2_EAC}if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821){if(g=e.get("WEBGL_compressed_texture_astc"),g===null)return null;if(n===37808)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:g.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:g.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:g.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:g.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:g.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:g.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:g.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:g.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:g.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:g.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:g.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:g.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:g.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:g.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===fe){if(g=e.get("EXT_texture_compression_bptc"),g===null)return null;if(n===fe)return r===ie?g.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:g.COMPRESSED_RGBA_BPTC_UNORM_EXT}if(n===36283||n===36284||n===36285||n===36286){if(g=e.get("EXT_texture_compression_rgtc"),g===null)return null;if(n===fe)return g.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return g.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return g.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return g.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===He?A?o.UNSIGNED_INT_24_8:(g=e.get("WEBGL_depth_texture"),g!==null?g.UNSIGNED_INT_24_8_WEBGL:null):o[n]!==void 0?o[n]:null}}}class _S extends Zi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Js extends gi{constructor(){super(),this.isGroup=!0,this.type="Group"}}const RS={type:"move"};class Kh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Js,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Js,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new re,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new re),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Js,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new re,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new re),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const A of e.hand.values())this._getHandJoint(t,A)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,A){let n=null,r=null,g=null;const h=this._targetRay,u=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){g=!0;for(const R of e.hand.values()){const _=t.getJointPose(R,A),N=this._getHandJoint(c,R);_!==null&&(N.matrix.fromArray(_.transform.matrix),N.matrix.decompose(N.position,N.rotation,N.scale),N.matrixWorldNeedsUpdate=!0,N.jointRadius=_.radius),N.visible=_!==null}const C=c.joints["index-finger-tip"],B=c.joints["thumb-tip"],p=C.position.distanceTo(B.position),w=.02,k=.005;c.inputState.pinching&&p>w+k?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=w-k&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,A),r!==null&&(u.matrix.fromArray(r.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,r.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(r.linearVelocity)):u.hasLinearVelocity=!1,r.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(r.angularVelocity)):u.hasAngularVelocity=!1));h!==null&&(n=t.getPose(e.targetRaySpace,A),n===null&&r!==null&&(n=r),n!==null&&(h.matrix.fromArray(n.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,n.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(n.linearVelocity)):h.hasLinearVelocity=!1,n.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(n.angularVelocity)):h.hasAngularVelocity=!1,this.dispatchEvent(RS)))}return h!==null&&(h.visible=n!==null),u!==null&&(u.visible=r!==null),c!==null&&(c.visible=g!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const A=new Js;A.matrixAutoUpdate=!1,A.visible=!1,e.joints[t.jointName]=A,e.add(A)}return e.joints[t.jointName]}}class NS extends Di{constructor(e,t,A,n,r,g,h,u,c,C){if((C=C!==void 0?C:st)!==st&&C!==Tt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");A===void 0&&C===st&&(A=U),A===void 0&&C===Tt&&(A=He),super(null,n,r,g,h,u,C,A,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=h!==void 0?h:Be,this.minFilter=u!==void 0?u:Be,this.flipY=!1,this.generateMipmaps=!1}}class kS extends ut{constructor(e,t){super();const A=this;let n=null,r=1,g=null,h="local-floor",u=1,c=null,C=null,B=null,p=null,w=null,k=null;const R=t.getContextAttributes();let _=null,N=null;const L=[],G=[],le=new Set,ne=new Map,Ae=new Zi;Ae.layers.enable(1),Ae.viewport=new zA;const te=new Zi;te.layers.enable(2),te.viewport=new zA;const ye=[Ae,te],ge=new _S;ge.layers.enable(1),ge.layers.enable(2);let Me=null,pe=null;function Ze(Ye){const dt=G.indexOf(Ye.inputSource);if(dt===-1)return;const bt=L[dt];bt!==void 0&&(bt.update(Ye.inputSource,Ye.frame,c||g),bt.dispatchEvent({type:Ye.type,data:Ye.inputSource}))}function Ct(){n.removeEventListener("select",Ze),n.removeEventListener("selectstart",Ze),n.removeEventListener("selectend",Ze),n.removeEventListener("squeeze",Ze),n.removeEventListener("squeezestart",Ze),n.removeEventListener("squeezeend",Ze),n.removeEventListener("end",Ct),n.removeEventListener("inputsourceschange",Qt);for(let Ye=0;Ye<L.length;Ye++){const dt=G[Ye];dt!==null&&(G[Ye]=null,L[Ye].disconnect(dt))}Me=null,pe=null,e.setRenderTarget(_),w=null,p=null,B=null,n=null,N=null,Ft.stop(),A.isPresenting=!1,A.dispatchEvent({type:"sessionend"})}function Qt(Ye){for(let dt=0;dt<Ye.removed.length;dt++){const bt=Ye.removed[dt],gt=G.indexOf(bt);gt>=0&&(G[gt]=null,L[gt].disconnect(bt))}for(let dt=0;dt<Ye.added.length;dt++){const bt=Ye.added[dt];let gt=G.indexOf(bt);if(gt===-1){for(let ce=0;ce<L.length;ce++){if(ce>=G.length){G.push(bt),gt=ce;break}if(G[ce]===null){G[ce]=bt,gt=ce;break}}if(gt===-1)break}const Xt=L[gt];Xt&&Xt.connect(bt)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Ye){let dt=L[Ye];return dt===void 0&&(dt=new Kh,L[Ye]=dt),dt.getTargetRaySpace()},this.getControllerGrip=function(Ye){let dt=L[Ye];return dt===void 0&&(dt=new Kh,L[Ye]=dt),dt.getGripSpace()},this.getHand=function(Ye){let dt=L[Ye];return dt===void 0&&(dt=new Kh,L[Ye]=dt),dt.getHandSpace()},this.setFramebufferScaleFactor=function(Ye){r=Ye,A.isPresenting},this.setReferenceSpaceType=function(Ye){h=Ye,A.isPresenting},this.getReferenceSpace=function(){return c||g},this.setReferenceSpace=function(Ye){c=Ye},this.getBaseLayer=function(){return p!==null?p:w},this.getBinding=function(){return B},this.getFrame=function(){return k},this.getSession=function(){return n},this.setSession=async function(Ye){if(n=Ye,n!==null){if(_=e.getRenderTarget(),n.addEventListener("select",Ze),n.addEventListener("selectstart",Ze),n.addEventListener("selectend",Ze),n.addEventListener("squeeze",Ze),n.addEventListener("squeezestart",Ze),n.addEventListener("squeezeend",Ze),n.addEventListener("end",Ct),n.addEventListener("inputsourceschange",Qt),R.xrCompatible!==!0&&await t.makeXRCompatible(),n.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const dt={antialias:n.renderState.layers!==void 0||R.antialias,alpha:!0,depth:R.depth,stencil:R.stencil,framebufferScaleFactor:r};w=new XRWebGLLayer(n,t,dt),n.updateRenderState({baseLayer:w}),N=new ei(w.framebufferWidth,w.framebufferHeight,{format:kt,type:be,colorSpace:e.outputColorSpace,stencilBuffer:R.stencil})}else{let dt=null,bt=null,gt=null;R.depth&&(gt=R.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,dt=R.stencil?Tt:st,bt=R.stencil?He:U);const Xt={colorFormat:t.RGBA8,depthFormat:gt,scaleFactor:r};B=new XRWebGLBinding(n,t),p=B.createProjectionLayer(Xt),n.updateRenderState({layers:[p]}),N=new ei(p.textureWidth,p.textureHeight,{format:kt,type:be,depthTexture:new NS(p.textureWidth,p.textureHeight,bt,void 0,void 0,void 0,void 0,void 0,void 0,dt),stencilBuffer:R.stencil,colorSpace:e.outputColorSpace,samples:R.antialias?4:0}),e.properties.get(N).__ignoreDepthValues=p.ignoreDepthValues}N.isXRRenderTarget=!0,this.setFoveation(u),c=null,g=await n.requestReferenceSpace(h),Ft.setContext(n),Ft.start(),A.isPresenting=!0,A.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode};const Wt=new re,ft=new re;function Mt(Ye,dt){dt===null?Ye.matrixWorld.copy(Ye.matrix):Ye.matrixWorld.multiplyMatrices(dt.matrixWorld,Ye.matrix),Ye.matrixWorldInverse.copy(Ye.matrixWorld).invert()}this.updateCamera=function(Ye){if(n===null)return;ge.near=te.near=Ae.near=Ye.near,ge.far=te.far=Ae.far=Ye.far,Me===ge.near&&pe===ge.far||(n.updateRenderState({depthNear:ge.near,depthFar:ge.far}),Me=ge.near,pe=ge.far);const dt=Ye.parent,bt=ge.cameras;Mt(ge,dt);for(let gt=0;gt<bt.length;gt++)Mt(bt[gt],dt);bt.length===2?(function(gt,Xt,ce){Wt.setFromMatrixPosition(Xt.matrixWorld),ft.setFromMatrixPosition(ce.matrixWorld);const Ie=Wt.distanceTo(ft),Se=Xt.projectionMatrix.elements,je=ce.projectionMatrix.elements,_e=Se[14]/(Se[10]-1),Et=Se[14]/(Se[10]+1),ke=(Se[9]+1)/Se[5],oe=(Se[9]-1)/Se[5],Te=(Se[8]-1)/Se[0],ct=(je[8]+1)/je[0],St=_e*Te,ht=_e*ct,Kt=Ie/(-Te+ct),Ht=Kt*-Te;Xt.matrixWorld.decompose(gt.position,gt.quaternion,gt.scale),gt.translateX(Ht),gt.translateZ(Kt),gt.matrixWorld.compose(gt.position,gt.quaternion,gt.scale),gt.matrixWorldInverse.copy(gt.matrixWorld).invert();const _t=_e+Kt,CA=Et+Kt,hA=St-Ht,J=ht+(Ie-Ht),$=ke*Et/CA*_t,xe=oe*Et/CA*_t;gt.projectionMatrix.makePerspective(hA,J,$,xe,_t,CA),gt.projectionMatrixInverse.copy(gt.projectionMatrix).invert()})(ge,Ae,te):ge.projectionMatrix.copy(Ae.projectionMatrix),(function(gt,Xt,ce){ce===null?gt.matrix.copy(Xt.matrixWorld):(gt.matrix.copy(ce.matrixWorld),gt.matrix.invert(),gt.matrix.multiply(Xt.matrixWorld)),gt.matrix.decompose(gt.position,gt.quaternion,gt.scale),gt.updateMatrixWorld(!0);const Ie=gt.children;for(let Se=0,je=Ie.length;Se<je;Se++)Ie[Se].updateMatrixWorld(!0);gt.projectionMatrix.copy(Xt.projectionMatrix),gt.projectionMatrixInverse.copy(Xt.projectionMatrixInverse),gt.isPerspectiveCamera&&(gt.fov=2*RA*Math.atan(1/gt.projectionMatrix.elements[5]),gt.zoom=1)})(Ye,ge,dt)},this.getCamera=function(){return ge},this.getFoveation=function(){if(p!==null||w!==null)return u},this.setFoveation=function(Ye){u=Ye,p!==null&&(p.fixedFoveation=Ye),w!==null&&w.fixedFoveation!==void 0&&(w.fixedFoveation=Ye)},this.getPlanes=function(){return le};let Rt=null;const Ft=new DE;Ft.setAnimationLoop((function(Ye,dt){if(C=dt.getViewerPose(c||g),k=dt,C!==null){const bt=C.views;w!==null&&(e.setRenderTargetFramebuffer(N,w.framebuffer),e.setRenderTarget(N));let gt=!1;bt.length!==ge.cameras.length&&(ge.cameras.length=0,gt=!0);for(let Xt=0;Xt<bt.length;Xt++){const ce=bt[Xt];let Ie=null;if(w!==null)Ie=w.getViewport(ce);else{const je=B.getViewSubImage(p,ce);Ie=je.viewport,Xt===0&&(e.setRenderTargetTextures(N,je.colorTexture,p.ignoreDepthValues?void 0:je.depthStencilTexture),e.setRenderTarget(N))}let Se=ye[Xt];Se===void 0&&(Se=new Zi,Se.layers.enable(Xt),Se.viewport=new zA,ye[Xt]=Se),Se.matrix.fromArray(ce.transform.matrix),Se.matrix.decompose(Se.position,Se.quaternion,Se.scale),Se.projectionMatrix.fromArray(ce.projectionMatrix),Se.projectionMatrixInverse.copy(Se.projectionMatrix).invert(),Se.viewport.set(Ie.x,Ie.y,Ie.width,Ie.height),Xt===0&&(ge.matrix.copy(Se.matrix),ge.matrix.decompose(ge.position,ge.quaternion,ge.scale)),gt===!0&&ge.cameras.push(Se)}}for(let bt=0;bt<L.length;bt++){const gt=G[bt],Xt=L[bt];gt!==null&&Xt!==void 0&&Xt.update(gt,dt,c||g)}if(Rt&&Rt(Ye,dt),dt.detectedPlanes){A.dispatchEvent({type:"planesdetected",data:dt.detectedPlanes});let bt=null;for(const gt of le)dt.detectedPlanes.has(gt)||(bt===null&&(bt=[]),bt.push(gt));if(bt!==null)for(const gt of bt)le.delete(gt),ne.delete(gt),A.dispatchEvent({type:"planeremoved",data:gt});for(const gt of dt.detectedPlanes)if(le.has(gt)){const Xt=ne.get(gt);gt.lastChangedTime>Xt&&(ne.set(gt,gt.lastChangedTime),A.dispatchEvent({type:"planechanged",data:gt}))}else le.add(gt),ne.set(gt,dt.lastChangedTime),A.dispatchEvent({type:"planeadded",data:gt})}k=null})),this.setAnimationLoop=function(Ye){Rt=Ye},this.dispose=function(){}}}function FS(o,e){function t(n,r){n.matrixAutoUpdate===!0&&n.updateMatrix(),r.value.copy(n.matrix)}function A(n,r){n.opacity.value=r.opacity,r.color&&n.diffuse.value.copy(r.color),r.emissive&&n.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(n.map.value=r.map,t(r.map,n.mapTransform)),r.alphaMap&&(n.alphaMap.value=r.alphaMap,t(r.alphaMap,n.alphaMapTransform)),r.bumpMap&&(n.bumpMap.value=r.bumpMap,t(r.bumpMap,n.bumpMapTransform),n.bumpScale.value=r.bumpScale,r.side===v&&(n.bumpScale.value*=-1)),r.normalMap&&(n.normalMap.value=r.normalMap,t(r.normalMap,n.normalMapTransform),n.normalScale.value.copy(r.normalScale),r.side===v&&n.normalScale.value.negate()),r.displacementMap&&(n.displacementMap.value=r.displacementMap,t(r.displacementMap,n.displacementMapTransform),n.displacementScale.value=r.displacementScale,n.displacementBias.value=r.displacementBias),r.emissiveMap&&(n.emissiveMap.value=r.emissiveMap,t(r.emissiveMap,n.emissiveMapTransform)),r.specularMap&&(n.specularMap.value=r.specularMap,t(r.specularMap,n.specularMapTransform)),r.alphaTest>0&&(n.alphaTest.value=r.alphaTest);const g=e.get(r).envMap;if(g&&(n.envMap.value=g,n.flipEnvMap.value=g.isCubeTexture&&g.isRenderTargetTexture===!1?-1:1,n.reflectivity.value=r.reflectivity,n.ior.value=r.ior,n.refractionRatio.value=r.refractionRatio),r.lightMap){n.lightMap.value=r.lightMap;const h=o.useLegacyLights===!0?Math.PI:1;n.lightMapIntensity.value=r.lightMapIntensity*h,t(r.lightMap,n.lightMapTransform)}r.aoMap&&(n.aoMap.value=r.aoMap,n.aoMapIntensity.value=r.aoMapIntensity,t(r.aoMap,n.aoMapTransform))}return{refreshFogUniforms:function(n,r){r.color.getRGB(n.fogColor.value,wE(o)),r.isFog?(n.fogNear.value=r.near,n.fogFar.value=r.far):r.isFogExp2&&(n.fogDensity.value=r.density)},refreshMaterialUniforms:function(n,r,g,h,u){r.isMeshBasicMaterial||r.isMeshLambertMaterial?A(n,r):r.isMeshToonMaterial?(A(n,r),(function(c,C){C.gradientMap&&(c.gradientMap.value=C.gradientMap)})(n,r)):r.isMeshPhongMaterial?(A(n,r),(function(c,C){c.specular.value.copy(C.specular),c.shininess.value=Math.max(C.shininess,1e-4)})(n,r)):r.isMeshStandardMaterial?(A(n,r),(function(c,C){c.metalness.value=C.metalness,C.metalnessMap&&(c.metalnessMap.value=C.metalnessMap,t(C.metalnessMap,c.metalnessMapTransform)),c.roughness.value=C.roughness,C.roughnessMap&&(c.roughnessMap.value=C.roughnessMap,t(C.roughnessMap,c.roughnessMapTransform)),e.get(C).envMap&&(c.envMapIntensity.value=C.envMapIntensity)})(n,r),r.isMeshPhysicalMaterial&&(function(c,C,B){c.ior.value=C.ior,C.sheen>0&&(c.sheenColor.value.copy(C.sheenColor).multiplyScalar(C.sheen),c.sheenRoughness.value=C.sheenRoughness,C.sheenColorMap&&(c.sheenColorMap.value=C.sheenColorMap,t(C.sheenColorMap,c.sheenColorMapTransform)),C.sheenRoughnessMap&&(c.sheenRoughnessMap.value=C.sheenRoughnessMap,t(C.sheenRoughnessMap,c.sheenRoughnessMapTransform))),C.clearcoat>0&&(c.clearcoat.value=C.clearcoat,c.clearcoatRoughness.value=C.clearcoatRoughness,C.clearcoatMap&&(c.clearcoatMap.value=C.clearcoatMap,t(C.clearcoatMap,c.clearcoatMapTransform)),C.clearcoatRoughnessMap&&(c.clearcoatRoughnessMap.value=C.clearcoatRoughnessMap,t(C.clearcoatRoughnessMap,c.clearcoatRoughnessMapTransform)),C.clearcoatNormalMap&&(c.clearcoatNormalMap.value=C.clearcoatNormalMap,t(C.clearcoatNormalMap,c.clearcoatNormalMapTransform),c.clearcoatNormalScale.value.copy(C.clearcoatNormalScale),C.side===v&&c.clearcoatNormalScale.value.negate())),C.iridescence>0&&(c.iridescence.value=C.iridescence,c.iridescenceIOR.value=C.iridescenceIOR,c.iridescenceThicknessMinimum.value=C.iridescenceThicknessRange[0],c.iridescenceThicknessMaximum.value=C.iridescenceThicknessRange[1],C.iridescenceMap&&(c.iridescenceMap.value=C.iridescenceMap,t(C.iridescenceMap,c.iridescenceMapTransform)),C.iridescenceThicknessMap&&(c.iridescenceThicknessMap.value=C.iridescenceThicknessMap,t(C.iridescenceThicknessMap,c.iridescenceThicknessMapTransform))),C.transmission>0&&(c.transmission.value=C.transmission,c.transmissionSamplerMap.value=B.texture,c.transmissionSamplerSize.value.set(B.width,B.height),C.transmissionMap&&(c.transmissionMap.value=C.transmissionMap,t(C.transmissionMap,c.transmissionMapTransform)),c.thickness.value=C.thickness,C.thicknessMap&&(c.thicknessMap.value=C.thicknessMap,t(C.thicknessMap,c.thicknessMapTransform)),c.attenuationDistance.value=C.attenuationDistance,c.attenuationColor.value.copy(C.attenuationColor)),c.specularIntensity.value=C.specularIntensity,c.specularColor.value.copy(C.specularColor),C.specularColorMap&&(c.specularColorMap.value=C.specularColorMap,t(C.specularColorMap,c.specularColorMapTransform)),C.specularIntensityMap&&(c.specularIntensityMap.value=C.specularIntensityMap,t(C.specularIntensityMap,c.specularIntensityMapTransform))})(n,r,u)):r.isMeshMatcapMaterial?(A(n,r),(function(c,C){C.matcap&&(c.matcap.value=C.matcap)})(n,r)):r.isMeshDepthMaterial?A(n,r):r.isMeshDistanceMaterial?(A(n,r),(function(c,C){const B=e.get(C).light;c.referencePosition.value.setFromMatrixPosition(B.matrixWorld),c.nearDistance.value=B.shadow.camera.near,c.farDistance.value=B.shadow.camera.far})(n,r)):r.isMeshNormalMaterial?A(n,r):r.isLineBasicMaterial?((function(c,C){c.diffuse.value.copy(C.color),c.opacity.value=C.opacity,C.map&&(c.map.value=C.map,t(C.map,c.mapTransform))})(n,r),r.isLineDashedMaterial&&(function(c,C){c.dashSize.value=C.dashSize,c.totalSize.value=C.dashSize+C.gapSize,c.scale.value=C.scale})(n,r)):r.isPointsMaterial?(function(c,C,B,p){c.diffuse.value.copy(C.color),c.opacity.value=C.opacity,c.size.value=C.size*B,c.scale.value=.5*p,C.map&&(c.map.value=C.map,t(C.map,c.uvTransform)),C.alphaMap&&(c.alphaMap.value=C.alphaMap),C.alphaTest>0&&(c.alphaTest.value=C.alphaTest)})(n,r,g,h):r.isSpriteMaterial?(function(c,C){c.diffuse.value.copy(C.color),c.opacity.value=C.opacity,c.rotation.value=C.rotation,C.map&&(c.map.value=C.map,t(C.map,c.mapTransform)),C.alphaMap&&(c.alphaMap.value=C.alphaMap),C.alphaTest>0&&(c.alphaTest.value=C.alphaTest)})(n,r):r.isShadowMaterial?(n.color.value.copy(r.color),n.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function LS(o,e,t,A){let n={},r={},g=[];const h=t.isWebGL2?o.getParameter(o.MAX_UNIFORM_BUFFER_BINDINGS):0;function u(B,p,w){const k=B.value;if(w[p]===void 0){if(typeof k=="number")w[p]=k;else{const R=Array.isArray(k)?k:[k],_=[];for(let N=0;N<R.length;N++)_.push(R[N].clone());w[p]=_}return!0}if(typeof k=="number"){if(w[p]!==k)return w[p]=k,!0}else{const R=Array.isArray(w[p])?w[p]:[w[p]],_=Array.isArray(k)?k:[k];for(let N=0;N<R.length;N++){const L=R[N];if(L.equals(_[N])===!1)return L.copy(_[N]),!0}}return!1}function c(B){const p={boundary:0,storage:0};return typeof B=="number"?(p.boundary=4,p.storage=4):B.isVector2?(p.boundary=8,p.storage=8):B.isVector3||B.isColor?(p.boundary=16,p.storage=12):B.isVector4?(p.boundary=16,p.storage=16):B.isMatrix3?(p.boundary=48,p.storage=48):B.isMatrix4?(p.boundary=64,p.storage=64):B.isTexture,p}function C(B){const p=B.target;p.removeEventListener("dispose",C);const w=g.indexOf(p.__bindingPointIndex);g.splice(w,1),o.deleteBuffer(n[p.id]),delete n[p.id],delete r[p.id]}return{bind:function(B,p){const w=p.program;A.uniformBlockBinding(B,w)},update:function(B,p){let w=n[B.id];w===void 0&&((function(_){const N=_.uniforms;let L=0;const G=16;let le=0;for(let ne=0,Ae=N.length;ne<Ae;ne++){const te=N[ne],ye={boundary:0,storage:0},ge=Array.isArray(te.value)?te.value:[te.value];for(let Me=0,pe=ge.length;Me<pe;Me++){const Ze=c(ge[Me]);ye.boundary+=Ze.boundary,ye.storage+=Ze.storage}te.__data=new Float32Array(ye.storage/Float32Array.BYTES_PER_ELEMENT),te.__offset=L,ne>0&&(le=L%G,le!==0&&G-le-ye.boundary<0&&(L+=G-le,te.__offset=L)),L+=ye.storage}le=L%G,le>0&&(L+=G-le),_.__size=L,_.__cache={}})(B),w=(function(_){const N=(function(){for(let ne=0;ne<h;ne++)if(g.indexOf(ne)===-1)return g.push(ne),ne;return 0})();_.__bindingPointIndex=N;const L=o.createBuffer(),G=_.__size,le=_.usage;return o.bindBuffer(o.UNIFORM_BUFFER,L),o.bufferData(o.UNIFORM_BUFFER,G,le),o.bindBuffer(o.UNIFORM_BUFFER,null),o.bindBufferBase(o.UNIFORM_BUFFER,N,L),L})(B),n[B.id]=w,B.addEventListener("dispose",C));const k=p.program;A.updateUBOMapping(B,k);const R=e.render.frame;r[B.id]!==R&&((function(_){const N=n[_.id],L=_.uniforms,G=_.__cache;o.bindBuffer(o.UNIFORM_BUFFER,N);for(let le=0,ne=L.length;le<ne;le++){const Ae=L[le];if(u(Ae,le,G)===!0){const te=Ae.__offset,ye=Array.isArray(Ae.value)?Ae.value:[Ae.value];let ge=0;for(let Me=0;Me<ye.length;Me++){const pe=ye[Me],Ze=c(pe);typeof pe=="number"?(Ae.__data[0]=pe,o.bufferSubData(o.UNIFORM_BUFFER,te+ge,Ae.__data)):pe.isMatrix3?(Ae.__data[0]=pe.elements[0],Ae.__data[1]=pe.elements[1],Ae.__data[2]=pe.elements[2],Ae.__data[3]=pe.elements[0],Ae.__data[4]=pe.elements[3],Ae.__data[5]=pe.elements[4],Ae.__data[6]=pe.elements[5],Ae.__data[7]=pe.elements[0],Ae.__data[8]=pe.elements[6],Ae.__data[9]=pe.elements[7],Ae.__data[10]=pe.elements[8],Ae.__data[11]=pe.elements[0]):(pe.toArray(Ae.__data,ge),ge+=Ze.storage/Float32Array.BYTES_PER_ELEMENT)}o.bufferSubData(o.UNIFORM_BUFFER,te,Ae.__data)}}o.bindBuffer(o.UNIFORM_BUFFER,null)})(B),r[B.id]=R)},dispose:function(){for(const B in n)o.deleteBuffer(n[B]);g=[],n={},r={}}}}function GS(){const o=wn("canvas");return o.style.display="block",o}class $E{constructor(e={}){const{canvas:t=GS(),context:A=null,depth:n=!0,stencil:r=!0,alpha:g=!1,antialias:h=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:c=!1,powerPreference:C="default",failIfMajorPerformanceCaveat:B=!1}=e;let p;this.isWebGLRenderer=!0,p=A!==null?A.getContextAttributes().alpha:g;let w=null,k=null;const R=[],_=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=ie,this.useLegacyLights=!0,this.toneMapping=F,this.toneMappingExposure=1;const N=this;let L=!1,G=0,le=0,ne=null,Ae=-1,te=null;const ye=new zA,ge=new zA;let Me=null,pe=t.width,Ze=t.height,Ct=1,Qt=null,Wt=null;const ft=new zA(0,0,pe,Ze),Mt=new zA(0,0,pe,Ze);let Rt=!1;const Ft=new Th;let Ye=!1,dt=!1,bt=null;const gt=new xA,Xt=new re,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ie(){return ne===null?Ct:1}let Se,je,_e,Et,ke,oe,Te,ct,St,ht,Kt,Ht,_t,CA,hA,J,$,xe,rt,$e,Re,Pe,Yt,Vt,ve=A;function zt(he,et){for(let Bt=0;Bt<he.length;Bt++){const lt=he[Bt],pt=t.getContext(lt,et);if(pt!==null)return pt}return null}try{const he={alpha:!0,depth:n,stencil:r,antialias:h,premultipliedAlpha:u,preserveDrawingBuffer:c,powerPreference:C,failIfMajorPerformanceCaveat:B};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${E}`),t.addEventListener("webglcontextlost",tA,!1),t.addEventListener("webglcontextrestored",dA,!1),t.addEventListener("webglcontextcreationerror",Pt,!1),ve===null){const et=["webgl2","webgl","experimental-webgl"];if(N.isWebGL1Renderer===!0&&et.shift(),ve=zt(et,he),ve===null)throw zt(et)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}ve.getShaderPrecisionFormat===void 0&&(ve.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(he){throw he.message,he}function qt(){Se=new gM(ve),je=new rM(ve,Se,e),Se.init(je),Pe=new bS(ve,Se,je),_e=new SS(ve,Se,je),Et=new hM(ve),ke=new ES,oe=new xS(ve,Se,_e,ke,je,Pe,Et),Te=new aM(N),ct=new oM(N),St=new tM(ve,je),Yt=new iM(ve,Se,St,je),ht=new lM(ve,St,Et,Yt),Kt=new dM(ve,ht,St,Et),rt=new CM(ve,je,oe),J=new sM(ke),Ht=new dS(N,Te,ct,Se,je,Yt,J),_t=new FS(N,ke),CA=new QS,hA=new yS(Se,je),xe=new AM(N,Te,ct,_e,Kt,p,u),$=new MS(N,Kt,je),Vt=new LS(ve,Et,je,_e),$e=new nM(ve,Se,Et,je),Re=new cM(ve,Se,Et,je),Et.programs=Ht.programs,N.capabilities=je,N.extensions=Se,N.properties=ke,N.renderLists=CA,N.shadowMap=$,N.state=_e,N.info=Et}qt();const Lt=new kS(N,ve);function tA(he){he.preventDefault(),L=!0}function dA(){L=!1;const he=Et.autoReset,et=$.enabled,Bt=$.autoUpdate,lt=$.needsUpdate,pt=$.type;qt(),Et.autoReset=he,$.enabled=et,$.autoUpdate=Bt,$.needsUpdate=lt,$.type=pt}function Pt(he){he.statusMessage}function sA(he){const et=he.target;et.removeEventListener("dispose",sA),(function(Bt){(function(lt){const pt=ke.get(lt).programs;pt!==void 0&&(pt.forEach((function(eA){Ht.releaseProgram(eA)})),lt.isShaderMaterial&&Ht.releaseShaderCache(lt))})(Bt),ke.remove(Bt)})(et)}this.xr=Lt,this.getContext=function(){return ve},this.getContextAttributes=function(){return ve.getContextAttributes()},this.forceContextLoss=function(){const he=Se.get("WEBGL_lose_context");he&&he.loseContext()},this.forceContextRestore=function(){const he=Se.get("WEBGL_lose_context");he&&he.restoreContext()},this.getPixelRatio=function(){return Ct},this.setPixelRatio=function(he){he!==void 0&&(Ct=he,this.setSize(pe,Ze,!1))},this.getSize=function(he){return he.set(pe,Ze)},this.setSize=function(he,et,Bt=!0){Lt.isPresenting||(pe=he,Ze=et,t.width=Math.floor(he*Ct),t.height=Math.floor(et*Ct),Bt===!0&&(t.style.width=he+"px",t.style.height=et+"px"),this.setViewport(0,0,he,et))},this.getDrawingBufferSize=function(he){return he.set(pe*Ct,Ze*Ct).floor()},this.setDrawingBufferSize=function(he,et,Bt){pe=he,Ze=et,Ct=Bt,t.width=Math.floor(he*Bt),t.height=Math.floor(et*Bt),this.setViewport(0,0,he,et)},this.getCurrentViewport=function(he){return he.copy(ye)},this.getViewport=function(he){return he.copy(ft)},this.setViewport=function(he,et,Bt,lt){he.isVector4?ft.set(he.x,he.y,he.z,he.w):ft.set(he,et,Bt,lt),_e.viewport(ye.copy(ft).multiplyScalar(Ct).floor())},this.getScissor=function(he){return he.copy(Mt)},this.setScissor=function(he,et,Bt,lt){he.isVector4?Mt.set(he.x,he.y,he.z,he.w):Mt.set(he,et,Bt,lt),_e.scissor(ge.copy(Mt).multiplyScalar(Ct).floor())},this.getScissorTest=function(){return Rt},this.setScissorTest=function(he){_e.setScissorTest(Rt=he)},this.setOpaqueSort=function(he){Qt=he},this.setTransparentSort=function(he){Wt=he},this.getClearColor=function(he){return he.copy(xe.getClearColor())},this.setClearColor=function(){xe.setClearColor.apply(xe,arguments)},this.getClearAlpha=function(){return xe.getClearAlpha()},this.setClearAlpha=function(){xe.setClearAlpha.apply(xe,arguments)},this.clear=function(he=!0,et=!0,Bt=!0){let lt=0;he&&(lt|=ve.COLOR_BUFFER_BIT),et&&(lt|=ve.DEPTH_BUFFER_BIT),Bt&&(lt|=ve.STENCIL_BUFFER_BIT),ve.clear(lt)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",tA,!1),t.removeEventListener("webglcontextrestored",dA,!1),t.removeEventListener("webglcontextcreationerror",Pt,!1),CA.dispose(),hA.dispose(),ke.dispose(),Te.dispose(),ct.dispose(),Kt.dispose(),Yt.dispose(),Vt.dispose(),Ht.dispose(),Lt.dispose(),Lt.removeEventListener("sessionstart",wA),Lt.removeEventListener("sessionend",mi),bt&&(bt.dispose(),bt=null),qA.stop()},this.renderBufferDirect=function(he,et,Bt,lt,pt,eA){et===null&&(et=ce);const IA=pt.isMesh&&pt.matrixWorld.determinant()<0,MA=(function(WA,Bn,Li,pA,bi){Bn.isScene!==!0&&(Bn=ce),oe.resetTextureUnits();const RI=Bn.fog,q_=pA.isMeshStandardMaterial?Bn.environment:null,W_=ne===null?N.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:W,Cc=(pA.isMeshStandardMaterial?ct:Te).get(pA.envMap||q_),V_=pA.vertexColors===!0&&!!Li.attributes.color&&Li.attributes.color.itemSize===4,Z_=!!pA.normalMap&&!!Li.attributes.tangent,j_=!!Li.morphAttributes.position,X_=!!Li.morphAttributes.normal,$_=!!Li.morphAttributes.color,eR=pA.toneMapped?N.toneMapping:F,LQ=Li.morphAttributes.position||Li.morphAttributes.normal||Li.morphAttributes.color,tR=LQ!==void 0?LQ.length:0,ii=ke.get(pA),AR=k.state.lights;if(Ye===!0&&(dt===!0||WA!==te)){const Nn=WA===te&&pA.id===Ae;J.setState(pA,WA,Nn)}let jr=!1;pA.version===ii.__version?ii.needsLights&&ii.lightsStateVersion!==AR.state.version||ii.outputColorSpace!==W_||bi.isInstancedMesh&&ii.instancing===!1?jr=!0:bi.isInstancedMesh||ii.instancing!==!0?bi.isSkinnedMesh&&ii.skinning===!1?jr=!0:bi.isSkinnedMesh||ii.skinning!==!0?ii.envMap!==Cc||pA.fog===!0&&ii.fog!==RI?jr=!0:ii.numClippingPlanes===void 0||ii.numClippingPlanes===J.numPlanes&&ii.numIntersection===J.numIntersection?(ii.vertexAlphas!==V_||ii.vertexTangents!==Z_||ii.morphTargets!==j_||ii.morphNormals!==X_||ii.morphColors!==$_||ii.toneMapping!==eR||je.isWebGL2===!0&&ii.morphTargetsCount!==tR)&&(jr=!0):jr=!0:jr=!0:jr=!0:(jr=!0,ii.__version=pA.version);let js=ii.currentProgram;jr===!0&&(js=Fi(pA,Bn,bi));let GQ=!1,ug=!1,NI=!1;const ln=js.getUniforms(),Xs=ii.uniforms;if(_e.useProgram(js.program)&&(GQ=!0,ug=!0,NI=!0),pA.id!==Ae&&(Ae=pA.id,ug=!0),GQ||te!==WA){if(ln.setValue(ve,"projectionMatrix",WA.projectionMatrix),je.logarithmicDepthBuffer&&ln.setValue(ve,"logDepthBufFC",2/(Math.log(WA.far+1)/Math.LN2)),te!==WA&&(te=WA,ug=!0,NI=!0),pA.isShaderMaterial||pA.isMeshPhongMaterial||pA.isMeshToonMaterial||pA.isMeshStandardMaterial||pA.envMap){const Nn=ln.map.cameraPosition;Nn!==void 0&&Nn.setValue(ve,Xt.setFromMatrixPosition(WA.matrixWorld))}(pA.isMeshPhongMaterial||pA.isMeshToonMaterial||pA.isMeshLambertMaterial||pA.isMeshBasicMaterial||pA.isMeshStandardMaterial||pA.isShaderMaterial)&&ln.setValue(ve,"isOrthographic",WA.isOrthographicCamera===!0),(pA.isMeshPhongMaterial||pA.isMeshToonMaterial||pA.isMeshLambertMaterial||pA.isMeshBasicMaterial||pA.isMeshStandardMaterial||pA.isShaderMaterial||pA.isShadowMaterial||bi.isSkinnedMesh)&&ln.setValue(ve,"viewMatrix",WA.matrixWorldInverse)}if(bi.isSkinnedMesh){ln.setOptional(ve,bi,"bindMatrix"),ln.setOptional(ve,bi,"bindMatrixInverse");const Nn=bi.skeleton;Nn&&je.floatVertexTextures&&(Nn.boneTexture===null&&Nn.computeBoneTexture(),ln.setValue(ve,"boneTexture",Nn.boneTexture,oe),ln.setValue(ve,"boneTextureSize",Nn.boneTextureSize))}const kI=Li.morphAttributes;(kI.position!==void 0||kI.normal!==void 0||kI.color!==void 0&&je.isWebGL2===!0)&&rt.update(bi,Li,js),(ug||ii.receiveShadow!==bi.receiveShadow)&&(ii.receiveShadow=bi.receiveShadow,ln.setValue(ve,"receiveShadow",bi.receiveShadow)),pA.isMeshGouraudMaterial&&pA.envMap!==null&&(Xs.envMap.value=Cc,Xs.flipEnvMap.value=Cc.isCubeTexture&&Cc.isRenderTargetTexture===!1?-1:1),ug&&(ln.setValue(ve,"toneMappingExposure",N.toneMappingExposure),ii.needsLights&&(sr=NI,(mr=Xs).ambientLightColor.needsUpdate=sr,mr.lightProbe.needsUpdate=sr,mr.directionalLights.needsUpdate=sr,mr.directionalLightShadows.needsUpdate=sr,mr.pointLights.needsUpdate=sr,mr.pointLightShadows.needsUpdate=sr,mr.spotLights.needsUpdate=sr,mr.spotLightShadows.needsUpdate=sr,mr.rectAreaLights.needsUpdate=sr,mr.hemisphereLights.needsUpdate=sr),RI&&pA.fog===!0&&_t.refreshFogUniforms(Xs,RI),_t.refreshMaterialUniforms(Xs,pA,Ct,Ze,bt),Hl.upload(ve,ii.uniformsList,Xs,oe));var mr,sr;if(pA.isShaderMaterial&&pA.uniformsNeedUpdate===!0&&(Hl.upload(ve,ii.uniformsList,Xs,oe),pA.uniformsNeedUpdate=!1),pA.isSpriteMaterial&&ln.setValue(ve,"center",bi.center),ln.setValue(ve,"modelViewMatrix",bi.modelViewMatrix),ln.setValue(ve,"normalMatrix",bi.normalMatrix),ln.setValue(ve,"modelMatrix",bi.matrixWorld),pA.isShaderMaterial||pA.isRawShaderMaterial){const Nn=pA.uniformsGroups;for(let FI=0,iR=Nn.length;FI<iR;FI++)if(je.isWebGL2){const UQ=Nn[FI];Vt.update(UQ,js),Vt.bind(UQ,js)}}return js})(he,et,Bt,lt,pt);_e.setMaterial(lt,IA);let GA=Bt.index,gA=1;lt.wireframe===!0&&(GA=ht.getWireframeAttribute(Bt),gA=2);const bA=Bt.drawRange,_A=Bt.attributes.position;let jA=bA.start*gA,DA=(bA.start+bA.count)*gA;eA!==null&&(jA=Math.max(jA,eA.start*gA),DA=Math.min(DA,(eA.start+eA.count)*gA)),GA!==null?(jA=Math.max(jA,0),DA=Math.min(DA,GA.count)):_A!=null&&(jA=Math.max(jA,0),DA=Math.min(DA,_A.count));const BA=DA-jA;if(BA<0||BA===1/0)return;let Xi;Yt.setup(pt,lt,MA,Bt,GA);let $A=$e;if(GA!==null&&(Xi=St.get(GA),$A=Re,$A.setIndex(Xi)),pt.isMesh)lt.wireframe===!0?(_e.setLineWidth(lt.wireframeLinewidth*Ie()),$A.setMode(ve.LINES)):$A.setMode(ve.TRIANGLES);else if(pt.isLine){let WA=lt.linewidth;WA===void 0&&(WA=1),_e.setLineWidth(WA*Ie()),pt.isLineSegments?$A.setMode(ve.LINES):pt.isLineLoop?$A.setMode(ve.LINE_LOOP):$A.setMode(ve.LINE_STRIP)}else pt.isPoints?$A.setMode(ve.POINTS):pt.isSprite&&$A.setMode(ve.TRIANGLES);if(pt.isInstancedMesh)$A.renderInstances(jA,BA,pt.count);else if(Bt.isInstancedBufferGeometry){const WA=Bt._maxInstanceCount!==void 0?Bt._maxInstanceCount:1/0,Bn=Math.min(Bt.instanceCount,WA);$A.renderInstances(jA,BA,Bn)}else $A.render(jA,BA)},this.compile=function(he,et){function Bt(lt,pt,eA){lt.transparent===!0&<.side===2&<.forceSinglePass===!1?(lt.side=v,lt.needsUpdate=!0,Fi(lt,pt,eA),lt.side=m,lt.needsUpdate=!0,Fi(lt,pt,eA),lt.side=2):Fi(lt,pt,eA)}k=hA.get(he),k.init(),_.push(k),he.traverseVisible((function(lt){lt.isLight&<.layers.test(et.layers)&&(k.pushLight(lt),lt.castShadow&&k.pushShadow(lt))})),k.setupLights(N.useLegacyLights),he.traverse((function(lt){const pt=lt.material;if(pt)if(Array.isArray(pt))for(let eA=0;eA<pt.length;eA++)Bt(pt[eA],he,lt);else Bt(pt,he,lt)})),_.pop(),k=null};let oA=null;function wA(){qA.stop()}function mi(){qA.start()}const qA=new DE;function cA(he,et,Bt,lt){if(he.visible===!1)return;if(he.layers.test(et.layers)){if(he.isGroup)Bt=he.renderOrder;else if(he.isLOD)he.autoUpdate===!0&&he.update(et);else if(he.isLight)k.pushLight(he),he.castShadow&&k.pushShadow(he);else if(he.isSprite){if(!he.frustumCulled||Ft.intersectsSprite(he)){lt&&Xt.setFromMatrixPosition(he.matrixWorld).applyMatrix4(gt);const eA=Kt.update(he),IA=he.material;IA.visible&&w.push(he,eA,IA,Bt,Xt.z,null)}}else if((he.isMesh||he.isLine||he.isPoints)&&(!he.frustumCulled||Ft.intersectsObject(he))){he.isSkinnedMesh&&he.skeleton.frame!==Et.render.frame&&(he.skeleton.update(),he.skeleton.frame=Et.render.frame);const eA=Kt.update(he),IA=he.material;if(lt&&(eA.boundingSphere===null&&eA.computeBoundingSphere(),Xt.copy(eA.boundingSphere.center).applyMatrix4(he.matrixWorld).applyMatrix4(gt)),Array.isArray(IA)){const MA=eA.groups;for(let GA=0,gA=MA.length;GA<gA;GA++){const bA=MA[GA],_A=IA[bA.materialIndex];_A&&_A.visible&&w.push(he,eA,_A,Bt,Xt.z,bA)}}else IA.visible&&w.push(he,eA,IA,Bt,Xt.z,null)}}const pt=he.children;for(let eA=0,IA=pt.length;eA<IA;eA++)cA(pt[eA],et,Bt,lt)}function FA(he,et,Bt,lt){const pt=he.opaque,eA=he.transmissive,IA=he.transparent;k.setupLightsView(Bt),Ye===!0&&J.setGlobalState(N.clippingPlanes,Bt),eA.length>0&&(function(MA,GA,gA,bA){if(bt===null){const BA=je.isWebGL2;bt=new ei(1024,1024,{generateMipmaps:!0,type:Se.has("EXT_color_buffer_half_float")?mt:be,minFilter:se,samples:BA&&h===!0?4:0})}const _A=N.getRenderTarget();N.setRenderTarget(bt),N.clear();const jA=N.toneMapping;N.toneMapping=F,hi(MA,gA,bA),oe.updateMultisampleRenderTarget(bt),oe.updateRenderTargetMipmap(bt);let DA=!1;for(let BA=0,Xi=GA.length;BA<Xi;BA++){const $A=GA[BA],WA=$A.object,Bn=$A.geometry,Li=$A.material,pA=$A.group;if(Li.side===2&&WA.layers.test(bA.layers)){const bi=Li.side;Li.side=v,Li.needsUpdate=!0,ji(WA,gA,bA,Bn,Li,pA),Li.side=bi,Li.needsUpdate=!0,DA=!0}}DA===!0&&(oe.updateMultisampleRenderTarget(bt),oe.updateRenderTargetMipmap(bt)),N.setRenderTarget(_A),N.toneMapping=jA})(pt,eA,et,Bt),lt&&_e.viewport(ye.copy(lt)),pt.length>0&&hi(pt,et,Bt),eA.length>0&&hi(eA,et,Bt),IA.length>0&&hi(IA,et,Bt),_e.buffers.depth.setTest(!0),_e.buffers.depth.setMask(!0),_e.buffers.color.setMask(!0),_e.setPolygonOffset(!1)}function hi(he,et,Bt){const lt=et.isScene===!0?et.overrideMaterial:null;for(let pt=0,eA=he.length;pt<eA;pt++){const IA=he[pt],MA=IA.object,GA=IA.geometry,gA=lt===null?IA.material:lt,bA=IA.group;MA.layers.test(Bt.layers)&&ji(MA,et,Bt,GA,gA,bA)}}function ji(he,et,Bt,lt,pt,eA){he.onBeforeRender(N,et,Bt,lt,pt,eA),he.modelViewMatrix.multiplyMatrices(Bt.matrixWorldInverse,he.matrixWorld),he.normalMatrix.getNormalMatrix(he.modelViewMatrix),pt.onBeforeRender(N,et,Bt,lt,he,eA),pt.transparent===!0&&pt.side===2&&pt.forceSinglePass===!1?(pt.side=v,pt.needsUpdate=!0,N.renderBufferDirect(Bt,et,lt,pt,he,eA),pt.side=m,pt.needsUpdate=!0,N.renderBufferDirect(Bt,et,lt,pt,he,eA),pt.side=2):N.renderBufferDirect(Bt,et,lt,pt,he,eA),he.onAfterRender(N,et,Bt,lt,pt,eA)}function Fi(he,et,Bt){et.isScene!==!0&&(et=ce);const lt=ke.get(he),pt=k.state.lights,eA=k.state.shadowsArray,IA=pt.state.version,MA=Ht.getParameters(he,pt.state,eA,et,Bt),GA=Ht.getProgramCacheKey(MA);let gA=lt.programs;lt.environment=he.isMeshStandardMaterial?et.environment:null,lt.fog=et.fog,lt.envMap=(he.isMeshStandardMaterial?ct:Te).get(he.envMap||lt.environment),gA===void 0&&(he.addEventListener("dispose",sA),gA=new Map,lt.programs=gA);let bA=gA.get(GA);if(bA!==void 0){if(lt.currentProgram===bA&<.lightsStateVersion===IA)return vi(he,MA),bA}else MA.uniforms=Ht.getUniforms(he),he.onBuild(Bt,MA,N),he.onBeforeCompile(MA,N),bA=Ht.acquireProgram(MA,GA),gA.set(GA,bA),lt.uniforms=MA.uniforms;const _A=lt.uniforms;(he.isShaderMaterial||he.isRawShaderMaterial)&&he.clipping!==!0||(_A.clippingPlanes=J.uniform),vi(he,MA),lt.needsLights=(function(BA){return BA.isMeshLambertMaterial||BA.isMeshToonMaterial||BA.isMeshPhongMaterial||BA.isMeshStandardMaterial||BA.isShadowMaterial||BA.isShaderMaterial&&BA.lights===!0})(he),lt.lightsStateVersion=IA,lt.needsLights&&(_A.ambientLightColor.value=pt.state.ambient,_A.lightProbe.value=pt.state.probe,_A.directionalLights.value=pt.state.directional,_A.directionalLightShadows.value=pt.state.directionalShadow,_A.spotLights.value=pt.state.spot,_A.spotLightShadows.value=pt.state.spotShadow,_A.rectAreaLights.value=pt.state.rectArea,_A.ltc_1.value=pt.state.rectAreaLTC1,_A.ltc_2.value=pt.state.rectAreaLTC2,_A.pointLights.value=pt.state.point,_A.pointLightShadows.value=pt.state.pointShadow,_A.hemisphereLights.value=pt.state.hemi,_A.directionalShadowMap.value=pt.state.directionalShadowMap,_A.directionalShadowMatrix.value=pt.state.directionalShadowMatrix,_A.spotShadowMap.value=pt.state.spotShadowMap,_A.spotLightMatrix.value=pt.state.spotLightMatrix,_A.spotLightMap.value=pt.state.spotLightMap,_A.pointShadowMap.value=pt.state.pointShadowMap,_A.pointShadowMatrix.value=pt.state.pointShadowMatrix);const jA=bA.getUniforms(),DA=Hl.seqWithValue(jA.seq,_A);return lt.currentProgram=bA,lt.uniformsList=DA,bA}function vi(he,et){const Bt=ke.get(he);Bt.outputColorSpace=et.outputColorSpace,Bt.instancing=et.instancing,Bt.skinning=et.skinning,Bt.morphTargets=et.morphTargets,Bt.morphNormals=et.morphNormals,Bt.morphColors=et.morphColors,Bt.morphTargetsCount=et.morphTargetsCount,Bt.numClippingPlanes=et.numClippingPlanes,Bt.numIntersection=et.numClipIntersection,Bt.vertexAlphas=et.vertexAlphas,Bt.vertexTangents=et.vertexTangents,Bt.toneMapping=et.toneMapping}qA.setAnimationLoop((function(he){oA&&oA(he)})),typeof self<"u"&&qA.setContext(self),this.setAnimationLoop=function(he){oA=he,Lt.setAnimationLoop(he),he===null?qA.stop():qA.start()},Lt.addEventListener("sessionstart",wA),Lt.addEventListener("sessionend",mi),this.render=function(he,et){if(et!==void 0&&et.isCamera!==!0||L===!0)return;he.matrixWorldAutoUpdate===!0&&he.updateMatrixWorld(),et.parent===null&&et.matrixWorldAutoUpdate===!0&&et.updateMatrixWorld(),Lt.enabled===!0&&Lt.isPresenting===!0&&(Lt.cameraAutoUpdate===!0&&Lt.updateCamera(et),et=Lt.getCamera()),he.isScene===!0&&he.onBeforeRender(N,he,et,ne),k=hA.get(he,_.length),k.init(),_.push(k),gt.multiplyMatrices(et.projectionMatrix,et.matrixWorldInverse),Ft.setFromProjectionMatrix(gt),dt=this.localClippingEnabled,Ye=J.init(this.clippingPlanes,dt),w=CA.get(he,R.length),w.init(),R.push(w),cA(he,et,0,N.sortObjects),w.finish(),N.sortObjects===!0&&w.sort(Qt,Wt),Ye===!0&&J.beginShadows();const Bt=k.state.shadowsArray;if($.render(Bt,he,et),Ye===!0&&J.endShadows(),this.info.autoReset===!0&&this.info.reset(),xe.render(w,he),k.setupLights(N.useLegacyLights),et.isArrayCamera){const lt=et.cameras;for(let pt=0,eA=lt.length;pt<eA;pt++){const IA=lt[pt];FA(w,he,IA,IA.viewport)}}else FA(w,he,et);ne!==null&&(oe.updateMultisampleRenderTarget(ne),oe.updateRenderTargetMipmap(ne)),he.isScene===!0&&he.onAfterRender(N,he,et),Yt.resetDefaultState(),Ae=-1,te=null,_.pop(),k=_.length>0?_[_.length-1]:null,R.pop(),w=R.length>0?R[R.length-1]:null},this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return le},this.getRenderTarget=function(){return ne},this.setRenderTargetTextures=function(he,et,Bt){ke.get(he.texture).__webglTexture=et,ke.get(he.depthTexture).__webglTexture=Bt;const lt=ke.get(he);lt.__hasExternalTextures=!0,lt.__hasExternalTextures&&(lt.__autoAllocateDepthBuffer=Bt===void 0,lt.__autoAllocateDepthBuffer||Se.has("WEBGL_multisampled_render_to_texture")===!0&&(lt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(he,et){const Bt=ke.get(he);Bt.__webglFramebuffer=et,Bt.__useDefaultFramebuffer=et===void 0},this.setRenderTarget=function(he,et=0,Bt=0){ne=he,G=et,le=Bt;let lt=!0,pt=null,eA=!1,IA=!1;if(he){const MA=ke.get(he);MA.__useDefaultFramebuffer!==void 0?(_e.bindFramebuffer(ve.FRAMEBUFFER,null),lt=!1):MA.__webglFramebuffer===void 0?oe.setupRenderTarget(he):MA.__hasExternalTextures&&oe.rebindTextures(he,ke.get(he.texture).__webglTexture,ke.get(he.depthTexture).__webglTexture);const GA=he.texture;(GA.isData3DTexture||GA.isDataArrayTexture||GA.isCompressedArrayTexture)&&(IA=!0);const gA=ke.get(he).__webglFramebuffer;he.isWebGLCubeRenderTarget?(pt=gA[et],eA=!0):pt=je.isWebGL2&&he.samples>0&&oe.useMultisampledRTT(he)===!1?ke.get(he).__webglMultisampledFramebuffer:gA,ye.copy(he.viewport),ge.copy(he.scissor),Me=he.scissorTest}else ye.copy(ft).multiplyScalar(Ct).floor(),ge.copy(Mt).multiplyScalar(Ct).floor(),Me=Rt;if(_e.bindFramebuffer(ve.FRAMEBUFFER,pt)&&je.drawBuffers&<&&_e.drawBuffers(he,pt),_e.viewport(ye),_e.scissor(ge),_e.setScissorTest(Me),eA){const MA=ke.get(he.texture);ve.framebufferTexture2D(ve.FRAMEBUFFER,ve.COLOR_ATTACHMENT0,ve.TEXTURE_CUBE_MAP_POSITIVE_X+et,MA.__webglTexture,Bt)}else if(IA){const MA=ke.get(he.texture),GA=et||0;ve.framebufferTextureLayer(ve.FRAMEBUFFER,ve.COLOR_ATTACHMENT0,MA.__webglTexture,Bt||0,GA)}Ae=-1},this.readRenderTargetPixels=function(he,et,Bt,lt,pt,eA,IA){if(!he||!he.isWebGLRenderTarget)return;let MA=ke.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&IA!==void 0&&(MA=MA[IA]),MA){_e.bindFramebuffer(ve.FRAMEBUFFER,MA);try{const GA=he.texture,gA=GA.format,bA=GA.type;if(gA!==kt&&Pe.convert(gA)!==ve.getParameter(ve.IMPLEMENTATION_COLOR_READ_FORMAT))return;const _A=bA===mt&&(Se.has("EXT_color_buffer_half_float")||je.isWebGL2&&Se.has("EXT_color_buffer_float"));if(!(bA===be||Pe.convert(bA)===ve.getParameter(ve.IMPLEMENTATION_COLOR_READ_TYPE)||bA===De&&(je.isWebGL2||Se.has("OES_texture_float")||Se.has("WEBGL_color_buffer_float"))||_A))return;et>=0&&et<=he.width-lt&&Bt>=0&&Bt<=he.height-pt&&ve.readPixels(et,Bt,lt,pt,Pe.convert(gA),Pe.convert(bA),eA)}finally{const GA=ne!==null?ke.get(ne).__webglFramebuffer:null;_e.bindFramebuffer(ve.FRAMEBUFFER,GA)}}},this.copyFramebufferToTexture=function(he,et,Bt=0){const lt=Math.pow(2,-Bt),pt=Math.floor(et.image.width*lt),eA=Math.floor(et.image.height*lt);oe.setTexture2D(et,0),ve.copyTexSubImage2D(ve.TEXTURE_2D,Bt,0,0,he.x,he.y,pt,eA),_e.unbindTexture()},this.copyTextureToTexture=function(he,et,Bt,lt=0){const pt=et.image.width,eA=et.image.height,IA=Pe.convert(Bt.format),MA=Pe.convert(Bt.type);oe.setTexture2D(Bt,0),ve.pixelStorei(ve.UNPACK_FLIP_Y_WEBGL,Bt.flipY),ve.pixelStorei(ve.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Bt.premultiplyAlpha),ve.pixelStorei(ve.UNPACK_ALIGNMENT,Bt.unpackAlignment),et.isDataTexture?ve.texSubImage2D(ve.TEXTURE_2D,lt,he.x,he.y,pt,eA,IA,MA,et.image.data):et.isCompressedTexture?ve.compressedTexSubImage2D(ve.TEXTURE_2D,lt,he.x,he.y,et.mipmaps[0].width,et.mipmaps[0].height,IA,et.mipmaps[0].data):ve.texSubImage2D(ve.TEXTURE_2D,lt,he.x,he.y,IA,MA,et.image),lt===0&&Bt.generateMipmaps&&ve.generateMipmap(ve.TEXTURE_2D),_e.unbindTexture()},this.copyTextureToTexture3D=function(he,et,Bt,lt,pt=0){if(N.isWebGL1Renderer)return;const eA=he.max.x-he.min.x+1,IA=he.max.y-he.min.y+1,MA=he.max.z-he.min.z+1,GA=Pe.convert(lt.format),gA=Pe.convert(lt.type);let bA;if(lt.isData3DTexture)oe.setTexture3D(lt,0),bA=ve.TEXTURE_3D;else{if(!lt.isDataArrayTexture)return;oe.setTexture2DArray(lt,0),bA=ve.TEXTURE_2D_ARRAY}ve.pixelStorei(ve.UNPACK_FLIP_Y_WEBGL,lt.flipY),ve.pixelStorei(ve.UNPACK_PREMULTIPLY_ALPHA_WEBGL,lt.premultiplyAlpha),ve.pixelStorei(ve.UNPACK_ALIGNMENT,lt.unpackAlignment);const _A=ve.getParameter(ve.UNPACK_ROW_LENGTH),jA=ve.getParameter(ve.UNPACK_IMAGE_HEIGHT),DA=ve.getParameter(ve.UNPACK_SKIP_PIXELS),BA=ve.getParameter(ve.UNPACK_SKIP_ROWS),Xi=ve.getParameter(ve.UNPACK_SKIP_IMAGES),$A=Bt.isCompressedTexture?Bt.mipmaps[0]:Bt.image;ve.pixelStorei(ve.UNPACK_ROW_LENGTH,$A.width),ve.pixelStorei(ve.UNPACK_IMAGE_HEIGHT,$A.height),ve.pixelStorei(ve.UNPACK_SKIP_PIXELS,he.min.x),ve.pixelStorei(ve.UNPACK_SKIP_ROWS,he.min.y),ve.pixelStorei(ve.UNPACK_SKIP_IMAGES,he.min.z),Bt.isDataTexture||Bt.isData3DTexture?ve.texSubImage3D(bA,pt,et.x,et.y,et.z,eA,IA,MA,GA,gA,$A.data):Bt.isCompressedArrayTexture?ve.compressedTexSubImage3D(bA,pt,et.x,et.y,et.z,eA,IA,MA,GA,$A.data):ve.texSubImage3D(bA,pt,et.x,et.y,et.z,eA,IA,MA,GA,gA,$A),ve.pixelStorei(ve.UNPACK_ROW_LENGTH,_A),ve.pixelStorei(ve.UNPACK_IMAGE_HEIGHT,jA),ve.pixelStorei(ve.UNPACK_SKIP_PIXELS,DA),ve.pixelStorei(ve.UNPACK_SKIP_ROWS,BA),ve.pixelStorei(ve.UNPACK_SKIP_IMAGES,Xi),pt===0&<.generateMipmaps&&ve.generateMipmap(bA),_e.unbindTexture()},this.initTexture=function(he){he.isCubeTexture?oe.setTextureCube(he,0):he.isData3DTexture?oe.setTexture3D(he,0):he.isDataArrayTexture||he.isCompressedArrayTexture?oe.setTexture2DArray(he,0):oe.setTexture2D(he,0),_e.unbindTexture()},this.resetState=function(){G=0,le=0,ne=null,_e.reset(),Yt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get physicallyCorrectLights(){return!this.useLegacyLights}set physicallyCorrectLights(e){this.useLegacyLights=!e}get outputEncoding(){return this.outputColorSpace===ie?M:3e3}set outputEncoding(e){this.outputColorSpace=e===M?ie:W}}(class extends $E{}).prototype.isWebGL1Renderer=!0;class Rn extends gi{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return this.matrixWorldAutoUpdate}set autoUpdate(e){this.matrixWorldAutoUpdate=e}}class eB{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=We,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=AA()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,A){e*=this.stride,A*=t.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=t.array[A+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=AA()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),A=new this.constructor(t,this.stride);return A.setUsage(this.usage),A}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=AA()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const on=new re;class Ho{constructor(e,t,A,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=A,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,A=this.data.count;t<A;t++)on.fromBufferAttribute(this,t),on.applyMatrix4(e),this.setXYZ(t,on.x,on.y,on.z);return this}applyNormalMatrix(e){for(let t=0,A=this.count;t<A;t++)on.fromBufferAttribute(this,t),on.applyNormalMatrix(e),this.setXYZ(t,on.x,on.y,on.z);return this}transformDirection(e){for(let t=0,A=this.count;t<A;t++)on.fromBufferAttribute(this,t),on.transformDirection(e),this.setXYZ(t,on.x,on.y,on.z);return this}setX(e,t){return this.normalized&&(t=SA(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=SA(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=SA(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=SA(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=nn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=nn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=nn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=nn(t,this.array)),t}setXY(e,t,A){return e=e*this.data.stride+this.offset,this.normalized&&(t=SA(t,this.array),A=SA(A,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=A,this}setXYZ(e,t,A,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=SA(t,this.array),A=SA(A,this.array),n=SA(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=A,this.data.array[e+2]=n,this}setXYZW(e,t,A,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=SA(t,this.array),A=SA(A,this.array),n=SA(n,this.array),r=SA(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=A,this.data.array[e+2]=n,this.data.array[e+3]=r,this}clone(e){if(e===void 0){const t=[];for(let A=0;A<this.count;A++){const n=A*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return new Vi(new this.array.constructor(t),this.itemSize,this.normalized)}return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Ho(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){const t=[];for(let A=0;A<this.count;A++){const n=A*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class tB extends Sn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new rA(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Ra;const Jo=new re,Na=new re,ka=new re,Fa=new Gt,Yo=new Gt,AB=new xA,Jl=new re,Po=new re,Yl=new re,iB=new Gt,zh=new Gt,nB=new Gt;class US extends gi{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",Ra===void 0){Ra=new bn;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),A=new eB(t,5);Ra.setIndex([0,1,2,0,2,3]),Ra.setAttribute("position",new Ho(A,3,0,!1)),Ra.setAttribute("uv",new Ho(A,2,3,!1))}this.geometry=Ra,this.material=e!==void 0?e:new tB,this.center=new Gt(.5,.5)}raycast(e,t){e.camera,Na.setFromMatrixScale(this.matrixWorld),AB.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ka.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Na.multiplyScalar(-ka.z);const A=this.material.rotation;let n,r;A!==0&&(r=Math.cos(A),n=Math.sin(A));const g=this.center;Pl(Jl.set(-.5,-.5,0),ka,g,Na,n,r),Pl(Po.set(.5,-.5,0),ka,g,Na,n,r),Pl(Yl.set(.5,.5,0),ka,g,Na,n,r),iB.set(0,0),zh.set(1,0),nB.set(1,1);let h=e.ray.intersectTriangle(Jl,Po,Yl,!1,Jo);if(h===null&&(Pl(Po.set(-.5,.5,0),ka,g,Na,n,r),zh.set(0,1),h=e.ray.intersectTriangle(Jl,Yl,Po,!1,Jo),h===null))return;const u=e.ray.origin.distanceTo(Jo);u<e.near||u>e.far||t.push({distance:u,point:Jo.clone(),uv:Hn.getInterpolation(Jo,Jl,Po,Yl,iB,zh,nB,new Gt),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Pl(o,e,t,A,n,r){Fa.subVectors(o,t).addScalar(.5).multiply(A),n!==void 0?(Yo.x=r*Fa.x-n*Fa.y,Yo.y=n*Fa.x+r*Fa.y):Yo.copy(Fa),o.copy(e),o.x+=Yo.x,o.y+=Yo.y,o.applyMatrix4(AB)}const rB=new re,sB=new zA,aB=new zA,TS=new re,oB=new xA,La=new re;class HS extends UA{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new xA,this.bindMatrixInverse=new xA,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Mi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let A=0;A<t.count;A++)La.fromBufferAttribute(t,A),this.applyBoneTransform(A,La),this.boundingBox.expandByPoint(La)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ur),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let A=0;A<t.count;A++)La.fromBufferAttribute(t,A),this.applyBoneTransform(A,La),this.boundingSphere.expandByPoint(La)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new zA,t=this.geometry.attributes.skinWeight;for(let A=0,n=t.count;A<n;A++){e.fromBufferAttribute(t,A);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(A,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"?this.bindMatrixInverse.copy(this.bindMatrix).invert():this.bindMode}applyBoneTransform(e,t){const A=this.skeleton,n=this.geometry;sB.fromBufferAttribute(n.attributes.skinIndex,e),aB.fromBufferAttribute(n.attributes.skinWeight,e),rB.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const g=aB.getComponent(r);if(g!==0){const h=sB.getComponent(r);oB.multiplyMatrices(A.bones[h].matrixWorld,A.boneInverses[h]),t.addScaledVector(TS.copy(rB).applyMatrix4(oB),g)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return this.applyBoneTransform(e,t)}}class gB extends gi{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Cs extends Di{constructor(e=null,t=1,A=1,n,r,g,h,u,c=1003,C=1003,B,p){super(null,g,h,u,c,C,n,r,B,p),this.isDataTexture=!0,this.image={data:e,width:t,height:A},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const lB=new xA,JS=new xA;class qh{constructor(e=[],t=[]){this.uuid=AA(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),t.length===0)this.calculateInverses();else if(e.length!==t.length){this.boneInverses=[];for(let A=0,n=this.bones.length;A<n;A++)this.boneInverses.push(new xA)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const A=new xA;this.bones[e]&&A.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(A)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const A=this.bones[e];A&&A.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const A=this.bones[e];A&&(A.parent&&A.parent.isBone?(A.matrix.copy(A.parent.matrixWorld).invert(),A.matrix.multiply(A.matrixWorld)):A.matrix.copy(A.matrixWorld),A.matrix.decompose(A.position,A.quaternion,A.scale))}}update(){const e=this.bones,t=this.boneInverses,A=this.boneMatrices,n=this.boneTexture;for(let r=0,g=e.length;r<g;r++){const h=e[r]?e[r].matrixWorld:JS;lB.multiplyMatrices(h,t[r]),lB.toArray(A,16*r)}n!==null&&(n.needsUpdate=!0)}clone(){return new qh(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=ai(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const A=new Cs(t,e,e,kt,De);return A.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=A,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,A=this.bones.length;t<A;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let A=0,n=e.bones.length;A<n;A++){const r=e.bones[A];let g=t[r];g===void 0&&(g=new gB),this.bones.push(g),this.boneInverses.push(new xA().fromArray(e.boneInverses[A]))}return this.init(),this}toJSON(){const e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,A=this.boneInverses;for(let n=0,r=t.length;n<r;n++){const g=t[n];e.bones.push(g.uuid);const h=A[n];e.boneInverses.push(h.toArray())}return e}}class cB extends Vi{constructor(e,t,A,n=1){super(e,t,A),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Ga=new xA,hB=new xA,Ol=[],IB=new Mi,YS=new xA,Oo=new UA,Ko=new Ur;class PS extends UA{constructor(e,t,A){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new cB(new Float32Array(16*A),16),this.instanceColor=null,this.count=A,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<A;n++)this.setMatrixAt(n,YS)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Mi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let A=0;A<t;A++)this.getMatrixAt(A,Ga),IB.copy(e.boundingBox).applyMatrix4(Ga),this.boundingBox.union(IB)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ur),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let A=0;A<t;A++)this.getMatrixAt(A,Ga),Ko.copy(e.boundingSphere).applyMatrix4(Ga),this.boundingSphere.union(Ko)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){const A=this.matrixWorld,n=this.count;if(Oo.geometry=this.geometry,Oo.material=this.material,Oo.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ko.copy(this.boundingSphere),Ko.applyMatrix4(A),e.ray.intersectsSphere(Ko)!==!1))for(let r=0;r<n;r++){this.getMatrixAt(r,Ga),hB.multiplyMatrices(A,Ga),Oo.matrixWorld=hB,Oo.raycast(e,Ol);for(let g=0,h=Ol.length;g<h;g++){const u=Ol[g];u.instanceId=r,u.object=this,t.push(u)}Ol.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new cB(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class uB extends Sn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new rA(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const CB=new re,dB=new re,EB=new xA,Wh=new Lo,Kl=new Ur;class Vh extends gi{constructor(e=new bn,t=new uB){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,A=[0];for(let n=1,r=t.count;n<r;n++)CB.fromBufferAttribute(t,n-1),dB.fromBufferAttribute(t,n),A[n]=A[n-1],A[n]+=CB.distanceTo(dB);e.setAttribute("lineDistance",new Cn(A,1))}return this}raycast(e,t){const A=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,g=A.drawRange;if(A.boundingSphere===null&&A.computeBoundingSphere(),Kl.copy(A.boundingSphere),Kl.applyMatrix4(n),Kl.radius+=r,e.ray.intersectsSphere(Kl)===!1)return;EB.copy(n).invert(),Wh.copy(e.ray).applyMatrix4(EB);const h=r/((this.scale.x+this.scale.y+this.scale.z)/3),u=h*h,c=new re,C=new re,B=new re,p=new re,w=this.isLineSegments?2:1,k=A.index,R=A.attributes.position;if(k!==null)for(let _=Math.max(0,g.start),N=Math.min(k.count,g.start+g.count)-1;_<N;_+=w){const L=k.getX(_),G=k.getX(_+1);if(c.fromBufferAttribute(R,L),C.fromBufferAttribute(R,G),Wh.distanceSqToSegment(c,C,p,B)>u)continue;p.applyMatrix4(this.matrixWorld);const le=e.ray.origin.distanceTo(p);le<e.near||le>e.far||t.push({distance:le,point:B.clone().applyMatrix4(this.matrixWorld),index:_,face:null,faceIndex:null,object:this})}else for(let _=Math.max(0,g.start),N=Math.min(R.count,g.start+g.count)-1;_<N;_+=w){if(c.fromBufferAttribute(R,_),C.fromBufferAttribute(R,_+1),Wh.distanceSqToSegment(c,C,p,B)>u)continue;p.applyMatrix4(this.matrixWorld);const L=e.ray.origin.distanceTo(p);L<e.near||L>e.far||t.push({distance:L,point:B.clone().applyMatrix4(this.matrixWorld),index:_,face:null,faceIndex:null,object:this})}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const A=e[t[0]];if(A!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=A.length;n<r;n++){const g=A[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[g]=n}}}}}const BB=new re,QB=new re;class OS extends Vh{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,A=[];for(let n=0,r=t.count;n<r;n+=2)BB.fromBufferAttribute(t,n),QB.fromBufferAttribute(t,n+1),A[n]=n===0?0:A[n-1],A[n+1]=A[n]+BB.distanceTo(QB);e.setAttribute("lineDistance",new Cn(A,1))}return this}}class KS extends Vh{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class fB extends Sn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new rA(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const pB=new xA,Zh=new Lo,zl=new Ur,ql=new re;class zS extends gi{constructor(e=new bn,t=new fB){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const A=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,g=A.drawRange;if(A.boundingSphere===null&&A.computeBoundingSphere(),zl.copy(A.boundingSphere),zl.applyMatrix4(n),zl.radius+=r,e.ray.intersectsSphere(zl)===!1)return;pB.copy(n).invert(),Zh.copy(e.ray).applyMatrix4(pB);const h=r/((this.scale.x+this.scale.y+this.scale.z)/3),u=h*h,c=A.index,C=A.attributes.position;if(c!==null)for(let B=Math.max(0,g.start),p=Math.min(c.count,g.start+g.count);B<p;B++){const w=c.getX(B);ql.fromBufferAttribute(C,w),mB(ql,w,u,n,e,t,this)}else for(let B=Math.max(0,g.start),p=Math.min(C.count,g.start+g.count);B<p;B++)ql.fromBufferAttribute(C,B),mB(ql,B,u,n,e,t,this)}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const A=e[t[0]];if(A!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=A.length;n<r;n++){const g=A[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[g]=n}}}}}function mB(o,e,t,A,n,r,g){const h=Zh.distanceSqToPoint(o);if(h<t){const u=new re;Zh.closestPointToPoint(o,u),u.applyMatrix4(A);const c=n.ray.origin.distanceTo(u);if(c<n.near||c>n.far)return;r.push({distance:c,distanceToRay:Math.sqrt(h),point:u,index:e,face:null,object:g})}}class wB extends Di{constructor(e,t,A,n,r,g,h,u,c){super(e,t,A,n,r,g,h,u,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Wl extends bn{constructor(e=1,t=32,A=16,n=0,r=2*Math.PI,g=0,h=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:A,phiStart:n,phiLength:r,thetaStart:g,thetaLength:h},t=Math.max(3,Math.floor(t)),A=Math.max(2,Math.floor(A));const u=Math.min(g+h,Math.PI);let c=0;const C=[],B=new re,p=new re,w=[],k=[],R=[],_=[];for(let N=0;N<=A;N++){const L=[],G=N/A;let le=0;N===0&&g===0?le=.5/t:N===A&&u===Math.PI&&(le=-.5/t);for(let ne=0;ne<=t;ne++){const Ae=ne/t;B.x=-e*Math.cos(n+Ae*r)*Math.sin(g+G*h),B.y=e*Math.cos(g+G*h),B.z=e*Math.sin(n+Ae*r)*Math.sin(g+G*h),k.push(B.x,B.y,B.z),p.copy(B).normalize(),R.push(p.x,p.y,p.z),_.push(Ae+le,1-G),L.push(c++)}C.push(L)}for(let N=0;N<A;N++)for(let L=0;L<t;L++){const G=C[N][L+1],le=C[N][L],ne=C[N+1][L],Ae=C[N+1][L+1];(N!==0||g>0)&&w.push(G,le,Ae),(N!==A-1||u<Math.PI)&&w.push(le,ne,Ae)}this.setIndex(w),this.setAttribute("position",new Cn(k,3)),this.setAttribute("normal",new Cn(R,3)),this.setAttribute("uv",new Cn(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Wl(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Ys extends Sn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new rA(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new rA(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Ps extends Ys{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Gt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return yA(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new rA(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new rA(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new rA(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._iridescence=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}function ds(o,e,t){return yB(o)?new o.constructor(o.subarray(e,t!==void 0?t:o.length)):o.slice(e,t)}function Vl(o,e,t){return!o||o.constructor===e?o:typeof e.BYTES_PER_ELEMENT=="number"?new e(o):Array.prototype.slice.call(o)}function yB(o){return ArrayBuffer.isView(o)&&!(o instanceof DataView)}function qS(o){const e=o.length,t=new Array(e);for(let A=0;A!==e;++A)t[A]=A;return t.sort((function(A,n){return o[A]-o[n]})),t}function vB(o,e,t){const A=o.length,n=new o.constructor(A);for(let r=0,g=0;g!==A;++r){const h=t[r]*e;for(let u=0;u!==e;++u)n[g++]=o[h+u]}return n}function DB(o,e,t,A){let n=1,r=o[0];for(;r!==void 0&&r[A]===void 0;)r=o[n++];if(r===void 0)return;let g=r[A];if(g!==void 0)if(Array.isArray(g))do g=r[A],g!==void 0&&(e.push(r.time),t.push.apply(t,g)),r=o[n++];while(r!==void 0);else if(g.toArray!==void 0)do g=r[A],g!==void 0&&(e.push(r.time),g.toArray(t,t.length)),r=o[n++];while(r!==void 0);else do g=r[A],g!==void 0&&(e.push(r.time),t.push(g)),r=o[n++];while(r!==void 0)}class zo{constructor(e,t,A,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new t.constructor(A),this.sampleValues=t,this.valueSize=A,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let A=this._cachedIndex,n=t[A],r=t[A-1];e:{t:{let g;A:{i:if(!(e<n)){for(let h=A+2;;){if(n===void 0){if(e<r)break i;return A=t.length,this._cachedIndex=A,this.copySampleValue_(A-1)}if(A===h)break;if(r=n,n=t[++A],e<n)break t}g=t.length;break A}if(e>=r)break e;{const h=t[1];e<h&&(A=2,r=h);for(let u=A-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(A===u)break;if(n=r,r=t[--A-1],e>=r)break t}g=A,A=0}}for(;A<g;){const h=A+g>>>1;e<t[h]?g=h:A=h+1}if(n=t[A],r=t[A-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return A=t.length,this._cachedIndex=A,this.copySampleValue_(A-1)}this._cachedIndex=A,this.intervalChanged_(A,r,n)}return this.interpolate_(A,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,A=this.sampleValues,n=this.valueSize,r=e*n;for(let g=0;g!==n;++g)t[g]=A[r+g];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class WS extends zo{constructor(e,t,A,n){super(e,t,A,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:At,endingEnd:At}}intervalChanged_(e,t,A){const n=this.parameterPositions;let r=e-2,g=e+1,h=n[r],u=n[g];if(h===void 0)switch(this.getSettings_().endingStart){case at:r=e,h=2*t-A;break;case Dt:r=n.length-2,h=t+n[r]-n[r+1];break;default:r=e,h=A}if(u===void 0)switch(this.getSettings_().endingEnd){case at:g=e,u=2*A-t;break;case Dt:g=1,u=A+n[1]-n[0];break;default:g=e-1,u=t}const c=.5*(A-t),C=this.valueSize;this._weightPrev=c/(t-h),this._weightNext=c/(u-A),this._offsetPrev=r*C,this._offsetNext=g*C}interpolate_(e,t,A,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=e*h,c=u-h,C=this._offsetPrev,B=this._offsetNext,p=this._weightPrev,w=this._weightNext,k=(A-t)/(n-t),R=k*k,_=R*k,N=-p*_+2*p*R-p*k,L=(1+p)*_+(-1.5-2*p)*R+(-.5+p)*k+1,G=(-1-w)*_+(1.5+w)*R+.5*k,le=w*_-w*R;for(let ne=0;ne!==h;++ne)r[ne]=N*g[C+ne]+L*g[c+ne]+G*g[u+ne]+le*g[B+ne];return r}}class MB extends zo{constructor(e,t,A,n){super(e,t,A,n)}interpolate_(e,t,A,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=e*h,c=u-h,C=(A-t)/(n-t),B=1-C;for(let p=0;p!==h;++p)r[p]=g[c+p]*B+g[u+p]*C;return r}}class VS extends zo{constructor(e,t,A,n){super(e,t,A,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class Qr{constructor(e,t,A,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Vl(t,this.TimeBufferType),this.values=Vl(A,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let A;if(t.toJSON!==this.toJSON)A=t.toJSON(e);else{A={name:e.name,times:Vl(e.times,Array),values:Vl(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(A.interpolation=n)}return A.type=e.ValueTypeName,A}InterpolantFactoryMethodDiscrete(e){return new VS(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new MB(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new WS(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ue:t=this.InterpolantFactoryMethodDiscrete;break;case Oe:t=this.InterpolantFactoryMethodLinear;break;case Ke:t=this.InterpolantFactoryMethodSmooth}if(t===void 0){const A="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0){if(e===this.DefaultInterpolation)throw new Error(A);this.setInterpolation(this.DefaultInterpolation)}return this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ue;case this.InterpolantFactoryMethodLinear:return Oe;case this.InterpolantFactoryMethodSmooth:return Ke}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let A=0,n=t.length;A!==n;++A)t[A]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let A=0,n=t.length;A!==n;++A)t[A]*=e}return this}trim(e,t){const A=this.times,n=A.length;let r=0,g=n-1;for(;r!==n&&A[r]<e;)++r;for(;g!==-1&&A[g]>t;)--g;if(++g,r!==0||g!==n){r>=g&&(g=Math.max(g,1),r=g-1);const h=this.getValueSize();this.times=ds(A,r,g),this.values=ds(this.values,r*h,g*h)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(e=!1);const A=this.times,n=this.values,r=A.length;r===0&&(e=!1);let g=null;for(let h=0;h!==r;h++){const u=A[h];if(typeof u=="number"&&isNaN(u)){e=!1;break}if(g!==null&&g>u){e=!1;break}g=u}if(n!==void 0&&yB(n))for(let h=0,u=n.length;h!==u;++h){const c=n[h];if(isNaN(c)){e=!1;break}}return e}optimize(){const e=ds(this.times),t=ds(this.values),A=this.getValueSize(),n=this.getInterpolation()===Ke,r=e.length-1;let g=1;for(let h=1;h<r;++h){let u=!1;const c=e[h];if(c!==e[h+1]&&(h!==1||c!==e[0]))if(n)u=!0;else{const C=h*A,B=C-A,p=C+A;for(let w=0;w!==A;++w){const k=t[C+w];if(k!==t[B+w]||k!==t[p+w]){u=!0;break}}}if(u){if(h!==g){e[g]=e[h];const C=h*A,B=g*A;for(let p=0;p!==A;++p)t[B+p]=t[C+p]}++g}}if(r>0){e[g]=e[r];for(let h=r*A,u=g*A,c=0;c!==A;++c)t[u+c]=t[h+c];++g}return g!==e.length?(this.times=ds(e,0,g),this.values=ds(t,0,g*A)):(this.times=e,this.values=t),this}clone(){const e=ds(this.times,0),t=ds(this.values,0),A=new this.constructor(this.name,e,t);return A.createInterpolant=this.createInterpolant,A}}Qr.prototype.TimeBufferType=Float32Array,Qr.prototype.ValueBufferType=Float32Array,Qr.prototype.DefaultInterpolation=Oe;class Ua extends Qr{}Ua.prototype.ValueTypeName="bool",Ua.prototype.ValueBufferType=Array,Ua.prototype.DefaultInterpolation=Ue,Ua.prototype.InterpolantFactoryMethodLinear=void 0,Ua.prototype.InterpolantFactoryMethodSmooth=void 0;class SB extends Qr{}SB.prototype.ValueTypeName="color";class qo extends Qr{}qo.prototype.ValueTypeName="number";class ZS extends zo{constructor(e,t,A,n){super(e,t,A,n)}interpolate_(e,t,A,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=(A-t)/(n-t);let c=e*h;for(let C=c+h;c!==C;c+=4)Ui.slerpFlat(r,0,g,c-h,g,c,u);return r}}class Os extends Qr{InterpolantFactoryMethodLinear(e){return new ZS(this.times,this.values,this.getValueSize(),e)}}Os.prototype.ValueTypeName="quaternion",Os.prototype.DefaultInterpolation=Oe,Os.prototype.InterpolantFactoryMethodSmooth=void 0;class Ta extends Qr{}Ta.prototype.ValueTypeName="string",Ta.prototype.ValueBufferType=Array,Ta.prototype.DefaultInterpolation=Ue,Ta.prototype.InterpolantFactoryMethodLinear=void 0,Ta.prototype.InterpolantFactoryMethodSmooth=void 0;class Wo extends Qr{}Wo.prototype.ValueTypeName="vector";class jh{constructor(e,t=-1,A,n=2500){this.name=e,this.tracks=A,this.duration=t,this.blendMode=n,this.uuid=AA(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],A=e.tracks,n=1/(e.fps||1);for(let g=0,h=A.length;g!==h;++g)t.push(jS(A[g]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],A=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,g=A.length;r!==g;++r)t.push(Qr.toJSON(A[r]));return n}static CreateFromMorphTargetSequence(e,t,A,n){const r=t.length,g=[];for(let h=0;h<r;h++){let u=[],c=[];u.push((h+r-1)%r,h,(h+1)%r),c.push(0,1,0);const C=qS(u);u=vB(u,1,C),c=vB(c,1,C),n||u[0]!==0||(u.push(r),c.push(c[0])),g.push(new qo(".morphTargetInfluences["+t[h].name+"]",u,c).scale(1/A))}return new this(e,-1,g)}static findByName(e,t){let A=e;if(!Array.isArray(e)){const n=e;A=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<A.length;n++)if(A[n].name===t)return A[n];return null}static CreateClipsFromMorphTargetSequences(e,t,A){const n={},r=/^([\w-]*?)([\d]+)$/;for(let h=0,u=e.length;h<u;h++){const c=e[h],C=c.name.match(r);if(C&&C.length>1){const B=C[1];let p=n[B];p||(n[B]=p=[]),p.push(c)}}const g=[];for(const h in n)g.push(this.CreateFromMorphTargetSequence(h,n[h],t,A));return g}static parseAnimation(e,t){if(!e)return null;const A=function(C,B,p,w,k){if(p.length!==0){const R=[],_=[];DB(p,R,_,w),R.length!==0&&k.push(new C(B,R,_))}},n=[],r=e.name||"default",g=e.fps||30,h=e.blendMode;let u=e.length||-1;const c=e.hierarchy||[];for(let C=0;C<c.length;C++){const B=c[C].keys;if(B&&B.length!==0)if(B[0].morphTargets){const p={};let w;for(w=0;w<B.length;w++)if(B[w].morphTargets)for(let k=0;k<B[w].morphTargets.length;k++)p[B[w].morphTargets[k]]=-1;for(const k in p){const R=[],_=[];for(let N=0;N!==B[w].morphTargets.length;++N){const L=B[w];R.push(L.time),_.push(L.morphTarget===k?1:0)}n.push(new qo(".morphTargetInfluence["+k+"]",R,_))}u=p.length*g}else{const p=".bones["+t[C].name+"]";A(Wo,p+".position",B,"pos",n),A(Os,p+".quaternion",B,"rot",n),A(Wo,p+".scale",B,"scl",n)}}return n.length===0?null:new this(r,u,n,h)}resetDuration(){let e=0;for(let t=0,A=this.tracks.length;t!==A;++t){const n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function jS(o){if(o.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=(function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return qo;case"vector":case"vector2":case"vector3":case"vector4":return Wo;case"color":return SB;case"quaternion":return Os;case"bool":case"boolean":return Ua;case"string":return Ta}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)})(o.type);if(o.times===void 0){const t=[],A=[];DB(o.keys,t,A,"value"),o.times=t,o.values=A}return e.parse!==void 0?e.parse(o):new e(o.name,o.times,o.values,o.interpolation)}const Ha={enabled:!1,files:{},add:function(o,e){this.enabled!==!1&&(this.files[o]=e)},get:function(o){if(this.enabled!==!1)return this.files[o]},remove:function(o){delete this.files[o]},clear:function(){this.files={}}};class XS{constructor(e,t,A){const n=this;let r,g=!1,h=0,u=0;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=A,this.itemStart=function(C){u++,g===!1&&n.onStart!==void 0&&n.onStart(C,h,u),g=!0},this.itemEnd=function(C){h++,n.onProgress!==void 0&&n.onProgress(C,h,u),h===u&&(g=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(C){n.onError!==void 0&&n.onError(C)},this.resolveURL=function(C){return r?r(C):C},this.setURLModifier=function(C){return r=C,this},this.addHandler=function(C,B){return c.push(C,B),this},this.removeHandler=function(C){const B=c.indexOf(C);return B!==-1&&c.splice(B,2),this},this.getHandler=function(C){for(let B=0,p=c.length;B<p;B+=2){const w=c[B],k=c[B+1];if(w.global&&(w.lastIndex=0),w.test(C))return k}return null}}}const $S=new XS;class Ja{constructor(e){this.manager=e!==void 0?e:$S,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const A=this;return new Promise((function(n,r){A.load(e,n,t,r)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}const Or={};class ex extends Error{constructor(e,t){super(e),this.response=t}}class Xh extends Ja{constructor(e){super(e)}load(e,t,A,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Ha.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout((()=>{t&&t(r),this.manager.itemEnd(e)}),0),r;if(Or[e]!==void 0)return void Or[e].push({onLoad:t,onProgress:A,onError:n});Or[e]=[],Or[e].push({onLoad:t,onProgress:A,onError:n});const g=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),h=this.mimeType,u=this.responseType;fetch(g).then((c=>{if(c.status===200||c.status===0){if(c.status,typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const C=Or[e],B=c.body.getReader(),p=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),w=p?parseInt(p):0,k=w!==0;let R=0;const _=new ReadableStream({start(N){(function L(){B.read().then((({done:G,value:le})=>{if(G)N.close();else{R+=le.byteLength;const ne=new ProgressEvent("progress",{lengthComputable:k,loaded:R,total:w});for(let Ae=0,te=C.length;Ae<te;Ae++){const ye=C[Ae];ye.onProgress&&ye.onProgress(ne)}N.enqueue(le),L()}}))})()}});return new Response(_)}throw new ex(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)})).then((c=>{switch(u){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((C=>new DOMParser().parseFromString(C,h)));case"json":return c.json();default:if(h===void 0)return c.text();{const C=/charset="?([^;"\s]*)"?/i.exec(h),B=C&&C[1]?C[1].toLowerCase():void 0,p=new TextDecoder(B);return c.arrayBuffer().then((w=>p.decode(w)))}}})).then((c=>{Ha.add(e,c);const C=Or[e];delete Or[e];for(let B=0,p=C.length;B<p;B++){const w=C[B];w.onLoad&&w.onLoad(c)}})).catch((c=>{const C=Or[e];if(C===void 0)throw this.manager.itemError(e),c;delete Or[e];for(let B=0,p=C.length;B<p;B++){const w=C[B];w.onError&&w.onError(c)}this.manager.itemError(e)})).finally((()=>{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class tx extends Ja{constructor(e){super(e)}load(e,t,A,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,g=Ha.get(e);if(g!==void 0)return r.manager.itemStart(e),setTimeout((function(){t&&t(g),r.manager.itemEnd(e)}),0),g;const h=wn("img");function u(){C(),Ha.add(e,this),t&&t(this),r.manager.itemEnd(e)}function c(B){C(),n&&n(B),r.manager.itemError(e),r.manager.itemEnd(e)}function C(){h.removeEventListener("load",u,!1),h.removeEventListener("error",c,!1)}return h.addEventListener("load",u,!1),h.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(h.crossOrigin=this.crossOrigin),r.manager.itemStart(e),h.src=e,h}}class Ax extends Ja{constructor(e){super(e)}load(e,t,A,n){const r=this,g=new Cs,h=new Xh(this.manager);return h.setResponseType("arraybuffer"),h.setRequestHeader(this.requestHeader),h.setPath(this.path),h.setWithCredentials(r.withCredentials),h.load(e,(function(u){const c=r.parse(u);c&&(c.image!==void 0?g.image=c.image:c.data!==void 0&&(g.image.width=c.width,g.image.height=c.height,g.image.data=c.data),g.wrapS=c.wrapS!==void 0?c.wrapS:ee,g.wrapT=c.wrapT!==void 0?c.wrapT:ee,g.magFilter=c.magFilter!==void 0?c.magFilter:Qe,g.minFilter=c.minFilter!==void 0?c.minFilter:Qe,g.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0?g.colorSpace=c.colorSpace:c.encoding!==void 0&&(g.encoding=c.encoding),c.flipY!==void 0&&(g.flipY=c.flipY),c.format!==void 0&&(g.format=c.format),c.type!==void 0&&(g.type=c.type),c.mipmaps!==void 0&&(g.mipmaps=c.mipmaps,g.minFilter=se),c.mipmapCount===1&&(g.minFilter=Qe),c.generateMipmaps!==void 0&&(g.generateMipmaps=c.generateMipmaps),g.needsUpdate=!0,t&&t(g,c))}),A,n),g}}class Ya extends Ja{constructor(e){super(e)}load(e,t,A,n){const r=new Di,g=new tx(this.manager);return g.setCrossOrigin(this.crossOrigin),g.setPath(this.path),g.load(e,(function(h){r.image=h,r.needsUpdate=!0,t!==void 0&&t(r)}),A,n),r}}class Zl extends gi{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new rA(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}const $h=new xA,xB=new re,bB=new re;class eI{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Gt(512,512),this.map=null,this.mapPass=null,this.matrix=new xA,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Th,this._frameExtents=new Gt(1,1),this._viewportCount=1,this._viewports=[new zA(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,A=this.matrix;xB.setFromMatrixPosition(e.matrixWorld),t.position.copy(xB),bB.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(bB),t.updateMatrixWorld(),$h.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix($h),A.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),A.multiply($h)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),this.mapSize.x===512&&this.mapSize.y===512||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class ix extends eI{constructor(){super(new Zi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,A=2*RA*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;A===t.fov&&n===t.aspect&&r===t.far||(t.fov=A,t.aspect=n,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class nx extends Zl{constructor(e,t,A=0,n=Math.PI/3,r=0,g=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gi.DEFAULT_UP),this.updateMatrix(),this.target=new gi,this.distance=A,this.angle=n,this.penumbra=r,this.decay=g,this.map=null,this.shadow=new ix}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const _B=new xA,Vo=new re,tI=new re;class rx extends eI{constructor(){super(new Zi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Gt(4,2),this._viewportCount=6,this._viewports=[new zA(2,1,1,1),new zA(0,1,1,1),new zA(3,1,1,1),new zA(1,1,1,1),new zA(3,0,1,1),new zA(1,0,1,1)],this._cubeDirections=[new re(1,0,0),new re(-1,0,0),new re(0,0,1),new re(0,0,-1),new re(0,1,0),new re(0,-1,0)],this._cubeUps=[new re(0,1,0),new re(0,1,0),new re(0,1,0),new re(0,1,0),new re(0,0,1),new re(0,0,-1)]}updateMatrices(e,t=0){const A=this.camera,n=this.matrix,r=e.distance||A.far;r!==A.far&&(A.far=r,A.updateProjectionMatrix()),Vo.setFromMatrixPosition(e.matrixWorld),A.position.copy(Vo),tI.copy(A.position),tI.add(this._cubeDirections[t]),A.up.copy(this._cubeUps[t]),A.lookAt(tI),A.updateMatrixWorld(),n.makeTranslation(-Vo.x,-Vo.y,-Vo.z),_B.multiplyMatrices(A.projectionMatrix,A.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_B)}}class sx extends Zl{constructor(e,t,A=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=A,this.decay=n,this.shadow=new rx}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class ax extends eI{constructor(){super(new _n(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class RB extends Zl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gi.DEFAULT_UP),this.updateMatrix(),this.target=new gi,this.shadow=new ax}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class ox extends Zl{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class AI{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let A=0,n=e.length;A<n;A++)t+=String.fromCharCode(e[A]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class gx extends Ja{constructor(e){super(e),this.isImageBitmapLoader=!0,this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,A,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,g=Ha.get(e);if(g!==void 0)return r.manager.itemStart(e),setTimeout((function(){t&&t(g),r.manager.itemEnd(e)}),0),g;const h={};h.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",h.headers=this.requestHeader,fetch(e,h).then((function(u){return u.blob()})).then((function(u){return createImageBitmap(u,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(u){Ha.add(e,u),t&&t(u),r.manager.itemEnd(e)})).catch((function(u){n&&n(u),r.manager.itemError(e),r.manager.itemEnd(e)})),r.manager.itemStart(e)}}class lx{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=NB(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=NB();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function NB(){return(typeof performance>"u"?Date:performance).now()}class cx{constructor(e,t,A){let n,r,g;switch(this.binding=e,this.valueSize=A,t){case"quaternion":n=this._slerp,r=this._slerpAdditive,g=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*A),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,g=this._setAdditiveIdentityOther,this.buffer=new Array(5*A);break;default:n=this._lerp,r=this._lerpAdditive,g=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*A)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=g,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const A=this.buffer,n=this.valueSize,r=e*n+n;let g=this.cumulativeWeight;if(g===0){for(let h=0;h!==n;++h)A[r+h]=A[h];g=t}else{g+=t;const h=t/g;this._mixBufferRegion(A,r,0,h,n)}this.cumulativeWeight=g}accumulateAdditive(e){const t=this.buffer,A=this.valueSize,n=A*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,A),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,A=this.buffer,n=e*t+t,r=this.cumulativeWeight,g=this.cumulativeWeightAdditive,h=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const u=t*this._origIndex;this._mixBufferRegion(A,n,u,1-r,t)}g>0&&this._mixBufferRegionAdditive(A,n,this._addIndex*t,1,t);for(let u=t,c=t+t;u!==c;++u)if(A[u]!==A[u+t]){h.setValue(A,n);break}}saveOriginalState(){const e=this.binding,t=this.buffer,A=this.valueSize,n=A*this._origIndex;e.getValue(t,n);for(let r=A,g=n;r!==g;++r)t[r]=t[n+r%A];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let A=e;A<t;A++)this.buffer[A]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let A=0;A<this.valueSize;A++)this.buffer[t+A]=this.buffer[e+A]}_select(e,t,A,n,r){if(n>=.5)for(let g=0;g!==r;++g)e[t+g]=e[A+g]}_slerp(e,t,A,n){Ui.slerpFlat(e,t,e,t,e,A,n)}_slerpAdditive(e,t,A,n,r){const g=this._workIndex*r;Ui.multiplyQuaternionsFlat(e,g,e,t,e,A),Ui.slerpFlat(e,t,e,t,e,g,n)}_lerp(e,t,A,n,r){const g=1-n;for(let h=0;h!==r;++h){const u=t+h;e[u]=e[u]*g+e[A+h]*n}}_lerpAdditive(e,t,A,n,r){for(let g=0;g!==r;++g){const h=t+g;e[h]=e[h]+e[A+g]*n}}}const iI="\\[\\]\\.:\\/",hx=new RegExp("["+iI+"]","g"),nI="[^"+iI+"]",Ix="[^"+iI.replace("\\.","")+"]",ux=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",nI)+/(WCOD+)?/.source.replace("WCOD",Ix)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",nI)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",nI)+"$"),Cx=["material","materials","bones","map"];class ZA{constructor(e,t,A){this.path=t,this.parsedPath=A||ZA.parseTrackName(t),this.node=ZA.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,A){return e&&e.isAnimationObjectGroup?new ZA.Composite(e,t,A):new ZA(e,t,A)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(hx,"")}static parseTrackName(e){const t=ux.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const A={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=A.nodeName&&A.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const r=A.nodeName.substring(n+1);Cx.indexOf(r)!==-1&&(A.nodeName=A.nodeName.substring(0,n),A.objectName=r)}if(A.propertyName===null||A.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return A}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const A=e.skeleton.getBoneByName(t);if(A!==void 0)return A}if(e.children){const A=function(r){for(let g=0;g<r.length;g++){const h=r[g];if(h.name===t||h.uuid===t)return h;const u=A(h.children);if(u)return u}return null},n=A(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const A=this.resolvedProperty;for(let n=0,r=A.length;n!==r;++n)e[t++]=A[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const A=this.resolvedProperty;for(let n=0,r=A.length;n!==r;++n)A[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const A=this.resolvedProperty;for(let n=0,r=A.length;n!==r;++n)A[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const A=this.resolvedProperty;for(let n=0,r=A.length;n!==r;++n)A[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,A=t.objectName,n=t.propertyName;let r=t.propertyIndex;if(e||(e=ZA.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void this.path;if(A){let c=t.objectIndex;switch(A){case"materials":if(!e.material||!e.material.materials)return;e=e.material.materials;break;case"bones":if(!e.skeleton)return;e=e.skeleton.bones;for(let C=0;C<e.length;C++)if(e[C].name===c){c=C;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material||!e.material.map)return;e=e.material.map;break;default:if(e[A]===void 0)return;e=e[A]}if(c!==void 0){if(e[c]===void 0)return;e=e[c]}}const g=e[n];if(g===void 0){t.nodeName;return}let h=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?h=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(h=this.Versioning.MatrixWorldNeedsUpdate);let u=this.BindingType.Direct;if(r!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry||!e.geometry.morphAttributes)return;e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}u=this.BindingType.ArrayElement,this.resolvedProperty=g,this.propertyIndex=r}else g.fromArray!==void 0&&g.toArray!==void 0?(u=this.BindingType.HasFromToArray,this.resolvedProperty=g):Array.isArray(g)?(u=this.BindingType.EntireArray,this.resolvedProperty=g):this.propertyName=n;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][h]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ZA.Composite=class{constructor(o,e,t){const A=t||ZA.parseTrackName(e);this._targetGroup=o,this._bindings=o.subscribe_(e,A)}getValue(o,e){this.bind();const t=this._targetGroup.nCachedObjects_,A=this._bindings[t];A!==void 0&&A.getValue(o,e)}setValue(o,e){const t=this._bindings;for(let A=this._targetGroup.nCachedObjects_,n=t.length;A!==n;++A)t[A].setValue(o,e)}bind(){const o=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=o.length;e!==t;++e)o[e].bind()}unbind(){const o=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=o.length;e!==t;++e)o[e].unbind()}},ZA.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},ZA.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},ZA.prototype.GetterByBindingType=[ZA.prototype._getValue_direct,ZA.prototype._getValue_array,ZA.prototype._getValue_arrayElement,ZA.prototype._getValue_toArray],ZA.prototype.SetterByBindingTypeAndVersioning=[[ZA.prototype._setValue_direct,ZA.prototype._setValue_direct_setNeedsUpdate,ZA.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ZA.prototype._setValue_array,ZA.prototype._setValue_array_setNeedsUpdate,ZA.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ZA.prototype._setValue_arrayElement,ZA.prototype._setValue_arrayElement_setNeedsUpdate,ZA.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ZA.prototype._setValue_fromArray,ZA.prototype._setValue_fromArray_setNeedsUpdate,ZA.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class dx{constructor(e,t,A=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=A,this.blendMode=n;const r=t.tracks,g=r.length,h=new Array(g),u={endingStart:At,endingEnd:At};for(let c=0;c!==g;++c){const C=r[c].createInterpolant(null);h[c]=C,C.settings=u}this._interpolantSettings=u,this._interpolants=h,this._propertyBindings=new Array(g),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,A){if(e.fadeOut(t),this.fadeIn(t),A){const n=this._clip.duration,r=e._clip.duration,g=r/n,h=n/r;e.warp(1,g,t),this.warp(h,1,t)}return this}crossFadeTo(e,t,A){return e.crossFadeFrom(this,t,A)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,A){const n=this._mixer,r=n.time,g=this.timeScale;let h=this._timeScaleInterpolant;h===null&&(h=n._lendControlInterpolant(),this._timeScaleInterpolant=h);const u=h.parameterPositions,c=h.sampleValues;return u[0]=r,u[1]=r+A,c[0]=e/g,c[1]=t/g,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,A,n){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(r!==null){const u=(e-r)*A;u<0||A===0?t=0:(this._startTime=null,t=A*u)}t*=this._updateTimeScale(e);const g=this._updateTime(t),h=this._updateWeight(e);if(h>0){const u=this._interpolants,c=this._propertyBindings;if(this.blendMode===2501)for(let C=0,B=u.length;C!==B;++C)u[C].evaluate(g),c[C].accumulateAdditive(h);else for(let C=0,B=u.length;C!==B;++C)u[C].evaluate(g),c[C].accumulate(n,h)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const A=this._weightInterpolant;if(A!==null){const n=A.evaluate(e)[0];t*=n,e>A.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const A=this._timeScaleInterpolant;A!==null&&(t*=A.evaluate(e)[0],e>A.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,A=this.loop;let n=this.time+e,r=this._loopCount;const g=A===2202;if(e===0)return r===-1?n:g&&(1&r)==1?t-n:n;if(A===2200){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else{if(!(n<0)){this.time=n;break e}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,g)):this._setEndings(this.repetitions===0,!0,g)),n>=t||n<0){const h=Math.floor(n/t);n-=t*h,r+=Math.abs(h);const u=this.repetitions-r;if(u<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(u===1){const c=e<0;this._setEndings(c,!c,g)}else this._setEndings(!1,!1,g);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:h})}}else this.time=n;if(g&&(1&r)==1)return t-n}return n}_setEndings(e,t,A){const n=this._interpolantSettings;A?(n.endingStart=at,n.endingEnd=at):(n.endingStart=e?this.zeroSlopeAtStart?at:At:Dt,n.endingEnd=t?this.zeroSlopeAtEnd?at:At:Dt)}_scheduleFading(e,t,A){const n=this._mixer,r=n.time;let g=this._weightInterpolant;g===null&&(g=n._lendControlInterpolant(),this._weightInterpolant=g);const h=g.parameterPositions,u=g.sampleValues;return h[0]=r,u[0]=t,h[1]=r+e,u[1]=A,this}}const Ex=new Float32Array(1);class Bx extends ut{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const A=e._localRoot||this._root,n=e._clip.tracks,r=n.length,g=e._propertyBindings,h=e._interpolants,u=A.uuid,c=this._bindingsByRootAndName;let C=c[u];C===void 0&&(C={},c[u]=C);for(let B=0;B!==r;++B){const p=n[B],w=p.name;let k=C[w];if(k!==void 0)++k.referenceCount,g[B]=k;else{if(k=g[B],k!==void 0){k._cacheIndex===null&&(++k.referenceCount,this._addInactiveBinding(k,u,w));continue}const R=t&&t._propertyBindings[B].binding.parsedPath;k=new cx(ZA.create(A,w,R),p.ValueTypeName,p.getValueSize()),++k.referenceCount,this._addInactiveBinding(k,u,w),g[B]=k}h[B].resultBuffer=k.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const A=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,A)}const t=e._propertyBindings;for(let A=0,n=t.length;A!==n;++A){const r=t[A];r.useCount++==0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let A=0,n=t.length;A!==n;++A){const r=t[A];--r.useCount==0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,A){const n=this._actions,r=this._actionsByClip;let g=r[t];if(g===void 0)g={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=g;else{const h=g.knownActions;e._byClipCacheIndex=h.length,h.push(e)}e._cacheIndex=n.length,n.push(e),g.actionByRoot[A]=e}_removeInactiveAction(e){const t=this._actions,A=t[t.length-1],n=e._cacheIndex;A._cacheIndex=n,t[n]=A,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,g=this._actionsByClip,h=g[r],u=h.knownActions,c=u[u.length-1],C=e._byClipCacheIndex;c._byClipCacheIndex=C,u[C]=c,u.pop(),e._byClipCacheIndex=null,delete h.actionByRoot[(e._localRoot||this._root).uuid],u.length===0&&delete g[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let A=0,n=t.length;A!==n;++A){const r=t[A];--r.referenceCount==0&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,A=e._cacheIndex,n=this._nActiveActions++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=A,t[A]=r}_takeBackAction(e){const t=this._actions,A=e._cacheIndex,n=--this._nActiveActions,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=A,t[A]=r}_addInactiveBinding(e,t,A){const n=this._bindingsByRootAndName,r=this._bindings;let g=n[t];g===void 0&&(g={},n[t]=g),g[A]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,A=e.binding,n=A.rootNode.uuid,r=A.path,g=this._bindingsByRootAndName,h=g[n],u=t[t.length-1],c=e._cacheIndex;u._cacheIndex=c,t[c]=u,t.pop(),delete h[r],Object.keys(h).length===0&&delete g[n]}_lendBinding(e){const t=this._bindings,A=e._cacheIndex,n=this._nActiveBindings++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=A,t[A]=r}_takeBackBinding(e){const t=this._bindings,A=e._cacheIndex,n=--this._nActiveBindings,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=A,t[A]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let A=e[t];return A===void 0&&(A=new MB(new Float32Array(2),new Float32Array(2),1,Ex),A.__cacheIndex=t,e[t]=A),A}_takeBackControlInterpolant(e){const t=this._controlInterpolants,A=e.__cacheIndex,n=--this._nActiveControlInterpolants,r=t[n];e.__cacheIndex=n,t[n]=e,r.__cacheIndex=A,t[A]=r}clipAction(e,t,A){const n=t||this._root,r=n.uuid;let g=typeof e=="string"?jh.findByName(n,e):e;const h=g!==null?g.uuid:e,u=this._actionsByClip[h];let c=null;if(A===void 0&&(A=g!==null?g.blendMode:yt),u!==void 0){const B=u.actionByRoot[r];if(B!==void 0&&B.blendMode===A)return B;c=u.knownActions[0],g===null&&(g=c._clip)}if(g===null)return null;const C=new dx(this,g,t,A);return this._bindAction(C,c),this._addInactiveAction(C,h,r),C}existingAction(e,t){const A=t||this._root,n=A.uuid,r=typeof e=="string"?jh.findByName(A,e):e,g=r?r.uuid:e,h=this._actionsByClip[g];return h!==void 0&&h.actionByRoot[n]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,A=this._nActiveActions,n=this.time+=e,r=Math.sign(e),g=this._accuIndex^=1;for(let c=0;c!==A;++c)t[c]._update(n,e,r,g);const h=this._bindings,u=this._nActiveBindings;for(let c=0;c!==u;++c)h[c].apply(g);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,A=e.uuid,n=this._actionsByClip,r=n[A];if(r!==void 0){const g=r.knownActions;for(let h=0,u=g.length;h!==u;++h){const c=g[h];this._deactivateAction(c);const C=c._cacheIndex,B=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,B._cacheIndex=C,t[C]=B,t.pop(),this._removeInactiveBindingsForAction(c)}delete n[A]}}uncacheRoot(e){const t=e.uuid,A=this._actionsByClip;for(const r in A){const g=A[r].actionByRoot[t];g!==void 0&&(this._deactivateAction(g),this._removeInactiveAction(g))}const n=this._bindingsByRootAndName[t];if(n!==void 0)for(const r in n){const g=n[r];g.restoreOriginalState(),this._removeInactiveBinding(g)}}uncacheAction(e,t){const A=this.existingAction(e,t);A!==null&&(this._deactivateAction(A),this._removeInactiveAction(A))}}class Zo{constructor(e,t,A=0,n=1/0){this.ray=new Lo(e,t),this.near=A,this.far=n,this.camera=null,this.layers=new bh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.type}intersectObject(e,t=!0,A=[]){return rI(e,this,A,t),A.sort(kB),A}intersectObjects(e,t=!0,A=[]){for(let n=0,r=e.length;n<r;n++)rI(e[n],this,A,t);return A.sort(kB),A}}function kB(o,e){return o.distance-e.distance}function rI(o,e,t,A){if(o.layers.test(e.layers)&&o.raycast(e,t),A===!0){const n=o.children;for(let r=0,g=n.length;r<g;r++)rI(n[r],e,t,!0)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:E}})),typeof window<"u"&&(window.__THREE__||(window.__THREE__=E));class ae{static isNavigationMarkerPlacementMode(){return ae.NAVIGATION_MARKERS_ADD_MODE||ae.NAVIGATION_MARKERS_ADD_STAIR_UP_MODE||ae.NAVIGATION_MARKERS_ADD_STAIR_DOWN_MODE}static getAspectRatio(){return K.width/K.height}static setSettingValue(e,t){e==="whitePoint"?this.whitePoint.set(t[0],t[1],t[2]):this[e]=t}static getKelvinRGB(e){const A=Math.floor((e-1e3)/1e3),n=A+1;if(A<0)return this.rgbValues[0].clone();if(n>=this.rgbValues.length)return this.rgbValues[this.rgbValues.length-1].clone();const r=(e-(A*1e3+1e3))/1e3;return this.rgbValues[A].clone().lerp(this.rgbValues[n],r)}showPopup(e){const t=document.createElement("div");t.style.position="absolute",t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",t.style.padding="10px",t.style.background="white",t.style.border="1px solid black",t.style.zIndex="1000",t.innerText=e,document.body.appendChild(t),setTimeout((()=>{document.body.removeChild(t)}),3e3)}enableGodMode(){window.addEventListener("keydown",(e=>{const t=new Date().getTime();if(e.key==="Enter")this.lastKeyPressTime=t;else if(this.lastKeyPressTime&&t-this.lastKeyPressTime<2e3){if(e.key==="p"||e.key==="P"){ae.EXPERIMENTAL_WEBASSEMBLY_QHDR_LOADER=!ae.EXPERIMENTAL_WEBASSEMBLY_QHDR_LOADER;const A=ae.EXPERIMENTAL_WEBASSEMBLY_QHDR_LOADER?"ON":"OFF";this.showPopup(`Experimental turboloader: ${A}`)}this.lastKeyPressTime=null}}))}constructor(e){this.enableUpscale=!1,this.lastKeyPressTime=null,ae.isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),ae.isWebGL2=e.capabilities.isWebGL2===!0,ae.hasFloat32Textures=e.extensions.get("OES_texture_float")!==null,ae.VERSION,ae.isWebGL2,ae.hasFloat32Textures,ae.FORCE_16BIT&&(ae.hasFloat32Textures=!1),ae.isMobile,e.getContext(),this.enableGodMode()}}ae.VERSION="QiPlayer v3.5",ae.SHOW_DEBUG=!1,ae.REDIRECT_CONSOLE=!1,ae.SHOW_TESTS=!1,ae.SHOW_DEMO=!1,ae.FORCE_EXR=!1,ae.FORCE_16BIT=!1,ae.EXPERIMENTAL_WEBASSEMBLY_QHDR_LOADER=!0,ae.PROFILE_MEMORY=!1,ae.USE_LOADING_MARKER=!1,ae.SHOW_MARKERS=!1,ae.LOAD_MARKERS_FROM="jsonFile",ae.MARKERS_JSON=void 0,ae.MARKER_SIZE=.05,ae.MARKER_HITBOX_SCALE=2,ae.TONEMAPPER_NONE="NoTonemap",ae.TONEMAPPER_AGX="AgXTonemap",ae.TONEMAPPER_REINHARD="reinhardTonemap",ae.TONEMAPPER_FUSION="fusionTonemap",ae.ACTIVE_TONEMAPPER=ae.TONEMAPPER_AGX,ae.DEFAULT_FOV=90,ae.MIN_FOV=40,ae.MAX_FOV=100,ae.HISTOGRAM_WIDTH=256,ae.HISTOGRAM_HEIGHT=144,ae.MAX_PITCH_ANGLE=60*yi.DEG2RAD,ae.SMOOTHING_FACTOR=.9999,ae.TRANSITION_MOVEMENT_SCALE=1.3,ae.AUTOROTATE=!1,ae.AUTOROTATE_SPEED=1,ae.UNREAL_BLOOM_ENABLED=!0,ae.UNREAL_BLOOOM_STRENGTH=.3,ae.UNREAL_BLOOOM_RADIUS=.5,ae.UNREAL_BLOOOM_THRESHOLD=.99,ae.whitePoint=new re(1,1,1),ae.temperature=6500,ae.lutTexture=void 0,ae.targetLuminance=1,ae.exposureFovScale=.6,ae.dragScale=new Gt(1,1),ae.sharpenFilter_amount=.6,ae.SHOW_ARROW_AND_MARKERS=!0,ae.SHOW_NAVIGATION_MARKERS_ID=!1,ae.NAVIGATION_MARKERS_EDIT_MODE=!1,ae.NAVIGATION_MARKERS_WHITELIST_MODE=!1,ae.NAVIGATION_MARKERS_ADD_MODE=!1,ae.NAVIGATION_MARKERS_ADD_STAIR_UP_MODE=!1,ae.NAVIGATION_MARKERS_ADD_STAIR_DOWN_MODE=!1,ae.NAVIGATION_MARKERS_PLAN_VIEW=!1,ae.NAVIGATION_MARKERS_PLAN_VIEW_PREVIEW_PREVIOUS_SCANS=!1,ae.NAV_MIN_NATURAL_VISIBLE=5,ae.NAV_FALLBACK_COUNT=4,ae.NAV_FALLBACK_DEBUG=!1,ae.NAV_HELPER_MARKER_RGB=[.15,1,.4],ae.rgbValues=[new re(1,.26,0),new re(1,.53,.05),new re(1,.69,.43),new re(1,.8,.65),new re(1,.89,.8),new re(1,.96,.93),new re(.95,.95,1),new re(.87,.9,1),new re(.82,.87,1),new re(.79,.85,1),new re(.76,.84,1),new re(.75,.83,1)];class jl{static linear(e){return e}static easeIn(e){return e*e}static easeOut(e){return e*(2-e)}static easeInOut(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}static bounce(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375}static moveTowards(e,t,A){const n=t-e;return e+(Math.abs(n)<=A?n:Math.sign(n)*A)}static lerpAngleRadians(e,t,A){const n=Math.PI;return e+((t-e+n+2*n)%(2*n)-n)*A}static lerpEuler(e,t,A){const n=new Mn;return n.x=this.lerpAngleRadians(e.x,t.x,A),n.y=this.lerpAngleRadians(e.y,t.y,A),n.z=this.lerpAngleRadians(e.z,t.z,A),n.order=e.order,n}}class Qx{constructor(){this.name="User",this.camera=new Zi,this.camera.rotation.order="YXZ",this.camera.fov=ae.DEFAULT_FOV,this.cameraSmooth=new Zi,this.cameraSmooth.rotation.order=this.camera.rotation.order,this.cameraSmooth.fov=this.camera.fov,this.cameraSmooth.aspect=this.camera.aspect,this.cameraSmooth.far=this.camera.far,this.camera.updateProjectionMatrix(),this.cameraSmooth.updateProjectionMatrix()}setCamera(e){K.userData.siteCamera=e,this.camera.position.copy(e.position),this.camera.rotation.copy(e.rotation),this.cameraSmooth.position.copy(e.position),this.cameraSmooth.rotation.copy(e.rotation)}update(){const e=1-Math.pow(1-ae.SMOOTHING_FACTOR,K.deltaTime);this.cameraSmooth.fov+=(this.camera.fov-this.cameraSmooth.fov)*e;const t=jl.lerpAngleRadians(this.cameraSmooth.rotation.x,this.camera.rotation.x,e),A=jl.lerpAngleRadians(this.cameraSmooth.rotation.y,this.camera.rotation.y,e);this.cameraSmooth.rotation.set(t,A,0),this.cameraSmooth.position.copy(this.camera.position),this.camera.aspect=ae.getAspectRatio(),this.cameraSmooth.aspect=ae.getAspectRatio(),this.cameraSmooth.updateProjectionMatrix()}}class Ve{static init(){this.addEventListeners()}static addEventListeners(){document.addEventListener("keydown",(e=>this.handleKeyDown(e))),document.addEventListener("keyup",(e=>this.handleKeyUp(e))),K.canvas.addEventListener("mousedown",(e=>this.handleMouseDown(e))),document.addEventListener("mouseup",(e=>this.handleMouseUp(e))),K.canvas.addEventListener("mousemove",(e=>this.handleMouseMove(e))),K.canvas.addEventListener("touchstart",(e=>this.handleTouchStart(e))),K.canvas.addEventListener("touchend",(e=>this.handleTouchEnd(e))),K.canvas.addEventListener("touchmove",(e=>this.handleTouchMove(e))),K.canvas.addEventListener("wheel",(e=>this.handleMouseWheel(e)))}static handleKeyDown(e){K.parent.matches(":hover")&&(e.preventDefault(),Ve.keysState.set(e.code,!0),Ve.keysDown.set(e.code,!0))}static handleKeyUp(e){K.parent.matches(":hover")&&(e.preventDefault(),Ve.keysState.set(e.code,!1),Ve.keysUp.set(e.code,!0))}static handleInputDown(e,t,A){Ve.mouseButtonsState.set(e,!0),Ve.mouseButtonsDown.set(e,!0),Ve.mouseDownPosition.set(t,A),Ve.mouseDownTime=performance.now()}static handleMouseDown(e){Ve.handleInputDown(e.button,e.clientX,e.clientY)}static handleTouchStart(e){if(e.touches.length===1&&(this.handleInputDown(0,e.touches[0].clientX,e.touches[0].clientY),Ve.lastTouchPosition.set(e.touches[0].clientX,e.touches[0].clientY)),e.touches.length===2){const t=e.touches[0].clientX-e.touches[1].clientX,A=e.touches[0].clientY-e.touches[1].clientY,n=Math.hypot(t,A);Ve.touchZoomDistanceEnd=Ve.touchZoomDistanceStart=n}}static handleInputUp(e,t,A){Ve.mouseButtonsState.set(e,!1),Ve.mouseButtonsUp.set(e,!0),Ve.mouseUpPosition.set(t,A),Ve.mouseUpTime=performance.now()}static handleMouseUp(e){Ve.handleInputUp(e.button,e.clientX,e.clientY)}static handleTouchEnd(e){const t=e.changedTouches[0];Ve.handleInputUp(0,t.clientX,t.clientY),Ve.touchZoomDistanceStart=0,Ve.touchZoomDistanceEnd=0}static handleInputMove(e,t,A,n){Ve.mousePosition.set(e,t),Ve.mouseDragDelta.x+=A*ae.dragScale.x,Ve.mouseDragDelta.y+=n*ae.dragScale.y}static handleMouseMove(e){Ve.handleInputMove(e.clientX,e.clientY,e.movementX,e.movementY)}static handleTouchMove(e){if(e.touches.length===1){const A=e.touches[0],n=A.clientX-Ve.lastTouchPosition.x,r=A.clientY-Ve.lastTouchPosition.y;Ve.handleInputMove(A.clientX,A.clientY,n,r),Ve.lastTouchPosition.set(A.clientX,A.clientY)}if(e.touches.length===2){const A=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY,r=Math.hypot(A,n);Ve.touchZoomDistanceEnd=r;var t=Ve.touchZoomDistanceEnd-Ve.touchZoomDistanceStart;Ve.touchZoomDistanceStart=Ve.touchZoomDistanceEnd,Ve.mouseScrollDelta.set(0,-2*t)}}static handleMouseWheel(e){Ve.mouseScrollDelta.set(e.deltaX,e.deltaY)}static GetKey(e){return Ve.keysState.get(e)||!1}static GetKeyDown(e){return!!Ve.keysUp.get(e)}static GetKeyUp(e){return!!Ve.keysUp.get(e)}static GetMouseButton(e){return Ve.mouseButtonsState.get(e)||!1}static GetMouseButtonDown(e){return!!Ve.mouseButtonsState.get(e)}static GetMouseButtonUp(e){return!!Ve.mouseButtonsUp.get(e)}static get MousePositionLocal(){const e=K.canvas.getBoundingClientRect();return new Gt(Ve.mousePosition.x-e.left,Ve.mousePosition.y-e.top)}static get MousePositionGlobal(){return Ve.mousePosition}static get MousePositionNormalized(){const e=K.canvas.getBoundingClientRect(),t=new Gt(Ve.mousePosition.x-e.left,Ve.mousePosition.y-e.top);return new Gt(t.x/e.width*2-1,-t.y/e.height*2+1)}static get MouseScrollDelta(){return Ve.mouseScrollDelta}static get MouseDragDelta(){return Ve.mouseDragDelta}static get MousePick(){return!(!Ve.GetMouseButtonUp(0)||Ve.mousePickConsumed||!Ve.isTapClick())&&(Ve.mousePickConsumed=!0,!0)}static isTapClick(){if(!Ve.GetMouseButtonUp(0))return!1;const e=Ve.mouseDownPosition.distanceTo(Ve.mouseUpPosition),t=Ve.mouseUpTime-Ve.mouseDownTime;return e<=Ve.maxTapMove&&t<=Ve.maxTapTime}static consumeMousePick(){Ve.mousePickConsumed=!0}static isMousePickPending(){return Ve.GetMouseButtonUp(0)&&!Ve.mousePickConsumed}static wasMouseButtonPressed(e){return Ve.mouseButtonsDown.get(e)||!1}static clientToNormalized(e,t){const A=K.canvas.getBoundingClientRect(),n=e-A.left,r=t-A.top;return new Gt(n/A.width*2-1,-r/A.height*2+1)}static getMouseDownPositionNormalized(){return Ve.clientToNormalized(Ve.mouseDownPosition.x,Ve.mouseDownPosition.y)}static EndFrame(){Ve.mouseButtonsUp.set(0,!1),Ve.mouseButtonsUp.set(1,!1),Ve.mouseButtonsDown.set(0,!1),Ve.mouseButtonsDown.set(1,!1),Ve.keysUp.clear(),Ve.keysDown.clear(),Ve.mouseDragDelta.set(0,0),Ve.mouseScrollDelta.set(0,0)}static updateState(){}static applyState(){const e=1*K.deltaTime,t=K.userData.camera.rotation.y;if(new re(Math.sin(t),0,Math.cos(t)),K.userData.camera.fov,this.keysState.get("KeyQ")&&K.userData.camera.position.addScaledVector(new re(0,1,0),-e),this.keysState.get("KeyE")&&K.userData.camera.position.addScaledVector(new re(0,1,0),e),Ve.GetMouseButton(0)&&!Ve.consumeDrag&&!ae.NAVIGATION_MARKERS_WHITELIST_MODE&&!ae.NAVIGATION_MARKERS_EDIT_MODE){let A=K.userData.camera.fov/300;K.userData.camera.rotation.x+=Ve.mouseDragDelta.y*A*yi.DEG2RAD,K.userData.camera.rotation.x<-ae.MAX_PITCH_ANGLE&&(K.userData.camera.rotation.x=-ae.MAX_PITCH_ANGLE),K.userData.camera.rotation.x>ae.MAX_PITCH_ANGLE&&(K.userData.camera.rotation.x=ae.MAX_PITCH_ANGLE),K.userData.camera.rotation.y+=Ve.mouseDragDelta.x*A*.8*yi.DEG2RAD}Ve.mouseScrollDelta.y!=0&&(K.userData.camera.fov=yi.clamp(K.userData.camera.fov+.1*Ve.mouseScrollDelta.y,ae.MIN_FOV,ae.MAX_FOV),K.userData.camera.updateProjectionMatrix())}static update(){Ve.GetMouseButton(0)||(Ve.mousePickConsumed=!1),this.updateState(),this.applyState()}}function FB(o,e){if(e===0)return o;if(e===2||e===1){let t=o.getIndex();if(t===null){const g=[],h=o.getAttribute("position");if(h===void 0)return o;for(let u=0;u<h.count;u++)g.push(u);o.setIndex(g),t=o.getIndex()}const A=t.count-2,n=[];if(e===2)for(let g=1;g<=A;g++)n.push(t.getX(0)),n.push(t.getX(g)),n.push(t.getX(g+1));else for(let g=0;g<A;g++)g%2==0?(n.push(t.getX(g)),n.push(t.getX(g+1)),n.push(t.getX(g+2))):(n.push(t.getX(g+2)),n.push(t.getX(g+1)),n.push(t.getX(g)));n.length;const r=o.clone();return r.setIndex(n),r.clearGroups(),r}return o}Ve.keysState=new Map,Ve.keysUp=new Map,Ve.keysDown=new Map,Ve.mouseButtonsState=new Map,Ve.mouseButtonsUp=new Map,Ve.mouseButtonsDown=new Map,Ve.mousePosition=new Gt,Ve.mouseScrollDelta=new Gt,Ve.mouseDragDelta=new Gt,Ve.mouseDownPosition=new Gt,Ve.mouseUpPosition=new Gt,Ve.mouseDownTime=0,Ve.mouseUpTime=0,Ve.maxTapTime=200,Ve.maxTapMove=5,Ve.lastTouchPosition=new Gt,Ve.consumeDrag=!1,Ve.mousePickConsumed=!1;class sI extends Ja{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(t){return new yx(t)})),this.register((function(t){return new _x(t)})),this.register((function(t){return new Rx(t)})),this.register((function(t){return new Nx(t)})),this.register((function(t){return new Dx(t)})),this.register((function(t){return new Mx(t)})),this.register((function(t){return new Sx(t)})),this.register((function(t){return new xx(t)})),this.register((function(t){return new wx(t)})),this.register((function(t){return new bx(t)})),this.register((function(t){return new vx(t)})),this.register((function(t){return new px(t)})),this.register((function(t){return new kx(t)})),this.register((function(t){return new Fx(t)}))}load(e,t,A,n){const r=this;let g;g=this.resourcePath!==""?this.resourcePath:this.path!==""?this.path:AI.extractUrlBase(e),this.manager.itemStart(e);const h=function(c){n&&n(c),r.manager.itemError(e),r.manager.itemEnd(e)},u=new Xh(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(this.withCredentials),u.load(e,(function(c){try{r.parse(c,g,(function(C){t(C),r.manager.itemEnd(e)}),h)}catch(C){h(C)}}),A,h)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,A,n){let r;const g={},h={},u=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(u.decode(new Uint8Array(e,0,4))===LB){try{g[HA.KHR_BINARY_GLTF]=new Ux(e)}catch(C){return void(n&&n(C))}r=JSON.parse(g[HA.KHR_BINARY_GLTF].content)}else r=JSON.parse(u.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const c=new jx(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let C=0;C<this.pluginCallbacks.length;C++){const B=this.pluginCallbacks[C](c);h[B.name]=B,g[B.name]=!0}if(r.extensionsUsed)for(let C=0;C<r.extensionsUsed.length;++C){const B=r.extensionsUsed[C],p=r.extensionsRequired||[];switch(B){case HA.KHR_MATERIALS_UNLIT:g[B]=new mx;break;case HA.KHR_DRACO_MESH_COMPRESSION:g[B]=new Tx(r,this.dracoLoader);break;case HA.KHR_TEXTURE_TRANSFORM:g[B]=new Hx;break;case HA.KHR_MESH_QUANTIZATION:g[B]=new Jx;break;default:p.indexOf(B)>=0&&h[B]}}c.setExtensions(g),c.setPlugins(h),c.parse(A,n)}parseAsync(e,t){const A=this;return new Promise((function(n,r){A.parse(e,t,n,r)}))}}function fx(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const HA={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class px{constructor(e){this.parser=e,this.name=HA.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let A=0,n=t.length;A<n;A++){const r=t[A];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,A="light:"+e;let n=t.cache.get(A);if(n)return n;const r=t.json,g=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let h;const u=new rA(16777215);g.color!==void 0&&u.fromArray(g.color);const c=g.range!==void 0?g.range:0;switch(g.type){case"directional":h=new RB(u),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new sx(u),h.distance=c;break;case"spot":h=new nx(u),h.distance=c,g.spot=g.spot||{},g.spot.innerConeAngle=g.spot.innerConeAngle!==void 0?g.spot.innerConeAngle:0,g.spot.outerConeAngle=g.spot.outerConeAngle!==void 0?g.spot.outerConeAngle:Math.PI/4,h.angle=g.spot.outerConeAngle,h.penumbra=1-g.spot.innerConeAngle/g.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+g.type)}return h.position.set(0,0,0),h.decay=2,Es(h,g),g.intensity!==void 0&&(h.intensity=g.intensity),h.name=t.createUniqueName(g.name||"light_"+e),n=Promise.resolve(h),t.cache.add(A,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,A=this.parser,n=A.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then((function(g){return A._getNodeRef(t.cache,r,g)}))}}class mx{constructor(){this.name=HA.KHR_MATERIALS_UNLIT}getMaterialType(){return Ji}extendParams(e,t,A){const n=[];e.color=new rA(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const g=r.baseColorFactor;e.color.fromArray(g),e.opacity=g[3]}r.baseColorTexture!==void 0&&n.push(A.assignTexture(e,"map",r.baseColorTexture,ie))}return Promise.all(n)}}class wx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const A=this.parser.json.materials[e];if(!A.extensions||!A.extensions[this.name])return Promise.resolve();const n=A.extensions[this.name].emissiveStrength;return n!==void 0&&(t.emissiveIntensity=n),Promise.resolve()}}class yx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Ps:null}extendMaterialParams(e,t){const A=this.parser,n=A.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],g=n.extensions[this.name];if(g.clearcoatFactor!==void 0&&(t.clearcoat=g.clearcoatFactor),g.clearcoatTexture!==void 0&&r.push(A.assignTexture(t,"clearcoatMap",g.clearcoatTexture)),g.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=g.clearcoatRoughnessFactor),g.clearcoatRoughnessTexture!==void 0&&r.push(A.assignTexture(t,"clearcoatRoughnessMap",g.clearcoatRoughnessTexture)),g.clearcoatNormalTexture!==void 0&&(r.push(A.assignTexture(t,"clearcoatNormalMap",g.clearcoatNormalTexture)),g.clearcoatNormalTexture.scale!==void 0)){const h=g.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Gt(h,h)}return Promise.all(r)}}class vx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Ps:null}extendMaterialParams(e,t){const A=this.parser,n=A.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],g=n.extensions[this.name];return g.iridescenceFactor!==void 0&&(t.iridescence=g.iridescenceFactor),g.iridescenceTexture!==void 0&&r.push(A.assignTexture(t,"iridescenceMap",g.iridescenceTexture)),g.iridescenceIor!==void 0&&(t.iridescenceIOR=g.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),g.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=g.iridescenceThicknessMinimum),g.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=g.iridescenceThicknessMaximum),g.iridescenceThicknessTexture!==void 0&&r.push(A.assignTexture(t,"iridescenceThicknessMap",g.iridescenceThicknessTexture)),Promise.all(r)}}class Dx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Ps:null}extendMaterialParams(e,t){const A=this.parser,n=A.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new rA(0,0,0),t.sheenRoughness=0,t.sheen=1;const g=n.extensions[this.name];return g.sheenColorFactor!==void 0&&t.sheenColor.fromArray(g.sheenColorFactor),g.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=g.sheenRoughnessFactor),g.sheenColorTexture!==void 0&&r.push(A.assignTexture(t,"sheenColorMap",g.sheenColorTexture,ie)),g.sheenRoughnessTexture!==void 0&&r.push(A.assignTexture(t,"sheenRoughnessMap",g.sheenRoughnessTexture)),Promise.all(r)}}class Mx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Ps:null}extendMaterialParams(e,t){const A=this.parser,n=A.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],g=n.extensions[this.name];return g.transmissionFactor!==void 0&&(t.transmission=g.transmissionFactor),g.transmissionTexture!==void 0&&r.push(A.assignTexture(t,"transmissionMap",g.transmissionTexture)),Promise.all(r)}}class Sx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Ps:null}extendMaterialParams(e,t){const A=this.parser,n=A.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],g=n.extensions[this.name];t.thickness=g.thicknessFactor!==void 0?g.thicknessFactor:0,g.thicknessTexture!==void 0&&r.push(A.assignTexture(t,"thicknessMap",g.thicknessTexture)),t.attenuationDistance=g.attenuationDistance||1/0;const h=g.attenuationColor||[1,1,1];return t.attenuationColor=new rA(h[0],h[1],h[2]),Promise.all(r)}}class xx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Ps:null}extendMaterialParams(e,t){const A=this.parser.json.materials[e];if(!A.extensions||!A.extensions[this.name])return Promise.resolve();const n=A.extensions[this.name];return t.ior=n.ior!==void 0?n.ior:1.5,Promise.resolve()}}class bx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Ps:null}extendMaterialParams(e,t){const A=this.parser,n=A.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],g=n.extensions[this.name];t.specularIntensity=g.specularFactor!==void 0?g.specularFactor:1,g.specularTexture!==void 0&&r.push(A.assignTexture(t,"specularIntensityMap",g.specularTexture));const h=g.specularColorFactor||[1,1,1];return t.specularColor=new rA(h[0],h[1],h[2]),g.specularColorTexture!==void 0&&r.push(A.assignTexture(t,"specularColorMap",g.specularColorTexture,ie)),Promise.all(r)}}class _x{constructor(e){this.parser=e,this.name=HA.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,A=t.json,n=A.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],g=t.options.ktx2Loader;if(!g){if(A.extensionsRequired&&A.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,g)}}class Rx{constructor(e){this.parser=e,this.name=HA.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,A=this.parser,n=A.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const g=r.extensions[t],h=n.images[g.source];let u=A.textureLoader;if(h.uri){const c=A.options.manager.getHandler(h.uri);c!==null&&(u=c)}return this.detectSupport().then((function(c){if(c)return A.loadTextureImage(e,g.source,u);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return A.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}}))),this.isSupported}}class Nx{constructor(e){this.parser=e,this.name=HA.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,A=this.parser,n=A.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const g=r.extensions[t],h=n.images[g.source];let u=A.textureLoader;if(h.uri){const c=A.options.manager.getHandler(h.uri);c!==null&&(u=c)}return this.detectSupport().then((function(c){if(c)return A.loadTextureImage(e,g.source,u);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return A.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}}))),this.isSupported}}class kx{constructor(e){this.name=HA.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,A=t.bufferViews[e];if(A.extensions&&A.extensions[this.name]){const n=A.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),g=this.parser.options.meshoptDecoder;if(!g||!g.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then((function(h){const u=n.byteOffset||0,c=n.byteLength||0,C=n.count,B=n.byteStride,p=new Uint8Array(h,u,c);return g.decodeGltfBufferAsync?g.decodeGltfBufferAsync(C,B,p,n.mode,n.filter).then((function(w){return w.buffer})):g.ready.then((function(){const w=new ArrayBuffer(C*B);return g.decodeGltfBuffer(new Uint8Array(w),C,B,p,n.mode,n.filter),w}))}))}return null}}class Fx{constructor(e){this.name=HA.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,A=t.nodes[e];if(!A.extensions||!A.extensions[this.name]||A.mesh===void 0)return null;const n=t.meshes[A.mesh];for(const u of n.primitives)if(u.mode!==Yn.TRIANGLES&&u.mode!==Yn.TRIANGLE_STRIP&&u.mode!==Yn.TRIANGLE_FAN&&u.mode!==void 0)return null;const r=A.extensions[this.name].attributes,g=[],h={};for(const u in r)g.push(this.parser.getDependency("accessor",r[u]).then((c=>(h[u]=c,h[u]))));return g.length<1?null:(g.push(this.parser.createNodeMesh(e)),Promise.all(g).then((u=>{const c=u.pop(),C=c.isGroup?c.children:[c],B=u[0].count,p=[];for(const w of C){const k=new xA,R=new re,_=new Ui,N=new re(1,1,1),L=new PS(w.geometry,w.material,B);for(let G=0;G<B;G++)h.TRANSLATION&&R.fromBufferAttribute(h.TRANSLATION,G),h.ROTATION&&_.fromBufferAttribute(h.ROTATION,G),h.SCALE&&N.fromBufferAttribute(h.SCALE,G),L.setMatrixAt(G,k.compose(R,_,N));for(const G in h)G!=="TRANSLATION"&&G!=="ROTATION"&&G!=="SCALE"&&w.geometry.setAttribute(G,h[G]);gi.prototype.copy.call(L,w),this.parser.assignFinalMaterial(L),p.push(L)}return c.isGroup?(c.clear(),c.add(...p),c):p[0]})))}}const LB="glTF",Lx=1313821514,Gx=5130562;class Ux{constructor(e){this.name=HA.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),A=new TextDecoder;if(this.header={magic:A.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==LB)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(e,12);let g=0;for(;g<n;){const h=r.getUint32(g,!0);g+=4;const u=r.getUint32(g,!0);if(g+=4,u===Lx){const c=new Uint8Array(e,12+g,h);this.content=A.decode(c)}else if(u===Gx){const c=12+g;this.body=e.slice(c,c+h)}g+=h}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Tx{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=HA.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const A=this.json,n=this.dracoLoader,r=e.extensions[this.name].bufferView,g=e.extensions[this.name].attributes,h={},u={},c={};for(const C in g){const B=oI[C]||C.toLowerCase();h[B]=g[C]}for(const C in e.attributes){const B=oI[C]||C.toLowerCase();if(g[C]!==void 0){const p=A.accessors[e.attributes[C]],w=Pa[p.componentType];c[B]=w.name,u[B]=p.normalized===!0}}return t.getDependency("bufferView",r).then((function(C){return new Promise((function(B){n.decodeDracoFile(C,(function(p){for(const w in p.attributes){const k=p.attributes[w],R=u[w];R!==void 0&&(k.normalized=R)}B(p)}),h,c)}))}))}}class Hx{constructor(){this.name=HA.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord!==void 0&&t.texCoord!==e.channel||t.offset!==void 0||t.rotation!==void 0||t.scale!==void 0)&&(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Jx{constructor(){this.name=HA.KHR_MESH_QUANTIZATION}}class GB extends zo{constructor(e,t,A,n){super(e,t,A,n)}copySampleValue_(e){const t=this.resultBuffer,A=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let g=0;g!==n;g++)t[g]=A[r+g];return t}interpolate_(e,t,A,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=2*h,c=3*h,C=n-t,B=(A-t)/C,p=B*B,w=p*B,k=e*c,R=k-c,_=-2*w+3*p,N=w-p,L=1-_,G=N-p+B;for(let le=0;le!==h;le++){const ne=g[R+le+h],Ae=g[R+le+u]*C,te=g[k+le+h],ye=g[k+le]*C;r[le]=L*ne+G*Ae+_*te+N*ye}return r}}const Yx=new Ui;class Px extends GB{interpolate_(e,t,A,n){const r=super.interpolate_(e,t,A,n);return Yx.fromArray(r).normalize().toArray(r),r}}const Yn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Pa={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},UB={9728:Be,9729:Qe,9984:qe,9985:tt,9986:me,9987:se},TB={33071:ee,33648:Fe,10497:Ce},aI={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},oI={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Oa={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ox={CUBICSPLINE:void 0,LINEAR:Oe,STEP:Ue},Kx="OPAQUE",zx="MASK",qx="BLEND";function jo(o,e,t){for(const A in t.extensions)o[A]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[A]=t.extensions[A])}function Es(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):e.extras)}function Wx(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,A=e.weights.length;t<A;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let A=0,n=t.length;A<n;A++)o.morphTargetDictionary[t[A]]=A}}}function Vx(o){const e=o.extensions&&o.extensions[HA.KHR_DRACO_MESH_COMPRESSION];let t;return t=e?"draco:"+e.bufferView+":"+e.indices+":"+HB(e.attributes):o.indices+":"+HB(o.attributes)+":"+o.mode,t}function HB(o){let e="";const t=Object.keys(o).sort();for(let A=0,n=t.length;A<n;A++)e+=t[A]+":"+o[t[A]]+";";return e}function gI(o){switch(o){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const Zx=new xA;class jx{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new fx,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let A=!1,n=!1,r=-1;typeof navigator<"u"&&(A=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,n=navigator.userAgent.indexOf("Firefox")>-1,r=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||A||n&&r<98?this.textureLoader=new Ya(this.options.manager):this.textureLoader=new gx(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Xh(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const A=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(g){return g._markDefs&&g._markDefs()})),Promise.all(this._invokeAll((function(g){return g.beforeRoot&&g.beforeRoot()}))).then((function(){return Promise.all([A.getDependencies("scene"),A.getDependencies("animation"),A.getDependencies("camera")])})).then((function(g){const h={scene:g[0][n.scene||0],scenes:g[0],animations:g[1],cameras:g[2],asset:n.asset,parser:A,userData:{}};jo(r,h,n),Es(h,n),Promise.all(A._invokeAll((function(u){return u.afterRoot&&u.afterRoot(h)}))).then((function(){e(h)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],A=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){const g=t[n].joints;for(let h=0,u=g.length;h<u;h++)e[g[h]].isBone=!0}for(let n=0,r=e.length;n<r;n++){const g=e[n];g.mesh!==void 0&&(this._addNodeRef(this.meshCache,g.mesh),g.skin!==void 0&&(A[g.mesh].isSkinnedMesh=!0)),g.camera!==void 0&&this._addNodeRef(this.cameraCache,g.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,A){if(e.refs[t]<=1)return A;const n=A.clone(),r=(g,h)=>{const u=this.associations.get(g);u!=null&&this.associations.set(h,u);for(const[c,C]of g.children.entries())r(C,h.children[c])};return r(A,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let A=0;A<t.length;A++){const n=e(t[A]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const A=[];for(let n=0;n<t.length;n++){const r=e(t[n]);r&&A.push(r)}return A}getDependency(e,t){const A=e+":"+t;let n=this.cache.get(A);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne((function(r){return r.loadNode&&r.loadNode(t)}));break;case"mesh":n=this._invokeOne((function(r){return r.loadMesh&&r.loadMesh(t)}));break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne((function(r){return r.loadBufferView&&r.loadBufferView(t)}));break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne((function(r){return r.loadMaterial&&r.loadMaterial(t)}));break;case"texture":n=this._invokeOne((function(r){return r.loadTexture&&r.loadTexture(t)}));break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne((function(r){return r.loadAnimation&&r.loadAnimation(t)}));break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne((function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)})),!n)throw new Error("Unknown type: "+e)}this.cache.add(A,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const A=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map((function(r,g){return A.getDependency(e,g)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],A=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[HA.KHR_BINARY_GLTF].body);const n=this.options;return new Promise((function(r,g){A.load(AI.resolveURL(t.uri,n.path),r,void 0,(function(){g(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(A){const n=t.byteLength||0,r=t.byteOffset||0;return A.slice(r,r+n)}))}loadAccessor(e){const t=this,A=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const g=aI[n.type],h=Pa[n.componentType],u=n.normalized===!0,c=new h(n.count*g);return Promise.resolve(new Vi(c,g,u))}const r=[];return n.bufferView!==void 0?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),n.sparse!==void 0&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then((function(g){const h=g[0],u=aI[n.type],c=Pa[n.componentType],C=c.BYTES_PER_ELEMENT,B=C*u,p=n.byteOffset||0,w=n.bufferView!==void 0?A.bufferViews[n.bufferView].byteStride:void 0,k=n.normalized===!0;let R,_;if(w&&w!==B){const N=Math.floor(p/w),L="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+N+":"+n.count;let G=t.cache.get(L);G||(R=new c(h,N*w,n.count*w/C),G=new eB(R,w/C),t.cache.add(L,G)),_=new Ho(G,u,p%w/C,k)}else R=h===null?new c(n.count*u):new c(h,p,n.count*u),_=new Vi(R,u,k);if(n.sparse!==void 0){const N=aI.SCALAR,L=Pa[n.sparse.indices.componentType],G=n.sparse.indices.byteOffset||0,le=n.sparse.values.byteOffset||0,ne=new L(g[1],G,n.sparse.count*N),Ae=new c(g[2],le,n.sparse.count*u);h!==null&&(_=new Vi(_.array.slice(),_.itemSize,_.normalized));for(let te=0,ye=ne.length;te<ye;te++){const ge=ne[te];if(_.setX(ge,Ae[te*u]),u>=2&&_.setY(ge,Ae[te*u+1]),u>=3&&_.setZ(ge,Ae[te*u+2]),u>=4&&_.setW(ge,Ae[te*u+3]),u>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return _}))}loadTexture(e){const t=this.json,A=this.options,n=t.textures[e].source,r=t.images[n];let g=this.textureLoader;if(r.uri){const h=A.manager.getHandler(r.uri);h!==null&&(g=h)}return this.loadTextureImage(e,n,g)}loadTextureImage(e,t,A){const n=this,r=this.json,g=r.textures[e],h=r.images[t],u=(h.uri||h.bufferView)+":"+g.sampler;if(this.textureCache[u])return this.textureCache[u];const c=this.loadImageSource(t,A).then((function(C){C.flipY=!1,C.name=g.name||h.name||"",C.name===""&&typeof h.uri=="string"&&h.uri.startsWith("data:image/")===!1&&(C.name=h.uri);const B=(r.samplers||{})[g.sampler]||{};return C.magFilter=UB[B.magFilter]||Qe,C.minFilter=UB[B.minFilter]||se,C.wrapS=TB[B.wrapS]||Ce,C.wrapT=TB[B.wrapT]||Ce,n.associations.set(C,{textures:e}),C})).catch((function(){return null}));return this.textureCache[u]=c,c}loadImageSource(e,t){const A=this,n=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((B=>B.clone()));const g=n.images[e],h=self.URL||self.webkitURL;let u=g.uri||"",c=!1;if(g.bufferView!==void 0)u=A.getDependency("bufferView",g.bufferView).then((function(B){c=!0;const p=new Blob([B],{type:g.mimeType});return u=h.createObjectURL(p),u}));else if(g.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const C=Promise.resolve(u).then((function(B){return new Promise((function(p,w){let k=p;t.isImageBitmapLoader===!0&&(k=function(R){const _=new Di(R);_.needsUpdate=!0,p(_)}),t.load(AI.resolveURL(B,r.path),k,void 0,w)}))})).then((function(B){var p;return c===!0&&h.revokeObjectURL(u),B.userData.mimeType=g.mimeType||((p=g.uri).search(/\.jpe?g($|\?)/i)>0||p.search(/^data\:image\/jpeg/)===0?"image/jpeg":p.search(/\.webp($|\?)/i)>0||p.search(/^data\:image\/webp/)===0?"image/webp":"image/png"),B})).catch((function(B){throw B}));return this.sourceCache[e]=C,C}assignTexture(e,t,A,n){const r=this;return this.getDependency("texture",A.index).then((function(g){if(!g)return null;if(A.texCoord!==void 0&&A.texCoord>0&&((g=g.clone()).channel=A.texCoord),r.extensions[HA.KHR_TEXTURE_TRANSFORM]){const h=A.extensions!==void 0?A.extensions[HA.KHR_TEXTURE_TRANSFORM]:void 0;if(h){const u=r.associations.get(g);g=r.extensions[HA.KHR_TEXTURE_TRANSFORM].extendTexture(g,h),r.associations.set(g,u)}}return n!==void 0&&(g.colorSpace=n),e[t]=g,g}))}assignFinalMaterial(e){const t=e.geometry;let A=e.material;const n=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,g=t.attributes.normal===void 0;if(e.isPoints){const h="PointsMaterial:"+A.uuid;let u=this.cache.get(h);u||(u=new fB,Sn.prototype.copy.call(u,A),u.color.copy(A.color),u.map=A.map,u.sizeAttenuation=!1,this.cache.add(h,u)),A=u}else if(e.isLine){const h="LineBasicMaterial:"+A.uuid;let u=this.cache.get(h);u||(u=new uB,Sn.prototype.copy.call(u,A),u.color.copy(A.color),u.map=A.map,this.cache.add(h,u)),A=u}if(n||r||g){let h="ClonedMaterial:"+A.uuid+":";n&&(h+="derivative-tangents:"),r&&(h+="vertex-colors:"),g&&(h+="flat-shading:");let u=this.cache.get(h);u||(u=A.clone(),r&&(u.vertexColors=!0),g&&(u.flatShading=!0),n&&(u.normalScale&&(u.normalScale.y*=-1),u.clearcoatNormalScale&&(u.clearcoatNormalScale.y*=-1)),this.cache.add(h,u),this.associations.set(u,this.associations.get(A))),A=u}e.material=A}getMaterialType(){return Ys}loadMaterial(e){const t=this,A=this.json,n=this.extensions,r=A.materials[e];let g;const h={},u=[];if((r.extensions||{})[HA.KHR_MATERIALS_UNLIT]){const C=n[HA.KHR_MATERIALS_UNLIT];g=C.getMaterialType(),u.push(C.extendParams(h,r,t))}else{const C=r.pbrMetallicRoughness||{};if(h.color=new rA(1,1,1),h.opacity=1,Array.isArray(C.baseColorFactor)){const B=C.baseColorFactor;h.color.fromArray(B),h.opacity=B[3]}C.baseColorTexture!==void 0&&u.push(t.assignTexture(h,"map",C.baseColorTexture,ie)),h.metalness=C.metallicFactor!==void 0?C.metallicFactor:1,h.roughness=C.roughnessFactor!==void 0?C.roughnessFactor:1,C.metallicRoughnessTexture!==void 0&&(u.push(t.assignTexture(h,"metalnessMap",C.metallicRoughnessTexture)),u.push(t.assignTexture(h,"roughnessMap",C.metallicRoughnessTexture))),g=this._invokeOne((function(B){return B.getMaterialType&&B.getMaterialType(e)})),u.push(Promise.all(this._invokeAll((function(B){return B.extendMaterialParams&&B.extendMaterialParams(e,h)}))))}r.doubleSided===!0&&(h.side=2);const c=r.alphaMode||Kx;if(c===qx?(h.transparent=!0,h.depthWrite=!1):(h.transparent=!1,c===zx&&(h.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&g!==Ji&&(u.push(t.assignTexture(h,"normalMap",r.normalTexture)),h.normalScale=new Gt(1,1),r.normalTexture.scale!==void 0)){const C=r.normalTexture.scale;h.normalScale.set(C,C)}return r.occlusionTexture!==void 0&&g!==Ji&&(u.push(t.assignTexture(h,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(h.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&g!==Ji&&(h.emissive=new rA().fromArray(r.emissiveFactor)),r.emissiveTexture!==void 0&&g!==Ji&&u.push(t.assignTexture(h,"emissiveMap",r.emissiveTexture,ie)),Promise.all(u).then((function(){const C=new g(h);return r.name&&(C.name=r.name),Es(C,r),t.associations.set(C,{materials:e}),r.extensions&&jo(n,C,r),C}))}createUniqueName(e){const t=ZA.sanitizeNodeName(e||"");let A=t;for(let n=1;this.nodeNamesUsed[A];++n)A=t+"_"+n;return this.nodeNamesUsed[A]=!0,A}loadGeometries(e){const t=this,A=this.extensions,n=this.primitiveCache;function r(h){return A[HA.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(h,t).then((function(u){return JB(u,h,t)}))}const g=[];for(let h=0,u=e.length;h<u;h++){const c=e[h],C=Vx(c),B=n[C];if(B)g.push(B.promise);else{let p;p=c.extensions&&c.extensions[HA.KHR_DRACO_MESH_COMPRESSION]?r(c):JB(new bn,c,t),n[C]={primitive:c,promise:p},g.push(p)}}return Promise.all(g)}loadMesh(e){const t=this,A=this.json,n=this.extensions,r=A.meshes[e],g=r.primitives,h=[];for(let c=0,C=g.length;c<C;c++){const B=g[c].material===void 0?((u=this.cache).DefaultMaterial===void 0&&(u.DefaultMaterial=new Ys({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:m})),u.DefaultMaterial):this.getDependency("material",g[c].material);h.push(B)}var u;return h.push(t.loadGeometries(g)),Promise.all(h).then((function(c){const C=c.slice(0,c.length-1),B=c[c.length-1],p=[];for(let k=0,R=B.length;k<R;k++){const _=B[k],N=g[k];let L;const G=C[k];if(N.mode===Yn.TRIANGLES||N.mode===Yn.TRIANGLE_STRIP||N.mode===Yn.TRIANGLE_FAN||N.mode===void 0)L=r.isSkinnedMesh===!0?new HS(_,G):new UA(_,G),L.isSkinnedMesh===!0&&L.normalizeSkinWeights(),N.mode===Yn.TRIANGLE_STRIP?L.geometry=FB(L.geometry,1):N.mode===Yn.TRIANGLE_FAN&&(L.geometry=FB(L.geometry,2));else if(N.mode===Yn.LINES)L=new OS(_,G);else if(N.mode===Yn.LINE_STRIP)L=new Vh(_,G);else if(N.mode===Yn.LINE_LOOP)L=new KS(_,G);else{if(N.mode!==Yn.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+N.mode);L=new zS(_,G)}Object.keys(L.geometry.morphAttributes).length>0&&Wx(L,r),L.name=t.createUniqueName(r.name||"mesh_"+e),Es(L,r),N.extensions&&jo(n,L,N),t.assignFinalMaterial(L),p.push(L)}for(let k=0,R=p.length;k<R;k++)t.associations.set(p[k],{meshes:e,primitives:k});if(p.length===1)return p[0];const w=new Js;t.associations.set(w,{meshes:e});for(let k=0,R=p.length;k<R;k++)w.add(p[k]);return w}))}loadCamera(e){let t;const A=this.json.cameras[e],n=A[A.type];if(n)return A.type==="perspective"?t=new Zi(yi.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):A.type==="orthographic"&&(t=new _n(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),A.name&&(t.name=this.createUniqueName(A.name)),Es(t,A),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],A=[];for(let n=0,r=t.joints.length;n<r;n++)A.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?A.push(this.getDependency("accessor",t.inverseBindMatrices)):A.push(null),Promise.all(A).then((function(n){const r=n.pop(),g=n,h=[],u=[];for(let c=0,C=g.length;c<C;c++){const B=g[c];if(B){h.push(B);const p=new xA;r!==null&&p.fromArray(r.array,16*c),u.push(p)}else t.joints[c]}return new qh(h,u)}))}loadAnimation(e){const t=this.json.animations[e],A=t.name?t.name:"animation_"+e,n=[],r=[],g=[],h=[],u=[];for(let c=0,C=t.channels.length;c<C;c++){const B=t.channels[c],p=t.samplers[B.sampler],w=B.target,k=w.node,R=t.parameters!==void 0?t.parameters[p.input]:p.input,_=t.parameters!==void 0?t.parameters[p.output]:p.output;w.node!==void 0&&(n.push(this.getDependency("node",k)),r.push(this.getDependency("accessor",R)),g.push(this.getDependency("accessor",_)),h.push(p),u.push(w))}return Promise.all([Promise.all(n),Promise.all(r),Promise.all(g),Promise.all(h),Promise.all(u)]).then((function(c){const C=c[0],B=c[1],p=c[2],w=c[3],k=c[4],R=[];for(let _=0,N=C.length;_<N;_++){const L=C[_],G=B[_],le=p[_],ne=w[_],Ae=k[_];if(L===void 0)continue;let te;switch(L.updateMatrix(),Oa[Ae.path]){case Oa.weights:te=qo;break;case Oa.rotation:te=Os;break;default:te=Wo}const ye=L.name?L.name:L.uuid,ge=ne.interpolation!==void 0?Ox[ne.interpolation]:Oe,Me=[];Oa[Ae.path]===Oa.weights?L.traverse((function(Ze){Ze.morphTargetInfluences&&Me.push(Ze.name?Ze.name:Ze.uuid)})):Me.push(ye);let pe=le.array;if(le.normalized){const Ze=gI(pe.constructor),Ct=new Float32Array(pe.length);for(let Qt=0,Wt=pe.length;Qt<Wt;Qt++)Ct[Qt]=pe[Qt]*Ze;pe=Ct}for(let Ze=0,Ct=Me.length;Ze<Ct;Ze++){const Qt=new te(Me[Ze]+"."+Oa[Ae.path],G.array,pe,ge);ne.interpolation==="CUBICSPLINE"&&(Qt.createInterpolant=function(Wt){return new(this instanceof Os?Px:GB)(this.times,this.values,this.getValueSize()/3,Wt)},Qt.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),R.push(Qt)}}return new jh(A,void 0,R)}))}createNodeMesh(e){const t=this.json,A=this,n=t.nodes[e];return n.mesh===void 0?null:A.getDependency("mesh",n.mesh).then((function(r){const g=A._getNodeRef(A.meshCache,n.mesh,r);return n.weights!==void 0&&g.traverse((function(h){if(h.isMesh)for(let u=0,c=n.weights.length;u<c;u++)h.morphTargetInfluences[u]=n.weights[u]})),g}))}loadNode(e){const t=this,A=this.json.nodes[e],n=t._loadNodeShallow(e),r=[],g=A.children||[];for(let u=0,c=g.length;u<c;u++)r.push(t.getDependency("node",g[u]));const h=A.skin===void 0?Promise.resolve(null):t.getDependency("skin",A.skin);return Promise.all([n,Promise.all(r),h]).then((function(u){const c=u[0],C=u[1],B=u[2];B!==null&&c.traverse((function(p){p.isSkinnedMesh&&p.bind(B,Zx)}));for(let p=0,w=C.length;p<w;p++)c.add(C[p]);return c}))}_loadNodeShallow(e){const t=this.json,A=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],g=r.name?n.createUniqueName(r.name):"",h=[],u=n._invokeOne((function(c){return c.createNodeMesh&&c.createNodeMesh(e)}));return u&&h.push(u),r.camera!==void 0&&h.push(n.getDependency("camera",r.camera).then((function(c){return n._getNodeRef(n.cameraCache,r.camera,c)}))),n._invokeAll((function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)})).forEach((function(c){h.push(c)})),this.nodeCache[e]=Promise.all(h).then((function(c){let C;if(C=r.isBone===!0?new gB:c.length>1?new Js:c.length===1?c[0]:new gi,C!==c[0])for(let B=0,p=c.length;B<p;B++)C.add(c[B]);if(r.name&&(C.userData.name=r.name,C.name=g),Es(C,r),r.extensions&&jo(A,C,r),r.matrix!==void 0){const B=new xA;B.fromArray(r.matrix),C.applyMatrix4(B)}else r.translation!==void 0&&C.position.fromArray(r.translation),r.rotation!==void 0&&C.quaternion.fromArray(r.rotation),r.scale!==void 0&&C.scale.fromArray(r.scale);return n.associations.has(C)||n.associations.set(C,{}),n.associations.get(C).nodes=e,C})),this.nodeCache[e]}loadScene(e){const t=this.extensions,A=this.json.scenes[e],n=this,r=new Js;A.name&&(r.name=n.createUniqueName(A.name)),Es(r,A),A.extensions&&jo(t,r,A);const g=A.nodes||[],h=[];for(let u=0,c=g.length;u<c;u++)h.push(n.getDependency("node",g[u]));return Promise.all(h).then((function(u){for(let c=0,C=u.length;c<C;c++)r.add(u[c]);return n.associations=(c=>{const C=new Map;for(const[B,p]of n.associations)(B instanceof Sn||B instanceof Di)&&C.set(B,p);return c.traverse((B=>{const p=n.associations.get(B);p!=null&&C.set(B,p)})),C})(r),r}))}}function JB(o,e,t){const A=e.attributes,n=[];function r(g,h){return t.getDependency("accessor",g).then((function(u){o.setAttribute(h,u)}))}for(const g in A){const h=oI[g]||g.toLowerCase();h in o.attributes||n.push(r(A[g],h))}if(e.indices!==void 0&&!o.index){const g=t.getDependency("accessor",e.indices).then((function(h){o.setIndex(h)}));n.push(g)}return Es(o,e),(function(g,h,u){const c=h.attributes,C=new Mi;if(c.POSITION===void 0)return;{const w=u.json.accessors[c.POSITION],k=w.min,R=w.max;if(k===void 0||R===void 0)return;if(C.set(new re(k[0],k[1],k[2]),new re(R[0],R[1],R[2])),w.normalized){const _=gI(Pa[w.componentType]);C.min.multiplyScalar(_),C.max.multiplyScalar(_)}}const B=h.targets;if(B!==void 0){const w=new re,k=new re;for(let R=0,_=B.length;R<_;R++){const N=B[R];if(N.POSITION!==void 0){const L=u.json.accessors[N.POSITION],G=L.min,le=L.max;if(G!==void 0&&le!==void 0){if(k.setX(Math.max(Math.abs(G[0]),Math.abs(le[0]))),k.setY(Math.max(Math.abs(G[1]),Math.abs(le[1]))),k.setZ(Math.max(Math.abs(G[2]),Math.abs(le[2]))),L.normalized){const ne=gI(Pa[L.componentType]);k.multiplyScalar(ne)}w.max(k)}}}C.expandByVector(w)}g.boundingBox=C;const p=new Ur;C.getCenter(p.center),p.radius=C.min.distanceTo(C.max)/2,g.boundingSphere=p})(o,e,t),Promise.all(n).then((function(){return e.targets!==void 0?(function(g,h,u){let c=!1,C=!1,B=!1;for(let R=0,_=h.length;R<_;R++){const N=h[R];if(N.POSITION!==void 0&&(c=!0),N.NORMAL!==void 0&&(C=!0),N.COLOR_0!==void 0&&(B=!0),c&&C&&B)break}if(!c&&!C&&!B)return Promise.resolve(g);const p=[],w=[],k=[];for(let R=0,_=h.length;R<_;R++){const N=h[R];if(c){const L=N.POSITION!==void 0?u.getDependency("accessor",N.POSITION):g.attributes.position;p.push(L)}if(C){const L=N.NORMAL!==void 0?u.getDependency("accessor",N.NORMAL):g.attributes.normal;w.push(L)}if(B){const L=N.COLOR_0!==void 0?u.getDependency("accessor",N.COLOR_0):g.attributes.color;k.push(L)}}return Promise.all([Promise.all(p),Promise.all(w),Promise.all(k)]).then((function(R){const _=R[0],N=R[1],L=R[2];return c&&(g.morphAttributes.position=_),C&&(g.morphAttributes.normal=N),B&&(g.morphAttributes.color=L),g.morphTargetsRelative=!0,g}))})(o,e.targets,t):o}))}var lI=function(o,e,t,A){return new(t||(t=Promise))((function(n,r){function g(c){try{u(A.next(c))}catch(C){r(C)}}function h(c){try{u(A.throw(c))}catch(C){r(C)}}function u(c){var C;c.done?n(c.value):(C=c.value,C instanceof t?C:new t((function(B){B(C)}))).then(g,h)}u((A=A.apply(o,[])).next())}))};class Xx{constructor(){this.modelCache=new Map,this.textureCache=new Map,this.loader=new sI}loadModel(e){return lI(this,void 0,void 0,(function*(){return this.modelCache.has(e)?this.modelCache.get(e).clone():(yield new Promise(((t,A)=>{this.loader.load(e,(n=>{this.modelCache.set(e,n.scene),t(n)}),void 0,A)}))).scene}))}loadTexture(e,t=!1){return lI(this,void 0,void 0,(function*(){if(this.textureCache.has(e))return this.textureCache.get(e);{let A=yield new Promise(((n,r)=>{new Ya().load(e,n,void 0,r)}));return t&&(A.minFilter=Be,A.magFilter=Be),this.textureCache.set(e,A),A}}))}loadTexturedPlaneModel(e,t,A=new re(0,0,0),n=new re(1,1,1),r=!1){return lI(this,void 0,void 0,(function*(){let g;const h=`plane:${e}:${A.x.toFixed(2)},${A.y.toFixed(2)},${A.z.toFixed(2)}:${n.x.toFixed(2)},${n.y.toFixed(2)},${n.z.toFixed(2)}`;if(this.modelCache.has(h))g=this.modelCache.get(h);else{const u=yield this.loadTexture(e,r),c=new Ri(1,1);t instanceof Ai?t.uniforms.map.value=u:t instanceof Ji&&(t.map=u),c.applyMatrix4(new xA().makeRotationX(-Math.PI/2).multiply(new xA().makeScale(n.x,n.y,n.z))),c.applyMatrix4(new xA().makeTranslation(A.x,A.y,A.z)),g=new UA(c,t),this.modelCache.set(h,g)}return g.clone()}))}dispose(){this.modelCache.forEach((e=>{e.traverse((t=>{if(t.isMesh){const A=t;A.geometry.dispose(),Array.isArray(A.material)?A.material.forEach((n=>{n instanceof Sn&&n.dispose()})):A.material instanceof Sn&&A.material.dispose()}}))})),this.textureCache.forEach((e=>{e.dispose()})),this.modelCache.clear(),this.textureCache.clear()}}class li{static convertUnityToThreeCoords(e){return new re(e.x,e.y,-e.z)}static normalizeAngle(e){let t=e%360;return t>180?t-=360:t<-180&&(t+=360),t}static convertUnityToThreeEuler(e){return new Mn(-li.normalizeAngle(e.x)*li.DEG_TO_RAD,-e.y*li.DEG_TO_RAD,-e.z*li.DEG_TO_RAD,"YXZ")}static convertThreeToUnityCoords(e){return new re(e.x,e.y,-e.z)}}li.DEG_TO_RAD=Math.PI/180,li.RAD_TO_DEG=180/Math.PI;class Xo{constructor(e){this.id=e.id,this.type=e.type,this.floor_vertical_position=e.floor_vertical_position,this.title=e.title,this.description=e.description,this.floorLevel=e.floorLevel,this.position=li.convertUnityToThreeCoords(this.toVector3(e.uposition)),this.rotation=li.convertUnityToThreeEuler(this.toVector3(e.urotation)),this.hasQA=e.hasQA,this.sunsimDayOfYear=e.sunsimDayOfYear,this.fieldOfView=e.fieldOfView,this.yawOffset=e.hasOwnProperty("yawOffset")?e.yawOffset:0,this.whitelist=Xo.parseWhitelist(e)}static hasWhitelist(e){var t;return!!(!((t=e?.whitelist)===null||t===void 0)&&t.length)}static parseWhitelist(e){return Array.isArray(e.whitelist)?e.whitelist.filter((t=>typeof t=="string")):Array.isArray(e.overrides)?e.overrides.filter((t=>t?.display&&t.cameraId)).map((t=>t.cameraId)):[]}toggleWhitelistMarker(e){this.whitelist||(this.whitelist=[]);const t=this.whitelist.indexOf(e);return t>=0?(this.whitelist.splice(t,1),!1):(this.whitelist.push(e),!0)}removeWhitelistMarker(e){var t;!((t=this.whitelist)===null||t===void 0)&&t.length&&(this.whitelist=this.whitelist.filter((A=>A!==e)))}clearWhitelist(){this.whitelist=[]}mergeWhitelist(e){this.whitelist||(this.whitelist=[]);const t=new Set(this.whitelist);for(const A of e)t.has(A)||(this.whitelist.push(A),t.add(A))}toVector3(e){const t=e.split(",").map(Number);return new re(t[0],t[1],t[2])}}class Ks{constructor(e){var t,A;this.id=e.id,this.direction=e.direction,this.floorLevel=e.floorLevel,this.floor_vertical_position=Number(e.floor_vertical_position),this.targetCameraId=e.targetCameraId,this.sourceCameraId=(t=e.sourceCameraId)!==null&&t!==void 0?t:"";const n=(A=e.position)!==null&&A!==void 0?A:e.uposition;this.position=li.convertUnityToThreeCoords(new re().fromArray(n.split(",").map((r=>Number(r.trim())))))}toJSON(){const e=li.convertThreeToUnityCoords(this.position);return{id:this.id,direction:this.direction,floorLevel:this.floorLevel,floor_vertical_position:String(this.floor_vertical_position),position:`${e.x.toFixed(3)},${e.y.toFixed(3)},${e.z.toFixed(3)}`,targetCameraId:this.targetCameraId,sourceCameraId:this.sourceCameraId}}static expectedTargetFloorLevel(e,t){return t==="up"?e+1:e-1}static isValidTargetFloor(e,t,A){return A===Ks.expectedTargetFloorLevel(e,t)}}class $x{constructor(e){this.id=e.id;const t=e.position.split(",").map(Number);this.position=new re(t[0],t[1],t[2]);const A=e.rotation?e.rotation.split(",").map(Number):[0,0,0];this.rotation=new Mn(A[0],A[1],A[2],"XYZ"),this.appearance=e.appearance;const n=e.scale?e.scale.split(",").map(Number):[1,1,1];this.scale=new re(n[0],n[1],n[2]);const r=e.color?e.color.split(",").map(Number):[1,1,1];this.color=new re(r[0],r[1],r[2]),this.depthOffset=e.depthOffset!==void 0?e.depthOffset:0}}var eb=function(o,e,t,A){return new(t||(t=Promise))((function(n,r){function g(c){try{u(A.next(c))}catch(C){r(C)}}function h(c){try{u(A.throw(c))}catch(C){r(C)}}function u(c){var C;c.done?n(c.value):(C=c.value,C instanceof t?C:new t((function(B){B(C)}))).then(g,h)}u((A=A.apply(o,[])).next())}))};class cI{constructor(e){this.constructorData=e,this.version=e.hasOwnProperty("version")?e.version:1,this.id=e.id,this.name=e.name,this.type=e.type,this.dayOfYear=e.dayOfYear,this.timeInHours=e.timeInHours,this.offsetUTC=e.offsetUTC,this.latitude=e.latitude,this.longitude=e.longitude,this.defaultMinimap=e.defaultMinimap,this.minimaps=e.minimaps,this.cameras=e.cameras.map((t=>new Xo(t))),Array.isArray(e.floorTransitions)?this.floorTransitions=e.floorTransitions.map((t=>new Ks(t))):this.floorTransitions=[],e.hasOwnProperty("interactiveObjects")&&Array.isArray(e.interactiveObjects)?this.interactiveObjects=e.interactiveObjects.map((t=>new $x(t))):this.interactiveObjects=[],this.hasHDR=!!e.hasOwnProperty("hasHDR")&&e.hasHDR,this.hasLores=!!e.hasOwnProperty("hasLores")&&e.hasLores,this.usesPngDepth=!!e.hasOwnProperty("usesPngDepth")&&e.usesPngDepth,this.version,this.hasHDR,this.hasLores}siteHasHDR(){return!!this.constructorData.hasOwnProperty("hasHDR")&&this.constructorData.hasHDR}static fromURL(e){return eb(this,void 0,void 0,(function*(){try{const t=yield K.fetch(e),A=yield t.json();return new cI(A)}catch(t){throw t}}))}}class YB{constructor(){this.needMaterialUpdate=!0,this.layers=[]}addLayer(e){this.layers.push(e),this.needMaterialUpdate=!0}removeLayer(e){const t=this.layers.indexOf(e);t!==-1&&this.layers.splice(t,1),this.needMaterialUpdate=!0}getActiveLayersCount(){let e=0;for(let t=0;t<this.layers.length;t++)this.layers[t].isActive&&e++;return e}clearLayers(){this.layers=[],this.needMaterialUpdate=!0}}class tb{constructor(){this.scene=new Rn,this.camera=new _n(-.5,.5,.5,-.5,0,1),this.material=this.createShaderMaterial();const e=new Ri(1,1);this.plane=new UA(e,this.material),this.scene.add(this.plane),this.renderTexture=new ei(ae.HISTOGRAM_WIDTH,ae.HISTOGRAM_HEIGHT,{type:be,depthBuffer:!1,stencilBuffer:!1}),this.pixelBuffer=new Uint8Array(ae.HISTOGRAM_WIDTH*ae.HISTOGRAM_HEIGHT*4)}createShaderMaterial(){return new Ai({uniforms:{u_image:{value:null},u_fovy_scale:{value:1}},vertexShader:`
|
|
3467
|
+
}`}),w=p.clone();w.defines.HORIZONTAL_PASS=1;const k=new bn;k.setAttribute("position",new Vi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const R=new UA(k,p),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=f;let N=this.type;function L(ne,Ae){const te=e.update(R);p.defines.VSM_SAMPLES!==ne.blurSamples&&(p.defines.VSM_SAMPLES=ne.blurSamples,w.defines.VSM_SAMPLES=ne.blurSamples,p.needsUpdate=!0,w.needsUpdate=!0),ne.mapPass===null&&(ne.mapPass=new ei(n.x,n.y)),p.uniforms.shadow_pass.value=ne.map.texture,p.uniforms.resolution.value=ne.mapSize,p.uniforms.radius.value=ne.radius,o.setRenderTarget(ne.mapPass),o.clear(),o.renderBufferDirect(Ae,null,te,p,R,null),w.uniforms.shadow_pass.value=ne.mapPass.texture,w.uniforms.resolution.value=ne.mapSize,w.uniforms.radius.value=ne.radius,o.setRenderTarget(ne.map),o.clear(),o.renderBufferDirect(Ae,null,te,w,R,null)}function G(ne,Ae,te,ye){let ge=null;const Me=te.isPointLight===!0?ne.customDistanceMaterial:ne.customDepthMaterial;if(Me!==void 0)ge=Me;else if(ge=te.isPointLight===!0?u:h,o.localClippingEnabled&&Ae.clipShadows===!0&&Array.isArray(Ae.clippingPlanes)&&Ae.clippingPlanes.length!==0||Ae.displacementMap&&Ae.displacementScale!==0||Ae.alphaMap&&Ae.alphaTest>0||Ae.map&&Ae.alphaTest>0){const pe=ge.uuid,Ze=Ae.uuid;let Ct=c[pe];Ct===void 0&&(Ct={},c[pe]=Ct);let Qt=Ct[Ze];Qt===void 0&&(Qt=ge.clone(),Ct[Ze]=Qt),ge=Qt}return ge.visible=Ae.visible,ge.wireframe=Ae.wireframe,ge.side=ye===Q?Ae.shadowSide!==null?Ae.shadowSide:Ae.side:Ae.shadowSide!==null?Ae.shadowSide:B[Ae.side],ge.alphaMap=Ae.alphaMap,ge.alphaTest=Ae.alphaTest,ge.map=Ae.map,ge.clipShadows=Ae.clipShadows,ge.clippingPlanes=Ae.clippingPlanes,ge.clipIntersection=Ae.clipIntersection,ge.displacementMap=Ae.displacementMap,ge.displacementScale=Ae.displacementScale,ge.displacementBias=Ae.displacementBias,ge.wireframeLinewidth=Ae.wireframeLinewidth,ge.linewidth=Ae.linewidth,te.isPointLight===!0&&ge.isMeshDistanceMaterial===!0&&(o.properties.get(ge).light=te),ge}function le(ne,Ae,te,ye,ge){if(ne.visible===!1)return;if(ne.layers.test(Ae.layers)&&(ne.isMesh||ne.isLine||ne.isPoints)&&(ne.castShadow||ne.receiveShadow&&ge===Q)&&(!ne.frustumCulled||A.intersectsObject(ne))){ne.modelViewMatrix.multiplyMatrices(te.matrixWorldInverse,ne.matrixWorld);const pe=e.update(ne),Ze=ne.material;if(Array.isArray(Ze)){const Ct=pe.groups;for(let Qt=0,Wt=Ct.length;Qt<Wt;Qt++){const ft=Ct[Qt],Mt=Ze[ft.materialIndex];if(Mt&&Mt.visible){const Rt=G(ne,Mt,ye,ge);o.renderBufferDirect(te,null,pe,Rt,ne,ft)}}}else if(Ze.visible){const Ct=G(ne,Ze,ye,ge);o.renderBufferDirect(te,null,pe,Ct,ne,null)}}const Me=ne.children;for(let pe=0,Ze=Me.length;pe<Ze;pe++)le(Me[pe],Ae,te,ye,ge)}this.render=function(ne,Ae,te){if(_.enabled===!1||_.autoUpdate===!1&&_.needsUpdate===!1||ne.length===0)return;const ye=o.getRenderTarget(),ge=o.getActiveCubeFace(),Me=o.getActiveMipmapLevel(),pe=o.state;pe.setBlending(0),pe.buffers.color.setClear(1,1,1,1),pe.buffers.depth.setTest(!0),pe.setScissorTest(!1);const Ze=N!==Q&&this.type===Q,Ct=N===Q&&this.type!==Q;for(let Qt=0,Wt=ne.length;Qt<Wt;Qt++){const ft=ne[Qt],Mt=ft.shadow;if(Mt===void 0||Mt.autoUpdate===!1&&Mt.needsUpdate===!1)continue;n.copy(Mt.mapSize);const Rt=Mt.getFrameExtents();if(n.multiply(Rt),r.copy(Mt.mapSize),(n.x>C||n.y>C)&&(n.x>C&&(r.x=Math.floor(C/Rt.x),n.x=r.x*Rt.x,Mt.mapSize.x=r.x),n.y>C&&(r.y=Math.floor(C/Rt.y),n.y=r.y*Rt.y,Mt.mapSize.y=r.y)),Mt.map===null||Ze===!0||Ct===!0){const Ye=this.type!==Q?{minFilter:Be,magFilter:Be}:{};Mt.map!==null&&Mt.map.dispose(),Mt.map=new ei(n.x,n.y,Ye),Mt.map.texture.name=ft.name+".shadowMap",Mt.camera.updateProjectionMatrix()}o.setRenderTarget(Mt.map),o.clear();const Ft=Mt.getViewportCount();for(let Ye=0;Ye<Ft;Ye++){const dt=Mt.getViewport(Ye);g.set(r.x*dt.x,r.y*dt.y,r.x*dt.z,r.y*dt.w),pe.viewport(g),Mt.updateMatrices(ft,Ye),A=Mt.getFrustum(),le(Ae,te,Mt.camera,ft,this.type)}Mt.isPointLightShadow!==!0&&this.type===Q&&L(Mt,te),Mt.needsUpdate=!1}N=this.type,_.needsUpdate=!1,o.setRenderTarget(ye,ge,Me)}}function SS(o,e,t){const A=t.isWebGL2,n=new function(){let oe=!1;const Te=new zA;let ct=null;const St=new zA(0,0,0,0);return{setMask:function(ht){ct===ht||oe||(o.colorMask(ht,ht,ht,ht),ct=ht)},setLocked:function(ht){oe=ht},setClear:function(ht,Kt,Ht,_t,CA){CA===!0&&(ht*=_t,Kt*=_t,Ht*=_t),Te.set(ht,Kt,Ht,_t),St.equals(Te)===!1&&(o.clearColor(ht,Kt,Ht,_t),St.copy(Te))},reset:function(){oe=!1,ct=null,St.set(-1,0,0,0)}}},r=new function(){let oe=!1,Te=null,ct=null,St=null;return{setTest:function(ht){ht?Xt(o.DEPTH_TEST):ce(o.DEPTH_TEST)},setMask:function(ht){Te===ht||oe||(o.depthMask(ht),Te=ht)},setFunc:function(ht){if(ct!==ht){switch(ht){case 0:o.depthFunc(o.NEVER);break;case 1:o.depthFunc(o.ALWAYS);break;case 2:o.depthFunc(o.LESS);break;case 3:default:o.depthFunc(o.LEQUAL);break;case 4:o.depthFunc(o.EQUAL);break;case 5:o.depthFunc(o.GEQUAL);break;case 6:o.depthFunc(o.GREATER);break;case 7:o.depthFunc(o.NOTEQUAL)}ct=ht}},setLocked:function(ht){oe=ht},setClear:function(ht){St!==ht&&(o.clearDepth(ht),St=ht)},reset:function(){oe=!1,Te=null,ct=null,St=null}}},g=new function(){let oe=!1,Te=null,ct=null,St=null,ht=null,Kt=null,Ht=null,_t=null,CA=null;return{setTest:function(hA){oe||(hA?Xt(o.STENCIL_TEST):ce(o.STENCIL_TEST))},setMask:function(hA){Te===hA||oe||(o.stencilMask(hA),Te=hA)},setFunc:function(hA,J,$){ct===hA&&St===J&&ht===$||(o.stencilFunc(hA,J,$),ct=hA,St=J,ht=$)},setOp:function(hA,J,$){Kt===hA&&Ht===J&&_t===$||(o.stencilOp(hA,J,$),Kt=hA,Ht=J,_t=$)},setLocked:function(hA){oe=hA},setClear:function(hA){CA!==hA&&(o.clearStencil(hA),CA=hA)},reset:function(){oe=!1,Te=null,ct=null,St=null,ht=null,Kt=null,Ht=null,_t=null,CA=null}}},h=new WeakMap,u=new WeakMap;let c={},C={},B=new WeakMap,p=[],w=null,k=!1,R=null,_=null,N=null,L=null,G=null,le=null,ne=null,Ae=!1,te=null,ye=null,ge=null,Me=null,pe=null;const Ze=o.getParameter(o.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Ct=!1,Qt=0;const Wt=o.getParameter(o.VERSION);Wt.indexOf("WebGL")!==-1?(Qt=parseFloat(/^WebGL (\d)/.exec(Wt)[1]),Ct=Qt>=1):Wt.indexOf("OpenGL ES")!==-1&&(Qt=parseFloat(/^OpenGL ES (\d)/.exec(Wt)[1]),Ct=Qt>=2);let ft=null,Mt={};const Rt=o.getParameter(o.SCISSOR_BOX),Ft=o.getParameter(o.VIEWPORT),Ye=new zA().fromArray(Rt),dt=new zA().fromArray(Ft);function bt(oe,Te,ct,St){const ht=new Uint8Array(4),Kt=o.createTexture();o.bindTexture(oe,Kt),o.texParameteri(oe,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(oe,o.TEXTURE_MAG_FILTER,o.NEAREST);for(let Ht=0;Ht<ct;Ht++)!A||oe!==o.TEXTURE_3D&&oe!==o.TEXTURE_2D_ARRAY?o.texImage2D(Te+Ht,0,o.RGBA,1,1,0,o.RGBA,o.UNSIGNED_BYTE,ht):o.texImage3D(Te,0,o.RGBA,1,1,St,0,o.RGBA,o.UNSIGNED_BYTE,ht);return Kt}const gt={};function Xt(oe){c[oe]!==!0&&(o.enable(oe),c[oe]=!0)}function ce(oe){c[oe]!==!1&&(o.disable(oe),c[oe]=!1)}gt[o.TEXTURE_2D]=bt(o.TEXTURE_2D,o.TEXTURE_2D,1),gt[o.TEXTURE_CUBE_MAP]=bt(o.TEXTURE_CUBE_MAP,o.TEXTURE_CUBE_MAP_POSITIVE_X,6),A&&(gt[o.TEXTURE_2D_ARRAY]=bt(o.TEXTURE_2D_ARRAY,o.TEXTURE_2D_ARRAY,1,1),gt[o.TEXTURE_3D]=bt(o.TEXTURE_3D,o.TEXTURE_3D,1,1)),n.setClear(0,0,0,1),r.setClear(1),g.setClear(0),Xt(o.DEPTH_TEST),r.setFunc(3),_e(!1),Et(1),Xt(o.CULL_FACE),je(0);const Ie={[S]:o.FUNC_ADD,101:o.FUNC_SUBTRACT,102:o.FUNC_REVERSE_SUBTRACT};if(A)Ie[103]=o.MIN,Ie[104]=o.MAX;else{const oe=e.get("EXT_blend_minmax");oe!==null&&(Ie[103]=oe.MIN_EXT,Ie[104]=oe.MAX_EXT)}const Se={200:o.ZERO,201:o.ONE,202:o.SRC_COLOR,204:o.SRC_ALPHA,210:o.SRC_ALPHA_SATURATE,208:o.DST_COLOR,206:o.DST_ALPHA,203:o.ONE_MINUS_SRC_COLOR,205:o.ONE_MINUS_SRC_ALPHA,209:o.ONE_MINUS_DST_COLOR,207:o.ONE_MINUS_DST_ALPHA};function je(oe,Te,ct,St,ht,Kt,Ht,_t){if(oe!==0){if(k===!1&&(Xt(o.BLEND),k=!0),oe===5)ht=ht||Te,Kt=Kt||ct,Ht=Ht||St,Te===_&&ht===G||(o.blendEquationSeparate(Ie[Te],Ie[ht]),_=Te,G=ht),ct===N&&St===L&&Kt===le&&Ht===ne||(o.blendFuncSeparate(Se[ct],Se[St],Se[Kt],Se[Ht]),N=ct,L=St,le=Kt,ne=Ht),R=oe,Ae=!1;else if(oe!==R||_t!==Ae){if(_===S&&G===S||(o.blendEquation(o.FUNC_ADD),_=S,G=S),_t)switch(oe){case 1:o.blendFuncSeparate(o.ONE,o.ONE_MINUS_SRC_ALPHA,o.ONE,o.ONE_MINUS_SRC_ALPHA);break;case 2:o.blendFunc(o.ONE,o.ONE);break;case 3:o.blendFuncSeparate(o.ZERO,o.ONE_MINUS_SRC_COLOR,o.ZERO,o.ONE);break;case 4:o.blendFuncSeparate(o.ZERO,o.SRC_COLOR,o.ZERO,o.SRC_ALPHA)}else switch(oe){case 1:o.blendFuncSeparate(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA,o.ONE,o.ONE_MINUS_SRC_ALPHA);break;case 2:o.blendFunc(o.SRC_ALPHA,o.ONE);break;case 3:o.blendFuncSeparate(o.ZERO,o.ONE_MINUS_SRC_COLOR,o.ZERO,o.ONE);break;case 4:o.blendFunc(o.ZERO,o.SRC_COLOR)}N=null,L=null,le=null,ne=null,R=oe,Ae=_t}}else k===!0&&(ce(o.BLEND),k=!1)}function _e(oe){te!==oe&&(oe?o.frontFace(o.CW):o.frontFace(o.CCW),te=oe)}function Et(oe){oe!==0?(Xt(o.CULL_FACE),oe!==ye&&(oe===1?o.cullFace(o.BACK):oe===2?o.cullFace(o.FRONT):o.cullFace(o.FRONT_AND_BACK))):ce(o.CULL_FACE),ye=oe}function ke(oe,Te,ct){oe?(Xt(o.POLYGON_OFFSET_FILL),Me===Te&&pe===ct||(o.polygonOffset(Te,ct),Me=Te,pe=ct)):ce(o.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:r,stencil:g},enable:Xt,disable:ce,bindFramebuffer:function(oe,Te){return C[oe]!==Te&&(o.bindFramebuffer(oe,Te),C[oe]=Te,A&&(oe===o.DRAW_FRAMEBUFFER&&(C[o.FRAMEBUFFER]=Te),oe===o.FRAMEBUFFER&&(C[o.DRAW_FRAMEBUFFER]=Te)),!0)},drawBuffers:function(oe,Te){let ct=p,St=!1;if(oe)if(ct=B.get(Te),ct===void 0&&(ct=[],B.set(Te,ct)),oe.isWebGLMultipleRenderTargets){const ht=oe.texture;if(ct.length!==ht.length||ct[0]!==o.COLOR_ATTACHMENT0){for(let Kt=0,Ht=ht.length;Kt<Ht;Kt++)ct[Kt]=o.COLOR_ATTACHMENT0+Kt;ct.length=ht.length,St=!0}}else ct[0]!==o.COLOR_ATTACHMENT0&&(ct[0]=o.COLOR_ATTACHMENT0,St=!0);else ct[0]!==o.BACK&&(ct[0]=o.BACK,St=!0);St&&(t.isWebGL2?o.drawBuffers(ct):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(ct))},useProgram:function(oe){return w!==oe&&(o.useProgram(oe),w=oe,!0)},setBlending:je,setMaterial:function(oe,Te){oe.side===2?ce(o.CULL_FACE):Xt(o.CULL_FACE);let ct=oe.side===v;Te&&(ct=!ct),_e(ct),oe.blending===1&&oe.transparent===!1?je(0):je(oe.blending,oe.blendEquation,oe.blendSrc,oe.blendDst,oe.blendEquationAlpha,oe.blendSrcAlpha,oe.blendDstAlpha,oe.premultipliedAlpha),r.setFunc(oe.depthFunc),r.setTest(oe.depthTest),r.setMask(oe.depthWrite),n.setMask(oe.colorWrite);const St=oe.stencilWrite;g.setTest(St),St&&(g.setMask(oe.stencilWriteMask),g.setFunc(oe.stencilFunc,oe.stencilRef,oe.stencilFuncMask),g.setOp(oe.stencilFail,oe.stencilZFail,oe.stencilZPass)),ke(oe.polygonOffset,oe.polygonOffsetFactor,oe.polygonOffsetUnits),oe.alphaToCoverage===!0?Xt(o.SAMPLE_ALPHA_TO_COVERAGE):ce(o.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:_e,setCullFace:Et,setLineWidth:function(oe){oe!==ge&&(Ct&&o.lineWidth(oe),ge=oe)},setPolygonOffset:ke,setScissorTest:function(oe){oe?Xt(o.SCISSOR_TEST):ce(o.SCISSOR_TEST)},activeTexture:function(oe){oe===void 0&&(oe=o.TEXTURE0+Ze-1),ft!==oe&&(o.activeTexture(oe),ft=oe)},bindTexture:function(oe,Te,ct){ct===void 0&&(ct=ft===null?o.TEXTURE0+Ze-1:ft);let St=Mt[ct];St===void 0&&(St={type:void 0,texture:void 0},Mt[ct]=St),St.type===oe&&St.texture===Te||(ft!==ct&&(o.activeTexture(ct),ft=ct),o.bindTexture(oe,Te||gt[oe]),St.type=oe,St.texture=Te)},unbindTexture:function(){const oe=Mt[ft];oe!==void 0&&oe.type!==void 0&&(o.bindTexture(oe.type,null),oe.type=void 0,oe.texture=void 0)},compressedTexImage2D:function(){try{o.compressedTexImage2D.apply(o,arguments)}catch{}},compressedTexImage3D:function(){try{o.compressedTexImage3D.apply(o,arguments)}catch{}},texImage2D:function(){try{o.texImage2D.apply(o,arguments)}catch{}},texImage3D:function(){try{o.texImage3D.apply(o,arguments)}catch{}},updateUBOMapping:function(oe,Te){let ct=u.get(Te);ct===void 0&&(ct=new WeakMap,u.set(Te,ct));let St=ct.get(oe);St===void 0&&(St=o.getUniformBlockIndex(Te,oe.name),ct.set(oe,St))},uniformBlockBinding:function(oe,Te){const ct=u.get(Te).get(oe);h.get(Te)!==ct&&(o.uniformBlockBinding(Te,ct,oe.__bindingPointIndex),h.set(Te,ct))},texStorage2D:function(){try{o.texStorage2D.apply(o,arguments)}catch{}},texStorage3D:function(){try{o.texStorage3D.apply(o,arguments)}catch{}},texSubImage2D:function(){try{o.texSubImage2D.apply(o,arguments)}catch{}},texSubImage3D:function(){try{o.texSubImage3D.apply(o,arguments)}catch{}},compressedTexSubImage2D:function(){try{o.compressedTexSubImage2D.apply(o,arguments)}catch{}},compressedTexSubImage3D:function(){try{o.compressedTexSubImage3D.apply(o,arguments)}catch{}},scissor:function(oe){Ye.equals(oe)===!1&&(o.scissor(oe.x,oe.y,oe.z,oe.w),Ye.copy(oe))},viewport:function(oe){dt.equals(oe)===!1&&(o.viewport(oe.x,oe.y,oe.z,oe.w),dt.copy(oe))},reset:function(){o.disable(o.BLEND),o.disable(o.CULL_FACE),o.disable(o.DEPTH_TEST),o.disable(o.POLYGON_OFFSET_FILL),o.disable(o.SCISSOR_TEST),o.disable(o.STENCIL_TEST),o.disable(o.SAMPLE_ALPHA_TO_COVERAGE),o.blendEquation(o.FUNC_ADD),o.blendFunc(o.ONE,o.ZERO),o.blendFuncSeparate(o.ONE,o.ZERO,o.ONE,o.ZERO),o.colorMask(!0,!0,!0,!0),o.clearColor(0,0,0,0),o.depthMask(!0),o.depthFunc(o.LESS),o.clearDepth(1),o.stencilMask(4294967295),o.stencilFunc(o.ALWAYS,0,4294967295),o.stencilOp(o.KEEP,o.KEEP,o.KEEP),o.clearStencil(0),o.cullFace(o.BACK),o.frontFace(o.CCW),o.polygonOffset(0,0),o.activeTexture(o.TEXTURE0),o.bindFramebuffer(o.FRAMEBUFFER,null),A===!0&&(o.bindFramebuffer(o.DRAW_FRAMEBUFFER,null),o.bindFramebuffer(o.READ_FRAMEBUFFER,null)),o.useProgram(null),o.lineWidth(1),o.scissor(0,0,o.canvas.width,o.canvas.height),o.viewport(0,0,o.canvas.width,o.canvas.height),c={},ft=null,Mt={},C={},B=new WeakMap,p=[],w=null,k=!1,R=null,_=null,N=null,L=null,G=null,le=null,ne=null,Ae=!1,te=null,ye=null,ge=null,Me=null,pe=null,Ye.set(0,0,o.canvas.width,o.canvas.height),dt.set(0,0,o.canvas.width,o.canvas.height),n.reset(),r.reset(),g.reset()}}}function xS(o,e,t,A,n,r,g){const h=n.isWebGL2,u=(n.maxTextures,n.maxCubemapSize),c=n.maxTextureSize,C=n.maxSamples,B=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator<"u"&&/OculusBrowser/g.test(navigator.userAgent),w=new WeakMap;let k;const R=new WeakMap;let _=!1;try{_=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function N(ce,Ie){return _?new OffscreenCanvas(ce,Ie):wn("canvas")}function L(ce,Ie,Se,je){let _e=1;if((ce.width>je||ce.height>je)&&(_e=je/Math.max(ce.width,ce.height)),_e<1||Ie===!0){if(typeof HTMLImageElement<"u"&&ce instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&ce instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&ce instanceof ImageBitmap){const Et=Ie?Fr:Math.floor,ke=Et(_e*ce.width),oe=Et(_e*ce.height);k===void 0&&(k=N(ke,oe));const Te=Se?N(ke,oe):k;return Te.width=ke,Te.height=oe,Te.getContext("2d").drawImage(ce,0,0,ke,oe),ce.width,ce.height,Te}return"data"in ce&&(ce.width,ce.height),ce}return ce}function G(ce){return $n(ce.width)&&$n(ce.height)}function le(ce,Ie){return ce.generateMipmaps&&Ie&&ce.minFilter!==Be&&ce.minFilter!==Qe}function ne(ce){o.generateMipmap(ce)}function Ae(ce,Ie,Se,je,_e=!1){if(h===!1)return Ie;if(ce!==null&&o[ce]!==void 0)return o[ce];let Et=Ie;return Ie===o.RED&&(Se===o.FLOAT&&(Et=o.R32F),Se===o.HALF_FLOAT&&(Et=o.R16F),Se===o.UNSIGNED_BYTE&&(Et=o.R8)),Ie===o.RG&&(Se===o.FLOAT&&(Et=o.RG32F),Se===o.HALF_FLOAT&&(Et=o.RG16F),Se===o.UNSIGNED_BYTE&&(Et=o.RG8)),Ie===o.RGBA&&(Se===o.FLOAT&&(Et=o.RGBA32F),Se===o.HALF_FLOAT&&(Et=o.RGBA16F),Se===o.UNSIGNED_BYTE&&(Et=je===ie&&_e===!1?o.SRGB8_ALPHA8:o.RGBA8),Se===o.UNSIGNED_SHORT_4_4_4_4&&(Et=o.RGBA4),Se===o.UNSIGNED_SHORT_5_5_5_1&&(Et=o.RGB5_A1)),Et!==o.R16F&&Et!==o.R32F&&Et!==o.RG16F&&Et!==o.RG32F&&Et!==o.RGBA16F&&Et!==o.RGBA32F||e.get("EXT_color_buffer_float"),Et}function te(ce,Ie,Se){return le(ce,Se)===!0||ce.isFramebufferTexture&&ce.minFilter!==Be&&ce.minFilter!==Qe?Math.log2(Math.max(Ie.width,Ie.height))+1:ce.mipmaps!==void 0&&ce.mipmaps.length>0?ce.mipmaps.length:ce.isCompressedTexture&&Array.isArray(ce.image)?Ie.mipmaps.length:1}function ye(ce){return ce===Be||ce===qe||ce===me?o.NEAREST:o.LINEAR}function ge(ce){const Ie=ce.target;Ie.removeEventListener("dispose",ge),(function(Se){const je=A.get(Se);if(je.__webglInit===void 0)return;const _e=Se.source,Et=R.get(_e);if(Et){const ke=Et[je.__cacheKey];ke.usedTimes--,ke.usedTimes===0&&pe(Se),Object.keys(Et).length===0&&R.delete(_e)}A.remove(Se)})(Ie),Ie.isVideoTexture&&w.delete(Ie)}function Me(ce){const Ie=ce.target;Ie.removeEventListener("dispose",Me),(function(Se){const je=Se.texture,_e=A.get(Se),Et=A.get(je);if(Et.__webglTexture!==void 0&&(o.deleteTexture(Et.__webglTexture),g.memory.textures--),Se.depthTexture&&Se.depthTexture.dispose(),Se.isWebGLCubeRenderTarget)for(let ke=0;ke<6;ke++)o.deleteFramebuffer(_e.__webglFramebuffer[ke]),_e.__webglDepthbuffer&&o.deleteRenderbuffer(_e.__webglDepthbuffer[ke]);else{if(o.deleteFramebuffer(_e.__webglFramebuffer),_e.__webglDepthbuffer&&o.deleteRenderbuffer(_e.__webglDepthbuffer),_e.__webglMultisampledFramebuffer&&o.deleteFramebuffer(_e.__webglMultisampledFramebuffer),_e.__webglColorRenderbuffer)for(let ke=0;ke<_e.__webglColorRenderbuffer.length;ke++)_e.__webglColorRenderbuffer[ke]&&o.deleteRenderbuffer(_e.__webglColorRenderbuffer[ke]);_e.__webglDepthRenderbuffer&&o.deleteRenderbuffer(_e.__webglDepthRenderbuffer)}if(Se.isWebGLMultipleRenderTargets)for(let ke=0,oe=je.length;ke<oe;ke++){const Te=A.get(je[ke]);Te.__webglTexture&&(o.deleteTexture(Te.__webglTexture),g.memory.textures--),A.remove(je[ke])}A.remove(je),A.remove(Se)})(Ie)}function pe(ce){const Ie=A.get(ce);o.deleteTexture(Ie.__webglTexture);const Se=ce.source;delete R.get(Se)[Ie.__cacheKey],g.memory.textures--}let Ze=0;function Ct(ce,Ie){const Se=A.get(ce);if(ce.isVideoTexture&&(function(je){const _e=g.render.frame;w.get(je)!==_e&&(w.set(je,_e),je.update())})(ce),ce.isRenderTargetTexture===!1&&ce.version>0&&Se.__version!==ce.version){const je=ce.image;if(je!==null){if(je.complete!==!1)return void Rt(Se,ce,Ie)}}t.bindTexture(o.TEXTURE_2D,Se.__webglTexture,o.TEXTURE0+Ie)}const Qt={[Ce]:o.REPEAT,[ee]:o.CLAMP_TO_EDGE,[Fe]:o.MIRRORED_REPEAT},Wt={[Be]:o.NEAREST,[qe]:o.NEAREST_MIPMAP_NEAREST,[me]:o.NEAREST_MIPMAP_LINEAR,[Qe]:o.LINEAR,[tt]:o.LINEAR_MIPMAP_NEAREST,[se]:o.LINEAR_MIPMAP_LINEAR};function ft(ce,Ie,Se){if(Se?(o.texParameteri(ce,o.TEXTURE_WRAP_S,Qt[Ie.wrapS]),o.texParameteri(ce,o.TEXTURE_WRAP_T,Qt[Ie.wrapT]),ce!==o.TEXTURE_3D&&ce!==o.TEXTURE_2D_ARRAY||o.texParameteri(ce,o.TEXTURE_WRAP_R,Qt[Ie.wrapR]),o.texParameteri(ce,o.TEXTURE_MAG_FILTER,Wt[Ie.magFilter]),o.texParameteri(ce,o.TEXTURE_MIN_FILTER,Wt[Ie.minFilter])):(o.texParameteri(ce,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(ce,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),ce!==o.TEXTURE_3D&&ce!==o.TEXTURE_2D_ARRAY||o.texParameteri(ce,o.TEXTURE_WRAP_R,o.CLAMP_TO_EDGE),Ie.wrapS!==ee||Ie.wrapT,o.texParameteri(ce,o.TEXTURE_MAG_FILTER,ye(Ie.magFilter)),o.texParameteri(ce,o.TEXTURE_MIN_FILTER,ye(Ie.minFilter)),Ie.minFilter!==Be&&Ie.minFilter),e.has("EXT_texture_filter_anisotropic")===!0){const je=e.get("EXT_texture_filter_anisotropic");if(Ie.magFilter===Be||Ie.minFilter!==me&&Ie.minFilter!==se||Ie.type===De&&e.has("OES_texture_float_linear")===!1||h===!1&&Ie.type===mt&&e.has("OES_texture_half_float_linear")===!1)return;(Ie.anisotropy>1||A.get(Ie).__currentAnisotropy)&&(o.texParameterf(ce,je.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(Ie.anisotropy,n.getMaxAnisotropy())),A.get(Ie).__currentAnisotropy=Ie.anisotropy)}}function Mt(ce,Ie){let Se=!1;ce.__webglInit===void 0&&(ce.__webglInit=!0,Ie.addEventListener("dispose",ge));const je=Ie.source;let _e=R.get(je);_e===void 0&&(_e={},R.set(je,_e));const Et=(function(ke){const oe=[];return oe.push(ke.wrapS),oe.push(ke.wrapT),oe.push(ke.wrapR||0),oe.push(ke.magFilter),oe.push(ke.minFilter),oe.push(ke.anisotropy),oe.push(ke.internalFormat),oe.push(ke.format),oe.push(ke.type),oe.push(ke.generateMipmaps),oe.push(ke.premultiplyAlpha),oe.push(ke.flipY),oe.push(ke.unpackAlignment),oe.push(ke.colorSpace),oe.join()})(Ie);if(Et!==ce.__cacheKey){_e[Et]===void 0&&(_e[Et]={texture:o.createTexture(),usedTimes:0},g.memory.textures++,Se=!0),_e[Et].usedTimes++;const ke=_e[ce.__cacheKey];ke!==void 0&&(_e[ce.__cacheKey].usedTimes--,ke.usedTimes===0&&pe(Ie)),ce.__cacheKey=Et,ce.__webglTexture=_e[Et].texture}return Se}function Rt(ce,Ie,Se){let je=o.TEXTURE_2D;(Ie.isDataArrayTexture||Ie.isCompressedArrayTexture)&&(je=o.TEXTURE_2D_ARRAY),Ie.isData3DTexture&&(je=o.TEXTURE_3D);const _e=Mt(ce,Ie),Et=Ie.source;t.bindTexture(je,ce.__webglTexture,o.TEXTURE0+Se);const ke=A.get(Et);if(Et.version!==ke.__version||_e===!0){t.activeTexture(o.TEXTURE0+Se),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,Ie.flipY),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ie.premultiplyAlpha),o.pixelStorei(o.UNPACK_ALIGNMENT,Ie.unpackAlignment),o.pixelStorei(o.UNPACK_COLORSPACE_CONVERSION_WEBGL,o.NONE);const oe=(function($){return!h&&($.wrapS!==ee||$.wrapT!==ee||$.minFilter!==Be&&$.minFilter!==Qe)})(Ie)&&G(Ie.image)===!1;let Te=L(Ie.image,oe,!1,c);Te=Xt(Ie,Te);const ct=G(Te)||h,St=r.convert(Ie.format,Ie.colorSpace);let ht,Kt=r.convert(Ie.type),Ht=Ae(Ie.internalFormat,St,Kt,Ie.colorSpace);ft(je,Ie,ct);const _t=Ie.mipmaps,CA=h&&Ie.isVideoTexture!==!0,hA=ke.__version===void 0||_e===!0,J=te(Ie,Te,ct);if(Ie.isDepthTexture)Ht=o.DEPTH_COMPONENT,h?Ht=Ie.type===De?o.DEPTH_COMPONENT32F:Ie.type===U?o.DEPTH_COMPONENT24:Ie.type===He?o.DEPTH24_STENCIL8:o.DEPTH_COMPONENT16:Ie.type,Ie.format===st&&Ht===o.DEPTH_COMPONENT&&Ie.type!==1012&&Ie.type!==U&&(Ie.type=U,Kt=r.convert(Ie.type)),Ie.format===Tt&&Ht===o.DEPTH_COMPONENT&&(Ht=o.DEPTH_STENCIL,Ie.type!==He&&(Ie.type=He,Kt=r.convert(Ie.type))),hA&&(CA?t.texStorage2D(o.TEXTURE_2D,1,Ht,Te.width,Te.height):t.texImage2D(o.TEXTURE_2D,0,Ht,Te.width,Te.height,0,St,Kt,null));else if(Ie.isDataTexture)if(_t.length>0&&ct){CA&&hA&&t.texStorage2D(o.TEXTURE_2D,J,Ht,_t[0].width,_t[0].height);for(let $=0,xe=_t.length;$<xe;$++)ht=_t[$],CA?t.texSubImage2D(o.TEXTURE_2D,$,0,0,ht.width,ht.height,St,Kt,ht.data):t.texImage2D(o.TEXTURE_2D,$,Ht,ht.width,ht.height,0,St,Kt,ht.data);Ie.generateMipmaps=!1}else CA?(hA&&t.texStorage2D(o.TEXTURE_2D,J,Ht,Te.width,Te.height),t.texSubImage2D(o.TEXTURE_2D,0,0,0,Te.width,Te.height,St,Kt,Te.data)):t.texImage2D(o.TEXTURE_2D,0,Ht,Te.width,Te.height,0,St,Kt,Te.data);else if(Ie.isCompressedTexture)if(Ie.isCompressedArrayTexture){CA&&hA&&t.texStorage3D(o.TEXTURE_2D_ARRAY,J,Ht,_t[0].width,_t[0].height,Te.depth);for(let $=0,xe=_t.length;$<xe;$++)ht=_t[$],Ie.format!==kt?St!==null&&(CA?t.compressedTexSubImage3D(o.TEXTURE_2D_ARRAY,$,0,0,0,ht.width,ht.height,Te.depth,St,ht.data,0,0):t.compressedTexImage3D(o.TEXTURE_2D_ARRAY,$,Ht,ht.width,ht.height,Te.depth,0,ht.data,0,0)):CA?t.texSubImage3D(o.TEXTURE_2D_ARRAY,$,0,0,0,ht.width,ht.height,Te.depth,St,Kt,ht.data):t.texImage3D(o.TEXTURE_2D_ARRAY,$,Ht,ht.width,ht.height,Te.depth,0,St,Kt,ht.data)}else{CA&&hA&&t.texStorage2D(o.TEXTURE_2D,J,Ht,_t[0].width,_t[0].height);for(let $=0,xe=_t.length;$<xe;$++)ht=_t[$],Ie.format!==kt?St!==null&&(CA?t.compressedTexSubImage2D(o.TEXTURE_2D,$,0,0,ht.width,ht.height,St,ht.data):t.compressedTexImage2D(o.TEXTURE_2D,$,Ht,ht.width,ht.height,0,ht.data)):CA?t.texSubImage2D(o.TEXTURE_2D,$,0,0,ht.width,ht.height,St,Kt,ht.data):t.texImage2D(o.TEXTURE_2D,$,Ht,ht.width,ht.height,0,St,Kt,ht.data)}else if(Ie.isDataArrayTexture)CA?(hA&&t.texStorage3D(o.TEXTURE_2D_ARRAY,J,Ht,Te.width,Te.height,Te.depth),t.texSubImage3D(o.TEXTURE_2D_ARRAY,0,0,0,0,Te.width,Te.height,Te.depth,St,Kt,Te.data)):t.texImage3D(o.TEXTURE_2D_ARRAY,0,Ht,Te.width,Te.height,Te.depth,0,St,Kt,Te.data);else if(Ie.isData3DTexture)CA?(hA&&t.texStorage3D(o.TEXTURE_3D,J,Ht,Te.width,Te.height,Te.depth),t.texSubImage3D(o.TEXTURE_3D,0,0,0,0,Te.width,Te.height,Te.depth,St,Kt,Te.data)):t.texImage3D(o.TEXTURE_3D,0,Ht,Te.width,Te.height,Te.depth,0,St,Kt,Te.data);else if(Ie.isFramebufferTexture){if(hA)if(CA)t.texStorage2D(o.TEXTURE_2D,J,Ht,Te.width,Te.height);else{let $=Te.width,xe=Te.height;for(let rt=0;rt<J;rt++)t.texImage2D(o.TEXTURE_2D,rt,Ht,$,xe,0,St,Kt,null),$>>=1,xe>>=1}}else if(_t.length>0&&ct){CA&&hA&&t.texStorage2D(o.TEXTURE_2D,J,Ht,_t[0].width,_t[0].height);for(let $=0,xe=_t.length;$<xe;$++)ht=_t[$],CA?t.texSubImage2D(o.TEXTURE_2D,$,0,0,St,Kt,ht):t.texImage2D(o.TEXTURE_2D,$,Ht,St,Kt,ht);Ie.generateMipmaps=!1}else CA?(hA&&t.texStorage2D(o.TEXTURE_2D,J,Ht,Te.width,Te.height),t.texSubImage2D(o.TEXTURE_2D,0,0,0,St,Kt,Te)):t.texImage2D(o.TEXTURE_2D,0,Ht,St,Kt,Te);le(Ie,ct)&&ne(je),ke.__version=Et.version,Ie.onUpdate&&Ie.onUpdate(Ie)}ce.__version=Ie.version}function Ft(ce,Ie,Se,je,_e){const Et=r.convert(Se.format,Se.colorSpace),ke=r.convert(Se.type),oe=Ae(Se.internalFormat,Et,ke,Se.colorSpace);A.get(Ie).__hasExternalTextures||(_e===o.TEXTURE_3D||_e===o.TEXTURE_2D_ARRAY?t.texImage3D(_e,0,oe,Ie.width,Ie.height,Ie.depth,0,Et,ke,null):t.texImage2D(_e,0,oe,Ie.width,Ie.height,0,Et,ke,null)),t.bindFramebuffer(o.FRAMEBUFFER,ce),gt(Ie)?B.framebufferTexture2DMultisampleEXT(o.FRAMEBUFFER,je,_e,A.get(Se).__webglTexture,0,bt(Ie)):(_e===o.TEXTURE_2D||_e>=o.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=o.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&o.framebufferTexture2D(o.FRAMEBUFFER,je,_e,A.get(Se).__webglTexture,0),t.bindFramebuffer(o.FRAMEBUFFER,null)}function Ye(ce,Ie,Se){if(o.bindRenderbuffer(o.RENDERBUFFER,ce),Ie.depthBuffer&&!Ie.stencilBuffer){let je=o.DEPTH_COMPONENT16;if(Se||gt(Ie)){const _e=Ie.depthTexture;_e&&_e.isDepthTexture&&(_e.type===De?je=o.DEPTH_COMPONENT32F:_e.type===U&&(je=o.DEPTH_COMPONENT24));const Et=bt(Ie);gt(Ie)?B.renderbufferStorageMultisampleEXT(o.RENDERBUFFER,Et,je,Ie.width,Ie.height):o.renderbufferStorageMultisample(o.RENDERBUFFER,Et,je,Ie.width,Ie.height)}else o.renderbufferStorage(o.RENDERBUFFER,je,Ie.width,Ie.height);o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,ce)}else if(Ie.depthBuffer&&Ie.stencilBuffer){const je=bt(Ie);Se&>(Ie)===!1?o.renderbufferStorageMultisample(o.RENDERBUFFER,je,o.DEPTH24_STENCIL8,Ie.width,Ie.height):gt(Ie)?B.renderbufferStorageMultisampleEXT(o.RENDERBUFFER,je,o.DEPTH24_STENCIL8,Ie.width,Ie.height):o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,Ie.width,Ie.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,ce)}else{const je=Ie.isWebGLMultipleRenderTargets===!0?Ie.texture:[Ie.texture];for(let _e=0;_e<je.length;_e++){const Et=je[_e],ke=r.convert(Et.format,Et.colorSpace),oe=r.convert(Et.type),Te=Ae(Et.internalFormat,ke,oe,Et.colorSpace),ct=bt(Ie);Se&>(Ie)===!1?o.renderbufferStorageMultisample(o.RENDERBUFFER,ct,Te,Ie.width,Ie.height):gt(Ie)?B.renderbufferStorageMultisampleEXT(o.RENDERBUFFER,ct,Te,Ie.width,Ie.height):o.renderbufferStorage(o.RENDERBUFFER,Te,Ie.width,Ie.height)}}o.bindRenderbuffer(o.RENDERBUFFER,null)}function dt(ce){const Ie=A.get(ce),Se=ce.isWebGLCubeRenderTarget===!0;if(ce.depthTexture&&!Ie.__autoAllocateDepthBuffer){if(Se)throw new Error("target.depthTexture not supported in Cube render targets");(function(je,_e){if(_e&&_e.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(o.FRAMEBUFFER,je),!_e.depthTexture||!_e.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");A.get(_e.depthTexture).__webglTexture&&_e.depthTexture.image.width===_e.width&&_e.depthTexture.image.height===_e.height||(_e.depthTexture.image.width=_e.width,_e.depthTexture.image.height=_e.height,_e.depthTexture.needsUpdate=!0),Ct(_e.depthTexture,0);const Et=A.get(_e.depthTexture).__webglTexture,ke=bt(_e);if(_e.depthTexture.format===st)gt(_e)?B.framebufferTexture2DMultisampleEXT(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.TEXTURE_2D,Et,0,ke):o.framebufferTexture2D(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.TEXTURE_2D,Et,0);else{if(_e.depthTexture.format!==Tt)throw new Error("Unknown depthTexture format");gt(_e)?B.framebufferTexture2DMultisampleEXT(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.TEXTURE_2D,Et,0,ke):o.framebufferTexture2D(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.TEXTURE_2D,Et,0)}})(Ie.__webglFramebuffer,ce)}else if(Se){Ie.__webglDepthbuffer=[];for(let je=0;je<6;je++)t.bindFramebuffer(o.FRAMEBUFFER,Ie.__webglFramebuffer[je]),Ie.__webglDepthbuffer[je]=o.createRenderbuffer(),Ye(Ie.__webglDepthbuffer[je],ce,!1)}else t.bindFramebuffer(o.FRAMEBUFFER,Ie.__webglFramebuffer),Ie.__webglDepthbuffer=o.createRenderbuffer(),Ye(Ie.__webglDepthbuffer,ce,!1);t.bindFramebuffer(o.FRAMEBUFFER,null)}function bt(ce){return Math.min(C,ce.samples)}function gt(ce){const Ie=A.get(ce);return h&&ce.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&Ie.__useRenderToTexture!==!1}function Xt(ce,Ie){const Se=ce.colorSpace,je=ce.format;return ce.type,ce.isCompressedTexture===!0||ce.format===Ne||Se!==W&&Se!==Ee&&Se===ie&&h===!1&&(e.has("EXT_sRGB")===!0&&je===kt?(ce.format=Ne,ce.minFilter=Qe,ce.generateMipmaps=!1):Ie=ul.sRGBToLinear(Ie)),Ie}this.allocateTextureUnit=function(){const ce=Ze;return Ze+=1,ce},this.resetTextureUnits=function(){Ze=0},this.setTexture2D=Ct,this.setTexture2DArray=function(ce,Ie){const Se=A.get(ce);ce.version>0&&Se.__version!==ce.version?Rt(Se,ce,Ie):t.bindTexture(o.TEXTURE_2D_ARRAY,Se.__webglTexture,o.TEXTURE0+Ie)},this.setTexture3D=function(ce,Ie){const Se=A.get(ce);ce.version>0&&Se.__version!==ce.version?Rt(Se,ce,Ie):t.bindTexture(o.TEXTURE_3D,Se.__webglTexture,o.TEXTURE0+Ie)},this.setTextureCube=function(ce,Ie){const Se=A.get(ce);ce.version>0&&Se.__version!==ce.version?(function(je,_e,Et){if(_e.image.length!==6)return;const ke=Mt(je,_e),oe=_e.source;t.bindTexture(o.TEXTURE_CUBE_MAP,je.__webglTexture,o.TEXTURE0+Et);const Te=A.get(oe);if(oe.version!==Te.__version||ke===!0){t.activeTexture(o.TEXTURE0+Et),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,_e.flipY),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_e.premultiplyAlpha),o.pixelStorei(o.UNPACK_ALIGNMENT,_e.unpackAlignment),o.pixelStorei(o.UNPACK_COLORSPACE_CONVERSION_WEBGL,o.NONE);const ct=_e.isCompressedTexture||_e.image[0].isCompressedTexture,St=_e.image[0]&&_e.image[0].isDataTexture,ht=[];for(let $e=0;$e<6;$e++)ht[$e]=ct||St?St?_e.image[$e].image:_e.image[$e]:L(_e.image[$e],!1,!0,u),ht[$e]=Xt(_e,ht[$e]);const Kt=ht[0],Ht=G(Kt)||h,_t=r.convert(_e.format,_e.colorSpace),CA=r.convert(_e.type),hA=Ae(_e.internalFormat,_t,CA,_e.colorSpace),J=h&&_e.isVideoTexture!==!0,$=Te.__version===void 0||ke===!0;let xe,rt=te(_e,Kt,Ht);if(ft(o.TEXTURE_CUBE_MAP,_e,Ht),ct){J&&$&&t.texStorage2D(o.TEXTURE_CUBE_MAP,rt,hA,Kt.width,Kt.height);for(let $e=0;$e<6;$e++){xe=ht[$e].mipmaps;for(let Re=0;Re<xe.length;Re++){const Pe=xe[Re];_e.format!==kt?_t!==null&&(J?t.compressedTexSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,0,0,Pe.width,Pe.height,_t,Pe.data):t.compressedTexImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,hA,Pe.width,Pe.height,0,Pe.data)):J?t.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,0,0,Pe.width,Pe.height,_t,CA,Pe.data):t.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,hA,Pe.width,Pe.height,0,_t,CA,Pe.data)}}}else{xe=_e.mipmaps,J&&$&&(xe.length>0&&rt++,t.texStorage2D(o.TEXTURE_CUBE_MAP,rt,hA,ht[0].width,ht[0].height));for(let $e=0;$e<6;$e++)if(St){J?t.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,0,0,ht[$e].width,ht[$e].height,_t,CA,ht[$e].data):t.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,hA,ht[$e].width,ht[$e].height,0,_t,CA,ht[$e].data);for(let Re=0;Re<xe.length;Re++){const Pe=xe[Re].image[$e].image;J?t.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,0,0,Pe.width,Pe.height,_t,CA,Pe.data):t.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,hA,Pe.width,Pe.height,0,_t,CA,Pe.data)}}else{J?t.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,0,0,_t,CA,ht[$e]):t.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,hA,_t,CA,ht[$e]);for(let Re=0;Re<xe.length;Re++){const Pe=xe[Re];J?t.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,0,0,_t,CA,Pe.image[$e]):t.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,hA,_t,CA,Pe.image[$e])}}}le(_e,Ht)&&ne(o.TEXTURE_CUBE_MAP),Te.__version=oe.version,_e.onUpdate&&_e.onUpdate(_e)}je.__version=_e.version})(Se,ce,Ie):t.bindTexture(o.TEXTURE_CUBE_MAP,Se.__webglTexture,o.TEXTURE0+Ie)},this.rebindTextures=function(ce,Ie,Se){const je=A.get(ce);Ie!==void 0&&Ft(je.__webglFramebuffer,ce,ce.texture,o.COLOR_ATTACHMENT0,o.TEXTURE_2D),Se!==void 0&&dt(ce)},this.setupRenderTarget=function(ce){const Ie=ce.texture,Se=A.get(ce),je=A.get(Ie);ce.addEventListener("dispose",Me),ce.isWebGLMultipleRenderTargets!==!0&&(je.__webglTexture===void 0&&(je.__webglTexture=o.createTexture()),je.__version=Ie.version,g.memory.textures++);const _e=ce.isWebGLCubeRenderTarget===!0,Et=ce.isWebGLMultipleRenderTargets===!0,ke=G(ce)||h;if(_e){Se.__webglFramebuffer=[];for(let oe=0;oe<6;oe++)Se.__webglFramebuffer[oe]=o.createFramebuffer()}else{if(Se.__webglFramebuffer=o.createFramebuffer(),Et&&n.drawBuffers){const oe=ce.texture;for(let Te=0,ct=oe.length;Te<ct;Te++){const St=A.get(oe[Te]);St.__webglTexture===void 0&&(St.__webglTexture=o.createTexture(),g.memory.textures++)}}if(h&&ce.samples>0&>(ce)===!1){const oe=Et?Ie:[Ie];Se.__webglMultisampledFramebuffer=o.createFramebuffer(),Se.__webglColorRenderbuffer=[],t.bindFramebuffer(o.FRAMEBUFFER,Se.__webglMultisampledFramebuffer);for(let Te=0;Te<oe.length;Te++){const ct=oe[Te];Se.__webglColorRenderbuffer[Te]=o.createRenderbuffer(),o.bindRenderbuffer(o.RENDERBUFFER,Se.__webglColorRenderbuffer[Te]);const St=r.convert(ct.format,ct.colorSpace),ht=r.convert(ct.type),Kt=Ae(ct.internalFormat,St,ht,ct.colorSpace,ce.isXRRenderTarget===!0),Ht=bt(ce);o.renderbufferStorageMultisample(o.RENDERBUFFER,Ht,Kt,ce.width,ce.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0+Te,o.RENDERBUFFER,Se.__webglColorRenderbuffer[Te])}o.bindRenderbuffer(o.RENDERBUFFER,null),ce.depthBuffer&&(Se.__webglDepthRenderbuffer=o.createRenderbuffer(),Ye(Se.__webglDepthRenderbuffer,ce,!0)),t.bindFramebuffer(o.FRAMEBUFFER,null)}}if(_e){t.bindTexture(o.TEXTURE_CUBE_MAP,je.__webglTexture),ft(o.TEXTURE_CUBE_MAP,Ie,ke);for(let oe=0;oe<6;oe++)Ft(Se.__webglFramebuffer[oe],ce,Ie,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+oe);le(Ie,ke)&&ne(o.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Et){const oe=ce.texture;for(let Te=0,ct=oe.length;Te<ct;Te++){const St=oe[Te],ht=A.get(St);t.bindTexture(o.TEXTURE_2D,ht.__webglTexture),ft(o.TEXTURE_2D,St,ke),Ft(Se.__webglFramebuffer,ce,St,o.COLOR_ATTACHMENT0+Te,o.TEXTURE_2D),le(St,ke)&&ne(o.TEXTURE_2D)}t.unbindTexture()}else{let oe=o.TEXTURE_2D;(ce.isWebGL3DRenderTarget||ce.isWebGLArrayRenderTarget)&&h&&(oe=ce.isWebGL3DRenderTarget?o.TEXTURE_3D:o.TEXTURE_2D_ARRAY),t.bindTexture(oe,je.__webglTexture),ft(oe,Ie,ke),Ft(Se.__webglFramebuffer,ce,Ie,o.COLOR_ATTACHMENT0,oe),le(Ie,ke)&&ne(oe),t.unbindTexture()}ce.depthBuffer&&dt(ce)},this.updateRenderTargetMipmap=function(ce){const Ie=G(ce)||h,Se=ce.isWebGLMultipleRenderTargets===!0?ce.texture:[ce.texture];for(let je=0,_e=Se.length;je<_e;je++){const Et=Se[je];if(le(Et,Ie)){const ke=ce.isWebGLCubeRenderTarget?o.TEXTURE_CUBE_MAP:o.TEXTURE_2D,oe=A.get(Et).__webglTexture;t.bindTexture(ke,oe),ne(ke),t.unbindTexture()}}},this.updateMultisampleRenderTarget=function(ce){if(h&&ce.samples>0&>(ce)===!1){const Ie=ce.isWebGLMultipleRenderTargets?ce.texture:[ce.texture],Se=ce.width,je=ce.height;let _e=o.COLOR_BUFFER_BIT;const Et=[],ke=ce.stencilBuffer?o.DEPTH_STENCIL_ATTACHMENT:o.DEPTH_ATTACHMENT,oe=A.get(ce),Te=ce.isWebGLMultipleRenderTargets===!0;if(Te)for(let ct=0;ct<Ie.length;ct++)t.bindFramebuffer(o.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0+ct,o.RENDERBUFFER,null),t.bindFramebuffer(o.FRAMEBUFFER,oe.__webglFramebuffer),o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0+ct,o.TEXTURE_2D,null,0);t.bindFramebuffer(o.READ_FRAMEBUFFER,oe.__webglMultisampledFramebuffer),t.bindFramebuffer(o.DRAW_FRAMEBUFFER,oe.__webglFramebuffer);for(let ct=0;ct<Ie.length;ct++){Et.push(o.COLOR_ATTACHMENT0+ct),ce.depthBuffer&&Et.push(ke);const St=oe.__ignoreDepthValues!==void 0&&oe.__ignoreDepthValues;if(St===!1&&(ce.depthBuffer&&(_e|=o.DEPTH_BUFFER_BIT),ce.stencilBuffer&&(_e|=o.STENCIL_BUFFER_BIT)),Te&&o.framebufferRenderbuffer(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.RENDERBUFFER,oe.__webglColorRenderbuffer[ct]),St===!0&&(o.invalidateFramebuffer(o.READ_FRAMEBUFFER,[ke]),o.invalidateFramebuffer(o.DRAW_FRAMEBUFFER,[ke])),Te){const ht=A.get(Ie[ct]).__webglTexture;o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,ht,0)}o.blitFramebuffer(0,0,Se,je,0,0,Se,je,_e,o.NEAREST),p&&o.invalidateFramebuffer(o.READ_FRAMEBUFFER,Et)}if(t.bindFramebuffer(o.READ_FRAMEBUFFER,null),t.bindFramebuffer(o.DRAW_FRAMEBUFFER,null),Te)for(let ct=0;ct<Ie.length;ct++){t.bindFramebuffer(o.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0+ct,o.RENDERBUFFER,oe.__webglColorRenderbuffer[ct]);const St=A.get(Ie[ct]).__webglTexture;t.bindFramebuffer(o.FRAMEBUFFER,oe.__webglFramebuffer),o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0+ct,o.TEXTURE_2D,St,0)}t.bindFramebuffer(o.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=dt,this.setupFrameBufferTexture=Ft,this.useMultisampledRTT=gt}function bS(o,e,t){const A=t.isWebGL2;return{convert:function(n,r=""){let g;if(n===be)return o.UNSIGNED_BYTE;if(n===1017)return o.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return o.UNSIGNED_SHORT_5_5_5_1;if(n===1010)return o.BYTE;if(n===1011)return o.SHORT;if(n===1012)return o.UNSIGNED_SHORT;if(n===1013)return o.INT;if(n===U)return o.UNSIGNED_INT;if(n===De)return o.FLOAT;if(n===mt)return A?o.HALF_FLOAT:(g=e.get("OES_texture_half_float"),g!==null?g.HALF_FLOAT_OES:null);if(n===1021)return o.ALPHA;if(n===kt)return o.RGBA;if(n===1024)return o.LUMINANCE;if(n===1025)return o.LUMINANCE_ALPHA;if(n===st)return o.DEPTH_COMPONENT;if(n===Tt)return o.DEPTH_STENCIL;if(n===Ne)return g=e.get("EXT_sRGB"),g!==null?g.SRGB_ALPHA_EXT:null;if(n===Ge)return o.RED;if(n===1029)return o.RED_INTEGER;if(n===1030)return o.RG;if(n===1031)return o.RG_INTEGER;if(n===1033)return o.RGBA_INTEGER;if(n===Le||n===jt||n===Nt||n===V)if(r===ie){if(g=e.get("WEBGL_compressed_texture_s3tc_srgb"),g===null)return null;if(n===Le)return g.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===jt)return g.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Nt)return g.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===V)return g.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(g=e.get("WEBGL_compressed_texture_s3tc"),g===null)return null;if(n===Le)return g.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===jt)return g.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Nt)return g.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===V)return g.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===35840||n===35841||n===35842||n===35843){if(g=e.get("WEBGL_compressed_texture_pvrtc"),g===null)return null;if(n===35840)return g.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return g.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return g.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return g.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===36196)return g=e.get("WEBGL_compressed_texture_etc1"),g!==null?g.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===37492||n===37496){if(g=e.get("WEBGL_compressed_texture_etc"),g===null)return null;if(n===37492)return r===ie?g.COMPRESSED_SRGB8_ETC2:g.COMPRESSED_RGB8_ETC2;if(n===37496)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:g.COMPRESSED_RGBA8_ETC2_EAC}if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821){if(g=e.get("WEBGL_compressed_texture_astc"),g===null)return null;if(n===37808)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:g.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:g.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:g.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:g.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:g.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:g.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:g.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:g.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:g.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:g.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:g.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:g.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:g.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return r===ie?g.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:g.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===fe){if(g=e.get("EXT_texture_compression_bptc"),g===null)return null;if(n===fe)return r===ie?g.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:g.COMPRESSED_RGBA_BPTC_UNORM_EXT}if(n===36283||n===36284||n===36285||n===36286){if(g=e.get("EXT_texture_compression_rgtc"),g===null)return null;if(n===fe)return g.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return g.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return g.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return g.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===He?A?o.UNSIGNED_INT_24_8:(g=e.get("WEBGL_depth_texture"),g!==null?g.UNSIGNED_INT_24_8_WEBGL:null):o[n]!==void 0?o[n]:null}}}class _S extends Zi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Js extends gi{constructor(){super(),this.isGroup=!0,this.type="Group"}}const RS={type:"move"};class Kh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Js,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Js,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new re,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new re),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Js,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new re,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new re),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const A of e.hand.values())this._getHandJoint(t,A)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,A){let n=null,r=null,g=null;const h=this._targetRay,u=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){g=!0;for(const R of e.hand.values()){const _=t.getJointPose(R,A),N=this._getHandJoint(c,R);_!==null&&(N.matrix.fromArray(_.transform.matrix),N.matrix.decompose(N.position,N.rotation,N.scale),N.matrixWorldNeedsUpdate=!0,N.jointRadius=_.radius),N.visible=_!==null}const C=c.joints["index-finger-tip"],B=c.joints["thumb-tip"],p=C.position.distanceTo(B.position),w=.02,k=.005;c.inputState.pinching&&p>w+k?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=w-k&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,A),r!==null&&(u.matrix.fromArray(r.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,r.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(r.linearVelocity)):u.hasLinearVelocity=!1,r.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(r.angularVelocity)):u.hasAngularVelocity=!1));h!==null&&(n=t.getPose(e.targetRaySpace,A),n===null&&r!==null&&(n=r),n!==null&&(h.matrix.fromArray(n.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,n.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(n.linearVelocity)):h.hasLinearVelocity=!1,n.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(n.angularVelocity)):h.hasAngularVelocity=!1,this.dispatchEvent(RS)))}return h!==null&&(h.visible=n!==null),u!==null&&(u.visible=r!==null),c!==null&&(c.visible=g!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const A=new Js;A.matrixAutoUpdate=!1,A.visible=!1,e.joints[t.jointName]=A,e.add(A)}return e.joints[t.jointName]}}class NS extends Di{constructor(e,t,A,n,r,g,h,u,c,C){if((C=C!==void 0?C:st)!==st&&C!==Tt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");A===void 0&&C===st&&(A=U),A===void 0&&C===Tt&&(A=He),super(null,n,r,g,h,u,C,A,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=h!==void 0?h:Be,this.minFilter=u!==void 0?u:Be,this.flipY=!1,this.generateMipmaps=!1}}class kS extends ut{constructor(e,t){super();const A=this;let n=null,r=1,g=null,h="local-floor",u=1,c=null,C=null,B=null,p=null,w=null,k=null;const R=t.getContextAttributes();let _=null,N=null;const L=[],G=[],le=new Set,ne=new Map,Ae=new Zi;Ae.layers.enable(1),Ae.viewport=new zA;const te=new Zi;te.layers.enable(2),te.viewport=new zA;const ye=[Ae,te],ge=new _S;ge.layers.enable(1),ge.layers.enable(2);let Me=null,pe=null;function Ze(Ye){const dt=G.indexOf(Ye.inputSource);if(dt===-1)return;const bt=L[dt];bt!==void 0&&(bt.update(Ye.inputSource,Ye.frame,c||g),bt.dispatchEvent({type:Ye.type,data:Ye.inputSource}))}function Ct(){n.removeEventListener("select",Ze),n.removeEventListener("selectstart",Ze),n.removeEventListener("selectend",Ze),n.removeEventListener("squeeze",Ze),n.removeEventListener("squeezestart",Ze),n.removeEventListener("squeezeend",Ze),n.removeEventListener("end",Ct),n.removeEventListener("inputsourceschange",Qt);for(let Ye=0;Ye<L.length;Ye++){const dt=G[Ye];dt!==null&&(G[Ye]=null,L[Ye].disconnect(dt))}Me=null,pe=null,e.setRenderTarget(_),w=null,p=null,B=null,n=null,N=null,Ft.stop(),A.isPresenting=!1,A.dispatchEvent({type:"sessionend"})}function Qt(Ye){for(let dt=0;dt<Ye.removed.length;dt++){const bt=Ye.removed[dt],gt=G.indexOf(bt);gt>=0&&(G[gt]=null,L[gt].disconnect(bt))}for(let dt=0;dt<Ye.added.length;dt++){const bt=Ye.added[dt];let gt=G.indexOf(bt);if(gt===-1){for(let ce=0;ce<L.length;ce++){if(ce>=G.length){G.push(bt),gt=ce;break}if(G[ce]===null){G[ce]=bt,gt=ce;break}}if(gt===-1)break}const Xt=L[gt];Xt&&Xt.connect(bt)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Ye){let dt=L[Ye];return dt===void 0&&(dt=new Kh,L[Ye]=dt),dt.getTargetRaySpace()},this.getControllerGrip=function(Ye){let dt=L[Ye];return dt===void 0&&(dt=new Kh,L[Ye]=dt),dt.getGripSpace()},this.getHand=function(Ye){let dt=L[Ye];return dt===void 0&&(dt=new Kh,L[Ye]=dt),dt.getHandSpace()},this.setFramebufferScaleFactor=function(Ye){r=Ye,A.isPresenting},this.setReferenceSpaceType=function(Ye){h=Ye,A.isPresenting},this.getReferenceSpace=function(){return c||g},this.setReferenceSpace=function(Ye){c=Ye},this.getBaseLayer=function(){return p!==null?p:w},this.getBinding=function(){return B},this.getFrame=function(){return k},this.getSession=function(){return n},this.setSession=async function(Ye){if(n=Ye,n!==null){if(_=e.getRenderTarget(),n.addEventListener("select",Ze),n.addEventListener("selectstart",Ze),n.addEventListener("selectend",Ze),n.addEventListener("squeeze",Ze),n.addEventListener("squeezestart",Ze),n.addEventListener("squeezeend",Ze),n.addEventListener("end",Ct),n.addEventListener("inputsourceschange",Qt),R.xrCompatible!==!0&&await t.makeXRCompatible(),n.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const dt={antialias:n.renderState.layers!==void 0||R.antialias,alpha:!0,depth:R.depth,stencil:R.stencil,framebufferScaleFactor:r};w=new XRWebGLLayer(n,t,dt),n.updateRenderState({baseLayer:w}),N=new ei(w.framebufferWidth,w.framebufferHeight,{format:kt,type:be,colorSpace:e.outputColorSpace,stencilBuffer:R.stencil})}else{let dt=null,bt=null,gt=null;R.depth&&(gt=R.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,dt=R.stencil?Tt:st,bt=R.stencil?He:U);const Xt={colorFormat:t.RGBA8,depthFormat:gt,scaleFactor:r};B=new XRWebGLBinding(n,t),p=B.createProjectionLayer(Xt),n.updateRenderState({layers:[p]}),N=new ei(p.textureWidth,p.textureHeight,{format:kt,type:be,depthTexture:new NS(p.textureWidth,p.textureHeight,bt,void 0,void 0,void 0,void 0,void 0,void 0,dt),stencilBuffer:R.stencil,colorSpace:e.outputColorSpace,samples:R.antialias?4:0}),e.properties.get(N).__ignoreDepthValues=p.ignoreDepthValues}N.isXRRenderTarget=!0,this.setFoveation(u),c=null,g=await n.requestReferenceSpace(h),Ft.setContext(n),Ft.start(),A.isPresenting=!0,A.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode};const Wt=new re,ft=new re;function Mt(Ye,dt){dt===null?Ye.matrixWorld.copy(Ye.matrix):Ye.matrixWorld.multiplyMatrices(dt.matrixWorld,Ye.matrix),Ye.matrixWorldInverse.copy(Ye.matrixWorld).invert()}this.updateCamera=function(Ye){if(n===null)return;ge.near=te.near=Ae.near=Ye.near,ge.far=te.far=Ae.far=Ye.far,Me===ge.near&&pe===ge.far||(n.updateRenderState({depthNear:ge.near,depthFar:ge.far}),Me=ge.near,pe=ge.far);const dt=Ye.parent,bt=ge.cameras;Mt(ge,dt);for(let gt=0;gt<bt.length;gt++)Mt(bt[gt],dt);bt.length===2?(function(gt,Xt,ce){Wt.setFromMatrixPosition(Xt.matrixWorld),ft.setFromMatrixPosition(ce.matrixWorld);const Ie=Wt.distanceTo(ft),Se=Xt.projectionMatrix.elements,je=ce.projectionMatrix.elements,_e=Se[14]/(Se[10]-1),Et=Se[14]/(Se[10]+1),ke=(Se[9]+1)/Se[5],oe=(Se[9]-1)/Se[5],Te=(Se[8]-1)/Se[0],ct=(je[8]+1)/je[0],St=_e*Te,ht=_e*ct,Kt=Ie/(-Te+ct),Ht=Kt*-Te;Xt.matrixWorld.decompose(gt.position,gt.quaternion,gt.scale),gt.translateX(Ht),gt.translateZ(Kt),gt.matrixWorld.compose(gt.position,gt.quaternion,gt.scale),gt.matrixWorldInverse.copy(gt.matrixWorld).invert();const _t=_e+Kt,CA=Et+Kt,hA=St-Ht,J=ht+(Ie-Ht),$=ke*Et/CA*_t,xe=oe*Et/CA*_t;gt.projectionMatrix.makePerspective(hA,J,$,xe,_t,CA),gt.projectionMatrixInverse.copy(gt.projectionMatrix).invert()})(ge,Ae,te):ge.projectionMatrix.copy(Ae.projectionMatrix),(function(gt,Xt,ce){ce===null?gt.matrix.copy(Xt.matrixWorld):(gt.matrix.copy(ce.matrixWorld),gt.matrix.invert(),gt.matrix.multiply(Xt.matrixWorld)),gt.matrix.decompose(gt.position,gt.quaternion,gt.scale),gt.updateMatrixWorld(!0);const Ie=gt.children;for(let Se=0,je=Ie.length;Se<je;Se++)Ie[Se].updateMatrixWorld(!0);gt.projectionMatrix.copy(Xt.projectionMatrix),gt.projectionMatrixInverse.copy(Xt.projectionMatrixInverse),gt.isPerspectiveCamera&&(gt.fov=2*RA*Math.atan(1/gt.projectionMatrix.elements[5]),gt.zoom=1)})(Ye,ge,dt)},this.getCamera=function(){return ge},this.getFoveation=function(){if(p!==null||w!==null)return u},this.setFoveation=function(Ye){u=Ye,p!==null&&(p.fixedFoveation=Ye),w!==null&&w.fixedFoveation!==void 0&&(w.fixedFoveation=Ye)},this.getPlanes=function(){return le};let Rt=null;const Ft=new DE;Ft.setAnimationLoop((function(Ye,dt){if(C=dt.getViewerPose(c||g),k=dt,C!==null){const bt=C.views;w!==null&&(e.setRenderTargetFramebuffer(N,w.framebuffer),e.setRenderTarget(N));let gt=!1;bt.length!==ge.cameras.length&&(ge.cameras.length=0,gt=!0);for(let Xt=0;Xt<bt.length;Xt++){const ce=bt[Xt];let Ie=null;if(w!==null)Ie=w.getViewport(ce);else{const je=B.getViewSubImage(p,ce);Ie=je.viewport,Xt===0&&(e.setRenderTargetTextures(N,je.colorTexture,p.ignoreDepthValues?void 0:je.depthStencilTexture),e.setRenderTarget(N))}let Se=ye[Xt];Se===void 0&&(Se=new Zi,Se.layers.enable(Xt),Se.viewport=new zA,ye[Xt]=Se),Se.matrix.fromArray(ce.transform.matrix),Se.matrix.decompose(Se.position,Se.quaternion,Se.scale),Se.projectionMatrix.fromArray(ce.projectionMatrix),Se.projectionMatrixInverse.copy(Se.projectionMatrix).invert(),Se.viewport.set(Ie.x,Ie.y,Ie.width,Ie.height),Xt===0&&(ge.matrix.copy(Se.matrix),ge.matrix.decompose(ge.position,ge.quaternion,ge.scale)),gt===!0&&ge.cameras.push(Se)}}for(let bt=0;bt<L.length;bt++){const gt=G[bt],Xt=L[bt];gt!==null&&Xt!==void 0&&Xt.update(gt,dt,c||g)}if(Rt&&Rt(Ye,dt),dt.detectedPlanes){A.dispatchEvent({type:"planesdetected",data:dt.detectedPlanes});let bt=null;for(const gt of le)dt.detectedPlanes.has(gt)||(bt===null&&(bt=[]),bt.push(gt));if(bt!==null)for(const gt of bt)le.delete(gt),ne.delete(gt),A.dispatchEvent({type:"planeremoved",data:gt});for(const gt of dt.detectedPlanes)if(le.has(gt)){const Xt=ne.get(gt);gt.lastChangedTime>Xt&&(ne.set(gt,gt.lastChangedTime),A.dispatchEvent({type:"planechanged",data:gt}))}else le.add(gt),ne.set(gt,dt.lastChangedTime),A.dispatchEvent({type:"planeadded",data:gt})}k=null})),this.setAnimationLoop=function(Ye){Rt=Ye},this.dispose=function(){}}}function FS(o,e){function t(n,r){n.matrixAutoUpdate===!0&&n.updateMatrix(),r.value.copy(n.matrix)}function A(n,r){n.opacity.value=r.opacity,r.color&&n.diffuse.value.copy(r.color),r.emissive&&n.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(n.map.value=r.map,t(r.map,n.mapTransform)),r.alphaMap&&(n.alphaMap.value=r.alphaMap,t(r.alphaMap,n.alphaMapTransform)),r.bumpMap&&(n.bumpMap.value=r.bumpMap,t(r.bumpMap,n.bumpMapTransform),n.bumpScale.value=r.bumpScale,r.side===v&&(n.bumpScale.value*=-1)),r.normalMap&&(n.normalMap.value=r.normalMap,t(r.normalMap,n.normalMapTransform),n.normalScale.value.copy(r.normalScale),r.side===v&&n.normalScale.value.negate()),r.displacementMap&&(n.displacementMap.value=r.displacementMap,t(r.displacementMap,n.displacementMapTransform),n.displacementScale.value=r.displacementScale,n.displacementBias.value=r.displacementBias),r.emissiveMap&&(n.emissiveMap.value=r.emissiveMap,t(r.emissiveMap,n.emissiveMapTransform)),r.specularMap&&(n.specularMap.value=r.specularMap,t(r.specularMap,n.specularMapTransform)),r.alphaTest>0&&(n.alphaTest.value=r.alphaTest);const g=e.get(r).envMap;if(g&&(n.envMap.value=g,n.flipEnvMap.value=g.isCubeTexture&&g.isRenderTargetTexture===!1?-1:1,n.reflectivity.value=r.reflectivity,n.ior.value=r.ior,n.refractionRatio.value=r.refractionRatio),r.lightMap){n.lightMap.value=r.lightMap;const h=o.useLegacyLights===!0?Math.PI:1;n.lightMapIntensity.value=r.lightMapIntensity*h,t(r.lightMap,n.lightMapTransform)}r.aoMap&&(n.aoMap.value=r.aoMap,n.aoMapIntensity.value=r.aoMapIntensity,t(r.aoMap,n.aoMapTransform))}return{refreshFogUniforms:function(n,r){r.color.getRGB(n.fogColor.value,wE(o)),r.isFog?(n.fogNear.value=r.near,n.fogFar.value=r.far):r.isFogExp2&&(n.fogDensity.value=r.density)},refreshMaterialUniforms:function(n,r,g,h,u){r.isMeshBasicMaterial||r.isMeshLambertMaterial?A(n,r):r.isMeshToonMaterial?(A(n,r),(function(c,C){C.gradientMap&&(c.gradientMap.value=C.gradientMap)})(n,r)):r.isMeshPhongMaterial?(A(n,r),(function(c,C){c.specular.value.copy(C.specular),c.shininess.value=Math.max(C.shininess,1e-4)})(n,r)):r.isMeshStandardMaterial?(A(n,r),(function(c,C){c.metalness.value=C.metalness,C.metalnessMap&&(c.metalnessMap.value=C.metalnessMap,t(C.metalnessMap,c.metalnessMapTransform)),c.roughness.value=C.roughness,C.roughnessMap&&(c.roughnessMap.value=C.roughnessMap,t(C.roughnessMap,c.roughnessMapTransform)),e.get(C).envMap&&(c.envMapIntensity.value=C.envMapIntensity)})(n,r),r.isMeshPhysicalMaterial&&(function(c,C,B){c.ior.value=C.ior,C.sheen>0&&(c.sheenColor.value.copy(C.sheenColor).multiplyScalar(C.sheen),c.sheenRoughness.value=C.sheenRoughness,C.sheenColorMap&&(c.sheenColorMap.value=C.sheenColorMap,t(C.sheenColorMap,c.sheenColorMapTransform)),C.sheenRoughnessMap&&(c.sheenRoughnessMap.value=C.sheenRoughnessMap,t(C.sheenRoughnessMap,c.sheenRoughnessMapTransform))),C.clearcoat>0&&(c.clearcoat.value=C.clearcoat,c.clearcoatRoughness.value=C.clearcoatRoughness,C.clearcoatMap&&(c.clearcoatMap.value=C.clearcoatMap,t(C.clearcoatMap,c.clearcoatMapTransform)),C.clearcoatRoughnessMap&&(c.clearcoatRoughnessMap.value=C.clearcoatRoughnessMap,t(C.clearcoatRoughnessMap,c.clearcoatRoughnessMapTransform)),C.clearcoatNormalMap&&(c.clearcoatNormalMap.value=C.clearcoatNormalMap,t(C.clearcoatNormalMap,c.clearcoatNormalMapTransform),c.clearcoatNormalScale.value.copy(C.clearcoatNormalScale),C.side===v&&c.clearcoatNormalScale.value.negate())),C.iridescence>0&&(c.iridescence.value=C.iridescence,c.iridescenceIOR.value=C.iridescenceIOR,c.iridescenceThicknessMinimum.value=C.iridescenceThicknessRange[0],c.iridescenceThicknessMaximum.value=C.iridescenceThicknessRange[1],C.iridescenceMap&&(c.iridescenceMap.value=C.iridescenceMap,t(C.iridescenceMap,c.iridescenceMapTransform)),C.iridescenceThicknessMap&&(c.iridescenceThicknessMap.value=C.iridescenceThicknessMap,t(C.iridescenceThicknessMap,c.iridescenceThicknessMapTransform))),C.transmission>0&&(c.transmission.value=C.transmission,c.transmissionSamplerMap.value=B.texture,c.transmissionSamplerSize.value.set(B.width,B.height),C.transmissionMap&&(c.transmissionMap.value=C.transmissionMap,t(C.transmissionMap,c.transmissionMapTransform)),c.thickness.value=C.thickness,C.thicknessMap&&(c.thicknessMap.value=C.thicknessMap,t(C.thicknessMap,c.thicknessMapTransform)),c.attenuationDistance.value=C.attenuationDistance,c.attenuationColor.value.copy(C.attenuationColor)),c.specularIntensity.value=C.specularIntensity,c.specularColor.value.copy(C.specularColor),C.specularColorMap&&(c.specularColorMap.value=C.specularColorMap,t(C.specularColorMap,c.specularColorMapTransform)),C.specularIntensityMap&&(c.specularIntensityMap.value=C.specularIntensityMap,t(C.specularIntensityMap,c.specularIntensityMapTransform))})(n,r,u)):r.isMeshMatcapMaterial?(A(n,r),(function(c,C){C.matcap&&(c.matcap.value=C.matcap)})(n,r)):r.isMeshDepthMaterial?A(n,r):r.isMeshDistanceMaterial?(A(n,r),(function(c,C){const B=e.get(C).light;c.referencePosition.value.setFromMatrixPosition(B.matrixWorld),c.nearDistance.value=B.shadow.camera.near,c.farDistance.value=B.shadow.camera.far})(n,r)):r.isMeshNormalMaterial?A(n,r):r.isLineBasicMaterial?((function(c,C){c.diffuse.value.copy(C.color),c.opacity.value=C.opacity,C.map&&(c.map.value=C.map,t(C.map,c.mapTransform))})(n,r),r.isLineDashedMaterial&&(function(c,C){c.dashSize.value=C.dashSize,c.totalSize.value=C.dashSize+C.gapSize,c.scale.value=C.scale})(n,r)):r.isPointsMaterial?(function(c,C,B,p){c.diffuse.value.copy(C.color),c.opacity.value=C.opacity,c.size.value=C.size*B,c.scale.value=.5*p,C.map&&(c.map.value=C.map,t(C.map,c.uvTransform)),C.alphaMap&&(c.alphaMap.value=C.alphaMap),C.alphaTest>0&&(c.alphaTest.value=C.alphaTest)})(n,r,g,h):r.isSpriteMaterial?(function(c,C){c.diffuse.value.copy(C.color),c.opacity.value=C.opacity,c.rotation.value=C.rotation,C.map&&(c.map.value=C.map,t(C.map,c.mapTransform)),C.alphaMap&&(c.alphaMap.value=C.alphaMap),C.alphaTest>0&&(c.alphaTest.value=C.alphaTest)})(n,r):r.isShadowMaterial?(n.color.value.copy(r.color),n.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function LS(o,e,t,A){let n={},r={},g=[];const h=t.isWebGL2?o.getParameter(o.MAX_UNIFORM_BUFFER_BINDINGS):0;function u(B,p,w){const k=B.value;if(w[p]===void 0){if(typeof k=="number")w[p]=k;else{const R=Array.isArray(k)?k:[k],_=[];for(let N=0;N<R.length;N++)_.push(R[N].clone());w[p]=_}return!0}if(typeof k=="number"){if(w[p]!==k)return w[p]=k,!0}else{const R=Array.isArray(w[p])?w[p]:[w[p]],_=Array.isArray(k)?k:[k];for(let N=0;N<R.length;N++){const L=R[N];if(L.equals(_[N])===!1)return L.copy(_[N]),!0}}return!1}function c(B){const p={boundary:0,storage:0};return typeof B=="number"?(p.boundary=4,p.storage=4):B.isVector2?(p.boundary=8,p.storage=8):B.isVector3||B.isColor?(p.boundary=16,p.storage=12):B.isVector4?(p.boundary=16,p.storage=16):B.isMatrix3?(p.boundary=48,p.storage=48):B.isMatrix4?(p.boundary=64,p.storage=64):B.isTexture,p}function C(B){const p=B.target;p.removeEventListener("dispose",C);const w=g.indexOf(p.__bindingPointIndex);g.splice(w,1),o.deleteBuffer(n[p.id]),delete n[p.id],delete r[p.id]}return{bind:function(B,p){const w=p.program;A.uniformBlockBinding(B,w)},update:function(B,p){let w=n[B.id];w===void 0&&((function(_){const N=_.uniforms;let L=0;const G=16;let le=0;for(let ne=0,Ae=N.length;ne<Ae;ne++){const te=N[ne],ye={boundary:0,storage:0},ge=Array.isArray(te.value)?te.value:[te.value];for(let Me=0,pe=ge.length;Me<pe;Me++){const Ze=c(ge[Me]);ye.boundary+=Ze.boundary,ye.storage+=Ze.storage}te.__data=new Float32Array(ye.storage/Float32Array.BYTES_PER_ELEMENT),te.__offset=L,ne>0&&(le=L%G,le!==0&&G-le-ye.boundary<0&&(L+=G-le,te.__offset=L)),L+=ye.storage}le=L%G,le>0&&(L+=G-le),_.__size=L,_.__cache={}})(B),w=(function(_){const N=(function(){for(let ne=0;ne<h;ne++)if(g.indexOf(ne)===-1)return g.push(ne),ne;return 0})();_.__bindingPointIndex=N;const L=o.createBuffer(),G=_.__size,le=_.usage;return o.bindBuffer(o.UNIFORM_BUFFER,L),o.bufferData(o.UNIFORM_BUFFER,G,le),o.bindBuffer(o.UNIFORM_BUFFER,null),o.bindBufferBase(o.UNIFORM_BUFFER,N,L),L})(B),n[B.id]=w,B.addEventListener("dispose",C));const k=p.program;A.updateUBOMapping(B,k);const R=e.render.frame;r[B.id]!==R&&((function(_){const N=n[_.id],L=_.uniforms,G=_.__cache;o.bindBuffer(o.UNIFORM_BUFFER,N);for(let le=0,ne=L.length;le<ne;le++){const Ae=L[le];if(u(Ae,le,G)===!0){const te=Ae.__offset,ye=Array.isArray(Ae.value)?Ae.value:[Ae.value];let ge=0;for(let Me=0;Me<ye.length;Me++){const pe=ye[Me],Ze=c(pe);typeof pe=="number"?(Ae.__data[0]=pe,o.bufferSubData(o.UNIFORM_BUFFER,te+ge,Ae.__data)):pe.isMatrix3?(Ae.__data[0]=pe.elements[0],Ae.__data[1]=pe.elements[1],Ae.__data[2]=pe.elements[2],Ae.__data[3]=pe.elements[0],Ae.__data[4]=pe.elements[3],Ae.__data[5]=pe.elements[4],Ae.__data[6]=pe.elements[5],Ae.__data[7]=pe.elements[0],Ae.__data[8]=pe.elements[6],Ae.__data[9]=pe.elements[7],Ae.__data[10]=pe.elements[8],Ae.__data[11]=pe.elements[0]):(pe.toArray(Ae.__data,ge),ge+=Ze.storage/Float32Array.BYTES_PER_ELEMENT)}o.bufferSubData(o.UNIFORM_BUFFER,te,Ae.__data)}}o.bindBuffer(o.UNIFORM_BUFFER,null)})(B),r[B.id]=R)},dispose:function(){for(const B in n)o.deleteBuffer(n[B]);g=[],n={},r={}}}}function GS(){const o=wn("canvas");return o.style.display="block",o}class $E{constructor(e={}){const{canvas:t=GS(),context:A=null,depth:n=!0,stencil:r=!0,alpha:g=!1,antialias:h=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:c=!1,powerPreference:C="default",failIfMajorPerformanceCaveat:B=!1}=e;let p;this.isWebGLRenderer=!0,p=A!==null?A.getContextAttributes().alpha:g;let w=null,k=null;const R=[],_=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=ie,this.useLegacyLights=!0,this.toneMapping=F,this.toneMappingExposure=1;const N=this;let L=!1,G=0,le=0,ne=null,Ae=-1,te=null;const ye=new zA,ge=new zA;let Me=null,pe=t.width,Ze=t.height,Ct=1,Qt=null,Wt=null;const ft=new zA(0,0,pe,Ze),Mt=new zA(0,0,pe,Ze);let Rt=!1;const Ft=new Th;let Ye=!1,dt=!1,bt=null;const gt=new xA,Xt=new re,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ie(){return ne===null?Ct:1}let Se,je,_e,Et,ke,oe,Te,ct,St,ht,Kt,Ht,_t,CA,hA,J,$,xe,rt,$e,Re,Pe,Yt,Vt,ve=A;function zt(he,et){for(let Bt=0;Bt<he.length;Bt++){const lt=he[Bt],pt=t.getContext(lt,et);if(pt!==null)return pt}return null}try{const he={alpha:!0,depth:n,stencil:r,antialias:h,premultipliedAlpha:u,preserveDrawingBuffer:c,powerPreference:C,failIfMajorPerformanceCaveat:B};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${E}`),t.addEventListener("webglcontextlost",tA,!1),t.addEventListener("webglcontextrestored",dA,!1),t.addEventListener("webglcontextcreationerror",Pt,!1),ve===null){const et=["webgl2","webgl","experimental-webgl"];if(N.isWebGL1Renderer===!0&&et.shift(),ve=zt(et,he),ve===null)throw zt(et)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}ve.getShaderPrecisionFormat===void 0&&(ve.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(he){throw he.message,he}function qt(){Se=new gM(ve),je=new rM(ve,Se,e),Se.init(je),Pe=new bS(ve,Se,je),_e=new SS(ve,Se,je),Et=new hM(ve),ke=new ES,oe=new xS(ve,Se,_e,ke,je,Pe,Et),Te=new aM(N),ct=new oM(N),St=new tM(ve,je),Yt=new iM(ve,Se,St,je),ht=new lM(ve,St,Et,Yt),Kt=new dM(ve,ht,St,Et),rt=new CM(ve,je,oe),J=new sM(ke),Ht=new dS(N,Te,ct,Se,je,Yt,J),_t=new FS(N,ke),CA=new QS,hA=new yS(Se,je),xe=new AM(N,Te,ct,_e,Kt,p,u),$=new MS(N,Kt,je),Vt=new LS(ve,Et,je,_e),$e=new nM(ve,Se,Et,je),Re=new cM(ve,Se,Et,je),Et.programs=Ht.programs,N.capabilities=je,N.extensions=Se,N.properties=ke,N.renderLists=CA,N.shadowMap=$,N.state=_e,N.info=Et}qt();const Lt=new kS(N,ve);function tA(he){he.preventDefault(),L=!0}function dA(){L=!1;const he=Et.autoReset,et=$.enabled,Bt=$.autoUpdate,lt=$.needsUpdate,pt=$.type;qt(),Et.autoReset=he,$.enabled=et,$.autoUpdate=Bt,$.needsUpdate=lt,$.type=pt}function Pt(he){he.statusMessage}function sA(he){const et=he.target;et.removeEventListener("dispose",sA),(function(Bt){(function(lt){const pt=ke.get(lt).programs;pt!==void 0&&(pt.forEach((function(eA){Ht.releaseProgram(eA)})),lt.isShaderMaterial&&Ht.releaseShaderCache(lt))})(Bt),ke.remove(Bt)})(et)}this.xr=Lt,this.getContext=function(){return ve},this.getContextAttributes=function(){return ve.getContextAttributes()},this.forceContextLoss=function(){const he=Se.get("WEBGL_lose_context");he&&he.loseContext()},this.forceContextRestore=function(){const he=Se.get("WEBGL_lose_context");he&&he.restoreContext()},this.getPixelRatio=function(){return Ct},this.setPixelRatio=function(he){he!==void 0&&(Ct=he,this.setSize(pe,Ze,!1))},this.getSize=function(he){return he.set(pe,Ze)},this.setSize=function(he,et,Bt=!0){Lt.isPresenting||(pe=he,Ze=et,t.width=Math.floor(he*Ct),t.height=Math.floor(et*Ct),Bt===!0&&(t.style.width=he+"px",t.style.height=et+"px"),this.setViewport(0,0,he,et))},this.getDrawingBufferSize=function(he){return he.set(pe*Ct,Ze*Ct).floor()},this.setDrawingBufferSize=function(he,et,Bt){pe=he,Ze=et,Ct=Bt,t.width=Math.floor(he*Bt),t.height=Math.floor(et*Bt),this.setViewport(0,0,he,et)},this.getCurrentViewport=function(he){return he.copy(ye)},this.getViewport=function(he){return he.copy(ft)},this.setViewport=function(he,et,Bt,lt){he.isVector4?ft.set(he.x,he.y,he.z,he.w):ft.set(he,et,Bt,lt),_e.viewport(ye.copy(ft).multiplyScalar(Ct).floor())},this.getScissor=function(he){return he.copy(Mt)},this.setScissor=function(he,et,Bt,lt){he.isVector4?Mt.set(he.x,he.y,he.z,he.w):Mt.set(he,et,Bt,lt),_e.scissor(ge.copy(Mt).multiplyScalar(Ct).floor())},this.getScissorTest=function(){return Rt},this.setScissorTest=function(he){_e.setScissorTest(Rt=he)},this.setOpaqueSort=function(he){Qt=he},this.setTransparentSort=function(he){Wt=he},this.getClearColor=function(he){return he.copy(xe.getClearColor())},this.setClearColor=function(){xe.setClearColor.apply(xe,arguments)},this.getClearAlpha=function(){return xe.getClearAlpha()},this.setClearAlpha=function(){xe.setClearAlpha.apply(xe,arguments)},this.clear=function(he=!0,et=!0,Bt=!0){let lt=0;he&&(lt|=ve.COLOR_BUFFER_BIT),et&&(lt|=ve.DEPTH_BUFFER_BIT),Bt&&(lt|=ve.STENCIL_BUFFER_BIT),ve.clear(lt)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",tA,!1),t.removeEventListener("webglcontextrestored",dA,!1),t.removeEventListener("webglcontextcreationerror",Pt,!1),CA.dispose(),hA.dispose(),ke.dispose(),Te.dispose(),ct.dispose(),Kt.dispose(),Yt.dispose(),Vt.dispose(),Ht.dispose(),Lt.dispose(),Lt.removeEventListener("sessionstart",wA),Lt.removeEventListener("sessionend",mi),bt&&(bt.dispose(),bt=null),qA.stop()},this.renderBufferDirect=function(he,et,Bt,lt,pt,eA){et===null&&(et=ce);const IA=pt.isMesh&&pt.matrixWorld.determinant()<0,MA=(function(WA,Bn,Li,pA,bi){Bn.isScene!==!0&&(Bn=ce),oe.resetTextureUnits();const RI=Bn.fog,q_=pA.isMeshStandardMaterial?Bn.environment:null,W_=ne===null?N.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:W,Cc=(pA.isMeshStandardMaterial?ct:Te).get(pA.envMap||q_),V_=pA.vertexColors===!0&&!!Li.attributes.color&&Li.attributes.color.itemSize===4,Z_=!!pA.normalMap&&!!Li.attributes.tangent,j_=!!Li.morphAttributes.position,X_=!!Li.morphAttributes.normal,$_=!!Li.morphAttributes.color,eR=pA.toneMapped?N.toneMapping:F,LQ=Li.morphAttributes.position||Li.morphAttributes.normal||Li.morphAttributes.color,tR=LQ!==void 0?LQ.length:0,ii=ke.get(pA),AR=k.state.lights;if(Ye===!0&&(dt===!0||WA!==te)){const Nn=WA===te&&pA.id===Ae;J.setState(pA,WA,Nn)}let jr=!1;pA.version===ii.__version?ii.needsLights&&ii.lightsStateVersion!==AR.state.version||ii.outputColorSpace!==W_||bi.isInstancedMesh&&ii.instancing===!1?jr=!0:bi.isInstancedMesh||ii.instancing!==!0?bi.isSkinnedMesh&&ii.skinning===!1?jr=!0:bi.isSkinnedMesh||ii.skinning!==!0?ii.envMap!==Cc||pA.fog===!0&&ii.fog!==RI?jr=!0:ii.numClippingPlanes===void 0||ii.numClippingPlanes===J.numPlanes&&ii.numIntersection===J.numIntersection?(ii.vertexAlphas!==V_||ii.vertexTangents!==Z_||ii.morphTargets!==j_||ii.morphNormals!==X_||ii.morphColors!==$_||ii.toneMapping!==eR||je.isWebGL2===!0&&ii.morphTargetsCount!==tR)&&(jr=!0):jr=!0:jr=!0:jr=!0:(jr=!0,ii.__version=pA.version);let js=ii.currentProgram;jr===!0&&(js=Fi(pA,Bn,bi));let GQ=!1,ug=!1,NI=!1;const ln=js.getUniforms(),Xs=ii.uniforms;if(_e.useProgram(js.program)&&(GQ=!0,ug=!0,NI=!0),pA.id!==Ae&&(Ae=pA.id,ug=!0),GQ||te!==WA){if(ln.setValue(ve,"projectionMatrix",WA.projectionMatrix),je.logarithmicDepthBuffer&&ln.setValue(ve,"logDepthBufFC",2/(Math.log(WA.far+1)/Math.LN2)),te!==WA&&(te=WA,ug=!0,NI=!0),pA.isShaderMaterial||pA.isMeshPhongMaterial||pA.isMeshToonMaterial||pA.isMeshStandardMaterial||pA.envMap){const Nn=ln.map.cameraPosition;Nn!==void 0&&Nn.setValue(ve,Xt.setFromMatrixPosition(WA.matrixWorld))}(pA.isMeshPhongMaterial||pA.isMeshToonMaterial||pA.isMeshLambertMaterial||pA.isMeshBasicMaterial||pA.isMeshStandardMaterial||pA.isShaderMaterial)&&ln.setValue(ve,"isOrthographic",WA.isOrthographicCamera===!0),(pA.isMeshPhongMaterial||pA.isMeshToonMaterial||pA.isMeshLambertMaterial||pA.isMeshBasicMaterial||pA.isMeshStandardMaterial||pA.isShaderMaterial||pA.isShadowMaterial||bi.isSkinnedMesh)&&ln.setValue(ve,"viewMatrix",WA.matrixWorldInverse)}if(bi.isSkinnedMesh){ln.setOptional(ve,bi,"bindMatrix"),ln.setOptional(ve,bi,"bindMatrixInverse");const Nn=bi.skeleton;Nn&&je.floatVertexTextures&&(Nn.boneTexture===null&&Nn.computeBoneTexture(),ln.setValue(ve,"boneTexture",Nn.boneTexture,oe),ln.setValue(ve,"boneTextureSize",Nn.boneTextureSize))}const kI=Li.morphAttributes;(kI.position!==void 0||kI.normal!==void 0||kI.color!==void 0&&je.isWebGL2===!0)&&rt.update(bi,Li,js),(ug||ii.receiveShadow!==bi.receiveShadow)&&(ii.receiveShadow=bi.receiveShadow,ln.setValue(ve,"receiveShadow",bi.receiveShadow)),pA.isMeshGouraudMaterial&&pA.envMap!==null&&(Xs.envMap.value=Cc,Xs.flipEnvMap.value=Cc.isCubeTexture&&Cc.isRenderTargetTexture===!1?-1:1),ug&&(ln.setValue(ve,"toneMappingExposure",N.toneMappingExposure),ii.needsLights&&(sr=NI,(mr=Xs).ambientLightColor.needsUpdate=sr,mr.lightProbe.needsUpdate=sr,mr.directionalLights.needsUpdate=sr,mr.directionalLightShadows.needsUpdate=sr,mr.pointLights.needsUpdate=sr,mr.pointLightShadows.needsUpdate=sr,mr.spotLights.needsUpdate=sr,mr.spotLightShadows.needsUpdate=sr,mr.rectAreaLights.needsUpdate=sr,mr.hemisphereLights.needsUpdate=sr),RI&&pA.fog===!0&&_t.refreshFogUniforms(Xs,RI),_t.refreshMaterialUniforms(Xs,pA,Ct,Ze,bt),Hl.upload(ve,ii.uniformsList,Xs,oe));var mr,sr;if(pA.isShaderMaterial&&pA.uniformsNeedUpdate===!0&&(Hl.upload(ve,ii.uniformsList,Xs,oe),pA.uniformsNeedUpdate=!1),pA.isSpriteMaterial&&ln.setValue(ve,"center",bi.center),ln.setValue(ve,"modelViewMatrix",bi.modelViewMatrix),ln.setValue(ve,"normalMatrix",bi.normalMatrix),ln.setValue(ve,"modelMatrix",bi.matrixWorld),pA.isShaderMaterial||pA.isRawShaderMaterial){const Nn=pA.uniformsGroups;for(let FI=0,iR=Nn.length;FI<iR;FI++)if(je.isWebGL2){const UQ=Nn[FI];Vt.update(UQ,js),Vt.bind(UQ,js)}}return js})(he,et,Bt,lt,pt);_e.setMaterial(lt,IA);let GA=Bt.index,gA=1;lt.wireframe===!0&&(GA=ht.getWireframeAttribute(Bt),gA=2);const bA=Bt.drawRange,_A=Bt.attributes.position;let jA=bA.start*gA,DA=(bA.start+bA.count)*gA;eA!==null&&(jA=Math.max(jA,eA.start*gA),DA=Math.min(DA,(eA.start+eA.count)*gA)),GA!==null?(jA=Math.max(jA,0),DA=Math.min(DA,GA.count)):_A!=null&&(jA=Math.max(jA,0),DA=Math.min(DA,_A.count));const BA=DA-jA;if(BA<0||BA===1/0)return;let Xi;Yt.setup(pt,lt,MA,Bt,GA);let $A=$e;if(GA!==null&&(Xi=St.get(GA),$A=Re,$A.setIndex(Xi)),pt.isMesh)lt.wireframe===!0?(_e.setLineWidth(lt.wireframeLinewidth*Ie()),$A.setMode(ve.LINES)):$A.setMode(ve.TRIANGLES);else if(pt.isLine){let WA=lt.linewidth;WA===void 0&&(WA=1),_e.setLineWidth(WA*Ie()),pt.isLineSegments?$A.setMode(ve.LINES):pt.isLineLoop?$A.setMode(ve.LINE_LOOP):$A.setMode(ve.LINE_STRIP)}else pt.isPoints?$A.setMode(ve.POINTS):pt.isSprite&&$A.setMode(ve.TRIANGLES);if(pt.isInstancedMesh)$A.renderInstances(jA,BA,pt.count);else if(Bt.isInstancedBufferGeometry){const WA=Bt._maxInstanceCount!==void 0?Bt._maxInstanceCount:1/0,Bn=Math.min(Bt.instanceCount,WA);$A.renderInstances(jA,BA,Bn)}else $A.render(jA,BA)},this.compile=function(he,et){function Bt(lt,pt,eA){lt.transparent===!0&<.side===2&<.forceSinglePass===!1?(lt.side=v,lt.needsUpdate=!0,Fi(lt,pt,eA),lt.side=m,lt.needsUpdate=!0,Fi(lt,pt,eA),lt.side=2):Fi(lt,pt,eA)}k=hA.get(he),k.init(),_.push(k),he.traverseVisible((function(lt){lt.isLight&<.layers.test(et.layers)&&(k.pushLight(lt),lt.castShadow&&k.pushShadow(lt))})),k.setupLights(N.useLegacyLights),he.traverse((function(lt){const pt=lt.material;if(pt)if(Array.isArray(pt))for(let eA=0;eA<pt.length;eA++)Bt(pt[eA],he,lt);else Bt(pt,he,lt)})),_.pop(),k=null};let oA=null;function wA(){qA.stop()}function mi(){qA.start()}const qA=new DE;function cA(he,et,Bt,lt){if(he.visible===!1)return;if(he.layers.test(et.layers)){if(he.isGroup)Bt=he.renderOrder;else if(he.isLOD)he.autoUpdate===!0&&he.update(et);else if(he.isLight)k.pushLight(he),he.castShadow&&k.pushShadow(he);else if(he.isSprite){if(!he.frustumCulled||Ft.intersectsSprite(he)){lt&&Xt.setFromMatrixPosition(he.matrixWorld).applyMatrix4(gt);const eA=Kt.update(he),IA=he.material;IA.visible&&w.push(he,eA,IA,Bt,Xt.z,null)}}else if((he.isMesh||he.isLine||he.isPoints)&&(!he.frustumCulled||Ft.intersectsObject(he))){he.isSkinnedMesh&&he.skeleton.frame!==Et.render.frame&&(he.skeleton.update(),he.skeleton.frame=Et.render.frame);const eA=Kt.update(he),IA=he.material;if(lt&&(eA.boundingSphere===null&&eA.computeBoundingSphere(),Xt.copy(eA.boundingSphere.center).applyMatrix4(he.matrixWorld).applyMatrix4(gt)),Array.isArray(IA)){const MA=eA.groups;for(let GA=0,gA=MA.length;GA<gA;GA++){const bA=MA[GA],_A=IA[bA.materialIndex];_A&&_A.visible&&w.push(he,eA,_A,Bt,Xt.z,bA)}}else IA.visible&&w.push(he,eA,IA,Bt,Xt.z,null)}}const pt=he.children;for(let eA=0,IA=pt.length;eA<IA;eA++)cA(pt[eA],et,Bt,lt)}function FA(he,et,Bt,lt){const pt=he.opaque,eA=he.transmissive,IA=he.transparent;k.setupLightsView(Bt),Ye===!0&&J.setGlobalState(N.clippingPlanes,Bt),eA.length>0&&(function(MA,GA,gA,bA){if(bt===null){const BA=je.isWebGL2;bt=new ei(1024,1024,{generateMipmaps:!0,type:Se.has("EXT_color_buffer_half_float")?mt:be,minFilter:se,samples:BA&&h===!0?4:0})}const _A=N.getRenderTarget();N.setRenderTarget(bt),N.clear();const jA=N.toneMapping;N.toneMapping=F,hi(MA,gA,bA),oe.updateMultisampleRenderTarget(bt),oe.updateRenderTargetMipmap(bt);let DA=!1;for(let BA=0,Xi=GA.length;BA<Xi;BA++){const $A=GA[BA],WA=$A.object,Bn=$A.geometry,Li=$A.material,pA=$A.group;if(Li.side===2&&WA.layers.test(bA.layers)){const bi=Li.side;Li.side=v,Li.needsUpdate=!0,ji(WA,gA,bA,Bn,Li,pA),Li.side=bi,Li.needsUpdate=!0,DA=!0}}DA===!0&&(oe.updateMultisampleRenderTarget(bt),oe.updateRenderTargetMipmap(bt)),N.setRenderTarget(_A),N.toneMapping=jA})(pt,eA,et,Bt),lt&&_e.viewport(ye.copy(lt)),pt.length>0&&hi(pt,et,Bt),eA.length>0&&hi(eA,et,Bt),IA.length>0&&hi(IA,et,Bt),_e.buffers.depth.setTest(!0),_e.buffers.depth.setMask(!0),_e.buffers.color.setMask(!0),_e.setPolygonOffset(!1)}function hi(he,et,Bt){const lt=et.isScene===!0?et.overrideMaterial:null;for(let pt=0,eA=he.length;pt<eA;pt++){const IA=he[pt],MA=IA.object,GA=IA.geometry,gA=lt===null?IA.material:lt,bA=IA.group;MA.layers.test(Bt.layers)&&ji(MA,et,Bt,GA,gA,bA)}}function ji(he,et,Bt,lt,pt,eA){he.onBeforeRender(N,et,Bt,lt,pt,eA),he.modelViewMatrix.multiplyMatrices(Bt.matrixWorldInverse,he.matrixWorld),he.normalMatrix.getNormalMatrix(he.modelViewMatrix),pt.onBeforeRender(N,et,Bt,lt,he,eA),pt.transparent===!0&&pt.side===2&&pt.forceSinglePass===!1?(pt.side=v,pt.needsUpdate=!0,N.renderBufferDirect(Bt,et,lt,pt,he,eA),pt.side=m,pt.needsUpdate=!0,N.renderBufferDirect(Bt,et,lt,pt,he,eA),pt.side=2):N.renderBufferDirect(Bt,et,lt,pt,he,eA),he.onAfterRender(N,et,Bt,lt,pt,eA)}function Fi(he,et,Bt){et.isScene!==!0&&(et=ce);const lt=ke.get(he),pt=k.state.lights,eA=k.state.shadowsArray,IA=pt.state.version,MA=Ht.getParameters(he,pt.state,eA,et,Bt),GA=Ht.getProgramCacheKey(MA);let gA=lt.programs;lt.environment=he.isMeshStandardMaterial?et.environment:null,lt.fog=et.fog,lt.envMap=(he.isMeshStandardMaterial?ct:Te).get(he.envMap||lt.environment),gA===void 0&&(he.addEventListener("dispose",sA),gA=new Map,lt.programs=gA);let bA=gA.get(GA);if(bA!==void 0){if(lt.currentProgram===bA&<.lightsStateVersion===IA)return vi(he,MA),bA}else MA.uniforms=Ht.getUniforms(he),he.onBuild(Bt,MA,N),he.onBeforeCompile(MA,N),bA=Ht.acquireProgram(MA,GA),gA.set(GA,bA),lt.uniforms=MA.uniforms;const _A=lt.uniforms;(he.isShaderMaterial||he.isRawShaderMaterial)&&he.clipping!==!0||(_A.clippingPlanes=J.uniform),vi(he,MA),lt.needsLights=(function(BA){return BA.isMeshLambertMaterial||BA.isMeshToonMaterial||BA.isMeshPhongMaterial||BA.isMeshStandardMaterial||BA.isShadowMaterial||BA.isShaderMaterial&&BA.lights===!0})(he),lt.lightsStateVersion=IA,lt.needsLights&&(_A.ambientLightColor.value=pt.state.ambient,_A.lightProbe.value=pt.state.probe,_A.directionalLights.value=pt.state.directional,_A.directionalLightShadows.value=pt.state.directionalShadow,_A.spotLights.value=pt.state.spot,_A.spotLightShadows.value=pt.state.spotShadow,_A.rectAreaLights.value=pt.state.rectArea,_A.ltc_1.value=pt.state.rectAreaLTC1,_A.ltc_2.value=pt.state.rectAreaLTC2,_A.pointLights.value=pt.state.point,_A.pointLightShadows.value=pt.state.pointShadow,_A.hemisphereLights.value=pt.state.hemi,_A.directionalShadowMap.value=pt.state.directionalShadowMap,_A.directionalShadowMatrix.value=pt.state.directionalShadowMatrix,_A.spotShadowMap.value=pt.state.spotShadowMap,_A.spotLightMatrix.value=pt.state.spotLightMatrix,_A.spotLightMap.value=pt.state.spotLightMap,_A.pointShadowMap.value=pt.state.pointShadowMap,_A.pointShadowMatrix.value=pt.state.pointShadowMatrix);const jA=bA.getUniforms(),DA=Hl.seqWithValue(jA.seq,_A);return lt.currentProgram=bA,lt.uniformsList=DA,bA}function vi(he,et){const Bt=ke.get(he);Bt.outputColorSpace=et.outputColorSpace,Bt.instancing=et.instancing,Bt.skinning=et.skinning,Bt.morphTargets=et.morphTargets,Bt.morphNormals=et.morphNormals,Bt.morphColors=et.morphColors,Bt.morphTargetsCount=et.morphTargetsCount,Bt.numClippingPlanes=et.numClippingPlanes,Bt.numIntersection=et.numClipIntersection,Bt.vertexAlphas=et.vertexAlphas,Bt.vertexTangents=et.vertexTangents,Bt.toneMapping=et.toneMapping}qA.setAnimationLoop((function(he){oA&&oA(he)})),typeof self<"u"&&qA.setContext(self),this.setAnimationLoop=function(he){oA=he,Lt.setAnimationLoop(he),he===null?qA.stop():qA.start()},Lt.addEventListener("sessionstart",wA),Lt.addEventListener("sessionend",mi),this.render=function(he,et){if(et!==void 0&&et.isCamera!==!0||L===!0)return;he.matrixWorldAutoUpdate===!0&&he.updateMatrixWorld(),et.parent===null&&et.matrixWorldAutoUpdate===!0&&et.updateMatrixWorld(),Lt.enabled===!0&&Lt.isPresenting===!0&&(Lt.cameraAutoUpdate===!0&&Lt.updateCamera(et),et=Lt.getCamera()),he.isScene===!0&&he.onBeforeRender(N,he,et,ne),k=hA.get(he,_.length),k.init(),_.push(k),gt.multiplyMatrices(et.projectionMatrix,et.matrixWorldInverse),Ft.setFromProjectionMatrix(gt),dt=this.localClippingEnabled,Ye=J.init(this.clippingPlanes,dt),w=CA.get(he,R.length),w.init(),R.push(w),cA(he,et,0,N.sortObjects),w.finish(),N.sortObjects===!0&&w.sort(Qt,Wt),Ye===!0&&J.beginShadows();const Bt=k.state.shadowsArray;if($.render(Bt,he,et),Ye===!0&&J.endShadows(),this.info.autoReset===!0&&this.info.reset(),xe.render(w,he),k.setupLights(N.useLegacyLights),et.isArrayCamera){const lt=et.cameras;for(let pt=0,eA=lt.length;pt<eA;pt++){const IA=lt[pt];FA(w,he,IA,IA.viewport)}}else FA(w,he,et);ne!==null&&(oe.updateMultisampleRenderTarget(ne),oe.updateRenderTargetMipmap(ne)),he.isScene===!0&&he.onAfterRender(N,he,et),Yt.resetDefaultState(),Ae=-1,te=null,_.pop(),k=_.length>0?_[_.length-1]:null,R.pop(),w=R.length>0?R[R.length-1]:null},this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return le},this.getRenderTarget=function(){return ne},this.setRenderTargetTextures=function(he,et,Bt){ke.get(he.texture).__webglTexture=et,ke.get(he.depthTexture).__webglTexture=Bt;const lt=ke.get(he);lt.__hasExternalTextures=!0,lt.__hasExternalTextures&&(lt.__autoAllocateDepthBuffer=Bt===void 0,lt.__autoAllocateDepthBuffer||Se.has("WEBGL_multisampled_render_to_texture")===!0&&(lt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(he,et){const Bt=ke.get(he);Bt.__webglFramebuffer=et,Bt.__useDefaultFramebuffer=et===void 0},this.setRenderTarget=function(he,et=0,Bt=0){ne=he,G=et,le=Bt;let lt=!0,pt=null,eA=!1,IA=!1;if(he){const MA=ke.get(he);MA.__useDefaultFramebuffer!==void 0?(_e.bindFramebuffer(ve.FRAMEBUFFER,null),lt=!1):MA.__webglFramebuffer===void 0?oe.setupRenderTarget(he):MA.__hasExternalTextures&&oe.rebindTextures(he,ke.get(he.texture).__webglTexture,ke.get(he.depthTexture).__webglTexture);const GA=he.texture;(GA.isData3DTexture||GA.isDataArrayTexture||GA.isCompressedArrayTexture)&&(IA=!0);const gA=ke.get(he).__webglFramebuffer;he.isWebGLCubeRenderTarget?(pt=gA[et],eA=!0):pt=je.isWebGL2&&he.samples>0&&oe.useMultisampledRTT(he)===!1?ke.get(he).__webglMultisampledFramebuffer:gA,ye.copy(he.viewport),ge.copy(he.scissor),Me=he.scissorTest}else ye.copy(ft).multiplyScalar(Ct).floor(),ge.copy(Mt).multiplyScalar(Ct).floor(),Me=Rt;if(_e.bindFramebuffer(ve.FRAMEBUFFER,pt)&&je.drawBuffers&<&&_e.drawBuffers(he,pt),_e.viewport(ye),_e.scissor(ge),_e.setScissorTest(Me),eA){const MA=ke.get(he.texture);ve.framebufferTexture2D(ve.FRAMEBUFFER,ve.COLOR_ATTACHMENT0,ve.TEXTURE_CUBE_MAP_POSITIVE_X+et,MA.__webglTexture,Bt)}else if(IA){const MA=ke.get(he.texture),GA=et||0;ve.framebufferTextureLayer(ve.FRAMEBUFFER,ve.COLOR_ATTACHMENT0,MA.__webglTexture,Bt||0,GA)}Ae=-1},this.readRenderTargetPixels=function(he,et,Bt,lt,pt,eA,IA){if(!he||!he.isWebGLRenderTarget)return;let MA=ke.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&IA!==void 0&&(MA=MA[IA]),MA){_e.bindFramebuffer(ve.FRAMEBUFFER,MA);try{const GA=he.texture,gA=GA.format,bA=GA.type;if(gA!==kt&&Pe.convert(gA)!==ve.getParameter(ve.IMPLEMENTATION_COLOR_READ_FORMAT))return;const _A=bA===mt&&(Se.has("EXT_color_buffer_half_float")||je.isWebGL2&&Se.has("EXT_color_buffer_float"));if(!(bA===be||Pe.convert(bA)===ve.getParameter(ve.IMPLEMENTATION_COLOR_READ_TYPE)||bA===De&&(je.isWebGL2||Se.has("OES_texture_float")||Se.has("WEBGL_color_buffer_float"))||_A))return;et>=0&&et<=he.width-lt&&Bt>=0&&Bt<=he.height-pt&&ve.readPixels(et,Bt,lt,pt,Pe.convert(gA),Pe.convert(bA),eA)}finally{const GA=ne!==null?ke.get(ne).__webglFramebuffer:null;_e.bindFramebuffer(ve.FRAMEBUFFER,GA)}}},this.copyFramebufferToTexture=function(he,et,Bt=0){const lt=Math.pow(2,-Bt),pt=Math.floor(et.image.width*lt),eA=Math.floor(et.image.height*lt);oe.setTexture2D(et,0),ve.copyTexSubImage2D(ve.TEXTURE_2D,Bt,0,0,he.x,he.y,pt,eA),_e.unbindTexture()},this.copyTextureToTexture=function(he,et,Bt,lt=0){const pt=et.image.width,eA=et.image.height,IA=Pe.convert(Bt.format),MA=Pe.convert(Bt.type);oe.setTexture2D(Bt,0),ve.pixelStorei(ve.UNPACK_FLIP_Y_WEBGL,Bt.flipY),ve.pixelStorei(ve.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Bt.premultiplyAlpha),ve.pixelStorei(ve.UNPACK_ALIGNMENT,Bt.unpackAlignment),et.isDataTexture?ve.texSubImage2D(ve.TEXTURE_2D,lt,he.x,he.y,pt,eA,IA,MA,et.image.data):et.isCompressedTexture?ve.compressedTexSubImage2D(ve.TEXTURE_2D,lt,he.x,he.y,et.mipmaps[0].width,et.mipmaps[0].height,IA,et.mipmaps[0].data):ve.texSubImage2D(ve.TEXTURE_2D,lt,he.x,he.y,IA,MA,et.image),lt===0&&Bt.generateMipmaps&&ve.generateMipmap(ve.TEXTURE_2D),_e.unbindTexture()},this.copyTextureToTexture3D=function(he,et,Bt,lt,pt=0){if(N.isWebGL1Renderer)return;const eA=he.max.x-he.min.x+1,IA=he.max.y-he.min.y+1,MA=he.max.z-he.min.z+1,GA=Pe.convert(lt.format),gA=Pe.convert(lt.type);let bA;if(lt.isData3DTexture)oe.setTexture3D(lt,0),bA=ve.TEXTURE_3D;else{if(!lt.isDataArrayTexture)return;oe.setTexture2DArray(lt,0),bA=ve.TEXTURE_2D_ARRAY}ve.pixelStorei(ve.UNPACK_FLIP_Y_WEBGL,lt.flipY),ve.pixelStorei(ve.UNPACK_PREMULTIPLY_ALPHA_WEBGL,lt.premultiplyAlpha),ve.pixelStorei(ve.UNPACK_ALIGNMENT,lt.unpackAlignment);const _A=ve.getParameter(ve.UNPACK_ROW_LENGTH),jA=ve.getParameter(ve.UNPACK_IMAGE_HEIGHT),DA=ve.getParameter(ve.UNPACK_SKIP_PIXELS),BA=ve.getParameter(ve.UNPACK_SKIP_ROWS),Xi=ve.getParameter(ve.UNPACK_SKIP_IMAGES),$A=Bt.isCompressedTexture?Bt.mipmaps[0]:Bt.image;ve.pixelStorei(ve.UNPACK_ROW_LENGTH,$A.width),ve.pixelStorei(ve.UNPACK_IMAGE_HEIGHT,$A.height),ve.pixelStorei(ve.UNPACK_SKIP_PIXELS,he.min.x),ve.pixelStorei(ve.UNPACK_SKIP_ROWS,he.min.y),ve.pixelStorei(ve.UNPACK_SKIP_IMAGES,he.min.z),Bt.isDataTexture||Bt.isData3DTexture?ve.texSubImage3D(bA,pt,et.x,et.y,et.z,eA,IA,MA,GA,gA,$A.data):Bt.isCompressedArrayTexture?ve.compressedTexSubImage3D(bA,pt,et.x,et.y,et.z,eA,IA,MA,GA,$A.data):ve.texSubImage3D(bA,pt,et.x,et.y,et.z,eA,IA,MA,GA,gA,$A),ve.pixelStorei(ve.UNPACK_ROW_LENGTH,_A),ve.pixelStorei(ve.UNPACK_IMAGE_HEIGHT,jA),ve.pixelStorei(ve.UNPACK_SKIP_PIXELS,DA),ve.pixelStorei(ve.UNPACK_SKIP_ROWS,BA),ve.pixelStorei(ve.UNPACK_SKIP_IMAGES,Xi),pt===0&<.generateMipmaps&&ve.generateMipmap(bA),_e.unbindTexture()},this.initTexture=function(he){he.isCubeTexture?oe.setTextureCube(he,0):he.isData3DTexture?oe.setTexture3D(he,0):he.isDataArrayTexture||he.isCompressedArrayTexture?oe.setTexture2DArray(he,0):oe.setTexture2D(he,0),_e.unbindTexture()},this.resetState=function(){G=0,le=0,ne=null,_e.reset(),Yt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get physicallyCorrectLights(){return!this.useLegacyLights}set physicallyCorrectLights(e){this.useLegacyLights=!e}get outputEncoding(){return this.outputColorSpace===ie?M:3e3}set outputEncoding(e){this.outputColorSpace=e===M?ie:W}}(class extends $E{}).prototype.isWebGL1Renderer=!0;class Rn extends gi{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return this.matrixWorldAutoUpdate}set autoUpdate(e){this.matrixWorldAutoUpdate=e}}class eB{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=We,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=AA()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,A){e*=this.stride,A*=t.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=t.array[A+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=AA()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),A=new this.constructor(t,this.stride);return A.setUsage(this.usage),A}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=AA()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const on=new re;class Ho{constructor(e,t,A,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=A,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,A=this.data.count;t<A;t++)on.fromBufferAttribute(this,t),on.applyMatrix4(e),this.setXYZ(t,on.x,on.y,on.z);return this}applyNormalMatrix(e){for(let t=0,A=this.count;t<A;t++)on.fromBufferAttribute(this,t),on.applyNormalMatrix(e),this.setXYZ(t,on.x,on.y,on.z);return this}transformDirection(e){for(let t=0,A=this.count;t<A;t++)on.fromBufferAttribute(this,t),on.transformDirection(e),this.setXYZ(t,on.x,on.y,on.z);return this}setX(e,t){return this.normalized&&(t=SA(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=SA(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=SA(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=SA(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=nn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=nn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=nn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=nn(t,this.array)),t}setXY(e,t,A){return e=e*this.data.stride+this.offset,this.normalized&&(t=SA(t,this.array),A=SA(A,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=A,this}setXYZ(e,t,A,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=SA(t,this.array),A=SA(A,this.array),n=SA(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=A,this.data.array[e+2]=n,this}setXYZW(e,t,A,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=SA(t,this.array),A=SA(A,this.array),n=SA(n,this.array),r=SA(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=A,this.data.array[e+2]=n,this.data.array[e+3]=r,this}clone(e){if(e===void 0){const t=[];for(let A=0;A<this.count;A++){const n=A*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return new Vi(new this.array.constructor(t),this.itemSize,this.normalized)}return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Ho(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){const t=[];for(let A=0;A<this.count;A++){const n=A*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[n+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class tB extends Sn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new rA(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Ra;const Jo=new re,Na=new re,ka=new re,Fa=new Gt,Yo=new Gt,AB=new xA,Jl=new re,Po=new re,Yl=new re,iB=new Gt,zh=new Gt,nB=new Gt;class US extends gi{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",Ra===void 0){Ra=new bn;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),A=new eB(t,5);Ra.setIndex([0,1,2,0,2,3]),Ra.setAttribute("position",new Ho(A,3,0,!1)),Ra.setAttribute("uv",new Ho(A,2,3,!1))}this.geometry=Ra,this.material=e!==void 0?e:new tB,this.center=new Gt(.5,.5)}raycast(e,t){e.camera,Na.setFromMatrixScale(this.matrixWorld),AB.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ka.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Na.multiplyScalar(-ka.z);const A=this.material.rotation;let n,r;A!==0&&(r=Math.cos(A),n=Math.sin(A));const g=this.center;Pl(Jl.set(-.5,-.5,0),ka,g,Na,n,r),Pl(Po.set(.5,-.5,0),ka,g,Na,n,r),Pl(Yl.set(.5,.5,0),ka,g,Na,n,r),iB.set(0,0),zh.set(1,0),nB.set(1,1);let h=e.ray.intersectTriangle(Jl,Po,Yl,!1,Jo);if(h===null&&(Pl(Po.set(-.5,.5,0),ka,g,Na,n,r),zh.set(0,1),h=e.ray.intersectTriangle(Jl,Yl,Po,!1,Jo),h===null))return;const u=e.ray.origin.distanceTo(Jo);u<e.near||u>e.far||t.push({distance:u,point:Jo.clone(),uv:Hn.getInterpolation(Jo,Jl,Po,Yl,iB,zh,nB,new Gt),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Pl(o,e,t,A,n,r){Fa.subVectors(o,t).addScalar(.5).multiply(A),n!==void 0?(Yo.x=r*Fa.x-n*Fa.y,Yo.y=n*Fa.x+r*Fa.y):Yo.copy(Fa),o.copy(e),o.x+=Yo.x,o.y+=Yo.y,o.applyMatrix4(AB)}const rB=new re,sB=new zA,aB=new zA,TS=new re,oB=new xA,La=new re;class HS extends UA{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new xA,this.bindMatrixInverse=new xA,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Mi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let A=0;A<t.count;A++)La.fromBufferAttribute(t,A),this.applyBoneTransform(A,La),this.boundingBox.expandByPoint(La)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ur),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let A=0;A<t.count;A++)La.fromBufferAttribute(t,A),this.applyBoneTransform(A,La),this.boundingSphere.expandByPoint(La)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new zA,t=this.geometry.attributes.skinWeight;for(let A=0,n=t.count;A<n;A++){e.fromBufferAttribute(t,A);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(A,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"?this.bindMatrixInverse.copy(this.bindMatrix).invert():this.bindMode}applyBoneTransform(e,t){const A=this.skeleton,n=this.geometry;sB.fromBufferAttribute(n.attributes.skinIndex,e),aB.fromBufferAttribute(n.attributes.skinWeight,e),rB.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const g=aB.getComponent(r);if(g!==0){const h=sB.getComponent(r);oB.multiplyMatrices(A.bones[h].matrixWorld,A.boneInverses[h]),t.addScaledVector(TS.copy(rB).applyMatrix4(oB),g)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return this.applyBoneTransform(e,t)}}class gB extends gi{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Cs extends Di{constructor(e=null,t=1,A=1,n,r,g,h,u,c=1003,C=1003,B,p){super(null,g,h,u,c,C,n,r,B,p),this.isDataTexture=!0,this.image={data:e,width:t,height:A},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const lB=new xA,JS=new xA;class qh{constructor(e=[],t=[]){this.uuid=AA(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),t.length===0)this.calculateInverses();else if(e.length!==t.length){this.boneInverses=[];for(let A=0,n=this.bones.length;A<n;A++)this.boneInverses.push(new xA)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const A=new xA;this.bones[e]&&A.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(A)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const A=this.bones[e];A&&A.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const A=this.bones[e];A&&(A.parent&&A.parent.isBone?(A.matrix.copy(A.parent.matrixWorld).invert(),A.matrix.multiply(A.matrixWorld)):A.matrix.copy(A.matrixWorld),A.matrix.decompose(A.position,A.quaternion,A.scale))}}update(){const e=this.bones,t=this.boneInverses,A=this.boneMatrices,n=this.boneTexture;for(let r=0,g=e.length;r<g;r++){const h=e[r]?e[r].matrixWorld:JS;lB.multiplyMatrices(h,t[r]),lB.toArray(A,16*r)}n!==null&&(n.needsUpdate=!0)}clone(){return new qh(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=ai(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const A=new Cs(t,e,e,kt,De);return A.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=A,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,A=this.bones.length;t<A;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let A=0,n=e.bones.length;A<n;A++){const r=e.bones[A];let g=t[r];g===void 0&&(g=new gB),this.bones.push(g),this.boneInverses.push(new xA().fromArray(e.boneInverses[A]))}return this.init(),this}toJSON(){const e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,A=this.boneInverses;for(let n=0,r=t.length;n<r;n++){const g=t[n];e.bones.push(g.uuid);const h=A[n];e.boneInverses.push(h.toArray())}return e}}class cB extends Vi{constructor(e,t,A,n=1){super(e,t,A),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Ga=new xA,hB=new xA,Ol=[],IB=new Mi,YS=new xA,Oo=new UA,Ko=new Ur;class PS extends UA{constructor(e,t,A){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new cB(new Float32Array(16*A),16),this.instanceColor=null,this.count=A,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<A;n++)this.setMatrixAt(n,YS)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Mi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let A=0;A<t;A++)this.getMatrixAt(A,Ga),IB.copy(e.boundingBox).applyMatrix4(Ga),this.boundingBox.union(IB)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ur),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let A=0;A<t;A++)this.getMatrixAt(A,Ga),Ko.copy(e.boundingSphere).applyMatrix4(Ga),this.boundingSphere.union(Ko)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){const A=this.matrixWorld,n=this.count;if(Oo.geometry=this.geometry,Oo.material=this.material,Oo.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ko.copy(this.boundingSphere),Ko.applyMatrix4(A),e.ray.intersectsSphere(Ko)!==!1))for(let r=0;r<n;r++){this.getMatrixAt(r,Ga),hB.multiplyMatrices(A,Ga),Oo.matrixWorld=hB,Oo.raycast(e,Ol);for(let g=0,h=Ol.length;g<h;g++){const u=Ol[g];u.instanceId=r,u.object=this,t.push(u)}Ol.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new cB(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class uB extends Sn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new rA(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const CB=new re,dB=new re,EB=new xA,Wh=new Lo,Kl=new Ur;class Vh extends gi{constructor(e=new bn,t=new uB){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,A=[0];for(let n=1,r=t.count;n<r;n++)CB.fromBufferAttribute(t,n-1),dB.fromBufferAttribute(t,n),A[n]=A[n-1],A[n]+=CB.distanceTo(dB);e.setAttribute("lineDistance",new Cn(A,1))}return this}raycast(e,t){const A=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,g=A.drawRange;if(A.boundingSphere===null&&A.computeBoundingSphere(),Kl.copy(A.boundingSphere),Kl.applyMatrix4(n),Kl.radius+=r,e.ray.intersectsSphere(Kl)===!1)return;EB.copy(n).invert(),Wh.copy(e.ray).applyMatrix4(EB);const h=r/((this.scale.x+this.scale.y+this.scale.z)/3),u=h*h,c=new re,C=new re,B=new re,p=new re,w=this.isLineSegments?2:1,k=A.index,R=A.attributes.position;if(k!==null)for(let _=Math.max(0,g.start),N=Math.min(k.count,g.start+g.count)-1;_<N;_+=w){const L=k.getX(_),G=k.getX(_+1);if(c.fromBufferAttribute(R,L),C.fromBufferAttribute(R,G),Wh.distanceSqToSegment(c,C,p,B)>u)continue;p.applyMatrix4(this.matrixWorld);const le=e.ray.origin.distanceTo(p);le<e.near||le>e.far||t.push({distance:le,point:B.clone().applyMatrix4(this.matrixWorld),index:_,face:null,faceIndex:null,object:this})}else for(let _=Math.max(0,g.start),N=Math.min(R.count,g.start+g.count)-1;_<N;_+=w){if(c.fromBufferAttribute(R,_),C.fromBufferAttribute(R,_+1),Wh.distanceSqToSegment(c,C,p,B)>u)continue;p.applyMatrix4(this.matrixWorld);const L=e.ray.origin.distanceTo(p);L<e.near||L>e.far||t.push({distance:L,point:B.clone().applyMatrix4(this.matrixWorld),index:_,face:null,faceIndex:null,object:this})}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const A=e[t[0]];if(A!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=A.length;n<r;n++){const g=A[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[g]=n}}}}}const BB=new re,QB=new re;class OS extends Vh{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,A=[];for(let n=0,r=t.count;n<r;n+=2)BB.fromBufferAttribute(t,n),QB.fromBufferAttribute(t,n+1),A[n]=n===0?0:A[n-1],A[n+1]=A[n]+BB.distanceTo(QB);e.setAttribute("lineDistance",new Cn(A,1))}return this}}class KS extends Vh{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class fB extends Sn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new rA(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const pB=new xA,Zh=new Lo,zl=new Ur,ql=new re;class zS extends gi{constructor(e=new bn,t=new fB){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const A=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,g=A.drawRange;if(A.boundingSphere===null&&A.computeBoundingSphere(),zl.copy(A.boundingSphere),zl.applyMatrix4(n),zl.radius+=r,e.ray.intersectsSphere(zl)===!1)return;pB.copy(n).invert(),Zh.copy(e.ray).applyMatrix4(pB);const h=r/((this.scale.x+this.scale.y+this.scale.z)/3),u=h*h,c=A.index,C=A.attributes.position;if(c!==null)for(let B=Math.max(0,g.start),p=Math.min(c.count,g.start+g.count);B<p;B++){const w=c.getX(B);ql.fromBufferAttribute(C,w),mB(ql,w,u,n,e,t,this)}else for(let B=Math.max(0,g.start),p=Math.min(C.count,g.start+g.count);B<p;B++)ql.fromBufferAttribute(C,B),mB(ql,B,u,n,e,t,this)}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const A=e[t[0]];if(A!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=A.length;n<r;n++){const g=A[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[g]=n}}}}}function mB(o,e,t,A,n,r,g){const h=Zh.distanceSqToPoint(o);if(h<t){const u=new re;Zh.closestPointToPoint(o,u),u.applyMatrix4(A);const c=n.ray.origin.distanceTo(u);if(c<n.near||c>n.far)return;r.push({distance:c,distanceToRay:Math.sqrt(h),point:u,index:e,face:null,object:g})}}class wB extends Di{constructor(e,t,A,n,r,g,h,u,c){super(e,t,A,n,r,g,h,u,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Wl extends bn{constructor(e=1,t=32,A=16,n=0,r=2*Math.PI,g=0,h=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:A,phiStart:n,phiLength:r,thetaStart:g,thetaLength:h},t=Math.max(3,Math.floor(t)),A=Math.max(2,Math.floor(A));const u=Math.min(g+h,Math.PI);let c=0;const C=[],B=new re,p=new re,w=[],k=[],R=[],_=[];for(let N=0;N<=A;N++){const L=[],G=N/A;let le=0;N===0&&g===0?le=.5/t:N===A&&u===Math.PI&&(le=-.5/t);for(let ne=0;ne<=t;ne++){const Ae=ne/t;B.x=-e*Math.cos(n+Ae*r)*Math.sin(g+G*h),B.y=e*Math.cos(g+G*h),B.z=e*Math.sin(n+Ae*r)*Math.sin(g+G*h),k.push(B.x,B.y,B.z),p.copy(B).normalize(),R.push(p.x,p.y,p.z),_.push(Ae+le,1-G),L.push(c++)}C.push(L)}for(let N=0;N<A;N++)for(let L=0;L<t;L++){const G=C[N][L+1],le=C[N][L],ne=C[N+1][L],Ae=C[N+1][L+1];(N!==0||g>0)&&w.push(G,le,Ae),(N!==A-1||u<Math.PI)&&w.push(le,ne,Ae)}this.setIndex(w),this.setAttribute("position",new Cn(k,3)),this.setAttribute("normal",new Cn(R,3)),this.setAttribute("uv",new Cn(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Wl(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Ys extends Sn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new rA(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new rA(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Ps extends Ys{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Gt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return yA(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new rA(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new rA(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new rA(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._iridescence=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}function ds(o,e,t){return yB(o)?new o.constructor(o.subarray(e,t!==void 0?t:o.length)):o.slice(e,t)}function Vl(o,e,t){return!o||o.constructor===e?o:typeof e.BYTES_PER_ELEMENT=="number"?new e(o):Array.prototype.slice.call(o)}function yB(o){return ArrayBuffer.isView(o)&&!(o instanceof DataView)}function qS(o){const e=o.length,t=new Array(e);for(let A=0;A!==e;++A)t[A]=A;return t.sort((function(A,n){return o[A]-o[n]})),t}function vB(o,e,t){const A=o.length,n=new o.constructor(A);for(let r=0,g=0;g!==A;++r){const h=t[r]*e;for(let u=0;u!==e;++u)n[g++]=o[h+u]}return n}function DB(o,e,t,A){let n=1,r=o[0];for(;r!==void 0&&r[A]===void 0;)r=o[n++];if(r===void 0)return;let g=r[A];if(g!==void 0)if(Array.isArray(g))do g=r[A],g!==void 0&&(e.push(r.time),t.push.apply(t,g)),r=o[n++];while(r!==void 0);else if(g.toArray!==void 0)do g=r[A],g!==void 0&&(e.push(r.time),g.toArray(t,t.length)),r=o[n++];while(r!==void 0);else do g=r[A],g!==void 0&&(e.push(r.time),t.push(g)),r=o[n++];while(r!==void 0)}class zo{constructor(e,t,A,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new t.constructor(A),this.sampleValues=t,this.valueSize=A,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let A=this._cachedIndex,n=t[A],r=t[A-1];e:{t:{let g;A:{i:if(!(e<n)){for(let h=A+2;;){if(n===void 0){if(e<r)break i;return A=t.length,this._cachedIndex=A,this.copySampleValue_(A-1)}if(A===h)break;if(r=n,n=t[++A],e<n)break t}g=t.length;break A}if(e>=r)break e;{const h=t[1];e<h&&(A=2,r=h);for(let u=A-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(A===u)break;if(n=r,r=t[--A-1],e>=r)break t}g=A,A=0}}for(;A<g;){const h=A+g>>>1;e<t[h]?g=h:A=h+1}if(n=t[A],r=t[A-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return A=t.length,this._cachedIndex=A,this.copySampleValue_(A-1)}this._cachedIndex=A,this.intervalChanged_(A,r,n)}return this.interpolate_(A,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,A=this.sampleValues,n=this.valueSize,r=e*n;for(let g=0;g!==n;++g)t[g]=A[r+g];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class WS extends zo{constructor(e,t,A,n){super(e,t,A,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:At,endingEnd:At}}intervalChanged_(e,t,A){const n=this.parameterPositions;let r=e-2,g=e+1,h=n[r],u=n[g];if(h===void 0)switch(this.getSettings_().endingStart){case at:r=e,h=2*t-A;break;case Dt:r=n.length-2,h=t+n[r]-n[r+1];break;default:r=e,h=A}if(u===void 0)switch(this.getSettings_().endingEnd){case at:g=e,u=2*A-t;break;case Dt:g=1,u=A+n[1]-n[0];break;default:g=e-1,u=t}const c=.5*(A-t),C=this.valueSize;this._weightPrev=c/(t-h),this._weightNext=c/(u-A),this._offsetPrev=r*C,this._offsetNext=g*C}interpolate_(e,t,A,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=e*h,c=u-h,C=this._offsetPrev,B=this._offsetNext,p=this._weightPrev,w=this._weightNext,k=(A-t)/(n-t),R=k*k,_=R*k,N=-p*_+2*p*R-p*k,L=(1+p)*_+(-1.5-2*p)*R+(-.5+p)*k+1,G=(-1-w)*_+(1.5+w)*R+.5*k,le=w*_-w*R;for(let ne=0;ne!==h;++ne)r[ne]=N*g[C+ne]+L*g[c+ne]+G*g[u+ne]+le*g[B+ne];return r}}class MB extends zo{constructor(e,t,A,n){super(e,t,A,n)}interpolate_(e,t,A,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=e*h,c=u-h,C=(A-t)/(n-t),B=1-C;for(let p=0;p!==h;++p)r[p]=g[c+p]*B+g[u+p]*C;return r}}class VS extends zo{constructor(e,t,A,n){super(e,t,A,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class Qr{constructor(e,t,A,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Vl(t,this.TimeBufferType),this.values=Vl(A,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let A;if(t.toJSON!==this.toJSON)A=t.toJSON(e);else{A={name:e.name,times:Vl(e.times,Array),values:Vl(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(A.interpolation=n)}return A.type=e.ValueTypeName,A}InterpolantFactoryMethodDiscrete(e){return new VS(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new MB(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new WS(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ue:t=this.InterpolantFactoryMethodDiscrete;break;case Oe:t=this.InterpolantFactoryMethodLinear;break;case Ke:t=this.InterpolantFactoryMethodSmooth}if(t===void 0){const A="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0){if(e===this.DefaultInterpolation)throw new Error(A);this.setInterpolation(this.DefaultInterpolation)}return this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ue;case this.InterpolantFactoryMethodLinear:return Oe;case this.InterpolantFactoryMethodSmooth:return Ke}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let A=0,n=t.length;A!==n;++A)t[A]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let A=0,n=t.length;A!==n;++A)t[A]*=e}return this}trim(e,t){const A=this.times,n=A.length;let r=0,g=n-1;for(;r!==n&&A[r]<e;)++r;for(;g!==-1&&A[g]>t;)--g;if(++g,r!==0||g!==n){r>=g&&(g=Math.max(g,1),r=g-1);const h=this.getValueSize();this.times=ds(A,r,g),this.values=ds(this.values,r*h,g*h)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(e=!1);const A=this.times,n=this.values,r=A.length;r===0&&(e=!1);let g=null;for(let h=0;h!==r;h++){const u=A[h];if(typeof u=="number"&&isNaN(u)){e=!1;break}if(g!==null&&g>u){e=!1;break}g=u}if(n!==void 0&&yB(n))for(let h=0,u=n.length;h!==u;++h){const c=n[h];if(isNaN(c)){e=!1;break}}return e}optimize(){const e=ds(this.times),t=ds(this.values),A=this.getValueSize(),n=this.getInterpolation()===Ke,r=e.length-1;let g=1;for(let h=1;h<r;++h){let u=!1;const c=e[h];if(c!==e[h+1]&&(h!==1||c!==e[0]))if(n)u=!0;else{const C=h*A,B=C-A,p=C+A;for(let w=0;w!==A;++w){const k=t[C+w];if(k!==t[B+w]||k!==t[p+w]){u=!0;break}}}if(u){if(h!==g){e[g]=e[h];const C=h*A,B=g*A;for(let p=0;p!==A;++p)t[B+p]=t[C+p]}++g}}if(r>0){e[g]=e[r];for(let h=r*A,u=g*A,c=0;c!==A;++c)t[u+c]=t[h+c];++g}return g!==e.length?(this.times=ds(e,0,g),this.values=ds(t,0,g*A)):(this.times=e,this.values=t),this}clone(){const e=ds(this.times,0),t=ds(this.values,0),A=new this.constructor(this.name,e,t);return A.createInterpolant=this.createInterpolant,A}}Qr.prototype.TimeBufferType=Float32Array,Qr.prototype.ValueBufferType=Float32Array,Qr.prototype.DefaultInterpolation=Oe;class Ua extends Qr{}Ua.prototype.ValueTypeName="bool",Ua.prototype.ValueBufferType=Array,Ua.prototype.DefaultInterpolation=Ue,Ua.prototype.InterpolantFactoryMethodLinear=void 0,Ua.prototype.InterpolantFactoryMethodSmooth=void 0;class SB extends Qr{}SB.prototype.ValueTypeName="color";class qo extends Qr{}qo.prototype.ValueTypeName="number";class ZS extends zo{constructor(e,t,A,n){super(e,t,A,n)}interpolate_(e,t,A,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=(A-t)/(n-t);let c=e*h;for(let C=c+h;c!==C;c+=4)Ui.slerpFlat(r,0,g,c-h,g,c,u);return r}}class Os extends Qr{InterpolantFactoryMethodLinear(e){return new ZS(this.times,this.values,this.getValueSize(),e)}}Os.prototype.ValueTypeName="quaternion",Os.prototype.DefaultInterpolation=Oe,Os.prototype.InterpolantFactoryMethodSmooth=void 0;class Ta extends Qr{}Ta.prototype.ValueTypeName="string",Ta.prototype.ValueBufferType=Array,Ta.prototype.DefaultInterpolation=Ue,Ta.prototype.InterpolantFactoryMethodLinear=void 0,Ta.prototype.InterpolantFactoryMethodSmooth=void 0;class Wo extends Qr{}Wo.prototype.ValueTypeName="vector";class jh{constructor(e,t=-1,A,n=2500){this.name=e,this.tracks=A,this.duration=t,this.blendMode=n,this.uuid=AA(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],A=e.tracks,n=1/(e.fps||1);for(let g=0,h=A.length;g!==h;++g)t.push(jS(A[g]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],A=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,g=A.length;r!==g;++r)t.push(Qr.toJSON(A[r]));return n}static CreateFromMorphTargetSequence(e,t,A,n){const r=t.length,g=[];for(let h=0;h<r;h++){let u=[],c=[];u.push((h+r-1)%r,h,(h+1)%r),c.push(0,1,0);const C=qS(u);u=vB(u,1,C),c=vB(c,1,C),n||u[0]!==0||(u.push(r),c.push(c[0])),g.push(new qo(".morphTargetInfluences["+t[h].name+"]",u,c).scale(1/A))}return new this(e,-1,g)}static findByName(e,t){let A=e;if(!Array.isArray(e)){const n=e;A=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<A.length;n++)if(A[n].name===t)return A[n];return null}static CreateClipsFromMorphTargetSequences(e,t,A){const n={},r=/^([\w-]*?)([\d]+)$/;for(let h=0,u=e.length;h<u;h++){const c=e[h],C=c.name.match(r);if(C&&C.length>1){const B=C[1];let p=n[B];p||(n[B]=p=[]),p.push(c)}}const g=[];for(const h in n)g.push(this.CreateFromMorphTargetSequence(h,n[h],t,A));return g}static parseAnimation(e,t){if(!e)return null;const A=function(C,B,p,w,k){if(p.length!==0){const R=[],_=[];DB(p,R,_,w),R.length!==0&&k.push(new C(B,R,_))}},n=[],r=e.name||"default",g=e.fps||30,h=e.blendMode;let u=e.length||-1;const c=e.hierarchy||[];for(let C=0;C<c.length;C++){const B=c[C].keys;if(B&&B.length!==0)if(B[0].morphTargets){const p={};let w;for(w=0;w<B.length;w++)if(B[w].morphTargets)for(let k=0;k<B[w].morphTargets.length;k++)p[B[w].morphTargets[k]]=-1;for(const k in p){const R=[],_=[];for(let N=0;N!==B[w].morphTargets.length;++N){const L=B[w];R.push(L.time),_.push(L.morphTarget===k?1:0)}n.push(new qo(".morphTargetInfluence["+k+"]",R,_))}u=p.length*g}else{const p=".bones["+t[C].name+"]";A(Wo,p+".position",B,"pos",n),A(Os,p+".quaternion",B,"rot",n),A(Wo,p+".scale",B,"scl",n)}}return n.length===0?null:new this(r,u,n,h)}resetDuration(){let e=0;for(let t=0,A=this.tracks.length;t!==A;++t){const n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function jS(o){if(o.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=(function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return qo;case"vector":case"vector2":case"vector3":case"vector4":return Wo;case"color":return SB;case"quaternion":return Os;case"bool":case"boolean":return Ua;case"string":return Ta}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)})(o.type);if(o.times===void 0){const t=[],A=[];DB(o.keys,t,A,"value"),o.times=t,o.values=A}return e.parse!==void 0?e.parse(o):new e(o.name,o.times,o.values,o.interpolation)}const Ha={enabled:!1,files:{},add:function(o,e){this.enabled!==!1&&(this.files[o]=e)},get:function(o){if(this.enabled!==!1)return this.files[o]},remove:function(o){delete this.files[o]},clear:function(){this.files={}}};class XS{constructor(e,t,A){const n=this;let r,g=!1,h=0,u=0;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=A,this.itemStart=function(C){u++,g===!1&&n.onStart!==void 0&&n.onStart(C,h,u),g=!0},this.itemEnd=function(C){h++,n.onProgress!==void 0&&n.onProgress(C,h,u),h===u&&(g=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(C){n.onError!==void 0&&n.onError(C)},this.resolveURL=function(C){return r?r(C):C},this.setURLModifier=function(C){return r=C,this},this.addHandler=function(C,B){return c.push(C,B),this},this.removeHandler=function(C){const B=c.indexOf(C);return B!==-1&&c.splice(B,2),this},this.getHandler=function(C){for(let B=0,p=c.length;B<p;B+=2){const w=c[B],k=c[B+1];if(w.global&&(w.lastIndex=0),w.test(C))return k}return null}}}const $S=new XS;class Ja{constructor(e){this.manager=e!==void 0?e:$S,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const A=this;return new Promise((function(n,r){A.load(e,n,t,r)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}const Or={};class ex extends Error{constructor(e,t){super(e),this.response=t}}class Xh extends Ja{constructor(e){super(e)}load(e,t,A,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Ha.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout((()=>{t&&t(r),this.manager.itemEnd(e)}),0),r;if(Or[e]!==void 0)return void Or[e].push({onLoad:t,onProgress:A,onError:n});Or[e]=[],Or[e].push({onLoad:t,onProgress:A,onError:n});const g=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),h=this.mimeType,u=this.responseType;fetch(g).then((c=>{if(c.status===200||c.status===0){if(c.status,typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const C=Or[e],B=c.body.getReader(),p=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),w=p?parseInt(p):0,k=w!==0;let R=0;const _=new ReadableStream({start(N){(function L(){B.read().then((({done:G,value:le})=>{if(G)N.close();else{R+=le.byteLength;const ne=new ProgressEvent("progress",{lengthComputable:k,loaded:R,total:w});for(let Ae=0,te=C.length;Ae<te;Ae++){const ye=C[Ae];ye.onProgress&&ye.onProgress(ne)}N.enqueue(le),L()}}))})()}});return new Response(_)}throw new ex(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)})).then((c=>{switch(u){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then((C=>new DOMParser().parseFromString(C,h)));case"json":return c.json();default:if(h===void 0)return c.text();{const C=/charset="?([^;"\s]*)"?/i.exec(h),B=C&&C[1]?C[1].toLowerCase():void 0,p=new TextDecoder(B);return c.arrayBuffer().then((w=>p.decode(w)))}}})).then((c=>{Ha.add(e,c);const C=Or[e];delete Or[e];for(let B=0,p=C.length;B<p;B++){const w=C[B];w.onLoad&&w.onLoad(c)}})).catch((c=>{const C=Or[e];if(C===void 0)throw this.manager.itemError(e),c;delete Or[e];for(let B=0,p=C.length;B<p;B++){const w=C[B];w.onError&&w.onError(c)}this.manager.itemError(e)})).finally((()=>{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class tx extends Ja{constructor(e){super(e)}load(e,t,A,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,g=Ha.get(e);if(g!==void 0)return r.manager.itemStart(e),setTimeout((function(){t&&t(g),r.manager.itemEnd(e)}),0),g;const h=wn("img");function u(){C(),Ha.add(e,this),t&&t(this),r.manager.itemEnd(e)}function c(B){C(),n&&n(B),r.manager.itemError(e),r.manager.itemEnd(e)}function C(){h.removeEventListener("load",u,!1),h.removeEventListener("error",c,!1)}return h.addEventListener("load",u,!1),h.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(h.crossOrigin=this.crossOrigin),r.manager.itemStart(e),h.src=e,h}}class Ax extends Ja{constructor(e){super(e)}load(e,t,A,n){const r=this,g=new Cs,h=new Xh(this.manager);return h.setResponseType("arraybuffer"),h.setRequestHeader(this.requestHeader),h.setPath(this.path),h.setWithCredentials(r.withCredentials),h.load(e,(function(u){const c=r.parse(u);c&&(c.image!==void 0?g.image=c.image:c.data!==void 0&&(g.image.width=c.width,g.image.height=c.height,g.image.data=c.data),g.wrapS=c.wrapS!==void 0?c.wrapS:ee,g.wrapT=c.wrapT!==void 0?c.wrapT:ee,g.magFilter=c.magFilter!==void 0?c.magFilter:Qe,g.minFilter=c.minFilter!==void 0?c.minFilter:Qe,g.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0?g.colorSpace=c.colorSpace:c.encoding!==void 0&&(g.encoding=c.encoding),c.flipY!==void 0&&(g.flipY=c.flipY),c.format!==void 0&&(g.format=c.format),c.type!==void 0&&(g.type=c.type),c.mipmaps!==void 0&&(g.mipmaps=c.mipmaps,g.minFilter=se),c.mipmapCount===1&&(g.minFilter=Qe),c.generateMipmaps!==void 0&&(g.generateMipmaps=c.generateMipmaps),g.needsUpdate=!0,t&&t(g,c))}),A,n),g}}class Ya extends Ja{constructor(e){super(e)}load(e,t,A,n){const r=new Di,g=new tx(this.manager);return g.setCrossOrigin(this.crossOrigin),g.setPath(this.path),g.load(e,(function(h){r.image=h,r.needsUpdate=!0,t!==void 0&&t(r)}),A,n),r}}class Zl extends gi{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new rA(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}const $h=new xA,xB=new re,bB=new re;class eI{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Gt(512,512),this.map=null,this.mapPass=null,this.matrix=new xA,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Th,this._frameExtents=new Gt(1,1),this._viewportCount=1,this._viewports=[new zA(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,A=this.matrix;xB.setFromMatrixPosition(e.matrixWorld),t.position.copy(xB),bB.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(bB),t.updateMatrixWorld(),$h.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix($h),A.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),A.multiply($h)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),this.mapSize.x===512&&this.mapSize.y===512||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class ix extends eI{constructor(){super(new Zi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,A=2*RA*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;A===t.fov&&n===t.aspect&&r===t.far||(t.fov=A,t.aspect=n,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class nx extends Zl{constructor(e,t,A=0,n=Math.PI/3,r=0,g=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gi.DEFAULT_UP),this.updateMatrix(),this.target=new gi,this.distance=A,this.angle=n,this.penumbra=r,this.decay=g,this.map=null,this.shadow=new ix}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const _B=new xA,Vo=new re,tI=new re;class rx extends eI{constructor(){super(new Zi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Gt(4,2),this._viewportCount=6,this._viewports=[new zA(2,1,1,1),new zA(0,1,1,1),new zA(3,1,1,1),new zA(1,1,1,1),new zA(3,0,1,1),new zA(1,0,1,1)],this._cubeDirections=[new re(1,0,0),new re(-1,0,0),new re(0,0,1),new re(0,0,-1),new re(0,1,0),new re(0,-1,0)],this._cubeUps=[new re(0,1,0),new re(0,1,0),new re(0,1,0),new re(0,1,0),new re(0,0,1),new re(0,0,-1)]}updateMatrices(e,t=0){const A=this.camera,n=this.matrix,r=e.distance||A.far;r!==A.far&&(A.far=r,A.updateProjectionMatrix()),Vo.setFromMatrixPosition(e.matrixWorld),A.position.copy(Vo),tI.copy(A.position),tI.add(this._cubeDirections[t]),A.up.copy(this._cubeUps[t]),A.lookAt(tI),A.updateMatrixWorld(),n.makeTranslation(-Vo.x,-Vo.y,-Vo.z),_B.multiplyMatrices(A.projectionMatrix,A.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_B)}}class sx extends Zl{constructor(e,t,A=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=A,this.decay=n,this.shadow=new rx}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class ax extends eI{constructor(){super(new _n(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class RB extends Zl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gi.DEFAULT_UP),this.updateMatrix(),this.target=new gi,this.shadow=new ax}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class ox extends Zl{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class AI{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let A=0,n=e.length;A<n;A++)t+=String.fromCharCode(e[A]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class gx extends Ja{constructor(e){super(e),this.isImageBitmapLoader=!0,this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,A,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,g=Ha.get(e);if(g!==void 0)return r.manager.itemStart(e),setTimeout((function(){t&&t(g),r.manager.itemEnd(e)}),0),g;const h={};h.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",h.headers=this.requestHeader,fetch(e,h).then((function(u){return u.blob()})).then((function(u){return createImageBitmap(u,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(u){Ha.add(e,u),t&&t(u),r.manager.itemEnd(e)})).catch((function(u){n&&n(u),r.manager.itemError(e),r.manager.itemEnd(e)})),r.manager.itemStart(e)}}class lx{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=NB(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=NB();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function NB(){return(typeof performance>"u"?Date:performance).now()}class cx{constructor(e,t,A){let n,r,g;switch(this.binding=e,this.valueSize=A,t){case"quaternion":n=this._slerp,r=this._slerpAdditive,g=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*A),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,g=this._setAdditiveIdentityOther,this.buffer=new Array(5*A);break;default:n=this._lerp,r=this._lerpAdditive,g=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*A)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=g,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const A=this.buffer,n=this.valueSize,r=e*n+n;let g=this.cumulativeWeight;if(g===0){for(let h=0;h!==n;++h)A[r+h]=A[h];g=t}else{g+=t;const h=t/g;this._mixBufferRegion(A,r,0,h,n)}this.cumulativeWeight=g}accumulateAdditive(e){const t=this.buffer,A=this.valueSize,n=A*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,A),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,A=this.buffer,n=e*t+t,r=this.cumulativeWeight,g=this.cumulativeWeightAdditive,h=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const u=t*this._origIndex;this._mixBufferRegion(A,n,u,1-r,t)}g>0&&this._mixBufferRegionAdditive(A,n,this._addIndex*t,1,t);for(let u=t,c=t+t;u!==c;++u)if(A[u]!==A[u+t]){h.setValue(A,n);break}}saveOriginalState(){const e=this.binding,t=this.buffer,A=this.valueSize,n=A*this._origIndex;e.getValue(t,n);for(let r=A,g=n;r!==g;++r)t[r]=t[n+r%A];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let A=e;A<t;A++)this.buffer[A]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let A=0;A<this.valueSize;A++)this.buffer[t+A]=this.buffer[e+A]}_select(e,t,A,n,r){if(n>=.5)for(let g=0;g!==r;++g)e[t+g]=e[A+g]}_slerp(e,t,A,n){Ui.slerpFlat(e,t,e,t,e,A,n)}_slerpAdditive(e,t,A,n,r){const g=this._workIndex*r;Ui.multiplyQuaternionsFlat(e,g,e,t,e,A),Ui.slerpFlat(e,t,e,t,e,g,n)}_lerp(e,t,A,n,r){const g=1-n;for(let h=0;h!==r;++h){const u=t+h;e[u]=e[u]*g+e[A+h]*n}}_lerpAdditive(e,t,A,n,r){for(let g=0;g!==r;++g){const h=t+g;e[h]=e[h]+e[A+g]*n}}}const iI="\\[\\]\\.:\\/",hx=new RegExp("["+iI+"]","g"),nI="[^"+iI+"]",Ix="[^"+iI.replace("\\.","")+"]",ux=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",nI)+/(WCOD+)?/.source.replace("WCOD",Ix)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",nI)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",nI)+"$"),Cx=["material","materials","bones","map"];class ZA{constructor(e,t,A){this.path=t,this.parsedPath=A||ZA.parseTrackName(t),this.node=ZA.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,A){return e&&e.isAnimationObjectGroup?new ZA.Composite(e,t,A):new ZA(e,t,A)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(hx,"")}static parseTrackName(e){const t=ux.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const A={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=A.nodeName&&A.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const r=A.nodeName.substring(n+1);Cx.indexOf(r)!==-1&&(A.nodeName=A.nodeName.substring(0,n),A.objectName=r)}if(A.propertyName===null||A.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return A}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const A=e.skeleton.getBoneByName(t);if(A!==void 0)return A}if(e.children){const A=function(r){for(let g=0;g<r.length;g++){const h=r[g];if(h.name===t||h.uuid===t)return h;const u=A(h.children);if(u)return u}return null},n=A(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const A=this.resolvedProperty;for(let n=0,r=A.length;n!==r;++n)e[t++]=A[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const A=this.resolvedProperty;for(let n=0,r=A.length;n!==r;++n)A[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const A=this.resolvedProperty;for(let n=0,r=A.length;n!==r;++n)A[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const A=this.resolvedProperty;for(let n=0,r=A.length;n!==r;++n)A[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,A=t.objectName,n=t.propertyName;let r=t.propertyIndex;if(e||(e=ZA.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void this.path;if(A){let c=t.objectIndex;switch(A){case"materials":if(!e.material||!e.material.materials)return;e=e.material.materials;break;case"bones":if(!e.skeleton)return;e=e.skeleton.bones;for(let C=0;C<e.length;C++)if(e[C].name===c){c=C;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material||!e.material.map)return;e=e.material.map;break;default:if(e[A]===void 0)return;e=e[A]}if(c!==void 0){if(e[c]===void 0)return;e=e[c]}}const g=e[n];if(g===void 0){t.nodeName;return}let h=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?h=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(h=this.Versioning.MatrixWorldNeedsUpdate);let u=this.BindingType.Direct;if(r!==void 0){if(n==="morphTargetInfluences"){if(!e.geometry||!e.geometry.morphAttributes)return;e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}u=this.BindingType.ArrayElement,this.resolvedProperty=g,this.propertyIndex=r}else g.fromArray!==void 0&&g.toArray!==void 0?(u=this.BindingType.HasFromToArray,this.resolvedProperty=g):Array.isArray(g)?(u=this.BindingType.EntireArray,this.resolvedProperty=g):this.propertyName=n;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][h]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ZA.Composite=class{constructor(o,e,t){const A=t||ZA.parseTrackName(e);this._targetGroup=o,this._bindings=o.subscribe_(e,A)}getValue(o,e){this.bind();const t=this._targetGroup.nCachedObjects_,A=this._bindings[t];A!==void 0&&A.getValue(o,e)}setValue(o,e){const t=this._bindings;for(let A=this._targetGroup.nCachedObjects_,n=t.length;A!==n;++A)t[A].setValue(o,e)}bind(){const o=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=o.length;e!==t;++e)o[e].bind()}unbind(){const o=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=o.length;e!==t;++e)o[e].unbind()}},ZA.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},ZA.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},ZA.prototype.GetterByBindingType=[ZA.prototype._getValue_direct,ZA.prototype._getValue_array,ZA.prototype._getValue_arrayElement,ZA.prototype._getValue_toArray],ZA.prototype.SetterByBindingTypeAndVersioning=[[ZA.prototype._setValue_direct,ZA.prototype._setValue_direct_setNeedsUpdate,ZA.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ZA.prototype._setValue_array,ZA.prototype._setValue_array_setNeedsUpdate,ZA.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ZA.prototype._setValue_arrayElement,ZA.prototype._setValue_arrayElement_setNeedsUpdate,ZA.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ZA.prototype._setValue_fromArray,ZA.prototype._setValue_fromArray_setNeedsUpdate,ZA.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class dx{constructor(e,t,A=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=A,this.blendMode=n;const r=t.tracks,g=r.length,h=new Array(g),u={endingStart:At,endingEnd:At};for(let c=0;c!==g;++c){const C=r[c].createInterpolant(null);h[c]=C,C.settings=u}this._interpolantSettings=u,this._interpolants=h,this._propertyBindings=new Array(g),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,A){if(e.fadeOut(t),this.fadeIn(t),A){const n=this._clip.duration,r=e._clip.duration,g=r/n,h=n/r;e.warp(1,g,t),this.warp(h,1,t)}return this}crossFadeTo(e,t,A){return e.crossFadeFrom(this,t,A)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,A){const n=this._mixer,r=n.time,g=this.timeScale;let h=this._timeScaleInterpolant;h===null&&(h=n._lendControlInterpolant(),this._timeScaleInterpolant=h);const u=h.parameterPositions,c=h.sampleValues;return u[0]=r,u[1]=r+A,c[0]=e/g,c[1]=t/g,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,A,n){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(r!==null){const u=(e-r)*A;u<0||A===0?t=0:(this._startTime=null,t=A*u)}t*=this._updateTimeScale(e);const g=this._updateTime(t),h=this._updateWeight(e);if(h>0){const u=this._interpolants,c=this._propertyBindings;if(this.blendMode===2501)for(let C=0,B=u.length;C!==B;++C)u[C].evaluate(g),c[C].accumulateAdditive(h);else for(let C=0,B=u.length;C!==B;++C)u[C].evaluate(g),c[C].accumulate(n,h)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const A=this._weightInterpolant;if(A!==null){const n=A.evaluate(e)[0];t*=n,e>A.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const A=this._timeScaleInterpolant;A!==null&&(t*=A.evaluate(e)[0],e>A.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,A=this.loop;let n=this.time+e,r=this._loopCount;const g=A===2202;if(e===0)return r===-1?n:g&&(1&r)==1?t-n:n;if(A===2200){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else{if(!(n<0)){this.time=n;break e}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,g)):this._setEndings(this.repetitions===0,!0,g)),n>=t||n<0){const h=Math.floor(n/t);n-=t*h,r+=Math.abs(h);const u=this.repetitions-r;if(u<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(u===1){const c=e<0;this._setEndings(c,!c,g)}else this._setEndings(!1,!1,g);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:h})}}else this.time=n;if(g&&(1&r)==1)return t-n}return n}_setEndings(e,t,A){const n=this._interpolantSettings;A?(n.endingStart=at,n.endingEnd=at):(n.endingStart=e?this.zeroSlopeAtStart?at:At:Dt,n.endingEnd=t?this.zeroSlopeAtEnd?at:At:Dt)}_scheduleFading(e,t,A){const n=this._mixer,r=n.time;let g=this._weightInterpolant;g===null&&(g=n._lendControlInterpolant(),this._weightInterpolant=g);const h=g.parameterPositions,u=g.sampleValues;return h[0]=r,u[0]=t,h[1]=r+e,u[1]=A,this}}const Ex=new Float32Array(1);class Bx extends ut{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const A=e._localRoot||this._root,n=e._clip.tracks,r=n.length,g=e._propertyBindings,h=e._interpolants,u=A.uuid,c=this._bindingsByRootAndName;let C=c[u];C===void 0&&(C={},c[u]=C);for(let B=0;B!==r;++B){const p=n[B],w=p.name;let k=C[w];if(k!==void 0)++k.referenceCount,g[B]=k;else{if(k=g[B],k!==void 0){k._cacheIndex===null&&(++k.referenceCount,this._addInactiveBinding(k,u,w));continue}const R=t&&t._propertyBindings[B].binding.parsedPath;k=new cx(ZA.create(A,w,R),p.ValueTypeName,p.getValueSize()),++k.referenceCount,this._addInactiveBinding(k,u,w),g[B]=k}h[B].resultBuffer=k.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const A=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,A)}const t=e._propertyBindings;for(let A=0,n=t.length;A!==n;++A){const r=t[A];r.useCount++==0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let A=0,n=t.length;A!==n;++A){const r=t[A];--r.useCount==0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,A){const n=this._actions,r=this._actionsByClip;let g=r[t];if(g===void 0)g={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=g;else{const h=g.knownActions;e._byClipCacheIndex=h.length,h.push(e)}e._cacheIndex=n.length,n.push(e),g.actionByRoot[A]=e}_removeInactiveAction(e){const t=this._actions,A=t[t.length-1],n=e._cacheIndex;A._cacheIndex=n,t[n]=A,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,g=this._actionsByClip,h=g[r],u=h.knownActions,c=u[u.length-1],C=e._byClipCacheIndex;c._byClipCacheIndex=C,u[C]=c,u.pop(),e._byClipCacheIndex=null,delete h.actionByRoot[(e._localRoot||this._root).uuid],u.length===0&&delete g[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let A=0,n=t.length;A!==n;++A){const r=t[A];--r.referenceCount==0&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,A=e._cacheIndex,n=this._nActiveActions++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=A,t[A]=r}_takeBackAction(e){const t=this._actions,A=e._cacheIndex,n=--this._nActiveActions,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=A,t[A]=r}_addInactiveBinding(e,t,A){const n=this._bindingsByRootAndName,r=this._bindings;let g=n[t];g===void 0&&(g={},n[t]=g),g[A]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,A=e.binding,n=A.rootNode.uuid,r=A.path,g=this._bindingsByRootAndName,h=g[n],u=t[t.length-1],c=e._cacheIndex;u._cacheIndex=c,t[c]=u,t.pop(),delete h[r],Object.keys(h).length===0&&delete g[n]}_lendBinding(e){const t=this._bindings,A=e._cacheIndex,n=this._nActiveBindings++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=A,t[A]=r}_takeBackBinding(e){const t=this._bindings,A=e._cacheIndex,n=--this._nActiveBindings,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=A,t[A]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let A=e[t];return A===void 0&&(A=new MB(new Float32Array(2),new Float32Array(2),1,Ex),A.__cacheIndex=t,e[t]=A),A}_takeBackControlInterpolant(e){const t=this._controlInterpolants,A=e.__cacheIndex,n=--this._nActiveControlInterpolants,r=t[n];e.__cacheIndex=n,t[n]=e,r.__cacheIndex=A,t[A]=r}clipAction(e,t,A){const n=t||this._root,r=n.uuid;let g=typeof e=="string"?jh.findByName(n,e):e;const h=g!==null?g.uuid:e,u=this._actionsByClip[h];let c=null;if(A===void 0&&(A=g!==null?g.blendMode:yt),u!==void 0){const B=u.actionByRoot[r];if(B!==void 0&&B.blendMode===A)return B;c=u.knownActions[0],g===null&&(g=c._clip)}if(g===null)return null;const C=new dx(this,g,t,A);return this._bindAction(C,c),this._addInactiveAction(C,h,r),C}existingAction(e,t){const A=t||this._root,n=A.uuid,r=typeof e=="string"?jh.findByName(A,e):e,g=r?r.uuid:e,h=this._actionsByClip[g];return h!==void 0&&h.actionByRoot[n]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,A=this._nActiveActions,n=this.time+=e,r=Math.sign(e),g=this._accuIndex^=1;for(let c=0;c!==A;++c)t[c]._update(n,e,r,g);const h=this._bindings,u=this._nActiveBindings;for(let c=0;c!==u;++c)h[c].apply(g);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,A=e.uuid,n=this._actionsByClip,r=n[A];if(r!==void 0){const g=r.knownActions;for(let h=0,u=g.length;h!==u;++h){const c=g[h];this._deactivateAction(c);const C=c._cacheIndex,B=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,B._cacheIndex=C,t[C]=B,t.pop(),this._removeInactiveBindingsForAction(c)}delete n[A]}}uncacheRoot(e){const t=e.uuid,A=this._actionsByClip;for(const r in A){const g=A[r].actionByRoot[t];g!==void 0&&(this._deactivateAction(g),this._removeInactiveAction(g))}const n=this._bindingsByRootAndName[t];if(n!==void 0)for(const r in n){const g=n[r];g.restoreOriginalState(),this._removeInactiveBinding(g)}}uncacheAction(e,t){const A=this.existingAction(e,t);A!==null&&(this._deactivateAction(A),this._removeInactiveAction(A))}}class Zo{constructor(e,t,A=0,n=1/0){this.ray=new Lo(e,t),this.near=A,this.far=n,this.camera=null,this.layers=new bh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.type}intersectObject(e,t=!0,A=[]){return rI(e,this,A,t),A.sort(kB),A}intersectObjects(e,t=!0,A=[]){for(let n=0,r=e.length;n<r;n++)rI(e[n],this,A,t);return A.sort(kB),A}}function kB(o,e){return o.distance-e.distance}function rI(o,e,t,A){if(o.layers.test(e.layers)&&o.raycast(e,t),A===!0){const n=o.children;for(let r=0,g=n.length;r<g;r++)rI(n[r],e,t,!0)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:E}})),typeof window<"u"&&(window.__THREE__||(window.__THREE__=E));class ae{static getFloorTransitionMarkerSize(){return ae.isMobile?ae.MARKER_SIZE*ae.FLOOR_TRANSITION_MARKER_MOBILE_SCALE:ae.MARKER_SIZE}static isNavigationMarkerPlacementMode(){return ae.NAVIGATION_MARKERS_ADD_MODE||ae.NAVIGATION_MARKERS_ADD_STAIR_UP_MODE||ae.NAVIGATION_MARKERS_ADD_STAIR_DOWN_MODE}static getAspectRatio(){return K.width/K.height}static setSettingValue(e,t){e==="whitePoint"?this.whitePoint.set(t[0],t[1],t[2]):this[e]=t}static getKelvinRGB(e){const A=Math.floor((e-1e3)/1e3),n=A+1;if(A<0)return this.rgbValues[0].clone();if(n>=this.rgbValues.length)return this.rgbValues[this.rgbValues.length-1].clone();const r=(e-(A*1e3+1e3))/1e3;return this.rgbValues[A].clone().lerp(this.rgbValues[n],r)}showPopup(e){const t=document.createElement("div");t.style.position="absolute",t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",t.style.padding="10px",t.style.background="white",t.style.border="1px solid black",t.style.zIndex="1000",t.innerText=e,document.body.appendChild(t),setTimeout((()=>{document.body.removeChild(t)}),3e3)}enableGodMode(){window.addEventListener("keydown",(e=>{const t=new Date().getTime();if(e.key==="Enter")this.lastKeyPressTime=t;else if(this.lastKeyPressTime&&t-this.lastKeyPressTime<2e3){if(e.key==="p"||e.key==="P"){ae.EXPERIMENTAL_WEBASSEMBLY_QHDR_LOADER=!ae.EXPERIMENTAL_WEBASSEMBLY_QHDR_LOADER;const A=ae.EXPERIMENTAL_WEBASSEMBLY_QHDR_LOADER?"ON":"OFF";this.showPopup(`Experimental turboloader: ${A}`)}this.lastKeyPressTime=null}}))}constructor(e){this.enableUpscale=!1,this.lastKeyPressTime=null,ae.isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),ae.isWebGL2=e.capabilities.isWebGL2===!0,ae.hasFloat32Textures=e.extensions.get("OES_texture_float")!==null,ae.VERSION,ae.isWebGL2,ae.hasFloat32Textures,ae.FORCE_16BIT&&(ae.hasFloat32Textures=!1),ae.isMobile,e.getContext(),this.enableGodMode()}}ae.VERSION="QiPlayer v3.5",ae.SHOW_DEBUG=!1,ae.REDIRECT_CONSOLE=!1,ae.SHOW_TESTS=!1,ae.SHOW_DEMO=!1,ae.FORCE_EXR=!1,ae.FORCE_16BIT=!1,ae.EXPERIMENTAL_WEBASSEMBLY_QHDR_LOADER=!0,ae.PROFILE_MEMORY=!1,ae.USE_LOADING_MARKER=!1,ae.SHOW_MARKERS=!1,ae.LOAD_MARKERS_FROM="jsonFile",ae.MARKERS_JSON=void 0,ae.MARKER_SIZE=.05,ae.MARKER_HITBOX_SCALE=2,ae.FLOOR_TRANSITION_MARKER_MOBILE_SCALE=5,ae.TONEMAPPER_NONE="NoTonemap",ae.TONEMAPPER_AGX="AgXTonemap",ae.TONEMAPPER_REINHARD="reinhardTonemap",ae.TONEMAPPER_FUSION="fusionTonemap",ae.ACTIVE_TONEMAPPER=ae.TONEMAPPER_AGX,ae.DEFAULT_FOV=90,ae.MIN_FOV=40,ae.MAX_FOV=100,ae.HISTOGRAM_WIDTH=256,ae.HISTOGRAM_HEIGHT=144,ae.MAX_PITCH_ANGLE=60*yi.DEG2RAD,ae.SMOOTHING_FACTOR=.9999,ae.TRANSITION_MOVEMENT_SCALE=1.3,ae.AUTOROTATE=!1,ae.AUTOROTATE_SPEED=1,ae.UNREAL_BLOOM_ENABLED=!0,ae.UNREAL_BLOOOM_STRENGTH=.3,ae.UNREAL_BLOOOM_RADIUS=.5,ae.UNREAL_BLOOOM_THRESHOLD=.99,ae.whitePoint=new re(1,1,1),ae.temperature=6500,ae.lutTexture=void 0,ae.targetLuminance=1,ae.exposureFovScale=.6,ae.dragScale=new Gt(1,1),ae.sharpenFilter_amount=.6,ae.SHOW_ARROW_AND_MARKERS=!0,ae.SHOW_NAVIGATION_MARKERS_ID=!1,ae.NAVIGATION_MARKERS_EDIT_MODE=!1,ae.NAVIGATION_MARKERS_WHITELIST_MODE=!1,ae.NAVIGATION_MARKERS_ADD_MODE=!1,ae.NAVIGATION_MARKERS_ADD_STAIR_UP_MODE=!1,ae.NAVIGATION_MARKERS_ADD_STAIR_DOWN_MODE=!1,ae.NAVIGATION_MARKERS_PLAN_VIEW=!1,ae.NAVIGATION_MARKERS_PLAN_VIEW_PREVIEW_PREVIOUS_SCANS=!1,ae.NAV_MIN_NATURAL_VISIBLE=5,ae.NAV_FALLBACK_COUNT=4,ae.NAV_FALLBACK_DEBUG=!1,ae.NAV_HELPER_MARKER_RGB=[.15,1,.4],ae.rgbValues=[new re(1,.26,0),new re(1,.53,.05),new re(1,.69,.43),new re(1,.8,.65),new re(1,.89,.8),new re(1,.96,.93),new re(.95,.95,1),new re(.87,.9,1),new re(.82,.87,1),new re(.79,.85,1),new re(.76,.84,1),new re(.75,.83,1)];class jl{static linear(e){return e}static easeIn(e){return e*e}static easeOut(e){return e*(2-e)}static easeInOut(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}static bounce(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375}static moveTowards(e,t,A){const n=t-e;return e+(Math.abs(n)<=A?n:Math.sign(n)*A)}static lerpAngleRadians(e,t,A){const n=Math.PI;return e+((t-e+n+2*n)%(2*n)-n)*A}static lerpEuler(e,t,A){const n=new Mn;return n.x=this.lerpAngleRadians(e.x,t.x,A),n.y=this.lerpAngleRadians(e.y,t.y,A),n.z=this.lerpAngleRadians(e.z,t.z,A),n.order=e.order,n}}class Qx{constructor(){this.name="User",this.camera=new Zi,this.camera.rotation.order="YXZ",this.camera.fov=ae.DEFAULT_FOV,this.cameraSmooth=new Zi,this.cameraSmooth.rotation.order=this.camera.rotation.order,this.cameraSmooth.fov=this.camera.fov,this.cameraSmooth.aspect=this.camera.aspect,this.cameraSmooth.far=this.camera.far,this.camera.updateProjectionMatrix(),this.cameraSmooth.updateProjectionMatrix()}setCamera(e){K.userData.siteCamera=e,this.camera.position.copy(e.position),this.camera.rotation.copy(e.rotation),this.cameraSmooth.position.copy(e.position),this.cameraSmooth.rotation.copy(e.rotation)}update(){const e=1-Math.pow(1-ae.SMOOTHING_FACTOR,K.deltaTime);this.cameraSmooth.fov+=(this.camera.fov-this.cameraSmooth.fov)*e;const t=jl.lerpAngleRadians(this.cameraSmooth.rotation.x,this.camera.rotation.x,e),A=jl.lerpAngleRadians(this.cameraSmooth.rotation.y,this.camera.rotation.y,e);this.cameraSmooth.rotation.set(t,A,0),this.cameraSmooth.position.copy(this.camera.position),this.camera.aspect=ae.getAspectRatio(),this.cameraSmooth.aspect=ae.getAspectRatio(),this.cameraSmooth.updateProjectionMatrix()}}class Ve{static init(){this.addEventListeners()}static addEventListeners(){document.addEventListener("keydown",(e=>this.handleKeyDown(e))),document.addEventListener("keyup",(e=>this.handleKeyUp(e))),K.canvas.addEventListener("mousedown",(e=>this.handleMouseDown(e))),document.addEventListener("mouseup",(e=>this.handleMouseUp(e))),K.canvas.addEventListener("mousemove",(e=>this.handleMouseMove(e))),K.canvas.addEventListener("touchstart",(e=>this.handleTouchStart(e))),K.canvas.addEventListener("touchend",(e=>this.handleTouchEnd(e))),K.canvas.addEventListener("touchmove",(e=>this.handleTouchMove(e))),K.canvas.addEventListener("wheel",(e=>this.handleMouseWheel(e)))}static handleKeyDown(e){K.parent.matches(":hover")&&(e.preventDefault(),Ve.keysState.set(e.code,!0),Ve.keysDown.set(e.code,!0))}static handleKeyUp(e){K.parent.matches(":hover")&&(e.preventDefault(),Ve.keysState.set(e.code,!1),Ve.keysUp.set(e.code,!0))}static handleInputDown(e,t,A){Ve.mouseButtonsState.set(e,!0),Ve.mouseButtonsDown.set(e,!0),Ve.mouseDownPosition.set(t,A),Ve.mouseDownTime=performance.now()}static handleMouseDown(e){Ve.handleInputDown(e.button,e.clientX,e.clientY)}static handleTouchStart(e){if(e.touches.length===1&&(this.handleInputDown(0,e.touches[0].clientX,e.touches[0].clientY),Ve.lastTouchPosition.set(e.touches[0].clientX,e.touches[0].clientY)),e.touches.length===2){const t=e.touches[0].clientX-e.touches[1].clientX,A=e.touches[0].clientY-e.touches[1].clientY,n=Math.hypot(t,A);Ve.touchZoomDistanceEnd=Ve.touchZoomDistanceStart=n}}static handleInputUp(e,t,A){Ve.mouseButtonsState.set(e,!1),Ve.mouseButtonsUp.set(e,!0),Ve.mouseUpPosition.set(t,A),Ve.mouseUpTime=performance.now()}static handleMouseUp(e){Ve.handleInputUp(e.button,e.clientX,e.clientY)}static handleTouchEnd(e){const t=e.changedTouches[0];Ve.handleInputUp(0,t.clientX,t.clientY),Ve.touchZoomDistanceStart=0,Ve.touchZoomDistanceEnd=0}static handleInputMove(e,t,A,n){Ve.mousePosition.set(e,t),Ve.mouseDragDelta.x+=A*ae.dragScale.x,Ve.mouseDragDelta.y+=n*ae.dragScale.y}static handleMouseMove(e){Ve.handleInputMove(e.clientX,e.clientY,e.movementX,e.movementY)}static handleTouchMove(e){if(e.touches.length===1){const A=e.touches[0],n=A.clientX-Ve.lastTouchPosition.x,r=A.clientY-Ve.lastTouchPosition.y;Ve.handleInputMove(A.clientX,A.clientY,n,r),Ve.lastTouchPosition.set(A.clientX,A.clientY)}if(e.touches.length===2){const A=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY,r=Math.hypot(A,n);Ve.touchZoomDistanceEnd=r;var t=Ve.touchZoomDistanceEnd-Ve.touchZoomDistanceStart;Ve.touchZoomDistanceStart=Ve.touchZoomDistanceEnd,Ve.mouseScrollDelta.set(0,-2*t)}}static handleMouseWheel(e){Ve.mouseScrollDelta.set(e.deltaX,e.deltaY)}static GetKey(e){return Ve.keysState.get(e)||!1}static GetKeyDown(e){return!!Ve.keysUp.get(e)}static GetKeyUp(e){return!!Ve.keysUp.get(e)}static GetMouseButton(e){return Ve.mouseButtonsState.get(e)||!1}static GetMouseButtonDown(e){return!!Ve.mouseButtonsState.get(e)}static GetMouseButtonUp(e){return!!Ve.mouseButtonsUp.get(e)}static get MousePositionLocal(){const e=K.canvas.getBoundingClientRect();return new Gt(Ve.mousePosition.x-e.left,Ve.mousePosition.y-e.top)}static get MousePositionGlobal(){return Ve.mousePosition}static get MousePositionNormalized(){const e=K.canvas.getBoundingClientRect(),t=new Gt(Ve.mousePosition.x-e.left,Ve.mousePosition.y-e.top);return new Gt(t.x/e.width*2-1,-t.y/e.height*2+1)}static get MouseScrollDelta(){return Ve.mouseScrollDelta}static get MouseDragDelta(){return Ve.mouseDragDelta}static get MousePick(){return!(!Ve.GetMouseButtonUp(0)||Ve.mousePickConsumed||!Ve.isTapClick())&&(Ve.mousePickConsumed=!0,!0)}static isTapClick(){if(!Ve.GetMouseButtonUp(0))return!1;const e=Ve.mouseDownPosition.distanceTo(Ve.mouseUpPosition),t=Ve.mouseUpTime-Ve.mouseDownTime;return e<=Ve.maxTapMove&&t<=Ve.maxTapTime}static consumeMousePick(){Ve.mousePickConsumed=!0}static isMousePickPending(){return Ve.GetMouseButtonUp(0)&&!Ve.mousePickConsumed}static wasMouseButtonPressed(e){return Ve.mouseButtonsDown.get(e)||!1}static clientToNormalized(e,t){const A=K.canvas.getBoundingClientRect(),n=e-A.left,r=t-A.top;return new Gt(n/A.width*2-1,-r/A.height*2+1)}static getMouseDownPositionNormalized(){return Ve.clientToNormalized(Ve.mouseDownPosition.x,Ve.mouseDownPosition.y)}static EndFrame(){Ve.mouseButtonsUp.set(0,!1),Ve.mouseButtonsUp.set(1,!1),Ve.mouseButtonsDown.set(0,!1),Ve.mouseButtonsDown.set(1,!1),Ve.keysUp.clear(),Ve.keysDown.clear(),Ve.mouseDragDelta.set(0,0),Ve.mouseScrollDelta.set(0,0)}static updateState(){}static applyState(){const e=1*K.deltaTime,t=K.userData.camera.rotation.y;if(new re(Math.sin(t),0,Math.cos(t)),K.userData.camera.fov,this.keysState.get("KeyQ")&&K.userData.camera.position.addScaledVector(new re(0,1,0),-e),this.keysState.get("KeyE")&&K.userData.camera.position.addScaledVector(new re(0,1,0),e),Ve.GetMouseButton(0)&&!Ve.consumeDrag&&!ae.NAVIGATION_MARKERS_WHITELIST_MODE&&!ae.NAVIGATION_MARKERS_EDIT_MODE){let A=K.userData.camera.fov/300;K.userData.camera.rotation.x+=Ve.mouseDragDelta.y*A*yi.DEG2RAD,K.userData.camera.rotation.x<-ae.MAX_PITCH_ANGLE&&(K.userData.camera.rotation.x=-ae.MAX_PITCH_ANGLE),K.userData.camera.rotation.x>ae.MAX_PITCH_ANGLE&&(K.userData.camera.rotation.x=ae.MAX_PITCH_ANGLE),K.userData.camera.rotation.y+=Ve.mouseDragDelta.x*A*.8*yi.DEG2RAD}Ve.mouseScrollDelta.y!=0&&(K.userData.camera.fov=yi.clamp(K.userData.camera.fov+.1*Ve.mouseScrollDelta.y,ae.MIN_FOV,ae.MAX_FOV),K.userData.camera.updateProjectionMatrix())}static update(){Ve.GetMouseButton(0)||(Ve.mousePickConsumed=!1),this.updateState(),this.applyState()}}function FB(o,e){if(e===0)return o;if(e===2||e===1){let t=o.getIndex();if(t===null){const g=[],h=o.getAttribute("position");if(h===void 0)return o;for(let u=0;u<h.count;u++)g.push(u);o.setIndex(g),t=o.getIndex()}const A=t.count-2,n=[];if(e===2)for(let g=1;g<=A;g++)n.push(t.getX(0)),n.push(t.getX(g)),n.push(t.getX(g+1));else for(let g=0;g<A;g++)g%2==0?(n.push(t.getX(g)),n.push(t.getX(g+1)),n.push(t.getX(g+2))):(n.push(t.getX(g+2)),n.push(t.getX(g+1)),n.push(t.getX(g)));n.length;const r=o.clone();return r.setIndex(n),r.clearGroups(),r}return o}Ve.keysState=new Map,Ve.keysUp=new Map,Ve.keysDown=new Map,Ve.mouseButtonsState=new Map,Ve.mouseButtonsUp=new Map,Ve.mouseButtonsDown=new Map,Ve.mousePosition=new Gt,Ve.mouseScrollDelta=new Gt,Ve.mouseDragDelta=new Gt,Ve.mouseDownPosition=new Gt,Ve.mouseUpPosition=new Gt,Ve.mouseDownTime=0,Ve.mouseUpTime=0,Ve.maxTapTime=200,Ve.maxTapMove=5,Ve.lastTouchPosition=new Gt,Ve.consumeDrag=!1,Ve.mousePickConsumed=!1;class sI extends Ja{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(t){return new yx(t)})),this.register((function(t){return new _x(t)})),this.register((function(t){return new Rx(t)})),this.register((function(t){return new Nx(t)})),this.register((function(t){return new Dx(t)})),this.register((function(t){return new Mx(t)})),this.register((function(t){return new Sx(t)})),this.register((function(t){return new xx(t)})),this.register((function(t){return new wx(t)})),this.register((function(t){return new bx(t)})),this.register((function(t){return new vx(t)})),this.register((function(t){return new px(t)})),this.register((function(t){return new kx(t)})),this.register((function(t){return new Fx(t)}))}load(e,t,A,n){const r=this;let g;g=this.resourcePath!==""?this.resourcePath:this.path!==""?this.path:AI.extractUrlBase(e),this.manager.itemStart(e);const h=function(c){n&&n(c),r.manager.itemError(e),r.manager.itemEnd(e)},u=new Xh(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(this.withCredentials),u.load(e,(function(c){try{r.parse(c,g,(function(C){t(C),r.manager.itemEnd(e)}),h)}catch(C){h(C)}}),A,h)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,A,n){let r;const g={},h={},u=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(u.decode(new Uint8Array(e,0,4))===LB){try{g[HA.KHR_BINARY_GLTF]=new Ux(e)}catch(C){return void(n&&n(C))}r=JSON.parse(g[HA.KHR_BINARY_GLTF].content)}else r=JSON.parse(u.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const c=new jx(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let C=0;C<this.pluginCallbacks.length;C++){const B=this.pluginCallbacks[C](c);h[B.name]=B,g[B.name]=!0}if(r.extensionsUsed)for(let C=0;C<r.extensionsUsed.length;++C){const B=r.extensionsUsed[C],p=r.extensionsRequired||[];switch(B){case HA.KHR_MATERIALS_UNLIT:g[B]=new mx;break;case HA.KHR_DRACO_MESH_COMPRESSION:g[B]=new Tx(r,this.dracoLoader);break;case HA.KHR_TEXTURE_TRANSFORM:g[B]=new Hx;break;case HA.KHR_MESH_QUANTIZATION:g[B]=new Jx;break;default:p.indexOf(B)>=0&&h[B]}}c.setExtensions(g),c.setPlugins(h),c.parse(A,n)}parseAsync(e,t){const A=this;return new Promise((function(n,r){A.parse(e,t,n,r)}))}}function fx(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const HA={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class px{constructor(e){this.parser=e,this.name=HA.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let A=0,n=t.length;A<n;A++){const r=t[A];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,A="light:"+e;let n=t.cache.get(A);if(n)return n;const r=t.json,g=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let h;const u=new rA(16777215);g.color!==void 0&&u.fromArray(g.color);const c=g.range!==void 0?g.range:0;switch(g.type){case"directional":h=new RB(u),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new sx(u),h.distance=c;break;case"spot":h=new nx(u),h.distance=c,g.spot=g.spot||{},g.spot.innerConeAngle=g.spot.innerConeAngle!==void 0?g.spot.innerConeAngle:0,g.spot.outerConeAngle=g.spot.outerConeAngle!==void 0?g.spot.outerConeAngle:Math.PI/4,h.angle=g.spot.outerConeAngle,h.penumbra=1-g.spot.innerConeAngle/g.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+g.type)}return h.position.set(0,0,0),h.decay=2,Es(h,g),g.intensity!==void 0&&(h.intensity=g.intensity),h.name=t.createUniqueName(g.name||"light_"+e),n=Promise.resolve(h),t.cache.add(A,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,A=this.parser,n=A.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then((function(g){return A._getNodeRef(t.cache,r,g)}))}}class mx{constructor(){this.name=HA.KHR_MATERIALS_UNLIT}getMaterialType(){return Ji}extendParams(e,t,A){const n=[];e.color=new rA(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const g=r.baseColorFactor;e.color.fromArray(g),e.opacity=g[3]}r.baseColorTexture!==void 0&&n.push(A.assignTexture(e,"map",r.baseColorTexture,ie))}return Promise.all(n)}}class wx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const A=this.parser.json.materials[e];if(!A.extensions||!A.extensions[this.name])return Promise.resolve();const n=A.extensions[this.name].emissiveStrength;return n!==void 0&&(t.emissiveIntensity=n),Promise.resolve()}}class yx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Ps:null}extendMaterialParams(e,t){const A=this.parser,n=A.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],g=n.extensions[this.name];if(g.clearcoatFactor!==void 0&&(t.clearcoat=g.clearcoatFactor),g.clearcoatTexture!==void 0&&r.push(A.assignTexture(t,"clearcoatMap",g.clearcoatTexture)),g.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=g.clearcoatRoughnessFactor),g.clearcoatRoughnessTexture!==void 0&&r.push(A.assignTexture(t,"clearcoatRoughnessMap",g.clearcoatRoughnessTexture)),g.clearcoatNormalTexture!==void 0&&(r.push(A.assignTexture(t,"clearcoatNormalMap",g.clearcoatNormalTexture)),g.clearcoatNormalTexture.scale!==void 0)){const h=g.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Gt(h,h)}return Promise.all(r)}}class vx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Ps:null}extendMaterialParams(e,t){const A=this.parser,n=A.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],g=n.extensions[this.name];return g.iridescenceFactor!==void 0&&(t.iridescence=g.iridescenceFactor),g.iridescenceTexture!==void 0&&r.push(A.assignTexture(t,"iridescenceMap",g.iridescenceTexture)),g.iridescenceIor!==void 0&&(t.iridescenceIOR=g.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),g.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=g.iridescenceThicknessMinimum),g.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=g.iridescenceThicknessMaximum),g.iridescenceThicknessTexture!==void 0&&r.push(A.assignTexture(t,"iridescenceThicknessMap",g.iridescenceThicknessTexture)),Promise.all(r)}}class Dx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Ps:null}extendMaterialParams(e,t){const A=this.parser,n=A.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new rA(0,0,0),t.sheenRoughness=0,t.sheen=1;const g=n.extensions[this.name];return g.sheenColorFactor!==void 0&&t.sheenColor.fromArray(g.sheenColorFactor),g.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=g.sheenRoughnessFactor),g.sheenColorTexture!==void 0&&r.push(A.assignTexture(t,"sheenColorMap",g.sheenColorTexture,ie)),g.sheenRoughnessTexture!==void 0&&r.push(A.assignTexture(t,"sheenRoughnessMap",g.sheenRoughnessTexture)),Promise.all(r)}}class Mx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Ps:null}extendMaterialParams(e,t){const A=this.parser,n=A.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],g=n.extensions[this.name];return g.transmissionFactor!==void 0&&(t.transmission=g.transmissionFactor),g.transmissionTexture!==void 0&&r.push(A.assignTexture(t,"transmissionMap",g.transmissionTexture)),Promise.all(r)}}class Sx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Ps:null}extendMaterialParams(e,t){const A=this.parser,n=A.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],g=n.extensions[this.name];t.thickness=g.thicknessFactor!==void 0?g.thicknessFactor:0,g.thicknessTexture!==void 0&&r.push(A.assignTexture(t,"thicknessMap",g.thicknessTexture)),t.attenuationDistance=g.attenuationDistance||1/0;const h=g.attenuationColor||[1,1,1];return t.attenuationColor=new rA(h[0],h[1],h[2]),Promise.all(r)}}class xx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Ps:null}extendMaterialParams(e,t){const A=this.parser.json.materials[e];if(!A.extensions||!A.extensions[this.name])return Promise.resolve();const n=A.extensions[this.name];return t.ior=n.ior!==void 0?n.ior:1.5,Promise.resolve()}}class bx{constructor(e){this.parser=e,this.name=HA.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Ps:null}extendMaterialParams(e,t){const A=this.parser,n=A.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],g=n.extensions[this.name];t.specularIntensity=g.specularFactor!==void 0?g.specularFactor:1,g.specularTexture!==void 0&&r.push(A.assignTexture(t,"specularIntensityMap",g.specularTexture));const h=g.specularColorFactor||[1,1,1];return t.specularColor=new rA(h[0],h[1],h[2]),g.specularColorTexture!==void 0&&r.push(A.assignTexture(t,"specularColorMap",g.specularColorTexture,ie)),Promise.all(r)}}class _x{constructor(e){this.parser=e,this.name=HA.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,A=t.json,n=A.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],g=t.options.ktx2Loader;if(!g){if(A.extensionsRequired&&A.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,g)}}class Rx{constructor(e){this.parser=e,this.name=HA.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,A=this.parser,n=A.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const g=r.extensions[t],h=n.images[g.source];let u=A.textureLoader;if(h.uri){const c=A.options.manager.getHandler(h.uri);c!==null&&(u=c)}return this.detectSupport().then((function(c){if(c)return A.loadTextureImage(e,g.source,u);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return A.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}}))),this.isSupported}}class Nx{constructor(e){this.parser=e,this.name=HA.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,A=this.parser,n=A.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const g=r.extensions[t],h=n.images[g.source];let u=A.textureLoader;if(h.uri){const c=A.options.manager.getHandler(h.uri);c!==null&&(u=c)}return this.detectSupport().then((function(c){if(c)return A.loadTextureImage(e,g.source,u);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return A.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}}))),this.isSupported}}class kx{constructor(e){this.name=HA.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,A=t.bufferViews[e];if(A.extensions&&A.extensions[this.name]){const n=A.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),g=this.parser.options.meshoptDecoder;if(!g||!g.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then((function(h){const u=n.byteOffset||0,c=n.byteLength||0,C=n.count,B=n.byteStride,p=new Uint8Array(h,u,c);return g.decodeGltfBufferAsync?g.decodeGltfBufferAsync(C,B,p,n.mode,n.filter).then((function(w){return w.buffer})):g.ready.then((function(){const w=new ArrayBuffer(C*B);return g.decodeGltfBuffer(new Uint8Array(w),C,B,p,n.mode,n.filter),w}))}))}return null}}class Fx{constructor(e){this.name=HA.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,A=t.nodes[e];if(!A.extensions||!A.extensions[this.name]||A.mesh===void 0)return null;const n=t.meshes[A.mesh];for(const u of n.primitives)if(u.mode!==Yn.TRIANGLES&&u.mode!==Yn.TRIANGLE_STRIP&&u.mode!==Yn.TRIANGLE_FAN&&u.mode!==void 0)return null;const r=A.extensions[this.name].attributes,g=[],h={};for(const u in r)g.push(this.parser.getDependency("accessor",r[u]).then((c=>(h[u]=c,h[u]))));return g.length<1?null:(g.push(this.parser.createNodeMesh(e)),Promise.all(g).then((u=>{const c=u.pop(),C=c.isGroup?c.children:[c],B=u[0].count,p=[];for(const w of C){const k=new xA,R=new re,_=new Ui,N=new re(1,1,1),L=new PS(w.geometry,w.material,B);for(let G=0;G<B;G++)h.TRANSLATION&&R.fromBufferAttribute(h.TRANSLATION,G),h.ROTATION&&_.fromBufferAttribute(h.ROTATION,G),h.SCALE&&N.fromBufferAttribute(h.SCALE,G),L.setMatrixAt(G,k.compose(R,_,N));for(const G in h)G!=="TRANSLATION"&&G!=="ROTATION"&&G!=="SCALE"&&w.geometry.setAttribute(G,h[G]);gi.prototype.copy.call(L,w),this.parser.assignFinalMaterial(L),p.push(L)}return c.isGroup?(c.clear(),c.add(...p),c):p[0]})))}}const LB="glTF",Lx=1313821514,Gx=5130562;class Ux{constructor(e){this.name=HA.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),A=new TextDecoder;if(this.header={magic:A.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==LB)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(e,12);let g=0;for(;g<n;){const h=r.getUint32(g,!0);g+=4;const u=r.getUint32(g,!0);if(g+=4,u===Lx){const c=new Uint8Array(e,12+g,h);this.content=A.decode(c)}else if(u===Gx){const c=12+g;this.body=e.slice(c,c+h)}g+=h}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Tx{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=HA.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const A=this.json,n=this.dracoLoader,r=e.extensions[this.name].bufferView,g=e.extensions[this.name].attributes,h={},u={},c={};for(const C in g){const B=oI[C]||C.toLowerCase();h[B]=g[C]}for(const C in e.attributes){const B=oI[C]||C.toLowerCase();if(g[C]!==void 0){const p=A.accessors[e.attributes[C]],w=Pa[p.componentType];c[B]=w.name,u[B]=p.normalized===!0}}return t.getDependency("bufferView",r).then((function(C){return new Promise((function(B){n.decodeDracoFile(C,(function(p){for(const w in p.attributes){const k=p.attributes[w],R=u[w];R!==void 0&&(k.normalized=R)}B(p)}),h,c)}))}))}}class Hx{constructor(){this.name=HA.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord!==void 0&&t.texCoord!==e.channel||t.offset!==void 0||t.rotation!==void 0||t.scale!==void 0)&&(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Jx{constructor(){this.name=HA.KHR_MESH_QUANTIZATION}}class GB extends zo{constructor(e,t,A,n){super(e,t,A,n)}copySampleValue_(e){const t=this.resultBuffer,A=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let g=0;g!==n;g++)t[g]=A[r+g];return t}interpolate_(e,t,A,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=2*h,c=3*h,C=n-t,B=(A-t)/C,p=B*B,w=p*B,k=e*c,R=k-c,_=-2*w+3*p,N=w-p,L=1-_,G=N-p+B;for(let le=0;le!==h;le++){const ne=g[R+le+h],Ae=g[R+le+u]*C,te=g[k+le+h],ye=g[k+le]*C;r[le]=L*ne+G*Ae+_*te+N*ye}return r}}const Yx=new Ui;class Px extends GB{interpolate_(e,t,A,n){const r=super.interpolate_(e,t,A,n);return Yx.fromArray(r).normalize().toArray(r),r}}const Yn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Pa={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},UB={9728:Be,9729:Qe,9984:qe,9985:tt,9986:me,9987:se},TB={33071:ee,33648:Fe,10497:Ce},aI={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},oI={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Oa={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ox={CUBICSPLINE:void 0,LINEAR:Oe,STEP:Ue},Kx="OPAQUE",zx="MASK",qx="BLEND";function jo(o,e,t){for(const A in t.extensions)o[A]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[A]=t.extensions[A])}function Es(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):e.extras)}function Wx(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,A=e.weights.length;t<A;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let A=0,n=t.length;A<n;A++)o.morphTargetDictionary[t[A]]=A}}}function Vx(o){const e=o.extensions&&o.extensions[HA.KHR_DRACO_MESH_COMPRESSION];let t;return t=e?"draco:"+e.bufferView+":"+e.indices+":"+HB(e.attributes):o.indices+":"+HB(o.attributes)+":"+o.mode,t}function HB(o){let e="";const t=Object.keys(o).sort();for(let A=0,n=t.length;A<n;A++)e+=t[A]+":"+o[t[A]]+";";return e}function gI(o){switch(o){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const Zx=new xA;class jx{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new fx,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let A=!1,n=!1,r=-1;typeof navigator<"u"&&(A=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,n=navigator.userAgent.indexOf("Firefox")>-1,r=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||A||n&&r<98?this.textureLoader=new Ya(this.options.manager):this.textureLoader=new gx(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Xh(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const A=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(g){return g._markDefs&&g._markDefs()})),Promise.all(this._invokeAll((function(g){return g.beforeRoot&&g.beforeRoot()}))).then((function(){return Promise.all([A.getDependencies("scene"),A.getDependencies("animation"),A.getDependencies("camera")])})).then((function(g){const h={scene:g[0][n.scene||0],scenes:g[0],animations:g[1],cameras:g[2],asset:n.asset,parser:A,userData:{}};jo(r,h,n),Es(h,n),Promise.all(A._invokeAll((function(u){return u.afterRoot&&u.afterRoot(h)}))).then((function(){e(h)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],A=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){const g=t[n].joints;for(let h=0,u=g.length;h<u;h++)e[g[h]].isBone=!0}for(let n=0,r=e.length;n<r;n++){const g=e[n];g.mesh!==void 0&&(this._addNodeRef(this.meshCache,g.mesh),g.skin!==void 0&&(A[g.mesh].isSkinnedMesh=!0)),g.camera!==void 0&&this._addNodeRef(this.cameraCache,g.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,A){if(e.refs[t]<=1)return A;const n=A.clone(),r=(g,h)=>{const u=this.associations.get(g);u!=null&&this.associations.set(h,u);for(const[c,C]of g.children.entries())r(C,h.children[c])};return r(A,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let A=0;A<t.length;A++){const n=e(t[A]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const A=[];for(let n=0;n<t.length;n++){const r=e(t[n]);r&&A.push(r)}return A}getDependency(e,t){const A=e+":"+t;let n=this.cache.get(A);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne((function(r){return r.loadNode&&r.loadNode(t)}));break;case"mesh":n=this._invokeOne((function(r){return r.loadMesh&&r.loadMesh(t)}));break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne((function(r){return r.loadBufferView&&r.loadBufferView(t)}));break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne((function(r){return r.loadMaterial&&r.loadMaterial(t)}));break;case"texture":n=this._invokeOne((function(r){return r.loadTexture&&r.loadTexture(t)}));break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne((function(r){return r.loadAnimation&&r.loadAnimation(t)}));break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne((function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)})),!n)throw new Error("Unknown type: "+e)}this.cache.add(A,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const A=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map((function(r,g){return A.getDependency(e,g)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],A=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[HA.KHR_BINARY_GLTF].body);const n=this.options;return new Promise((function(r,g){A.load(AI.resolveURL(t.uri,n.path),r,void 0,(function(){g(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(A){const n=t.byteLength||0,r=t.byteOffset||0;return A.slice(r,r+n)}))}loadAccessor(e){const t=this,A=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const g=aI[n.type],h=Pa[n.componentType],u=n.normalized===!0,c=new h(n.count*g);return Promise.resolve(new Vi(c,g,u))}const r=[];return n.bufferView!==void 0?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),n.sparse!==void 0&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then((function(g){const h=g[0],u=aI[n.type],c=Pa[n.componentType],C=c.BYTES_PER_ELEMENT,B=C*u,p=n.byteOffset||0,w=n.bufferView!==void 0?A.bufferViews[n.bufferView].byteStride:void 0,k=n.normalized===!0;let R,_;if(w&&w!==B){const N=Math.floor(p/w),L="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+N+":"+n.count;let G=t.cache.get(L);G||(R=new c(h,N*w,n.count*w/C),G=new eB(R,w/C),t.cache.add(L,G)),_=new Ho(G,u,p%w/C,k)}else R=h===null?new c(n.count*u):new c(h,p,n.count*u),_=new Vi(R,u,k);if(n.sparse!==void 0){const N=aI.SCALAR,L=Pa[n.sparse.indices.componentType],G=n.sparse.indices.byteOffset||0,le=n.sparse.values.byteOffset||0,ne=new L(g[1],G,n.sparse.count*N),Ae=new c(g[2],le,n.sparse.count*u);h!==null&&(_=new Vi(_.array.slice(),_.itemSize,_.normalized));for(let te=0,ye=ne.length;te<ye;te++){const ge=ne[te];if(_.setX(ge,Ae[te*u]),u>=2&&_.setY(ge,Ae[te*u+1]),u>=3&&_.setZ(ge,Ae[te*u+2]),u>=4&&_.setW(ge,Ae[te*u+3]),u>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return _}))}loadTexture(e){const t=this.json,A=this.options,n=t.textures[e].source,r=t.images[n];let g=this.textureLoader;if(r.uri){const h=A.manager.getHandler(r.uri);h!==null&&(g=h)}return this.loadTextureImage(e,n,g)}loadTextureImage(e,t,A){const n=this,r=this.json,g=r.textures[e],h=r.images[t],u=(h.uri||h.bufferView)+":"+g.sampler;if(this.textureCache[u])return this.textureCache[u];const c=this.loadImageSource(t,A).then((function(C){C.flipY=!1,C.name=g.name||h.name||"",C.name===""&&typeof h.uri=="string"&&h.uri.startsWith("data:image/")===!1&&(C.name=h.uri);const B=(r.samplers||{})[g.sampler]||{};return C.magFilter=UB[B.magFilter]||Qe,C.minFilter=UB[B.minFilter]||se,C.wrapS=TB[B.wrapS]||Ce,C.wrapT=TB[B.wrapT]||Ce,n.associations.set(C,{textures:e}),C})).catch((function(){return null}));return this.textureCache[u]=c,c}loadImageSource(e,t){const A=this,n=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((B=>B.clone()));const g=n.images[e],h=self.URL||self.webkitURL;let u=g.uri||"",c=!1;if(g.bufferView!==void 0)u=A.getDependency("bufferView",g.bufferView).then((function(B){c=!0;const p=new Blob([B],{type:g.mimeType});return u=h.createObjectURL(p),u}));else if(g.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const C=Promise.resolve(u).then((function(B){return new Promise((function(p,w){let k=p;t.isImageBitmapLoader===!0&&(k=function(R){const _=new Di(R);_.needsUpdate=!0,p(_)}),t.load(AI.resolveURL(B,r.path),k,void 0,w)}))})).then((function(B){var p;return c===!0&&h.revokeObjectURL(u),B.userData.mimeType=g.mimeType||((p=g.uri).search(/\.jpe?g($|\?)/i)>0||p.search(/^data\:image\/jpeg/)===0?"image/jpeg":p.search(/\.webp($|\?)/i)>0||p.search(/^data\:image\/webp/)===0?"image/webp":"image/png"),B})).catch((function(B){throw B}));return this.sourceCache[e]=C,C}assignTexture(e,t,A,n){const r=this;return this.getDependency("texture",A.index).then((function(g){if(!g)return null;if(A.texCoord!==void 0&&A.texCoord>0&&((g=g.clone()).channel=A.texCoord),r.extensions[HA.KHR_TEXTURE_TRANSFORM]){const h=A.extensions!==void 0?A.extensions[HA.KHR_TEXTURE_TRANSFORM]:void 0;if(h){const u=r.associations.get(g);g=r.extensions[HA.KHR_TEXTURE_TRANSFORM].extendTexture(g,h),r.associations.set(g,u)}}return n!==void 0&&(g.colorSpace=n),e[t]=g,g}))}assignFinalMaterial(e){const t=e.geometry;let A=e.material;const n=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,g=t.attributes.normal===void 0;if(e.isPoints){const h="PointsMaterial:"+A.uuid;let u=this.cache.get(h);u||(u=new fB,Sn.prototype.copy.call(u,A),u.color.copy(A.color),u.map=A.map,u.sizeAttenuation=!1,this.cache.add(h,u)),A=u}else if(e.isLine){const h="LineBasicMaterial:"+A.uuid;let u=this.cache.get(h);u||(u=new uB,Sn.prototype.copy.call(u,A),u.color.copy(A.color),u.map=A.map,this.cache.add(h,u)),A=u}if(n||r||g){let h="ClonedMaterial:"+A.uuid+":";n&&(h+="derivative-tangents:"),r&&(h+="vertex-colors:"),g&&(h+="flat-shading:");let u=this.cache.get(h);u||(u=A.clone(),r&&(u.vertexColors=!0),g&&(u.flatShading=!0),n&&(u.normalScale&&(u.normalScale.y*=-1),u.clearcoatNormalScale&&(u.clearcoatNormalScale.y*=-1)),this.cache.add(h,u),this.associations.set(u,this.associations.get(A))),A=u}e.material=A}getMaterialType(){return Ys}loadMaterial(e){const t=this,A=this.json,n=this.extensions,r=A.materials[e];let g;const h={},u=[];if((r.extensions||{})[HA.KHR_MATERIALS_UNLIT]){const C=n[HA.KHR_MATERIALS_UNLIT];g=C.getMaterialType(),u.push(C.extendParams(h,r,t))}else{const C=r.pbrMetallicRoughness||{};if(h.color=new rA(1,1,1),h.opacity=1,Array.isArray(C.baseColorFactor)){const B=C.baseColorFactor;h.color.fromArray(B),h.opacity=B[3]}C.baseColorTexture!==void 0&&u.push(t.assignTexture(h,"map",C.baseColorTexture,ie)),h.metalness=C.metallicFactor!==void 0?C.metallicFactor:1,h.roughness=C.roughnessFactor!==void 0?C.roughnessFactor:1,C.metallicRoughnessTexture!==void 0&&(u.push(t.assignTexture(h,"metalnessMap",C.metallicRoughnessTexture)),u.push(t.assignTexture(h,"roughnessMap",C.metallicRoughnessTexture))),g=this._invokeOne((function(B){return B.getMaterialType&&B.getMaterialType(e)})),u.push(Promise.all(this._invokeAll((function(B){return B.extendMaterialParams&&B.extendMaterialParams(e,h)}))))}r.doubleSided===!0&&(h.side=2);const c=r.alphaMode||Kx;if(c===qx?(h.transparent=!0,h.depthWrite=!1):(h.transparent=!1,c===zx&&(h.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&g!==Ji&&(u.push(t.assignTexture(h,"normalMap",r.normalTexture)),h.normalScale=new Gt(1,1),r.normalTexture.scale!==void 0)){const C=r.normalTexture.scale;h.normalScale.set(C,C)}return r.occlusionTexture!==void 0&&g!==Ji&&(u.push(t.assignTexture(h,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(h.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&g!==Ji&&(h.emissive=new rA().fromArray(r.emissiveFactor)),r.emissiveTexture!==void 0&&g!==Ji&&u.push(t.assignTexture(h,"emissiveMap",r.emissiveTexture,ie)),Promise.all(u).then((function(){const C=new g(h);return r.name&&(C.name=r.name),Es(C,r),t.associations.set(C,{materials:e}),r.extensions&&jo(n,C,r),C}))}createUniqueName(e){const t=ZA.sanitizeNodeName(e||"");let A=t;for(let n=1;this.nodeNamesUsed[A];++n)A=t+"_"+n;return this.nodeNamesUsed[A]=!0,A}loadGeometries(e){const t=this,A=this.extensions,n=this.primitiveCache;function r(h){return A[HA.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(h,t).then((function(u){return JB(u,h,t)}))}const g=[];for(let h=0,u=e.length;h<u;h++){const c=e[h],C=Vx(c),B=n[C];if(B)g.push(B.promise);else{let p;p=c.extensions&&c.extensions[HA.KHR_DRACO_MESH_COMPRESSION]?r(c):JB(new bn,c,t),n[C]={primitive:c,promise:p},g.push(p)}}return Promise.all(g)}loadMesh(e){const t=this,A=this.json,n=this.extensions,r=A.meshes[e],g=r.primitives,h=[];for(let c=0,C=g.length;c<C;c++){const B=g[c].material===void 0?((u=this.cache).DefaultMaterial===void 0&&(u.DefaultMaterial=new Ys({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:m})),u.DefaultMaterial):this.getDependency("material",g[c].material);h.push(B)}var u;return h.push(t.loadGeometries(g)),Promise.all(h).then((function(c){const C=c.slice(0,c.length-1),B=c[c.length-1],p=[];for(let k=0,R=B.length;k<R;k++){const _=B[k],N=g[k];let L;const G=C[k];if(N.mode===Yn.TRIANGLES||N.mode===Yn.TRIANGLE_STRIP||N.mode===Yn.TRIANGLE_FAN||N.mode===void 0)L=r.isSkinnedMesh===!0?new HS(_,G):new UA(_,G),L.isSkinnedMesh===!0&&L.normalizeSkinWeights(),N.mode===Yn.TRIANGLE_STRIP?L.geometry=FB(L.geometry,1):N.mode===Yn.TRIANGLE_FAN&&(L.geometry=FB(L.geometry,2));else if(N.mode===Yn.LINES)L=new OS(_,G);else if(N.mode===Yn.LINE_STRIP)L=new Vh(_,G);else if(N.mode===Yn.LINE_LOOP)L=new KS(_,G);else{if(N.mode!==Yn.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+N.mode);L=new zS(_,G)}Object.keys(L.geometry.morphAttributes).length>0&&Wx(L,r),L.name=t.createUniqueName(r.name||"mesh_"+e),Es(L,r),N.extensions&&jo(n,L,N),t.assignFinalMaterial(L),p.push(L)}for(let k=0,R=p.length;k<R;k++)t.associations.set(p[k],{meshes:e,primitives:k});if(p.length===1)return p[0];const w=new Js;t.associations.set(w,{meshes:e});for(let k=0,R=p.length;k<R;k++)w.add(p[k]);return w}))}loadCamera(e){let t;const A=this.json.cameras[e],n=A[A.type];if(n)return A.type==="perspective"?t=new Zi(yi.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):A.type==="orthographic"&&(t=new _n(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),A.name&&(t.name=this.createUniqueName(A.name)),Es(t,A),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],A=[];for(let n=0,r=t.joints.length;n<r;n++)A.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?A.push(this.getDependency("accessor",t.inverseBindMatrices)):A.push(null),Promise.all(A).then((function(n){const r=n.pop(),g=n,h=[],u=[];for(let c=0,C=g.length;c<C;c++){const B=g[c];if(B){h.push(B);const p=new xA;r!==null&&p.fromArray(r.array,16*c),u.push(p)}else t.joints[c]}return new qh(h,u)}))}loadAnimation(e){const t=this.json.animations[e],A=t.name?t.name:"animation_"+e,n=[],r=[],g=[],h=[],u=[];for(let c=0,C=t.channels.length;c<C;c++){const B=t.channels[c],p=t.samplers[B.sampler],w=B.target,k=w.node,R=t.parameters!==void 0?t.parameters[p.input]:p.input,_=t.parameters!==void 0?t.parameters[p.output]:p.output;w.node!==void 0&&(n.push(this.getDependency("node",k)),r.push(this.getDependency("accessor",R)),g.push(this.getDependency("accessor",_)),h.push(p),u.push(w))}return Promise.all([Promise.all(n),Promise.all(r),Promise.all(g),Promise.all(h),Promise.all(u)]).then((function(c){const C=c[0],B=c[1],p=c[2],w=c[3],k=c[4],R=[];for(let _=0,N=C.length;_<N;_++){const L=C[_],G=B[_],le=p[_],ne=w[_],Ae=k[_];if(L===void 0)continue;let te;switch(L.updateMatrix(),Oa[Ae.path]){case Oa.weights:te=qo;break;case Oa.rotation:te=Os;break;default:te=Wo}const ye=L.name?L.name:L.uuid,ge=ne.interpolation!==void 0?Ox[ne.interpolation]:Oe,Me=[];Oa[Ae.path]===Oa.weights?L.traverse((function(Ze){Ze.morphTargetInfluences&&Me.push(Ze.name?Ze.name:Ze.uuid)})):Me.push(ye);let pe=le.array;if(le.normalized){const Ze=gI(pe.constructor),Ct=new Float32Array(pe.length);for(let Qt=0,Wt=pe.length;Qt<Wt;Qt++)Ct[Qt]=pe[Qt]*Ze;pe=Ct}for(let Ze=0,Ct=Me.length;Ze<Ct;Ze++){const Qt=new te(Me[Ze]+"."+Oa[Ae.path],G.array,pe,ge);ne.interpolation==="CUBICSPLINE"&&(Qt.createInterpolant=function(Wt){return new(this instanceof Os?Px:GB)(this.times,this.values,this.getValueSize()/3,Wt)},Qt.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),R.push(Qt)}}return new jh(A,void 0,R)}))}createNodeMesh(e){const t=this.json,A=this,n=t.nodes[e];return n.mesh===void 0?null:A.getDependency("mesh",n.mesh).then((function(r){const g=A._getNodeRef(A.meshCache,n.mesh,r);return n.weights!==void 0&&g.traverse((function(h){if(h.isMesh)for(let u=0,c=n.weights.length;u<c;u++)h.morphTargetInfluences[u]=n.weights[u]})),g}))}loadNode(e){const t=this,A=this.json.nodes[e],n=t._loadNodeShallow(e),r=[],g=A.children||[];for(let u=0,c=g.length;u<c;u++)r.push(t.getDependency("node",g[u]));const h=A.skin===void 0?Promise.resolve(null):t.getDependency("skin",A.skin);return Promise.all([n,Promise.all(r),h]).then((function(u){const c=u[0],C=u[1],B=u[2];B!==null&&c.traverse((function(p){p.isSkinnedMesh&&p.bind(B,Zx)}));for(let p=0,w=C.length;p<w;p++)c.add(C[p]);return c}))}_loadNodeShallow(e){const t=this.json,A=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],g=r.name?n.createUniqueName(r.name):"",h=[],u=n._invokeOne((function(c){return c.createNodeMesh&&c.createNodeMesh(e)}));return u&&h.push(u),r.camera!==void 0&&h.push(n.getDependency("camera",r.camera).then((function(c){return n._getNodeRef(n.cameraCache,r.camera,c)}))),n._invokeAll((function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)})).forEach((function(c){h.push(c)})),this.nodeCache[e]=Promise.all(h).then((function(c){let C;if(C=r.isBone===!0?new gB:c.length>1?new Js:c.length===1?c[0]:new gi,C!==c[0])for(let B=0,p=c.length;B<p;B++)C.add(c[B]);if(r.name&&(C.userData.name=r.name,C.name=g),Es(C,r),r.extensions&&jo(A,C,r),r.matrix!==void 0){const B=new xA;B.fromArray(r.matrix),C.applyMatrix4(B)}else r.translation!==void 0&&C.position.fromArray(r.translation),r.rotation!==void 0&&C.quaternion.fromArray(r.rotation),r.scale!==void 0&&C.scale.fromArray(r.scale);return n.associations.has(C)||n.associations.set(C,{}),n.associations.get(C).nodes=e,C})),this.nodeCache[e]}loadScene(e){const t=this.extensions,A=this.json.scenes[e],n=this,r=new Js;A.name&&(r.name=n.createUniqueName(A.name)),Es(r,A),A.extensions&&jo(t,r,A);const g=A.nodes||[],h=[];for(let u=0,c=g.length;u<c;u++)h.push(n.getDependency("node",g[u]));return Promise.all(h).then((function(u){for(let c=0,C=u.length;c<C;c++)r.add(u[c]);return n.associations=(c=>{const C=new Map;for(const[B,p]of n.associations)(B instanceof Sn||B instanceof Di)&&C.set(B,p);return c.traverse((B=>{const p=n.associations.get(B);p!=null&&C.set(B,p)})),C})(r),r}))}}function JB(o,e,t){const A=e.attributes,n=[];function r(g,h){return t.getDependency("accessor",g).then((function(u){o.setAttribute(h,u)}))}for(const g in A){const h=oI[g]||g.toLowerCase();h in o.attributes||n.push(r(A[g],h))}if(e.indices!==void 0&&!o.index){const g=t.getDependency("accessor",e.indices).then((function(h){o.setIndex(h)}));n.push(g)}return Es(o,e),(function(g,h,u){const c=h.attributes,C=new Mi;if(c.POSITION===void 0)return;{const w=u.json.accessors[c.POSITION],k=w.min,R=w.max;if(k===void 0||R===void 0)return;if(C.set(new re(k[0],k[1],k[2]),new re(R[0],R[1],R[2])),w.normalized){const _=gI(Pa[w.componentType]);C.min.multiplyScalar(_),C.max.multiplyScalar(_)}}const B=h.targets;if(B!==void 0){const w=new re,k=new re;for(let R=0,_=B.length;R<_;R++){const N=B[R];if(N.POSITION!==void 0){const L=u.json.accessors[N.POSITION],G=L.min,le=L.max;if(G!==void 0&&le!==void 0){if(k.setX(Math.max(Math.abs(G[0]),Math.abs(le[0]))),k.setY(Math.max(Math.abs(G[1]),Math.abs(le[1]))),k.setZ(Math.max(Math.abs(G[2]),Math.abs(le[2]))),L.normalized){const ne=gI(Pa[L.componentType]);k.multiplyScalar(ne)}w.max(k)}}}C.expandByVector(w)}g.boundingBox=C;const p=new Ur;C.getCenter(p.center),p.radius=C.min.distanceTo(C.max)/2,g.boundingSphere=p})(o,e,t),Promise.all(n).then((function(){return e.targets!==void 0?(function(g,h,u){let c=!1,C=!1,B=!1;for(let R=0,_=h.length;R<_;R++){const N=h[R];if(N.POSITION!==void 0&&(c=!0),N.NORMAL!==void 0&&(C=!0),N.COLOR_0!==void 0&&(B=!0),c&&C&&B)break}if(!c&&!C&&!B)return Promise.resolve(g);const p=[],w=[],k=[];for(let R=0,_=h.length;R<_;R++){const N=h[R];if(c){const L=N.POSITION!==void 0?u.getDependency("accessor",N.POSITION):g.attributes.position;p.push(L)}if(C){const L=N.NORMAL!==void 0?u.getDependency("accessor",N.NORMAL):g.attributes.normal;w.push(L)}if(B){const L=N.COLOR_0!==void 0?u.getDependency("accessor",N.COLOR_0):g.attributes.color;k.push(L)}}return Promise.all([Promise.all(p),Promise.all(w),Promise.all(k)]).then((function(R){const _=R[0],N=R[1],L=R[2];return c&&(g.morphAttributes.position=_),C&&(g.morphAttributes.normal=N),B&&(g.morphAttributes.color=L),g.morphTargetsRelative=!0,g}))})(o,e.targets,t):o}))}var lI=function(o,e,t,A){return new(t||(t=Promise))((function(n,r){function g(c){try{u(A.next(c))}catch(C){r(C)}}function h(c){try{u(A.throw(c))}catch(C){r(C)}}function u(c){var C;c.done?n(c.value):(C=c.value,C instanceof t?C:new t((function(B){B(C)}))).then(g,h)}u((A=A.apply(o,[])).next())}))};class Xx{constructor(){this.modelCache=new Map,this.textureCache=new Map,this.loader=new sI}loadModel(e){return lI(this,void 0,void 0,(function*(){return this.modelCache.has(e)?this.modelCache.get(e).clone():(yield new Promise(((t,A)=>{this.loader.load(e,(n=>{this.modelCache.set(e,n.scene),t(n)}),void 0,A)}))).scene}))}loadTexture(e,t=!1){return lI(this,void 0,void 0,(function*(){if(this.textureCache.has(e))return this.textureCache.get(e);{let A=yield new Promise(((n,r)=>{new Ya().load(e,n,void 0,r)}));return t&&(A.minFilter=Be,A.magFilter=Be),this.textureCache.set(e,A),A}}))}loadTexturedPlaneModel(e,t,A=new re(0,0,0),n=new re(1,1,1),r=!1){return lI(this,void 0,void 0,(function*(){let g;const h=`plane:${e}:${A.x.toFixed(2)},${A.y.toFixed(2)},${A.z.toFixed(2)}:${n.x.toFixed(2)},${n.y.toFixed(2)},${n.z.toFixed(2)}`;if(this.modelCache.has(h))g=this.modelCache.get(h);else{const u=yield this.loadTexture(e,r),c=new Ri(1,1);t instanceof Ai?t.uniforms.map.value=u:t instanceof Ji&&(t.map=u),c.applyMatrix4(new xA().makeRotationX(-Math.PI/2).multiply(new xA().makeScale(n.x,n.y,n.z))),c.applyMatrix4(new xA().makeTranslation(A.x,A.y,A.z)),g=new UA(c,t),this.modelCache.set(h,g)}return g.clone()}))}dispose(){this.modelCache.forEach((e=>{e.traverse((t=>{if(t.isMesh){const A=t;A.geometry.dispose(),Array.isArray(A.material)?A.material.forEach((n=>{n instanceof Sn&&n.dispose()})):A.material instanceof Sn&&A.material.dispose()}}))})),this.textureCache.forEach((e=>{e.dispose()})),this.modelCache.clear(),this.textureCache.clear()}}class li{static convertUnityToThreeCoords(e){return new re(e.x,e.y,-e.z)}static normalizeAngle(e){let t=e%360;return t>180?t-=360:t<-180&&(t+=360),t}static convertUnityToThreeEuler(e){return new Mn(-li.normalizeAngle(e.x)*li.DEG_TO_RAD,-e.y*li.DEG_TO_RAD,-e.z*li.DEG_TO_RAD,"YXZ")}static convertThreeToUnityCoords(e){return new re(e.x,e.y,-e.z)}}li.DEG_TO_RAD=Math.PI/180,li.RAD_TO_DEG=180/Math.PI;class Xo{constructor(e){this.id=e.id,this.type=e.type,this.floor_vertical_position=e.floor_vertical_position,this.title=e.title,this.description=e.description,this.floorLevel=e.floorLevel,this.position=li.convertUnityToThreeCoords(this.toVector3(e.uposition)),this.rotation=li.convertUnityToThreeEuler(this.toVector3(e.urotation)),this.hasQA=e.hasQA,this.sunsimDayOfYear=e.sunsimDayOfYear,this.fieldOfView=e.fieldOfView,this.yawOffset=e.hasOwnProperty("yawOffset")?e.yawOffset:0,this.whitelist=Xo.parseWhitelist(e)}static hasWhitelist(e){var t;return!!(!((t=e?.whitelist)===null||t===void 0)&&t.length)}static parseWhitelist(e){return Array.isArray(e.whitelist)?e.whitelist.filter((t=>typeof t=="string")):Array.isArray(e.overrides)?e.overrides.filter((t=>t?.display&&t.cameraId)).map((t=>t.cameraId)):[]}toggleWhitelistMarker(e){this.whitelist||(this.whitelist=[]);const t=this.whitelist.indexOf(e);return t>=0?(this.whitelist.splice(t,1),!1):(this.whitelist.push(e),!0)}removeWhitelistMarker(e){var t;!((t=this.whitelist)===null||t===void 0)&&t.length&&(this.whitelist=this.whitelist.filter((A=>A!==e)))}clearWhitelist(){this.whitelist=[]}mergeWhitelist(e){this.whitelist||(this.whitelist=[]);const t=new Set(this.whitelist);for(const A of e)t.has(A)||(this.whitelist.push(A),t.add(A))}toVector3(e){const t=e.split(",").map(Number);return new re(t[0],t[1],t[2])}}class Ks{constructor(e){var t,A;this.id=e.id,this.direction=e.direction,this.floorLevel=e.floorLevel,this.floor_vertical_position=Number(e.floor_vertical_position),this.targetCameraId=e.targetCameraId,this.sourceCameraId=(t=e.sourceCameraId)!==null&&t!==void 0?t:"";const n=(A=e.position)!==null&&A!==void 0?A:e.uposition;this.position=li.convertUnityToThreeCoords(new re().fromArray(n.split(",").map((r=>Number(r.trim())))))}toJSON(){const e=li.convertThreeToUnityCoords(this.position);return{id:this.id,direction:this.direction,floorLevel:this.floorLevel,floor_vertical_position:String(this.floor_vertical_position),position:`${e.x.toFixed(3)},${e.y.toFixed(3)},${e.z.toFixed(3)}`,targetCameraId:this.targetCameraId,sourceCameraId:this.sourceCameraId}}static expectedTargetFloorLevel(e,t){return t==="up"?e+1:e-1}static isValidTargetFloor(e,t,A){return A===Ks.expectedTargetFloorLevel(e,t)}}class $x{constructor(e){this.id=e.id;const t=e.position.split(",").map(Number);this.position=new re(t[0],t[1],t[2]);const A=e.rotation?e.rotation.split(",").map(Number):[0,0,0];this.rotation=new Mn(A[0],A[1],A[2],"XYZ"),this.appearance=e.appearance;const n=e.scale?e.scale.split(",").map(Number):[1,1,1];this.scale=new re(n[0],n[1],n[2]);const r=e.color?e.color.split(",").map(Number):[1,1,1];this.color=new re(r[0],r[1],r[2]),this.depthOffset=e.depthOffset!==void 0?e.depthOffset:0}}var eb=function(o,e,t,A){return new(t||(t=Promise))((function(n,r){function g(c){try{u(A.next(c))}catch(C){r(C)}}function h(c){try{u(A.throw(c))}catch(C){r(C)}}function u(c){var C;c.done?n(c.value):(C=c.value,C instanceof t?C:new t((function(B){B(C)}))).then(g,h)}u((A=A.apply(o,[])).next())}))};class cI{constructor(e){this.constructorData=e,this.version=e.hasOwnProperty("version")?e.version:1,this.id=e.id,this.name=e.name,this.type=e.type,this.dayOfYear=e.dayOfYear,this.timeInHours=e.timeInHours,this.offsetUTC=e.offsetUTC,this.latitude=e.latitude,this.longitude=e.longitude,this.defaultMinimap=e.defaultMinimap,this.minimaps=e.minimaps,this.cameras=e.cameras.map((t=>new Xo(t))),Array.isArray(e.floorTransitions)?this.floorTransitions=e.floorTransitions.map((t=>new Ks(t))):this.floorTransitions=[],e.hasOwnProperty("interactiveObjects")&&Array.isArray(e.interactiveObjects)?this.interactiveObjects=e.interactiveObjects.map((t=>new $x(t))):this.interactiveObjects=[],this.hasHDR=!!e.hasOwnProperty("hasHDR")&&e.hasHDR,this.hasLores=!!e.hasOwnProperty("hasLores")&&e.hasLores,this.usesPngDepth=!!e.hasOwnProperty("usesPngDepth")&&e.usesPngDepth,this.version,this.hasHDR,this.hasLores}siteHasHDR(){return!!this.constructorData.hasOwnProperty("hasHDR")&&this.constructorData.hasHDR}static fromURL(e){return eb(this,void 0,void 0,(function*(){try{const t=yield K.fetch(e),A=yield t.json();return new cI(A)}catch(t){throw t}}))}}class YB{constructor(){this.needMaterialUpdate=!0,this.layers=[]}addLayer(e){this.layers.push(e),this.needMaterialUpdate=!0}removeLayer(e){const t=this.layers.indexOf(e);t!==-1&&this.layers.splice(t,1),this.needMaterialUpdate=!0}getActiveLayersCount(){let e=0;for(let t=0;t<this.layers.length;t++)this.layers[t].isActive&&e++;return e}clearLayers(){this.layers=[],this.needMaterialUpdate=!0}}class tb{constructor(){this.scene=new Rn,this.camera=new _n(-.5,.5,.5,-.5,0,1),this.material=this.createShaderMaterial();const e=new Ri(1,1);this.plane=new UA(e,this.material),this.scene.add(this.plane),this.renderTexture=new ei(ae.HISTOGRAM_WIDTH,ae.HISTOGRAM_HEIGHT,{type:be,depthBuffer:!1,stencilBuffer:!1}),this.pixelBuffer=new Uint8Array(ae.HISTOGRAM_WIDTH*ae.HISTOGRAM_HEIGHT*4)}createShaderMaterial(){return new Ai({uniforms:{u_image:{value:null},u_fovy_scale:{value:1}},vertexShader:`
|
|
3468
3468
|
varying vec2 v_texCoord;
|
|
3469
3469
|
void main() {
|
|
3470
3470
|
v_texCoord = uv;
|
|
@@ -4375,7 +4375,7 @@ vec2 getEquirectangularTexCoord() {
|
|
|
4375
4375
|
float depth = distance(cameraPosition, vWorldPosition) + depthOffset;
|
|
4376
4376
|
gl_FragColor = vec4(rgb, depth);
|
|
4377
4377
|
}
|
|
4378
|
-
`,side:m,transparent:!1})}}const pQ="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAIAAABMXPacAAAMAUlEQVR4nO2dy49cRxXGf3X7Od3TYxvsxEoi7IBRFthAgoKErEgxQhYo2bILysIR/0b+DBSBxIJISCzIDiOFlXk4UiQgRhCEeNiQ2NiWE+GZ6e6Z6e5icebUVL9ft+remelPo5Fn5rpv3e+rc049zqlr3uRwwMx5vQ3SivRRzLoBY+EYt2ChBz3v3+P+i4HE++7Llk9J8iWA8CUUd70vR/3snyMaJFCAIhRUEvQWOUH2AjhSutDRr24/R6b/yllgodP/CQUoQEn1cJdliywFEEK7sAt72tPdn+Z1+uM+30Gk3QEDRSipGGQqQwYCCC892FXqrf5+edKn3lewB3uqRBnKkABZKBFVANfld2AXuvrLoLxPaAmqRAvKUMnCICIJIA/cgTbsgs2I92G4sN+GHShBFUr6ywiIIYCBDrRgV3/MA/UDkCaJVyzBWiwZwgpgoAdN2NFen3NIC8UvVWANCoE1CCWAAQstaEMvr71+HKSpEqiqsKaPEwJBBBCfsw2dw0a9D2m2eM46lMJokLIArtGtQ+JzpsJAFx5DFWoBTCFNAaSt2zrEPgLsC+RB2tCBOhRT1SBJ64MM7MJjZf/oQfzqY51Lp4V0LMBAC5r676MKebQt6EAtpc9MR4CttPtFnmF0aLeeRkhYygUJ45vHiX2B87e9pR98cQFkknWEnf5kuJDQXe7xFxTAsd85luwL3Ah1GQ0WEcCxv6T4RwDLU7GIABY2V+wrnAaLxYNFBNg83p5nGKLB5vhsgQmYTwDjTXRX8CExeWv+/ziHADLbOm4jztlhYA+ac/IzqwAy8p33048bZI7WnoelmQRwq2wr9qfCQHOeGDmrBWwvFGGOJyxszbxEMV0AkXQVeGeHOIwZ3fUUAYymMqzYnwtG8z+m8jZFAAvbOcjfO6RozkDdJAGMbgOtuv8CmNERTRKgl1fn46ehj8xEzwkM7EzrwWM3ZCT2Lr/enQocv5K53tGEdf+CxPtiznT2cJDcnMb4C0YLYLxE4myRaKK55PCWoAY1WPfyRNwyQBOa0AKjmc8mayWMJiCPy2oZawHZ5pUYz4cm8Bl4Gs7DU3ASaprP7AToaY7t/+Au3IGP4JEmuBWzlqEJG2P+NEIAoz0uK/YTtb8GXIQvwzlYh8QrmNkb9b8acBI+D5dhGz6GW/AhfAplKGU0l3R8lkd1gtEW0M6o+yfQg204BS/DC3AGLOxCC9AmjQy5Vksw5CGLcAGeg0/gFrwH96EKhYxkaEN51O8HBTBaspIJ+20owRV4CU7p8h9eaJ0M4323mhFch5fha/Ae3IBtqEXXwGjC73AkGGEB8TOZ5V7b8EV4Bc5DW9f+lsnacIFkG0pwFS7BdbgVON92HNqa8u5jUIBe9O7vQui34CoksLU09QOfb3SB7LPwOtyAX+qYKpopGK2DG3iuZORF0ZDAHiTwGryq605JmB4g92rDFbgGdb1XNNhRnXuwATvRmgMJ7MA6XIOvwubIBqUKsYZNuADfhyehFVeD3SG/d3B3o5W6cfyPzFAacA2ehS2vdjc0CrANZ+ANOBvRDoyO03yG+249rE+4pvSgBN+Dp2A7IvuCArRhA16HjbiTnt3+H/sEGJ7dhMMefBeezYJ9gYx6T8NrOqmOo0Gnv5cfCNCNlWuVQBOuwPPZse+35AvwSqx1XzPEc+L+0IkyJpN+dwGu6jpPtijAFlyG52O1x/Z7moM7xvE/4vpf1TCQB8jg+zuwEWsM4p8isi+AjTL8T6AF34BzsJOD7i8QAU7DN6OswJv+Y0n2SeiFDwDi5U7BS/nYafAhPeNFeCbKQoAfBhJUk9ADUNmf+zqcyuU+cw+qcDlW25y/2beAzrgLU71lA17IaKl1KmRafhGeiDItcITvCxA6AMjjPQdncpzj1YV1uBSli/TFgAnH4KUFCwl8Jd/l8xKlLkI1MCFGzyDEFyAcLy78fm5oIp4ryHDoLJwNb6Y95TwxQykeqUMe7BlYz31hUw8qcC58KHZJAglRMgYsnMvNwH8CpDuejzUlxgkQ+k4leDr33V/QgbOwFn5g0hcDwkH61BqcjLvXthiMnkHQCJ8VeGABoYdAPahD7ZBYgISBRkwLCI1ufyZhzmGhABux8mJjCCAxIP8R2MGMSaIKgUi0HIq+7yNagw9RvzyaiCRA/mPvAKI1OIYAZmgnOuewEfMTYggg2Ya5XQQdgOyObMZKHk0IL0IC25qDln87kJWrzfDpGon7Hnq+V9DalQwzUGaE1TyJCAL0bUmGvtMe3A1/EHYqKMJ9TVEJvUiDEyCCd75zGNiXjaM7UVZN9l2QDZYO7iAz4f9AM/deSIz1TnhjNQMWENTcLBThE/g43ytC0lEewt0xBXUpwnF+IEBQyFTgVr7DgAjw5/A5itaretu/UWjPYKEMH8InaZ8+niIkPeuDKGbqCN8XIPSrZMQLfQq3oJJLASQx669wL7z/wSP8wAJCB30xgptxi2Fmh4Tf38SaLfZZgNV3Lga9sXjYB3AT1nKTGi2QTdMP4F9RDNRn+6A+IEKvFDO/EcvMZ4TMfjfh3Sje3+qbRQUH0X64hjgECtCE63nyQhaq8C48jDVK9iNu4v82wnxYjP1PcAPqOciT6EId/gA3Ix5h4Pf1gwKNQqwBojii6/C3rDWQltyDd2K903GY574JRxwvhJraT+F+dgFZiqWa8Da0Is5OBjzNoABx9kxkRPQYfqKv6IqsgbDfhbfhHlQiNqDS/+OBADJXitYRxPzvw4/gUZRUQIcuVKANP4a/R3T9I/384JpHtHwYPA3egtuaDRh6LiKZhw/hrbjsC8qTD+uw3rul40A02IIfwq+hBsVgjPQg0THPD+BBdPbNkP9hOPgnUI57XGhPrfLncBu+DaehpXyldQsDdXgMv4DfQTGu30c79/Byw4jRVyXuoTVo3VINfg//gCvwop7n011iw87qKksN9uB9+JV2fLIYeg13f4YFkFBcil7LKGTVoAXvwPtwGb4EDT1yUPiaKoYrNjFQghK04I/wW/gnlKCeBfWO1VlPTaxmVMzVgwLU4b/wM3gCLsFFrZiQcxG7Y2K10UWuoh6O9QD+ArfgrlpYhHLEcaiOSTQyb4662mT9ijyj68PyTuuzcB7OwZPQgMqo9fMu7MAWPIB/w224C00o6cJfVmt/Mvo8MeavY2fga1Gqt8fBembbg4/gtnpzKV/Z8NZTjb5VcBM2oQldKKjDybDXO0w4pHG0AFYdaLZV7a7bljWCdeARPFQvZPQyo7usBajo0+aBeqsjrnH2N2kNqhb3DK0JGAitjOoW1rsyJzsNgslvHh4rgHiuqh5Gnh9Y73vOYaEybY9h0lzHwlq+E0lyjkSHXpOvmQSZQK6wAGRaM3UyP+UCicbVlRHMCasDh6m8TV9usbpGttJgdiQ6Ap7lyukQR5SrUJxnWH3dxCyY6TIZzM4o6TGHOIzZsytmXfGVEdUqGEyGuP61eViaY8ndQj3f+eXZQvzE+pz8zLfnYaGxCsijIBsP6/NHyrk3nQw0VrOzISxMy9wCWH1h1KGoOY2GhR3DItuuVg90WWkgj99YIjQuuO+90gBdBl+GfZZJPHAbPcczHogr3lh6WLhU5kdajTh0kBHnRhoDwmVTb5wZHp85msy2NlIy/dSysutafGGP7qqR0F3TuW4qHS41AaTOpAhbh+R0xHnhplrp+ts0E0HFM55Qd3SUPJK4nRMBol3KhSHSuLrWPhwBU7C6uF8J06uCVOZIfylCK4t3s6YF4bqiO4uBDDpUaZTVbZwKtDTR8bDIIFyXYE19Tjh3GrY2TaJCA/agqal2eZZBiC5CVVPBQkey4MWBrjdt6NtkJdkrbzL41JdjndhHrOrMgwzDsieDS3bLEK4NZU2iMnGHcJEEEDhrKOmb63e9FODI5QiCglJf0N9HHj1HFUAgT5jAGlShA7taghHaJnzeS/pl+v8UGRkI4OAbhIUu7Okrj/2euIwePq2J5rsXvWrpzCeMWQogcM9f1Nb09GV/HX3b0ALlq0aPgClo2Yx/RknmvDtkL4CD3+VL3rkJPc3073lZ/yMnd8YrFEj0R3dZfkj3kSMBfPhMueKvxT4kh6T7+D/tbpO6AiN6WQAAAABJRU5ErkJggg==";class ac{constructor(e){this.data=e}addMarker(e){this.data.push(e)}removeMarker(e){const t=this.data.indexOf(e);t>-1&&this.data.splice(t,1)}clearMarkers(){this.data=[]}getMarker(e){return this.data.find((t=>t.id===e))}toJson(){return JSON.stringify(this.data.map((e=>e.toJSON())),null,2)}}var sg=function(o,e,t,A){return new(t||(t=Promise))((function(n,r){function g(c){try{u(A.next(c))}catch(C){r(C)}}function h(c){try{u(A.throw(c))}catch(C){r(C)}}function u(c){var C;c.done?n(c.value):(C=c.value,C instanceof t?C:new t((function(B){B(C)}))).then(g,h)}u((A=A.apply(o,[])).next())}))};class Kn{constructor(e){this.idLabels=[],this.posLabels=[],this.floorTransitionPosLabels=[],this.floorTransitionLabelAnchors=[],this.billboardScene=new Rn,this.billboardRaycaster=new Zo,this.billboardDirection=new re,this.billboardProjected=new re,this.validatorIndex=0,this.autoOverrideMarkerIds=new Set,this.worldCenter=new re,this.siteManager=e,this.floorTransitionMarkers=new ac([]),this.billboardOrthoCamera=new _n(-1,1,1,-1,1,1e3),this.billboardOrthoCamera.position.set(0,0,10),this.billboardOrthoCamera.lookAt(0,0,0)}getAllSceneMarkers(){return[...this.markers.data,...this.floorTransitionMarkers.data]}isFloorTransitionMarker(e){return e.type===pi.TYPE_FLOOR_TRANSITION}getTargetNavigationMarker(e){var t;if(!this.isFloorTransitionMarker(e))return null;const A=e.payload;return(t=this.markers.getMarker(A.targetCameraId))!==null&&t!==void 0?t:null}addMarkers(e){return sg(this,void 0,void 0,(function*(){this.markers=new ac([]);const t=[pQ];let A=yield Promise.all(t.map((n=>K.assetManager.loadTexture(n,!1))));for(const n of e.cameras){const r=new re(.25,.25,.25),g=yield K.assetManager.loadTexturedPlaneModel(t[0],gn.getMaterial(Qs,{depthOffset:-.2,color:new rA(1,1,1)}),new re(0,n.floor_vertical_position-n.position.y,0),r,!0);g.position.copy(n.position);const h=new pi;h.id=n.id,h.description=n.description,h.position=n.position,h.rotation=new re(0,0,0),h.model=g,h.textures=A,h.payload=n;const u=n.floor_vertical_position-n.position.y,c=this.createTextLabel(n.id);c.position.set(0,u+.15,0),c.visible=ae.SHOW_NAVIGATION_MARKERS_ID,h.model.add(c),this.idLabels.push(c);const C=this.createPositionLabel(n.position);C.position.set(0,u-.1,0),C.visible=ae.NAVIGATION_MARKERS_EDIT_MODE,h.model.add(C),this.posLabels.push(C),h.model.visible=!1,this.markers.addMarker(h)}}))}addSingleMarker(e,t){return sg(this,void 0,void 0,(function*(){const A=e.id+"_new",n=Object.create(e);n.id=A,n.position=t.clone();const r=[pQ],g=yield Promise.all(r.map((k=>K.assetManager.loadTexture(k,!1)))),h=new re(.25,.25,.25),u=yield K.assetManager.loadTexturedPlaneModel(r[0],gn.getMaterial(Qs,{depthOffset:-.2,color:new rA(1,1,1)}),new re(0,n.floor_vertical_position-n.position.y,0),h,!0);u.position.copy(n.position);const c=new pi;c.id=A,c.description=n.description,c.position=n.position,c.rotation=new re(0,0,0),c.model=u,c.textures=g,c.payload=n;const C=n.floor_vertical_position-n.position.y,B=this.createTextLabel(A);B.position.set(0,C+.15,0),B.visible=ae.SHOW_NAVIGATION_MARKERS_ID,c.model.add(B),this.idLabels.push(B);const p=this.createPositionLabel(n.position);p.position.set(0,C-.1,0),p.visible=ae.NAVIGATION_MARKERS_EDIT_MODE,c.model.add(p),this.posLabels.push(p),c.model.visible=!0,c.isVisible=!0,this.markers.addMarker(c);const w=K.instance.siteManager.siteData;return w&&w.cameras.push(n),c}))}addFloorTransitions(e){return sg(this,void 0,void 0,(function*(){for(const t of e.floorTransitions){const A=yield this.createFloorTransitionMarker(t);this.floorTransitionMarkers.addMarker(A)}}))}addSingleFloorTransition(e){return sg(this,void 0,void 0,(function*(){const t=yield this.createFloorTransitionMarker(e);this.floorTransitionMarkers.addMarker(t);const A=K.instance.siteManager.siteData;return A&&A.floorTransitions.push(e),t}))}getStairTextureUrl(e){return e==="up"?pi.MARKER_APPEARANCES.ICON_STAIRS_UP:pi.MARKER_APPEARANCES.ICON_STAIRS_DOWN}createFloorTransitionMarker(e){return sg(this,void 0,void 0,(function*(){const t=this.getStairTextureUrl(e.direction),A=yield K.assetManager.loadTexture(t,!1),n=new Ri(1,1),r=new Ji({transparent:!0,depthTest:!1,depthWrite:!1,alphaTest:.05}),g=new UA(n,r);g.visible=!1;const h=new pi;if(h.id=e.id,h.description=`Stairs ${e.direction} → ${e.targetCameraId}`,h.position=e.position.clone(),h.rotation=new re(0,0,0),h.type=pi.TYPE_FLOOR_TRANSITION,h.model=g,h.textures=[A],h.payload=e,g.userData.marker=h,ae.isMobile){const B=new Ri(ae.MARKER_HITBOX_SCALE,ae.MARKER_HITBOX_SCALE),p=new Ji({visible:!1}),w=new UA(B,p);w.userData.marker=h,g.add(w)}const u=new gi;u.position.copy(e.position);const c=this.createPositionLabel(e.position);c.position.set(0,.15,0),c.visible=!1,u.add(c),this.floorTransitionPosLabels.push(c);const C=this.createTextLabel(`→ ${e.targetCameraId}`,384,48,"bold 22px Arial");return C.position.set(0,-.15,0),C.visible=!1,u.add(C),this.floorTransitionLabelAnchors.push(u),h}))}getPosLabelForFloorTransitionMarker(e){const t=this.floorTransitionMarkers.data.indexOf(e);return t>=0&&t<this.floorTransitionPosLabels.length?this.floorTransitionPosLabels[t]:null}getFloorTransitionLabelAnchors(){return this.floorTransitionLabelAnchors}hideFloorTransitionMarkers(e=null){for(const t of this.floorTransitionMarkers.data)t!==e&&(t.isVisible=!1,t.model&&(t.model.visible=!1))}pickFloorTransition(e){var t;this.billboardRaycaster.setFromCamera(e,this.billboardOrthoCamera);const A=this.billboardRaycaster.intersectObjects(this.billboardScene.children,!0);for(const n of A){let r=n.object;for(;r;){const g=(t=r.userData)===null||t===void 0?void 0:t.marker;if(g&&this.isFloorTransitionMarker(g))return g;r=r.parent}}return null}renderFloorTransitionBillboards(e){this.billboardScene.children.length!==0&&(K.renderer.setRenderTarget(e),K.renderer.render(this.billboardScene,this.billboardOrthoCamera))}syncFloorTransitionLabelAnchors(e,t,A){for(const n of this.floorTransitionLabelAnchors)e.remove(n);t&&A&&this.floorTransitionMarkers.data.forEach(((n,r)=>{const g=n.payload;if(!(g.sourceCameraId?g.sourceCameraId===A.id:g.floorLevel===A.floorLevel))return;const h=this.floorTransitionLabelAnchors[r];h&&(h.position.copy(n.position),h.children.forEach((u=>{u.visible=!0})),e.add(h))}))}createPositionLabel(e){const t=`${e.x.toFixed(2)}, ${e.y.toFixed(2)}, ${e.z.toFixed(2)}`;return this.createTextLabel(t,512,64,"bold 28px Arial")}updatePositionLabel(e,t){const A=document.createElement("canvas"),n=A.getContext("2d");A.width=512,A.height=64,n.fillStyle="rgba(0, 0, 0, 0.6)",n.roundRect(0,0,A.width,A.height,8),n.fill(),n.font="bold 28px Arial",n.fillStyle="#00ff88",n.textAlign="center",n.textBaseline="middle",n.fillText(`${t.x.toFixed(2)}, ${t.y.toFixed(2)}, ${t.z.toFixed(2)}`,A.width/2,A.height/2);const r=e.material.map;r&&r.dispose();const g=new wB(A);e.material.map=g,e.material.needsUpdate=!0}getPosLabelForMarker(e){const t=this.markers.data.indexOf(e);return t>=0&&t<this.posLabels.length?this.posLabels[t]:null}createTextLabel(e,t=256,A=64,n="bold 32px Arial"){const r=document.createElement("canvas"),g=r.getContext("2d");r.width=t,r.height=A,g.fillStyle="rgba(0, 0, 0, 0.6)",g.roundRect(0,0,r.width,r.height,8),g.fill(),g.font=n,g.fillStyle="white",g.textAlign="center",g.textBaseline="middle",g.fillText(e,r.width/2,r.height/2);const h=new wB(r),u=new tB({map:h,transparent:!0,depthTest:!1}),c=new US(u);return c.scale.set(t/512,A/512,1),c}isHelperMarker(e){return this.autoOverrideMarkerIds.has(e.id)}getHelperMarkerColor(){const[e,t,A]=ae.NAV_HELPER_MARKER_RGB;return Kn.helperMarkerColor.setRGB(e,t,A),Kn.helperMarkerColor}applyDepthOverride(e,t){e.model.visible=!0;const A=e.model,n=A.material;if(n?.uniforms){A.userData.overrideMaterial||(A.userData.overrideMaterial=n.clone(),A.userData.originalMaterial=n),A.material=A.userData.overrideMaterial;const r=A.material,g=K.userData.cameraSmooth.position.distanceTo(e.model.position);r.uniforms.depthOffset.value=.01-g,r.uniforms.color&&r.uniforms.color.value.copy(t)}}restoreOriginalMaterial(e){const t=e.model;t.userData.originalMaterial&&(t.material=t.userData.originalMaterial,t.userData.overrideMaterial=null,t.userData.helperMaterial=null,t.userData.originalMaterial=null)}getMarkerMap(e){var t,A,n,r;const g=(t=e.userData.originalMaterial)!==null&&t!==void 0?t:e.material;return(r=(n=(A=g?.uniforms)===null||A===void 0?void 0:A.map)===null||n===void 0?void 0:n.value)!==null&&r!==void 0?r:null}applyHelperMarker(e){e.isVisible=!0;const t=e.model;t.userData.originalMaterial||(t.userData.originalMaterial=t.material);let A=t.userData.helperMaterial;if(!A){A=gn.getMaterial(r_,{depthOffset:-.2,color:this.getHelperMarkerColor()});const r=this.getMarkerMap(t);r&&A.uniforms.map&&(A.uniforms.map.value=r),t.userData.helperMaterial=A}A.uniforms.color.value.copy(this.getHelperMarkerColor());const n=K.userData.cameraSmooth.position.distanceTo(e.model.position);A.uniforms.depthOffset.value=.01-n,t.material=A,e.model.visible=!0}isSameFloorAsCurrent(e,t){if(!t)return!0;const A=e.payload;return A==null||A.floorLevel==null||t.floorLevel==null||A.floorLevel===t.floorLevel}isEligibleMarker(e,t){return(!t||e.id!==t.id)&&this.isSameFloorAsCurrent(e,t)}clearAutoFallbackHelpers(){if(this.autoOverrideMarkerIds.size!==0){for(const e of this.autoOverrideMarkerIds){const t=this.markers.data.find((A=>A.id===e));t&&this.restoreOriginalMaterial(t)}this.autoOverrideMarkerIds.clear()}}hideMarker(e){e.model.visible=!1,e.isVisible=!1,this.autoOverrideMarkerIds.delete(e.id),this.restoreOriginalMaterial(e)}showWhitelistedMarker(e,t=Kn.naturalMarkerColor){this.applyDepthOverride(e,t),e.isVisible=!0}cacheMarkerScreenPos(e){const t=K.userData.cameraSmooth;e.model.updateWorldMatrix(!0,!1),new Mi().setFromObject(e.model).getCenter(this.worldCenter),this.worldCenter.project(t),e.screenPos||(e.screenPos=new Gt),e.screenPos.set(this.worldCenter.x,this.worldCenter.y)}updateNaturalVisibility(e,t){this.restoreOriginalMaterial(e);const A=e.setIsVisible(t);return e.model.visible=A,A}snapshotNaturalVisibility(){const e=K.userData.siteCamera,t=this.siteManager.getCurrentPanoramaData(),A=[];for(const n of this.markers.data)this.isEligibleMarker(n,e)&&this.updateNaturalVisibility(n,t)&&A.push(n.id);return A}updateWhitelistMarkers(e,t,A){this.clearAutoFallbackHelpers();const n=new Set(t);for(const r of this.markers.data)if(this.isEligibleMarker(r,e))if(n.has(r.id)){const g=A?Kn.whitelistEditActiveColor:Kn.naturalMarkerColor;this.showWhitelistedMarker(r,g),A&&this.cacheMarkerScreenPos(r)}else A?(this.showWhitelistedMarker(r,Kn.whitelistEditDimColor),r.isVisible=!1,this.cacheMarkerScreenPos(r)):this.hideMarker(r);else this.hideMarker(r)}updateWhitelistEditPreview(e){var t;const A=(t=e.whitelist)!==null&&t!==void 0?t:[];this.updateWhitelistMarkers(e,A,!0)}isFloorTransitionVisibleFromCamera(e,t){if(!t)return!1;const A=e.payload;return!!A&&(A.sourceCameraId?A.sourceCameraId===t.id:A.floorLevel!=null&&t.floorLevel!=null&&A.floorLevel===t.floorLevel)}updateFloorTransitionMarkers(e,t){for(;this.billboardScene.children.length>0;)this.billboardScene.remove(this.billboardScene.children[0]);if(t){for(const h of this.floorTransitionMarkers.data)h.isVisible=!1,h.model&&(h.model.visible=!1);return}const A=this.siteManager.getCurrentPanoramaData(),n=K.userData.cameraSmooth.position,r=K.getCurrentCanvasSize(),g=r.width/r.height;for(const h of this.floorTransitionMarkers.data){if(h.update(),h.isVisible=!1,h.model&&(h.model.visible=!1),!this.isFloorTransitionVisibleFromCamera(h,e))continue;this.billboardDirection.subVectors(h.position,n);const u=this.billboardDirection.length();if(this.billboardDirection.normalize(),A.depth.getDepth(this.billboardDirection)<=u-.5)continue;const c=h.model,C=c.material;C.color.set(16777215);const B=h.textures[h.textureIndex],p=B?.image,w=p?.width&&p?.height?p.width/p.height:1;C.map=B,C.needsUpdate=!0,this.billboardProjected.copy(h.position).project(K.userData.cameraSmooth),c.position.set(this.billboardProjected.x,this.billboardProjected.y,this.billboardProjected.z),this.billboardProjected.z<-1||this.billboardProjected.z>1||(c.scale.set(ae.MARKER_SIZE,ae.MARKER_SIZE*g*w,1),c.visible=!0,h.isVisible=!0,this.billboardScene.add(c))}}update(){const e=ae.SHOW_NAVIGATION_MARKERS_ID;this.idLabels.forEach((N=>N.visible=e));const t=ae.NAVIGATION_MARKERS_EDIT_MODE,A=ae.NAVIGATION_MARKERS_WHITELIST_MODE;this.posLabels.forEach((N=>N.visible=t)),this.floorTransitionPosLabels.forEach((N=>N.visible=t));const n=this.markers.data.length,r=K.userData.siteCamera,g=K.instance.siteManager.isLoading();if(r?.id!==this.lastNavCameraId&&(this.clearAutoFallbackHelpers(),this.lastNavCameraId=r?.id,this.validatorIndex=0),A&&r)return this.markers.data.forEach((N=>N.update())),g||this.updateWhitelistEditPreview(r),void this.updateFloorTransitionMarkers(r,g);if(Xo.hasWhitelist(r))return this.markers.data.forEach((N=>N.update())),!g&&r&&this.updateWhitelistMarkers(r,r.whitelist,!1),void this.updateFloorTransitionMarkers(r,g);if(n===0)return void this.updateFloorTransitionMarkers(r,g);if(this.markers.data.forEach(((N,L)=>{if(N.update(),!(t||g)){if(!this.isEligibleMarker(N,r))return void this.hideMarker(N);this.autoOverrideMarkerIds.has(N.id)?this.applyHelperMarker(N):L===this.validatorIndex&&this.updateNaturalVisibility(N,this.siteManager.getCurrentPanoramaData())}})),this.validatorIndex=(this.validatorIndex+1)%n,this.validatorIndex!==0||t||g)return void this.updateFloorTransitionMarkers(r,g);const h=this.siteManager.getCurrentPanoramaData(),u=new Set;for(const N of this.markers.data)this.isEligibleMarker(N,r)&&this.updateNaturalVisibility(N,h)&&u.add(N.id);const c=u.size,C=Math.max(0,0|ae.NAV_MIN_NATURAL_VISIBLE);if(c>=C)return this.autoOverrideMarkerIds.size>0&&(ae.NAV_FALLBACK_DEBUG&&console.debug("[nav-fallback] deactivated",{from:r?.id,naturalVisibleCount:c,minNaturalVisible:C,naturallyVisibleIds:[...u]}),this.clearAutoFallbackHelpers()),void this.updateFloorTransitionMarkers(r,g);const B=K.userData.cameraSmooth.position,p=[];for(const N of this.markers.data)this.isEligibleMarker(N,r)&&(u.has(N.id)||p.push({id:N.id,dist:B.distanceTo(N.model.position)}));p.sort(((N,L)=>N.dist-L.dist));const w=Math.max(0,C-c),k=Math.max(0,Math.min(0|ae.NAV_FALLBACK_COUNT,w)),R=Math.min(k,p.length);if(R===0){ae.NAV_FALLBACK_DEBUG&&console.debug("[nav-fallback] no eligible candidates",{from:r?.id,keeping:[...this.autoOverrideMarkerIds],naturalVisibleCount:c,minNaturalVisible:C,requested:k,naturallyVisibleIds:[...u]});for(const N of this.autoOverrideMarkerIds){const L=this.markers.data.find((G=>G.id===N));L&&this.applyHelperMarker(L)}return void this.updateFloorTransitionMarkers(r,g)}const _=new Set(p.slice(0,R).map((N=>N.id)));for(const N of this.autoOverrideMarkerIds)if(!_.has(N)){const L=this.markers.data.find((G=>G.id===N));L&&this.restoreOriginalMaterial(L)}for(const N of _){const L=this.markers.data.find((G=>G.id===N));L&&this.applyHelperMarker(L)}ae.NAV_FALLBACK_DEBUG&&(_.size!==this.autoOverrideMarkerIds.size||[..._].some((L=>!this.autoOverrideMarkerIds.has(L))))&&console.debug("[nav-fallback] activated",{from:r?.id,ids:[..._],candidateCount:p.length,naturalVisibleCount:c,minNaturalVisible:C,requested:k,naturallyVisibleIds:[...u]}),this.autoOverrideMarkerIds=_,this.updateFloorTransitionMarkers(r,g)}}Kn.naturalMarkerColor=new rA(1,1,1),Kn.whitelistEditDimColor=new rA(.45,.45,.5),Kn.whitelistEditActiveColor=new rA(.35,.75,1),Kn.helperMarkerColor=new rA(1,1,1);class xi{constructor(e=xi.LAYER_TYPE_DEFAULT){this.renderTextureScaler=1,this.isActive=!0,this.alpha=1,this.needRender=!0,window.addEventListener("beforeunload",(()=>this.cleanup())),this.type=e}getScaledCanvasSize(){const{width:e,height:t}=K.getCurrentCanvasSize();return{width:Math.floor(e*this.renderTextureScaler),height:Math.floor(t*this.renderTextureScaler)}}get renderTexture(){const{width:e,height:t}=this.getScaledCanvasSize();return this._renderTexture&&this._renderTexture.width===e&&this._renderTexture.height===t||(this._renderTexture&&this._renderTexture.dispose(),this._renderTexture=new ei(e,t,{type:mt,wrapS:Ce,wrapT:Ce,minFilter:Be,magFilter:Be}),this.needRender=!0),this._renderTexture}update(){}cleanup(){var e;(e=this._renderTexture)===null||e===void 0||e.dispose(),this._renderTexture=void 0}}xi.LAYER_TYPE_DEFAULT=0,xi.LAYER_TYPE_ADDITIVE=1,xi.LAYER_TYPE_MULTIPLY=2,xi.LAYER_TYPE_ANIMATED_MARKERS=3,xi.LAYER_TYPE_NO_DEPTH=4;class dn extends xi{constructor(e){super(xi.LAYER_TYPE_NO_DEPTH),this.raycaster=new Zo,this.markers=e,this.scene=new Rn,this.initOrthographicCamera()}initOrthographicCamera(){this.orthoCamera=new _n(-1,1,1,-1,1,1e3),this.orthoCamera.position.set(0,0,10),this.orthoCamera.lookAt(0,0,0)}getClosestMouseOverMarker(){const e=Ve.MousePositionNormalized;this.raycaster.setFromCamera(e,this.orthoCamera);const t=this.raycaster.intersectObjects(this.scene.children,!0);let A=null,n=1/0;return t.forEach((r=>{r.object.userData.marker&&r.object.visible&&r.distance<n&&(n=r.distance,A=r.object.userData.marker)})),A}update(){for(dn.selectedMarker=this.getClosestMouseOverMarker();this.scene.children.length>0;)this.scene.remove(this.scene.children[0]);if(!ae.SHOW_MARKERS)return;const e=K.instance.siteManager.getCurrentPanoramaData(),t=K.userData.cameraSmooth.position,A=new re;this.markers.data.forEach((n=>{if(!n.model){const h=new Ri(1,1),u=new Ji({transparent:!0,depthTest:!1}),c=new UA(h,u);if(ae.isMobile){const C=new Ri(ae.MARKER_HITBOX_SCALE,ae.MARKER_HITBOX_SCALE),B=new Ji({visible:!1}),p=new UA(C,B);p.userData.marker=n,c.add(p)}c.userData.marker=n,n.model=c}const r=K.getCurrentCanvasSize(),g=r.width/r.height;if(n.model.visible=n.isVisible,n.isVisible){A.subVectors(n.position,t);const h=A.length();if(A.normalize(),e.depth.getDepth(A)>h-.5){const u=n.model.material;if(n===dn.selectedMarker)u.color.set(16711680);else if(K.playerPlugins.markerEditor&&n===K.playerPlugins.markerEditor.selectedMarker){const p=Math.floor(127*(.5*Math.sin(8*K.time)+.5))+127;u.color.set(p<<16|p<<8|p)}else u.color.set(16777215);const c=n.textures[n.textureIndex],C=c.image.width/c.image.height;u.map=c,u.needsUpdate=!0;const B=n.position.clone().project(K.userData.cameraSmooth);n.model.position.set(B.x,B.y,B.z),B.z>=-1&&B.z<=1&&this.scene.add(n.model),n.model.scale.set(ae.MARKER_SIZE,ae.MARKER_SIZE*g*C,1)}}})),dn.selectedMarker&&Ve.MousePick&&K.playerPlugins.markerActions.executeAction(dn.selectedMarker).then((n=>{n||K.playerAPI.setPickedMarker(dn.selectedMarker,Ve.MousePositionNormalized.clone())})).catch((n=>{})),K.renderer.setClearColor(0,0),K.renderer.setRenderTarget(this.renderTexture),K.renderer.render(this.scene,this.orthoCamera),K.renderer.setRenderTarget(null)}}dn.selectedMarker=null;class qa{constructor(e,t){this.arrowLayer=e,this.navigationLayer=t}static calculateMouseHitpoint(e,t,A){this.raycaster.setFromCamera(t,e),this.hitPlane.constant=-A;let n=new re,r=this.raycaster.ray.intersectPlane(this.hitPlane,n),g=!0;if(!r){g=!1;const u=e.position.y+(e.position.y-A);this.hitPlane.constant=-u,r=this.raycaster.ray.intersectPlane(this.hitPlane,n)}let h=new re(n.x-e.position.x,0,n.z-e.position.z);return h.normalize(),{hitPoint:n,directionXZ:h,isFloor:g}}update(){if(!K.userData.siteCamera)return;let e,t=qa.calculateMouseHitpoint(K.userData.cameraSmooth,Ve.MousePositionNormalized,K.userData.siteCamera.floor_vertical_position);this.arrowLayer&&this.arrowLayer.updateArrowPosition(K.userData.cameraSmooth,t.hitPoint,t.directionXZ,t.isFloor);const A=ae.isNavigationMarkerPlacementMode();if(dn.selectedMarker||!Ve.MousePick||this.navigationLayer.getPickedMarker()||ae.NAVIGATION_MARKERS_WHITELIST_MODE||A||(e=this.navigationLayer.pick(),e||(e=this.navigationLayer.pickClosest(K.userData.cameraSmooth.position,t.hitPoint)),e||t.isFloor||(e=this.navigationLayer.pickRaymarch(K.userData.cameraSmooth.position,t.directionXZ))),!e&&!A){const n=new re(Math.sin(K.userData.camera.rotation.y),0,Math.cos(K.userData.camera.rotation.y));if(Ve.GetKeyUp("KeyW")||Ve.GetKeyUp("ArrowUp"))e=this.navigationLayer.pickRaymarch(K.userData.cameraSmooth.position,n.multiplyScalar(-1));else if(Ve.GetKeyUp("KeyS")||Ve.GetKeyUp("ArrowDown"))e=this.navigationLayer.pickRaymarch(K.userData.cameraSmooth.position,n);else if(Ve.GetKeyUp("KeyA")||Ve.GetKeyUp("ArrowLeft")){const r=new re;r.crossVectors(n,new re(0,1,0)).normalize(),e=this.navigationLayer.pickRaymarch(K.userData.cameraSmooth.position,r)}else if(Ve.GetKeyUp("KeyD")||Ve.GetKeyUp("ArrowRight")){const r=new re;r.crossVectors(n,new re(0,-1,0)).normalize(),e=this.navigationLayer.pickRaymarch(K.userData.cameraSmooth.position,r)}}e&&this.navigationLayer.setPickedMarker(e)}}qa.raycaster=new Zo,qa.hitPlane=new Er(new re(0,1,0),0);var mQ=function(o,e,t,A){return new(t||(t=Promise))((function(n,r){function g(c){try{u(A.next(c))}catch(C){r(C)}}function h(c){try{u(A.throw(c))}catch(C){r(C)}}function u(c){var C;c.done?n(c.value):(C=c.value,C instanceof t?C:new t((function(B){B(C)}))).then(g,h)}u((A=A.apply(o,[])).next())}))};class En extends xi{constructor(e,t=xi.LAYER_TYPE_ANIMATED_MARKERS){super(t),this.pickedMarker=null,this.pickedMarkerBehaviour=0,this.draggedMarker=null,this.lastDraggedMarker=null,this.onWhitelistChanged=null,this.onStairPlacementComplete=null,this.dragFloorY=0,this.dragOffset=new re,this.dragHit=new re,this.dragFloorPlane=new Er,this.projectedPos=new re,this.addModeDropdownOpen=!1,this.addModeMouseWasDown=!1,this.addStairModeMouseWasDown=!1,this.navigationMarkers=e,this.scene=new Rn,this.raycaster=new Zo,this.navigationMarkers.markers.data.forEach((A=>{let n=A.model;n.userData.marker=A,this.scene.add(n)}))}hideMarkers(e=null,t=!0){this.navigationMarkers.markers.data.forEach((A=>{A!==e&&(A.isVisible=!1,t&&(A.model.visible=!1))})),this.navigationMarkers.hideFloorTransitionMarkers(this.navigationMarkers.isFloorTransitionMarker(e)?e:null)}setPickedMarker(e,t=!1){if(!K.instance.siteManager.isLoading()||t||!e){if(e&&this.navigationMarkers.isFloorTransitionMarker(e)){const A=this.navigationMarkers.getTargetNavigationMarker(e);if(!A)return void e.id;e=A,this.pickedMarkerBehaviour=En.TRANSITION_BEHAVIOUR_CAM_ROTATE}else this.pickedMarkerBehaviour=0;this.pickedMarker=e}}getPickedMarker(){return this.pickedMarker}pick(){const e=Ve.MousePositionNormalized.clone();this.raycaster.setFromCamera(e,K.userData.cameraSmooth);const t=this.scene.children.filter((n=>n.visible));let A=this.raycaster.intersectObjects(t,!0);for(const n of A){let r=n.object;for(;r;){if(r.userData.marker)return r.userData.marker;r=r.parent}}return this.navigationMarkers.pickFloorTransition(e)}pickScreenSpace(e,t,A,n=!1){var r;const g=K.userData.cameraSmooth,h=K.canvas.getBoundingClientRect(),u=(.5*t.x+.5)*h.width,c=(.5*-t.y+.5)*h.height;let C=null,B=e*e;for(const p of this.navigationMarkers.markers.data){if(!(!((r=p.model)===null||r===void 0)&&r.visible)||!A(p)||(n&&p.screenPos?this.projectedPos.set(p.screenPos.x,p.screenPos.y,0):(p.model.updateWorldMatrix(!0,!1),new Mi().setFromObject(p.model).getCenter(this.projectedPos),this.projectedPos.project(g)),this.projectedPos.z<-1||this.projectedPos.z>1))continue;const w=(.5*this.projectedPos.x+.5)*h.width-u,k=(.5*-this.projectedPos.y+.5)*h.height-c,R=w*w+k*k;R<B&&(B=R,C=p)}return C}pickFloorWhitelist(e,t,A){var n;const r=Number(e.floor_vertical_position),g=qa.calculateMouseHitpoint(K.userData.cameraSmooth,t,r);let h=null,u=Math.pow(En.WHITELIST_FLOOR_PICK_RADIUS,2);for(const c of this.navigationMarkers.markers.data){if(!(!((n=c.model)===null||n===void 0)&&n.visible)||!A(c))continue;const C=c.position.x-g.hitPoint.x,B=c.position.z-g.hitPoint.z,p=C*C+B*B;p<u&&(u=p,h=c)}return h}pickWhitelistEdit(e,t){const A=r=>this.isWhitelistEditEligible(r,e);return this.pickScreenSpace(En.WHITELIST_PICK_RADIUS_PX,t,A,!0)||this.pickFloorWhitelist(e,t,A)}isWhitelistEditEligible(e,t){if(e.id===t.id)return!1;const A=e.payload;return A?.floorLevel==null||t.floorLevel==null||A.floorLevel===t.floorLevel}isDirectionNavigationMarker(e){return e.isVisible&&!this.navigationMarkers.isHelperMarker(e)&&!this.navigationMarkers.isFloorTransitionMarker(e)}pickClosest(e,t){const A=this.scene.children.filter((g=>g.visible));let n=null,r=1/0;return A.forEach((g=>{if(g.position.x===e.x&&g.position.y===e.y&&g.position.z===e.z)return;const h=g.userData.marker;if(!h||!this.isDirectionNavigationMarker(h))return;let u=t.distanceTo(g.position);u<r&&(r=u,n=h)})),n}pickRaymarch(e,t){let A=null,n=1/0;for(const r of this.navigationMarkers.markers.data)if(this.isDirectionNavigationMarker(r)){let g=e.distanceTo(r.position);if(g>.1){let h=new re().subVectors(r.position,e);if(h.dot(t)>0){let u=.1*g+h.cross(t).length();u<n&&(n=u,A=r)}}}return A}addMarkerToScene(e){e.model.userData.marker=e,this.scene.add(e.model)}update(){ae.SHOW_ARROW_AND_MARKERS||this.hideMarkers(),ae.NAVIGATION_MARKERS_EDIT_MODE&&this.updateEditModeDrag(),ae.NAVIGATION_MARKERS_ADD_MODE&&this.updateAddMode(),ae.NAVIGATION_MARKERS_ADD_STAIR_UP_MODE&&this.updateAddStairMode("up"),ae.NAVIGATION_MARKERS_ADD_STAIR_DOWN_MODE&&this.updateAddStairMode("down"),K.renderer.setClearColor(0,0),this.navigationMarkers.update(),this.navigationMarkers.syncFloorTransitionLabelAnchors(this.scene,ae.NAVIGATION_MARKERS_EDIT_MODE,K.userData.siteCamera),ae.NAVIGATION_MARKERS_WHITELIST_MODE&&this.updateWhitelistEditClick(),this.mixer&&this.mixer.update(K.deltaTime),K.renderer.setRenderTarget(this.renderTexture),K.renderer.render(this.scene,K.userData.cameraSmooth),K.renderer.setRenderTarget(null)}getMarkerFloorY(e){if(this.navigationMarkers.isFloorTransitionMarker(e))return e.position.y;const t=e.payload;return t?.floor_vertical_position!=null?t.floor_vertical_position:e.model.position.y}beginMarkerDrag(e){this.dragFloorY=this.getMarkerFloorY(e),this.dragOffset.set(0,0,0);const t=Ve.MousePositionNormalized.clone();this.raycaster.setFromCamera(t,K.userData.cameraSmooth),this.dragFloorPlane.set(En.UP,-this.dragFloorY),this.raycaster.ray.intersectPlane(this.dragFloorPlane,this.dragHit)&&(this.dragOffset.subVectors(e.model.position,this.dragHit),this.dragOffset.y=0)}setMarkerWorldPosition(e,t){this.commitMarkerPosition(e,t),this.lastDraggedMarker=e}alignMarkerToPreviousScanPosition(e,t){this.commitMarkerPosition(e,t);const A=e.payload;A&&(A.floor_vertical_position=t.y-1.3),this.lastDraggedMarker=e}commitMarkerPosition(e,t){if(e.position.copy(t),this.navigationMarkers.isFloorTransitionMarker(e)){e.payload.position.copy(t);const n=this.navigationMarkers.floorTransitionMarkers.data.indexOf(e),r=this.navigationMarkers.getFloorTransitionLabelAnchors()[n];r&&r.position.copy(t)}else e.model.position.copy(t),e.payload&&e.payload.position.copy(t);const A=this.navigationMarkers.isFloorTransitionMarker(e)?this.navigationMarkers.getPosLabelForFloorTransitionMarker(e):this.navigationMarkers.getPosLabelForMarker(e);A&&this.navigationMarkers.updatePositionLabel(A,t)}applyMarkerDragXZ(e){const t=this.navigationMarkers.isFloorTransitionMarker(e)?e.position.y:e.model.position.y,A=Ve.MousePositionNormalized.clone();if(this.raycaster.setFromCamera(A,K.userData.cameraSmooth),this.dragFloorPlane.set(En.UP,-this.dragFloorY),this.raycaster.ray.intersectPlane(this.dragFloorPlane,this.dragHit))return this.dragHit.add(this.dragOffset),this.dragHit.y=t,void this.commitMarkerPosition(e,this.dragHit);this.applyMarkerDragFloorDelta(e,t)}applyMarkerDragFloorDelta(e,t){const A=Ve.MouseDragDelta;if(A.x===0&&A.y===0)return;const n=K.userData.cameraSmooth,r=n.rotation.y,g=new re(Math.sin(r),0,Math.cos(r)),h=new re().crossVectors(g,En.UP).normalize(),u=n.position.distanceTo(e.model.position)*Math.tan(n.fov*Math.PI/180/2)*(2/K.canvas.clientHeight),c=e.model.position;c.x+=h.x*A.x*u-g.x*A.y*u,c.z+=h.z*A.x*u-g.z*A.y*u,c.y=t,this.commitMarkerPosition(e,c)}updateWhitelistEditClick(){var e;if(!Ve.wasMouseButtonPressed(0)||Ve.consumeDrag)return;const t=K.userData.siteCamera;if(!t)return;const A=Ve.getMouseDownPositionNormalized(),n=this.pickWhitelistEdit(t,A);n&&(t.toggleWhitelistMarker(n.id),(e=this.onWhitelistChanged)===null||e===void 0||e.call(this),t.id,t.whitelist.length,t.whitelist)}updateEditModeDrag(){const e=Ve.GetMouseButtonDown(0),t=Ve.GetMouseButton(0),A=Ve.GetMouseButtonUp(0),n=K.canvas;if(e&&!this.draggedMarker){const r=this.pick();r&&(this.draggedMarker=r,this.beginMarkerDrag(r),Ve.consumeDrag=!0,n.style.cursor="grabbing")}if(this.draggedMarker&&t&&this.applyMarkerDragXZ(this.draggedMarker),A&&this.draggedMarker&&(Ve.consumeDrag=!1,this.lastDraggedMarker=this.draggedMarker,this.draggedMarker=null,n.style.cursor=""),!this.draggedMarker&&!t){const r=this.pick();n.style.cursor=r?"grab":""}}updateAddMode(){if(this.addModeDropdownOpen)return;if(Ve.GetMouseButton(0))return void(this.addModeMouseWasDown=!0);if(!this.addModeMouseWasDown||(this.addModeMouseWasDown=!1,this.pick()))return;const e=K.instance.screenToWorld(Ve.MousePositionNormalized);if(!e)return;const t=K.instance.siteManager.siteData;t&&(this.addModeDropdownOpen=!0,this.showCameraDropdown(e,t.cameras))}showCameraDropdown(e,t){const A=Ve.MousePositionLocal,n=document.createElement("div");n.style.cssText=`
|
|
4378
|
+
`,side:m,transparent:!1})}}const pQ="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAIAAABMXPacAAAMAUlEQVR4nO2dy49cRxXGf3X7Od3TYxvsxEoi7IBRFthAgoKErEgxQhYo2bILysIR/0b+DBSBxIJISCzIDiOFlXk4UiQgRhCEeNiQ2NiWE+GZ6e6Z6e5icebUVL9ft+remelPo5Fn5rpv3e+rc049zqlr3uRwwMx5vQ3SivRRzLoBY+EYt2ChBz3v3+P+i4HE++7Llk9J8iWA8CUUd70vR/3snyMaJFCAIhRUEvQWOUH2AjhSutDRr24/R6b/yllgodP/CQUoQEn1cJdliywFEEK7sAt72tPdn+Z1+uM+30Gk3QEDRSipGGQqQwYCCC892FXqrf5+edKn3lewB3uqRBnKkABZKBFVANfld2AXuvrLoLxPaAmqRAvKUMnCICIJIA/cgTbsgs2I92G4sN+GHShBFUr6ywiIIYCBDrRgV3/MA/UDkCaJVyzBWiwZwgpgoAdN2NFen3NIC8UvVWANCoE1CCWAAQstaEMvr71+HKSpEqiqsKaPEwJBBBCfsw2dw0a9D2m2eM46lMJokLIArtGtQ+JzpsJAFx5DFWoBTCFNAaSt2zrEPgLsC+RB2tCBOhRT1SBJ64MM7MJjZf/oQfzqY51Lp4V0LMBAC5r676MKebQt6EAtpc9MR4CttPtFnmF0aLeeRkhYygUJ45vHiX2B87e9pR98cQFkknWEnf5kuJDQXe7xFxTAsd85luwL3Ah1GQ0WEcCxv6T4RwDLU7GIABY2V+wrnAaLxYNFBNg83p5nGKLB5vhsgQmYTwDjTXRX8CExeWv+/ziHADLbOm4jztlhYA+ac/IzqwAy8p33048bZI7WnoelmQRwq2wr9qfCQHOeGDmrBWwvFGGOJyxszbxEMV0AkXQVeGeHOIwZ3fUUAYymMqzYnwtG8z+m8jZFAAvbOcjfO6RozkDdJAGMbgOtuv8CmNERTRKgl1fn46ehj8xEzwkM7EzrwWM3ZCT2Lr/enQocv5K53tGEdf+CxPtiznT2cJDcnMb4C0YLYLxE4myRaKK55PCWoAY1WPfyRNwyQBOa0AKjmc8mayWMJiCPy2oZawHZ5pUYz4cm8Bl4Gs7DU3ASaprP7AToaY7t/+Au3IGP4JEmuBWzlqEJG2P+NEIAoz0uK/YTtb8GXIQvwzlYh8QrmNkb9b8acBI+D5dhGz6GW/AhfAplKGU0l3R8lkd1gtEW0M6o+yfQg204BS/DC3AGLOxCC9AmjQy5Vksw5CGLcAGeg0/gFrwH96EKhYxkaEN51O8HBTBaspIJ+20owRV4CU7p8h9eaJ0M4323mhFch5fha/Ae3IBtqEXXwGjC73AkGGEB8TOZ5V7b8EV4Bc5DW9f+lsnacIFkG0pwFS7BdbgVON92HNqa8u5jUIBe9O7vQui34CoksLU09QOfb3SB7LPwOtyAX+qYKpopGK2DG3iuZORF0ZDAHiTwGryq605JmB4g92rDFbgGdb1XNNhRnXuwATvRmgMJ7MA6XIOvwubIBqUKsYZNuADfhyehFVeD3SG/d3B3o5W6cfyPzFAacA2ehS2vdjc0CrANZ+ANOBvRDoyO03yG+249rE+4pvSgBN+Dp2A7IvuCArRhA16HjbiTnt3+H/sEGJ7dhMMefBeezYJ9gYx6T8NrOqmOo0Gnv5cfCNCNlWuVQBOuwPPZse+35AvwSqx1XzPEc+L+0IkyJpN+dwGu6jpPtijAFlyG52O1x/Z7moM7xvE/4vpf1TCQB8jg+zuwEWsM4p8isi+AjTL8T6AF34BzsJOD7i8QAU7DN6OswJv+Y0n2SeiFDwDi5U7BS/nYafAhPeNFeCbKQoAfBhJUk9ADUNmf+zqcyuU+cw+qcDlW25y/2beAzrgLU71lA17IaKl1KmRafhGeiDItcITvCxA6AMjjPQdncpzj1YV1uBSli/TFgAnH4KUFCwl8Jd/l8xKlLkI1MCFGzyDEFyAcLy78fm5oIp4ryHDoLJwNb6Y95TwxQykeqUMe7BlYz31hUw8qcC58KHZJAglRMgYsnMvNwH8CpDuejzUlxgkQ+k4leDr33V/QgbOwFn5g0hcDwkH61BqcjLvXthiMnkHQCJ8VeGABoYdAPahD7ZBYgISBRkwLCI1ufyZhzmGhABux8mJjCCAxIP8R2MGMSaIKgUi0HIq+7yNagw9RvzyaiCRA/mPvAKI1OIYAZmgnOuewEfMTYggg2Ya5XQQdgOyObMZKHk0IL0IC25qDln87kJWrzfDpGon7Hnq+V9DalQwzUGaE1TyJCAL0bUmGvtMe3A1/EHYqKMJ9TVEJvUiDEyCCd75zGNiXjaM7UVZN9l2QDZYO7iAz4f9AM/deSIz1TnhjNQMWENTcLBThE/g43ytC0lEewt0xBXUpwnF+IEBQyFTgVr7DgAjw5/A5itaretu/UWjPYKEMH8InaZ8+niIkPeuDKGbqCN8XIPSrZMQLfQq3oJJLASQx669wL7z/wSP8wAJCB30xgptxi2Fmh4Tf38SaLfZZgNV3Lga9sXjYB3AT1nKTGi2QTdMP4F9RDNRn+6A+IEKvFDO/EcvMZ4TMfjfh3Sje3+qbRQUH0X64hjgECtCE63nyQhaq8C48jDVK9iNu4v82wnxYjP1PcAPqOciT6EId/gA3Ix5h4Pf1gwKNQqwBojii6/C3rDWQltyDd2K903GY574JRxwvhJraT+F+dgFZiqWa8Da0Is5OBjzNoABx9kxkRPQYfqKv6IqsgbDfhbfhHlQiNqDS/+OBADJXitYRxPzvw4/gUZRUQIcuVKANP4a/R3T9I/384JpHtHwYPA3egtuaDRh6LiKZhw/hrbjsC8qTD+uw3rul40A02IIfwq+hBsVgjPQg0THPD+BBdPbNkP9hOPgnUI57XGhPrfLncBu+DaehpXyldQsDdXgMv4DfQTGu30c79/Byw4jRVyXuoTVo3VINfg//gCvwop7n011iw87qKksN9uB9+JV2fLIYeg13f4YFkFBcil7LKGTVoAXvwPtwGb4EDT1yUPiaKoYrNjFQghK04I/wW/gnlKCeBfWO1VlPTaxmVMzVgwLU4b/wM3gCLsFFrZiQcxG7Y2K10UWuoh6O9QD+ArfgrlpYhHLEcaiOSTQyb4662mT9ijyj68PyTuuzcB7OwZPQgMqo9fMu7MAWPIB/w224C00o6cJfVmt/Mvo8MeavY2fga1Gqt8fBembbg4/gtnpzKV/Z8NZTjb5VcBM2oQldKKjDybDXO0w4pHG0AFYdaLZV7a7bljWCdeARPFQvZPQyo7usBajo0+aBeqsjrnH2N2kNqhb3DK0JGAitjOoW1rsyJzsNgslvHh4rgHiuqh5Gnh9Y73vOYaEybY9h0lzHwlq+E0lyjkSHXpOvmQSZQK6wAGRaM3UyP+UCicbVlRHMCasDh6m8TV9usbpGttJgdiQ6Ap7lyukQR5SrUJxnWH3dxCyY6TIZzM4o6TGHOIzZsytmXfGVEdUqGEyGuP61eViaY8ndQj3f+eXZQvzE+pz8zLfnYaGxCsijIBsP6/NHyrk3nQw0VrOzISxMy9wCWH1h1KGoOY2GhR3DItuuVg90WWkgj99YIjQuuO+90gBdBl+GfZZJPHAbPcczHogr3lh6WLhU5kdajTh0kBHnRhoDwmVTb5wZHp85msy2NlIy/dSysutafGGP7qqR0F3TuW4qHS41AaTOpAhbh+R0xHnhplrp+ts0E0HFM55Qd3SUPJK4nRMBol3KhSHSuLrWPhwBU7C6uF8J06uCVOZIfylCK4t3s6YF4bqiO4uBDDpUaZTVbZwKtDTR8bDIIFyXYE19Tjh3GrY2TaJCA/agqal2eZZBiC5CVVPBQkey4MWBrjdt6NtkJdkrbzL41JdjndhHrOrMgwzDsieDS3bLEK4NZU2iMnGHcJEEEDhrKOmb63e9FODI5QiCglJf0N9HHj1HFUAgT5jAGlShA7taghHaJnzeS/pl+v8UGRkI4OAbhIUu7Okrj/2euIwePq2J5rsXvWrpzCeMWQogcM9f1Nb09GV/HX3b0ALlq0aPgClo2Yx/RknmvDtkL4CD3+VL3rkJPc3073lZ/yMnd8YrFEj0R3dZfkj3kSMBfPhMueKvxT4kh6T7+D/tbpO6AiN6WQAAAABJRU5ErkJggg==";class ac{constructor(e){this.data=e}addMarker(e){this.data.push(e)}removeMarker(e){const t=this.data.indexOf(e);t>-1&&this.data.splice(t,1)}clearMarkers(){this.data=[]}getMarker(e){return this.data.find((t=>t.id===e))}toJson(){return JSON.stringify(this.data.map((e=>e.toJSON())),null,2)}}var sg=function(o,e,t,A){return new(t||(t=Promise))((function(n,r){function g(c){try{u(A.next(c))}catch(C){r(C)}}function h(c){try{u(A.throw(c))}catch(C){r(C)}}function u(c){var C;c.done?n(c.value):(C=c.value,C instanceof t?C:new t((function(B){B(C)}))).then(g,h)}u((A=A.apply(o,[])).next())}))};class Kn{constructor(e){this.idLabels=[],this.posLabels=[],this.floorTransitionPosLabels=[],this.floorTransitionLabelAnchors=[],this.billboardScene=new Rn,this.billboardRaycaster=new Zo,this.billboardDirection=new re,this.billboardProjected=new re,this.validatorIndex=0,this.autoOverrideMarkerIds=new Set,this.worldCenter=new re,this.siteManager=e,this.floorTransitionMarkers=new ac([]),this.billboardOrthoCamera=new _n(-1,1,1,-1,1,1e3),this.billboardOrthoCamera.position.set(0,0,10),this.billboardOrthoCamera.lookAt(0,0,0)}getAllSceneMarkers(){return[...this.markers.data,...this.floorTransitionMarkers.data]}isFloorTransitionMarker(e){return e.type===pi.TYPE_FLOOR_TRANSITION}getTargetNavigationMarker(e){var t;if(!this.isFloorTransitionMarker(e))return null;const A=e.payload;return(t=this.markers.getMarker(A.targetCameraId))!==null&&t!==void 0?t:null}addMarkers(e){return sg(this,void 0,void 0,(function*(){this.markers=new ac([]);const t=[pQ];let A=yield Promise.all(t.map((n=>K.assetManager.loadTexture(n,!1))));for(const n of e.cameras){const r=new re(.25,.25,.25),g=yield K.assetManager.loadTexturedPlaneModel(t[0],gn.getMaterial(Qs,{depthOffset:-.2,color:new rA(1,1,1)}),new re(0,n.floor_vertical_position-n.position.y,0),r,!0);g.position.copy(n.position);const h=new pi;h.id=n.id,h.description=n.description,h.position=n.position,h.rotation=new re(0,0,0),h.model=g,h.textures=A,h.payload=n;const u=n.floor_vertical_position-n.position.y,c=this.createTextLabel(n.id);c.position.set(0,u+.15,0),c.visible=ae.SHOW_NAVIGATION_MARKERS_ID,h.model.add(c),this.idLabels.push(c);const C=this.createPositionLabel(n.position);C.position.set(0,u-.1,0),C.visible=ae.NAVIGATION_MARKERS_EDIT_MODE,h.model.add(C),this.posLabels.push(C),h.model.visible=!1,this.markers.addMarker(h)}}))}addSingleMarker(e,t){return sg(this,void 0,void 0,(function*(){const A=e.id+"_new",n=Object.create(e);n.id=A,n.position=t.clone();const r=[pQ],g=yield Promise.all(r.map((k=>K.assetManager.loadTexture(k,!1)))),h=new re(.25,.25,.25),u=yield K.assetManager.loadTexturedPlaneModel(r[0],gn.getMaterial(Qs,{depthOffset:-.2,color:new rA(1,1,1)}),new re(0,n.floor_vertical_position-n.position.y,0),h,!0);u.position.copy(n.position);const c=new pi;c.id=A,c.description=n.description,c.position=n.position,c.rotation=new re(0,0,0),c.model=u,c.textures=g,c.payload=n;const C=n.floor_vertical_position-n.position.y,B=this.createTextLabel(A);B.position.set(0,C+.15,0),B.visible=ae.SHOW_NAVIGATION_MARKERS_ID,c.model.add(B),this.idLabels.push(B);const p=this.createPositionLabel(n.position);p.position.set(0,C-.1,0),p.visible=ae.NAVIGATION_MARKERS_EDIT_MODE,c.model.add(p),this.posLabels.push(p),c.model.visible=!0,c.isVisible=!0,this.markers.addMarker(c);const w=K.instance.siteManager.siteData;return w&&w.cameras.push(n),c}))}addFloorTransitions(e){return sg(this,void 0,void 0,(function*(){for(const t of e.floorTransitions){const A=yield this.createFloorTransitionMarker(t);this.floorTransitionMarkers.addMarker(A)}}))}addSingleFloorTransition(e){return sg(this,void 0,void 0,(function*(){const t=yield this.createFloorTransitionMarker(e);this.floorTransitionMarkers.addMarker(t);const A=K.instance.siteManager.siteData;return A&&A.floorTransitions.push(e),t}))}getStairTextureUrl(e){return e==="up"?pi.MARKER_APPEARANCES.ICON_STAIRS_UP:pi.MARKER_APPEARANCES.ICON_STAIRS_DOWN}createFloorTransitionMarker(e){return sg(this,void 0,void 0,(function*(){const t=this.getStairTextureUrl(e.direction),A=yield K.assetManager.loadTexture(t,!1),n=new Ri(1,1),r=new Ji({transparent:!0,depthTest:!1,depthWrite:!1,alphaTest:.05}),g=new UA(n,r);g.visible=!1;const h=new pi;if(h.id=e.id,h.description=`Stairs ${e.direction} → ${e.targetCameraId}`,h.position=e.position.clone(),h.rotation=new re(0,0,0),h.type=pi.TYPE_FLOOR_TRANSITION,h.model=g,h.textures=[A],h.payload=e,g.userData.marker=h,ae.isMobile){const B=new Ri(ae.MARKER_HITBOX_SCALE,ae.MARKER_HITBOX_SCALE),p=new Ji({visible:!1}),w=new UA(B,p);w.userData.marker=h,g.add(w)}const u=new gi;u.position.copy(e.position);const c=this.createPositionLabel(e.position);c.position.set(0,.15,0),c.visible=!1,u.add(c),this.floorTransitionPosLabels.push(c);const C=this.createTextLabel(`→ ${e.targetCameraId}`,384,48,"bold 22px Arial");return C.position.set(0,-.15,0),C.visible=!1,u.add(C),this.floorTransitionLabelAnchors.push(u),h}))}getPosLabelForFloorTransitionMarker(e){const t=this.floorTransitionMarkers.data.indexOf(e);return t>=0&&t<this.floorTransitionPosLabels.length?this.floorTransitionPosLabels[t]:null}getFloorTransitionLabelAnchors(){return this.floorTransitionLabelAnchors}hideFloorTransitionMarkers(e=null){for(const t of this.floorTransitionMarkers.data)t!==e&&(t.isVisible=!1,t.model&&(t.model.visible=!1))}pickFloorTransition(e){var t;this.billboardRaycaster.setFromCamera(e,this.billboardOrthoCamera);const A=this.billboardRaycaster.intersectObjects(this.billboardScene.children,!0);for(const n of A){let r=n.object;for(;r;){const g=(t=r.userData)===null||t===void 0?void 0:t.marker;if(g&&this.isFloorTransitionMarker(g))return g;r=r.parent}}return null}renderFloorTransitionBillboards(e){this.billboardScene.children.length!==0&&(K.renderer.setRenderTarget(e),K.renderer.render(this.billboardScene,this.billboardOrthoCamera))}syncFloorTransitionLabelAnchors(e,t,A){for(const n of this.floorTransitionLabelAnchors)e.remove(n);t&&A&&this.floorTransitionMarkers.data.forEach(((n,r)=>{const g=n.payload;if(!(g.sourceCameraId?g.sourceCameraId===A.id:g.floorLevel===A.floorLevel))return;const h=this.floorTransitionLabelAnchors[r];h&&(h.position.copy(n.position),h.children.forEach((u=>{u.visible=!0})),e.add(h))}))}createPositionLabel(e){const t=`${e.x.toFixed(2)}, ${e.y.toFixed(2)}, ${e.z.toFixed(2)}`;return this.createTextLabel(t,512,64,"bold 28px Arial")}updatePositionLabel(e,t){const A=document.createElement("canvas"),n=A.getContext("2d");A.width=512,A.height=64,n.fillStyle="rgba(0, 0, 0, 0.6)",n.roundRect(0,0,A.width,A.height,8),n.fill(),n.font="bold 28px Arial",n.fillStyle="#00ff88",n.textAlign="center",n.textBaseline="middle",n.fillText(`${t.x.toFixed(2)}, ${t.y.toFixed(2)}, ${t.z.toFixed(2)}`,A.width/2,A.height/2);const r=e.material.map;r&&r.dispose();const g=new wB(A);e.material.map=g,e.material.needsUpdate=!0}getPosLabelForMarker(e){const t=this.markers.data.indexOf(e);return t>=0&&t<this.posLabels.length?this.posLabels[t]:null}createTextLabel(e,t=256,A=64,n="bold 32px Arial"){const r=document.createElement("canvas"),g=r.getContext("2d");r.width=t,r.height=A,g.fillStyle="rgba(0, 0, 0, 0.6)",g.roundRect(0,0,r.width,r.height,8),g.fill(),g.font=n,g.fillStyle="white",g.textAlign="center",g.textBaseline="middle",g.fillText(e,r.width/2,r.height/2);const h=new wB(r),u=new tB({map:h,transparent:!0,depthTest:!1}),c=new US(u);return c.scale.set(t/512,A/512,1),c}isHelperMarker(e){return this.autoOverrideMarkerIds.has(e.id)}getHelperMarkerColor(){const[e,t,A]=ae.NAV_HELPER_MARKER_RGB;return Kn.helperMarkerColor.setRGB(e,t,A),Kn.helperMarkerColor}applyDepthOverride(e,t){e.model.visible=!0;const A=e.model,n=A.material;if(n?.uniforms){A.userData.overrideMaterial||(A.userData.overrideMaterial=n.clone(),A.userData.originalMaterial=n),A.material=A.userData.overrideMaterial;const r=A.material,g=K.userData.cameraSmooth.position.distanceTo(e.model.position);r.uniforms.depthOffset.value=.01-g,r.uniforms.color&&r.uniforms.color.value.copy(t)}}restoreOriginalMaterial(e){const t=e.model;t.userData.originalMaterial&&(t.material=t.userData.originalMaterial,t.userData.overrideMaterial=null,t.userData.helperMaterial=null,t.userData.originalMaterial=null)}getMarkerMap(e){var t,A,n,r;const g=(t=e.userData.originalMaterial)!==null&&t!==void 0?t:e.material;return(r=(n=(A=g?.uniforms)===null||A===void 0?void 0:A.map)===null||n===void 0?void 0:n.value)!==null&&r!==void 0?r:null}applyHelperMarker(e){e.isVisible=!0;const t=e.model;t.userData.originalMaterial||(t.userData.originalMaterial=t.material);let A=t.userData.helperMaterial;if(!A){A=gn.getMaterial(r_,{depthOffset:-.2,color:this.getHelperMarkerColor()});const r=this.getMarkerMap(t);r&&A.uniforms.map&&(A.uniforms.map.value=r),t.userData.helperMaterial=A}A.uniforms.color.value.copy(this.getHelperMarkerColor());const n=K.userData.cameraSmooth.position.distanceTo(e.model.position);A.uniforms.depthOffset.value=.01-n,t.material=A,e.model.visible=!0}isSameFloorAsCurrent(e,t){if(!t)return!0;const A=e.payload;return A==null||A.floorLevel==null||t.floorLevel==null||A.floorLevel===t.floorLevel}isEligibleMarker(e,t){return(!t||e.id!==t.id)&&this.isSameFloorAsCurrent(e,t)}clearAutoFallbackHelpers(){if(this.autoOverrideMarkerIds.size!==0){for(const e of this.autoOverrideMarkerIds){const t=this.markers.data.find((A=>A.id===e));t&&this.restoreOriginalMaterial(t)}this.autoOverrideMarkerIds.clear()}}hideMarker(e){e.model.visible=!1,e.isVisible=!1,this.autoOverrideMarkerIds.delete(e.id),this.restoreOriginalMaterial(e)}showWhitelistedMarker(e,t=Kn.naturalMarkerColor){this.applyDepthOverride(e,t),e.isVisible=!0}cacheMarkerScreenPos(e){const t=K.userData.cameraSmooth;e.model.updateWorldMatrix(!0,!1),new Mi().setFromObject(e.model).getCenter(this.worldCenter),this.worldCenter.project(t),e.screenPos||(e.screenPos=new Gt),e.screenPos.set(this.worldCenter.x,this.worldCenter.y)}updateNaturalVisibility(e,t){this.restoreOriginalMaterial(e);const A=e.setIsVisible(t);return e.model.visible=A,A}snapshotNaturalVisibility(){const e=K.userData.siteCamera,t=this.siteManager.getCurrentPanoramaData(),A=[];for(const n of this.markers.data)this.isEligibleMarker(n,e)&&this.updateNaturalVisibility(n,t)&&A.push(n.id);return A}updateWhitelistMarkers(e,t,A){this.clearAutoFallbackHelpers();const n=new Set(t);for(const r of this.markers.data)if(this.isEligibleMarker(r,e))if(n.has(r.id)){const g=A?Kn.whitelistEditActiveColor:Kn.naturalMarkerColor;this.showWhitelistedMarker(r,g),A&&this.cacheMarkerScreenPos(r)}else A?(this.showWhitelistedMarker(r,Kn.whitelistEditDimColor),r.isVisible=!1,this.cacheMarkerScreenPos(r)):this.hideMarker(r);else this.hideMarker(r)}updateWhitelistEditPreview(e){var t;const A=(t=e.whitelist)!==null&&t!==void 0?t:[];this.updateWhitelistMarkers(e,A,!0)}isFloorTransitionVisibleFromCamera(e,t){if(!t)return!1;const A=e.payload;return!!A&&(A.sourceCameraId?A.sourceCameraId===t.id:A.floorLevel!=null&&t.floorLevel!=null&&A.floorLevel===t.floorLevel)}updateFloorTransitionMarkers(e,t){for(;this.billboardScene.children.length>0;)this.billboardScene.remove(this.billboardScene.children[0]);if(t){for(const h of this.floorTransitionMarkers.data)h.isVisible=!1,h.model&&(h.model.visible=!1);return}const A=this.siteManager.getCurrentPanoramaData(),n=K.userData.cameraSmooth.position,r=K.getCurrentCanvasSize(),g=r.width/r.height;for(const h of this.floorTransitionMarkers.data){if(h.update(),h.isVisible=!1,h.model&&(h.model.visible=!1),!this.isFloorTransitionVisibleFromCamera(h,e))continue;this.billboardDirection.subVectors(h.position,n);const u=this.billboardDirection.length();if(this.billboardDirection.normalize(),A.depth.getDepth(this.billboardDirection)<=u-.5)continue;const c=h.model,C=c.material;C.color.set(16777215);const B=h.textures[h.textureIndex],p=B?.image,w=p?.width&&p?.height?p.width/p.height:1;if(C.map=B,C.needsUpdate=!0,this.billboardProjected.copy(h.position).project(K.userData.cameraSmooth),c.position.set(this.billboardProjected.x,this.billboardProjected.y,this.billboardProjected.z),this.billboardProjected.z<-1||this.billboardProjected.z>1)continue;const k=ae.getFloorTransitionMarkerSize();c.scale.set(k,k*g*w,1),c.visible=!0,h.isVisible=!0,this.billboardScene.add(c)}}update(){const e=ae.SHOW_NAVIGATION_MARKERS_ID;this.idLabels.forEach((N=>N.visible=e));const t=ae.NAVIGATION_MARKERS_EDIT_MODE,A=ae.NAVIGATION_MARKERS_WHITELIST_MODE;this.posLabels.forEach((N=>N.visible=t)),this.floorTransitionPosLabels.forEach((N=>N.visible=t));const n=this.markers.data.length,r=K.userData.siteCamera,g=K.instance.siteManager.isLoading();if(r?.id!==this.lastNavCameraId&&(this.clearAutoFallbackHelpers(),this.lastNavCameraId=r?.id,this.validatorIndex=0),A&&r)return this.markers.data.forEach((N=>N.update())),g||this.updateWhitelistEditPreview(r),void this.updateFloorTransitionMarkers(r,g);if(Xo.hasWhitelist(r))return this.markers.data.forEach((N=>N.update())),!g&&r&&this.updateWhitelistMarkers(r,r.whitelist,!1),void this.updateFloorTransitionMarkers(r,g);if(n===0)return void this.updateFloorTransitionMarkers(r,g);if(this.markers.data.forEach(((N,L)=>{if(N.update(),!(t||g)){if(!this.isEligibleMarker(N,r))return void this.hideMarker(N);this.autoOverrideMarkerIds.has(N.id)?this.applyHelperMarker(N):L===this.validatorIndex&&this.updateNaturalVisibility(N,this.siteManager.getCurrentPanoramaData())}})),this.validatorIndex=(this.validatorIndex+1)%n,this.validatorIndex!==0||t||g)return void this.updateFloorTransitionMarkers(r,g);const h=this.siteManager.getCurrentPanoramaData(),u=new Set;for(const N of this.markers.data)this.isEligibleMarker(N,r)&&this.updateNaturalVisibility(N,h)&&u.add(N.id);const c=u.size,C=Math.max(0,0|ae.NAV_MIN_NATURAL_VISIBLE);if(c>=C)return this.autoOverrideMarkerIds.size>0&&(ae.NAV_FALLBACK_DEBUG&&console.debug("[nav-fallback] deactivated",{from:r?.id,naturalVisibleCount:c,minNaturalVisible:C,naturallyVisibleIds:[...u]}),this.clearAutoFallbackHelpers()),void this.updateFloorTransitionMarkers(r,g);const B=K.userData.cameraSmooth.position,p=[];for(const N of this.markers.data)this.isEligibleMarker(N,r)&&(u.has(N.id)||p.push({id:N.id,dist:B.distanceTo(N.model.position)}));p.sort(((N,L)=>N.dist-L.dist));const w=Math.max(0,C-c),k=Math.max(0,Math.min(0|ae.NAV_FALLBACK_COUNT,w)),R=Math.min(k,p.length);if(R===0){ae.NAV_FALLBACK_DEBUG&&console.debug("[nav-fallback] no eligible candidates",{from:r?.id,keeping:[...this.autoOverrideMarkerIds],naturalVisibleCount:c,minNaturalVisible:C,requested:k,naturallyVisibleIds:[...u]});for(const N of this.autoOverrideMarkerIds){const L=this.markers.data.find((G=>G.id===N));L&&this.applyHelperMarker(L)}return void this.updateFloorTransitionMarkers(r,g)}const _=new Set(p.slice(0,R).map((N=>N.id)));for(const N of this.autoOverrideMarkerIds)if(!_.has(N)){const L=this.markers.data.find((G=>G.id===N));L&&this.restoreOriginalMaterial(L)}for(const N of _){const L=this.markers.data.find((G=>G.id===N));L&&this.applyHelperMarker(L)}ae.NAV_FALLBACK_DEBUG&&(_.size!==this.autoOverrideMarkerIds.size||[..._].some((L=>!this.autoOverrideMarkerIds.has(L))))&&console.debug("[nav-fallback] activated",{from:r?.id,ids:[..._],candidateCount:p.length,naturalVisibleCount:c,minNaturalVisible:C,requested:k,naturallyVisibleIds:[...u]}),this.autoOverrideMarkerIds=_,this.updateFloorTransitionMarkers(r,g)}}Kn.naturalMarkerColor=new rA(1,1,1),Kn.whitelistEditDimColor=new rA(.45,.45,.5),Kn.whitelistEditActiveColor=new rA(.35,.75,1),Kn.helperMarkerColor=new rA(1,1,1);class xi{constructor(e=xi.LAYER_TYPE_DEFAULT){this.renderTextureScaler=1,this.isActive=!0,this.alpha=1,this.needRender=!0,window.addEventListener("beforeunload",(()=>this.cleanup())),this.type=e}getScaledCanvasSize(){const{width:e,height:t}=K.getCurrentCanvasSize();return{width:Math.floor(e*this.renderTextureScaler),height:Math.floor(t*this.renderTextureScaler)}}get renderTexture(){const{width:e,height:t}=this.getScaledCanvasSize();return this._renderTexture&&this._renderTexture.width===e&&this._renderTexture.height===t||(this._renderTexture&&this._renderTexture.dispose(),this._renderTexture=new ei(e,t,{type:mt,wrapS:Ce,wrapT:Ce,minFilter:Be,magFilter:Be}),this.needRender=!0),this._renderTexture}update(){}cleanup(){var e;(e=this._renderTexture)===null||e===void 0||e.dispose(),this._renderTexture=void 0}}xi.LAYER_TYPE_DEFAULT=0,xi.LAYER_TYPE_ADDITIVE=1,xi.LAYER_TYPE_MULTIPLY=2,xi.LAYER_TYPE_ANIMATED_MARKERS=3,xi.LAYER_TYPE_NO_DEPTH=4;class dn extends xi{constructor(e){super(xi.LAYER_TYPE_NO_DEPTH),this.raycaster=new Zo,this.markers=e,this.scene=new Rn,this.initOrthographicCamera()}initOrthographicCamera(){this.orthoCamera=new _n(-1,1,1,-1,1,1e3),this.orthoCamera.position.set(0,0,10),this.orthoCamera.lookAt(0,0,0)}getClosestMouseOverMarker(){const e=Ve.MousePositionNormalized;this.raycaster.setFromCamera(e,this.orthoCamera);const t=this.raycaster.intersectObjects(this.scene.children,!0);let A=null,n=1/0;return t.forEach((r=>{r.object.userData.marker&&r.object.visible&&r.distance<n&&(n=r.distance,A=r.object.userData.marker)})),A}update(){for(dn.selectedMarker=this.getClosestMouseOverMarker();this.scene.children.length>0;)this.scene.remove(this.scene.children[0]);if(!ae.SHOW_MARKERS)return;const e=K.instance.siteManager.getCurrentPanoramaData(),t=K.userData.cameraSmooth.position,A=new re;this.markers.data.forEach((n=>{if(!n.model){const h=new Ri(1,1),u=new Ji({transparent:!0,depthTest:!1}),c=new UA(h,u);if(ae.isMobile){const C=new Ri(ae.MARKER_HITBOX_SCALE,ae.MARKER_HITBOX_SCALE),B=new Ji({visible:!1}),p=new UA(C,B);p.userData.marker=n,c.add(p)}c.userData.marker=n,n.model=c}const r=K.getCurrentCanvasSize(),g=r.width/r.height;if(n.model.visible=n.isVisible,n.isVisible){A.subVectors(n.position,t);const h=A.length();if(A.normalize(),e.depth.getDepth(A)>h-.5){const u=n.model.material;if(n===dn.selectedMarker)u.color.set(16711680);else if(K.playerPlugins.markerEditor&&n===K.playerPlugins.markerEditor.selectedMarker){const p=Math.floor(127*(.5*Math.sin(8*K.time)+.5))+127;u.color.set(p<<16|p<<8|p)}else u.color.set(16777215);const c=n.textures[n.textureIndex],C=c.image.width/c.image.height;u.map=c,u.needsUpdate=!0;const B=n.position.clone().project(K.userData.cameraSmooth);n.model.position.set(B.x,B.y,B.z),B.z>=-1&&B.z<=1&&this.scene.add(n.model),n.model.scale.set(ae.MARKER_SIZE,ae.MARKER_SIZE*g*C,1)}}})),dn.selectedMarker&&Ve.MousePick&&K.playerPlugins.markerActions.executeAction(dn.selectedMarker).then((n=>{n||K.playerAPI.setPickedMarker(dn.selectedMarker,Ve.MousePositionNormalized.clone())})).catch((n=>{})),K.renderer.setClearColor(0,0),K.renderer.setRenderTarget(this.renderTexture),K.renderer.render(this.scene,this.orthoCamera),K.renderer.setRenderTarget(null)}}dn.selectedMarker=null;class qa{constructor(e,t){this.arrowLayer=e,this.navigationLayer=t}static calculateMouseHitpoint(e,t,A){this.raycaster.setFromCamera(t,e),this.hitPlane.constant=-A;let n=new re,r=this.raycaster.ray.intersectPlane(this.hitPlane,n),g=!0;if(!r){g=!1;const u=e.position.y+(e.position.y-A);this.hitPlane.constant=-u,r=this.raycaster.ray.intersectPlane(this.hitPlane,n)}let h=new re(n.x-e.position.x,0,n.z-e.position.z);return h.normalize(),{hitPoint:n,directionXZ:h,isFloor:g}}update(){if(!K.userData.siteCamera)return;let e,t=qa.calculateMouseHitpoint(K.userData.cameraSmooth,Ve.MousePositionNormalized,K.userData.siteCamera.floor_vertical_position);this.arrowLayer&&this.arrowLayer.updateArrowPosition(K.userData.cameraSmooth,t.hitPoint,t.directionXZ,t.isFloor);const A=ae.isNavigationMarkerPlacementMode();if(dn.selectedMarker||!Ve.MousePick||this.navigationLayer.getPickedMarker()||ae.NAVIGATION_MARKERS_WHITELIST_MODE||A||(e=this.navigationLayer.pick(),e||(e=this.navigationLayer.pickClosest(K.userData.cameraSmooth.position,t.hitPoint)),e||t.isFloor||(e=this.navigationLayer.pickRaymarch(K.userData.cameraSmooth.position,t.directionXZ))),!e&&!A){const n=new re(Math.sin(K.userData.camera.rotation.y),0,Math.cos(K.userData.camera.rotation.y));if(Ve.GetKeyUp("KeyW")||Ve.GetKeyUp("ArrowUp"))e=this.navigationLayer.pickRaymarch(K.userData.cameraSmooth.position,n.multiplyScalar(-1));else if(Ve.GetKeyUp("KeyS")||Ve.GetKeyUp("ArrowDown"))e=this.navigationLayer.pickRaymarch(K.userData.cameraSmooth.position,n);else if(Ve.GetKeyUp("KeyA")||Ve.GetKeyUp("ArrowLeft")){const r=new re;r.crossVectors(n,new re(0,1,0)).normalize(),e=this.navigationLayer.pickRaymarch(K.userData.cameraSmooth.position,r)}else if(Ve.GetKeyUp("KeyD")||Ve.GetKeyUp("ArrowRight")){const r=new re;r.crossVectors(n,new re(0,-1,0)).normalize(),e=this.navigationLayer.pickRaymarch(K.userData.cameraSmooth.position,r)}}e&&this.navigationLayer.setPickedMarker(e)}}qa.raycaster=new Zo,qa.hitPlane=new Er(new re(0,1,0),0);var mQ=function(o,e,t,A){return new(t||(t=Promise))((function(n,r){function g(c){try{u(A.next(c))}catch(C){r(C)}}function h(c){try{u(A.throw(c))}catch(C){r(C)}}function u(c){var C;c.done?n(c.value):(C=c.value,C instanceof t?C:new t((function(B){B(C)}))).then(g,h)}u((A=A.apply(o,[])).next())}))};class En extends xi{constructor(e,t=xi.LAYER_TYPE_ANIMATED_MARKERS){super(t),this.pickedMarker=null,this.pickedMarkerBehaviour=0,this.draggedMarker=null,this.lastDraggedMarker=null,this.onWhitelistChanged=null,this.onStairPlacementComplete=null,this.dragFloorY=0,this.dragOffset=new re,this.dragHit=new re,this.dragFloorPlane=new Er,this.projectedPos=new re,this.addModeDropdownOpen=!1,this.addModeMouseWasDown=!1,this.addStairModeMouseWasDown=!1,this.navigationMarkers=e,this.scene=new Rn,this.raycaster=new Zo,this.navigationMarkers.markers.data.forEach((A=>{let n=A.model;n.userData.marker=A,this.scene.add(n)}))}hideMarkers(e=null,t=!0){this.navigationMarkers.markers.data.forEach((A=>{A!==e&&(A.isVisible=!1,t&&(A.model.visible=!1))})),this.navigationMarkers.hideFloorTransitionMarkers(this.navigationMarkers.isFloorTransitionMarker(e)?e:null)}setPickedMarker(e,t=!1){if(!K.instance.siteManager.isLoading()||t||!e){if(e&&this.navigationMarkers.isFloorTransitionMarker(e)){const A=this.navigationMarkers.getTargetNavigationMarker(e);if(!A)return void e.id;e=A,this.pickedMarkerBehaviour=En.TRANSITION_BEHAVIOUR_CAM_ROTATE}else this.pickedMarkerBehaviour=0;this.pickedMarker=e}}getPickedMarker(){return this.pickedMarker}pick(){const e=Ve.MousePositionNormalized.clone();this.raycaster.setFromCamera(e,K.userData.cameraSmooth);const t=this.scene.children.filter((n=>n.visible));let A=this.raycaster.intersectObjects(t,!0);for(const n of A){let r=n.object;for(;r;){if(r.userData.marker)return r.userData.marker;r=r.parent}}return this.navigationMarkers.pickFloorTransition(e)}pickScreenSpace(e,t,A,n=!1){var r;const g=K.userData.cameraSmooth,h=K.canvas.getBoundingClientRect(),u=(.5*t.x+.5)*h.width,c=(.5*-t.y+.5)*h.height;let C=null,B=e*e;for(const p of this.navigationMarkers.markers.data){if(!(!((r=p.model)===null||r===void 0)&&r.visible)||!A(p)||(n&&p.screenPos?this.projectedPos.set(p.screenPos.x,p.screenPos.y,0):(p.model.updateWorldMatrix(!0,!1),new Mi().setFromObject(p.model).getCenter(this.projectedPos),this.projectedPos.project(g)),this.projectedPos.z<-1||this.projectedPos.z>1))continue;const w=(.5*this.projectedPos.x+.5)*h.width-u,k=(.5*-this.projectedPos.y+.5)*h.height-c,R=w*w+k*k;R<B&&(B=R,C=p)}return C}pickFloorWhitelist(e,t,A){var n;const r=Number(e.floor_vertical_position),g=qa.calculateMouseHitpoint(K.userData.cameraSmooth,t,r);let h=null,u=Math.pow(En.WHITELIST_FLOOR_PICK_RADIUS,2);for(const c of this.navigationMarkers.markers.data){if(!(!((n=c.model)===null||n===void 0)&&n.visible)||!A(c))continue;const C=c.position.x-g.hitPoint.x,B=c.position.z-g.hitPoint.z,p=C*C+B*B;p<u&&(u=p,h=c)}return h}pickWhitelistEdit(e,t){const A=r=>this.isWhitelistEditEligible(r,e);return this.pickScreenSpace(En.WHITELIST_PICK_RADIUS_PX,t,A,!0)||this.pickFloorWhitelist(e,t,A)}isWhitelistEditEligible(e,t){if(e.id===t.id)return!1;const A=e.payload;return A?.floorLevel==null||t.floorLevel==null||A.floorLevel===t.floorLevel}isDirectionNavigationMarker(e){return e.isVisible&&!this.navigationMarkers.isHelperMarker(e)&&!this.navigationMarkers.isFloorTransitionMarker(e)}pickClosest(e,t){const A=this.scene.children.filter((g=>g.visible));let n=null,r=1/0;return A.forEach((g=>{if(g.position.x===e.x&&g.position.y===e.y&&g.position.z===e.z)return;const h=g.userData.marker;if(!h||!this.isDirectionNavigationMarker(h))return;let u=t.distanceTo(g.position);u<r&&(r=u,n=h)})),n}pickRaymarch(e,t){let A=null,n=1/0;for(const r of this.navigationMarkers.markers.data)if(this.isDirectionNavigationMarker(r)){let g=e.distanceTo(r.position);if(g>.1){let h=new re().subVectors(r.position,e);if(h.dot(t)>0){let u=.1*g+h.cross(t).length();u<n&&(n=u,A=r)}}}return A}addMarkerToScene(e){e.model.userData.marker=e,this.scene.add(e.model)}update(){ae.SHOW_ARROW_AND_MARKERS||this.hideMarkers(),ae.NAVIGATION_MARKERS_EDIT_MODE&&this.updateEditModeDrag(),ae.NAVIGATION_MARKERS_ADD_MODE&&this.updateAddMode(),ae.NAVIGATION_MARKERS_ADD_STAIR_UP_MODE&&this.updateAddStairMode("up"),ae.NAVIGATION_MARKERS_ADD_STAIR_DOWN_MODE&&this.updateAddStairMode("down"),K.renderer.setClearColor(0,0),this.navigationMarkers.update(),this.navigationMarkers.syncFloorTransitionLabelAnchors(this.scene,ae.NAVIGATION_MARKERS_EDIT_MODE,K.userData.siteCamera),ae.NAVIGATION_MARKERS_WHITELIST_MODE&&this.updateWhitelistEditClick(),this.mixer&&this.mixer.update(K.deltaTime),K.renderer.setRenderTarget(this.renderTexture),K.renderer.render(this.scene,K.userData.cameraSmooth),K.renderer.setRenderTarget(null)}getMarkerFloorY(e){if(this.navigationMarkers.isFloorTransitionMarker(e))return e.position.y;const t=e.payload;return t?.floor_vertical_position!=null?t.floor_vertical_position:e.model.position.y}beginMarkerDrag(e){this.dragFloorY=this.getMarkerFloorY(e),this.dragOffset.set(0,0,0);const t=Ve.MousePositionNormalized.clone();this.raycaster.setFromCamera(t,K.userData.cameraSmooth),this.dragFloorPlane.set(En.UP,-this.dragFloorY),this.raycaster.ray.intersectPlane(this.dragFloorPlane,this.dragHit)&&(this.dragOffset.subVectors(e.model.position,this.dragHit),this.dragOffset.y=0)}setMarkerWorldPosition(e,t){this.commitMarkerPosition(e,t),this.lastDraggedMarker=e}alignMarkerToPreviousScanPosition(e,t){this.commitMarkerPosition(e,t);const A=e.payload;A&&(A.floor_vertical_position=t.y-1.3),this.lastDraggedMarker=e}commitMarkerPosition(e,t){if(e.position.copy(t),this.navigationMarkers.isFloorTransitionMarker(e)){e.payload.position.copy(t);const n=this.navigationMarkers.floorTransitionMarkers.data.indexOf(e),r=this.navigationMarkers.getFloorTransitionLabelAnchors()[n];r&&r.position.copy(t)}else e.model.position.copy(t),e.payload&&e.payload.position.copy(t);const A=this.navigationMarkers.isFloorTransitionMarker(e)?this.navigationMarkers.getPosLabelForFloorTransitionMarker(e):this.navigationMarkers.getPosLabelForMarker(e);A&&this.navigationMarkers.updatePositionLabel(A,t)}applyMarkerDragXZ(e){const t=this.navigationMarkers.isFloorTransitionMarker(e)?e.position.y:e.model.position.y,A=Ve.MousePositionNormalized.clone();if(this.raycaster.setFromCamera(A,K.userData.cameraSmooth),this.dragFloorPlane.set(En.UP,-this.dragFloorY),this.raycaster.ray.intersectPlane(this.dragFloorPlane,this.dragHit))return this.dragHit.add(this.dragOffset),this.dragHit.y=t,void this.commitMarkerPosition(e,this.dragHit);this.applyMarkerDragFloorDelta(e,t)}applyMarkerDragFloorDelta(e,t){const A=Ve.MouseDragDelta;if(A.x===0&&A.y===0)return;const n=K.userData.cameraSmooth,r=n.rotation.y,g=new re(Math.sin(r),0,Math.cos(r)),h=new re().crossVectors(g,En.UP).normalize(),u=n.position.distanceTo(e.model.position)*Math.tan(n.fov*Math.PI/180/2)*(2/K.canvas.clientHeight),c=e.model.position;c.x+=h.x*A.x*u-g.x*A.y*u,c.z+=h.z*A.x*u-g.z*A.y*u,c.y=t,this.commitMarkerPosition(e,c)}updateWhitelistEditClick(){var e;if(!Ve.wasMouseButtonPressed(0)||Ve.consumeDrag)return;const t=K.userData.siteCamera;if(!t)return;const A=Ve.getMouseDownPositionNormalized(),n=this.pickWhitelistEdit(t,A);n&&(t.toggleWhitelistMarker(n.id),(e=this.onWhitelistChanged)===null||e===void 0||e.call(this),t.id,t.whitelist.length,t.whitelist)}updateEditModeDrag(){const e=Ve.GetMouseButtonDown(0),t=Ve.GetMouseButton(0),A=Ve.GetMouseButtonUp(0),n=K.canvas;if(e&&!this.draggedMarker){const r=this.pick();r&&(this.draggedMarker=r,this.beginMarkerDrag(r),Ve.consumeDrag=!0,n.style.cursor="grabbing")}if(this.draggedMarker&&t&&this.applyMarkerDragXZ(this.draggedMarker),A&&this.draggedMarker&&(Ve.consumeDrag=!1,this.lastDraggedMarker=this.draggedMarker,this.draggedMarker=null,n.style.cursor=""),!this.draggedMarker&&!t){const r=this.pick();n.style.cursor=r?"grab":""}}updateAddMode(){if(this.addModeDropdownOpen)return;if(Ve.GetMouseButton(0))return void(this.addModeMouseWasDown=!0);if(!this.addModeMouseWasDown||(this.addModeMouseWasDown=!1,this.pick()))return;const e=K.instance.screenToWorld(Ve.MousePositionNormalized);if(!e)return;const t=K.instance.siteManager.siteData;t&&(this.addModeDropdownOpen=!0,this.showCameraDropdown(e,t.cameras))}showCameraDropdown(e,t){const A=Ve.MousePositionLocal,n=document.createElement("div");n.style.cssText=`
|
|
4379
4379
|
position: absolute; left: ${A.x}px; top: ${A.y}px;
|
|
4380
4380
|
z-index: 10000; background: #222; border: 1px solid #555;
|
|
4381
4381
|
border-radius: 4px; padding: 8px; font-family: monospace; font-size: 13px;
|