@qispace/vue3-player 0.4.63 → 0.4.64
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.
|
@@ -24518,7 +24518,7 @@ void main() {
|
|
|
24518
24518
|
const I = h.split(",").map(Number);
|
|
24519
24519
|
return I.length !== 3 || I.some(((c) => !Number.isFinite(c))) ? null : new re(I[0], I[1], I[2]);
|
|
24520
24520
|
})(n[r]);
|
|
24521
|
-
g ? e.position.
|
|
24521
|
+
g ? e.position.set(t.x + g.x, A.y, t.z + g.z) : e.position.copy(A);
|
|
24522
24522
|
}
|
|
24523
24523
|
function Ah(o, e) {
|
|
24524
24524
|
o.position.copy(e);
|
|
@@ -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 Wi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const R=new Ut(k,p),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=f;let N=this.type;function L(ne,te){const Ae=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(te,null,Ae,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(te,null,Ae,w,R,null)}function G(ne,te,Ae,ye){let ge=null;const Me=Ae.isPointLight===!0?ne.customDistanceMaterial:ne.customDepthMaterial;if(Me!==void 0)ge=Me;else if(ge=Ae.isPointLight===!0?u:h,o.localClippingEnabled&&te.clipShadows===!0&&Array.isArray(te.clippingPlanes)&&te.clippingPlanes.length!==0||te.displacementMap&&te.displacementScale!==0||te.alphaMap&&te.alphaTest>0||te.map&&te.alphaTest>0){const pe=ge.uuid,Ze=te.uuid;let CA=c[pe];CA===void 0&&(CA={},c[pe]=CA);let QA=CA[Ze];QA===void 0&&(QA=ge.clone(),CA[Ze]=QA),ge=QA}return ge.visible=te.visible,ge.wireframe=te.wireframe,ge.side=ye===Q?te.shadowSide!==null?te.shadowSide:te.side:te.shadowSide!==null?te.shadowSide:E[te.side],ge.alphaMap=te.alphaMap,ge.alphaTest=te.alphaTest,ge.map=te.map,ge.clipShadows=te.clipShadows,ge.clippingPlanes=te.clippingPlanes,ge.clipIntersection=te.clipIntersection,ge.displacementMap=te.displacementMap,ge.displacementScale=te.displacementScale,ge.displacementBias=te.displacementBias,ge.wireframeLinewidth=te.wireframeLinewidth,ge.linewidth=te.linewidth,Ae.isPointLight===!0&&ge.isMeshDistanceMaterial===!0&&(o.properties.get(ge).light=Ae),ge}function le(ne,te,Ae,ye,ge){if(ne.visible===!1)return;if(ne.layers.test(te.layers)&&(ne.isMesh||ne.isLine||ne.isPoints)&&(ne.castShadow||ne.receiveShadow&&ge===Q)&&(!ne.frustumCulled||t.intersectsObject(ne))){ne.modelViewMatrix.multiplyMatrices(Ae.matrixWorldInverse,ne.matrixWorld);const pe=e.update(ne),Ze=ne.material;if(Array.isArray(Ze)){const CA=pe.groups;for(let QA=0,VA=CA.length;QA<VA;QA++){const fA=CA[QA],MA=Ze[fA.materialIndex];if(MA&&MA.visible){const RA=G(ne,MA,ye,ge);o.renderBufferDirect(Ae,null,pe,RA,ne,fA)}}}else if(Ze.visible){const CA=G(ne,Ze,ye,ge);o.renderBufferDirect(Ae,null,pe,CA,ne,null)}}const Me=ne.children;for(let pe=0,Ze=Me.length;pe<Ze;pe++)le(Me[pe],te,Ae,ye,ge)}this.render=function(ne,te,Ae){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,CA=N===Q&&this.type!==Q;for(let QA=0,VA=ne.length;QA<VA;QA++){const fA=ne[QA],MA=fA.shadow;if(MA===void 0||MA.autoUpdate===!1&&MA.needsUpdate===!1)continue;n.copy(MA.mapSize);const RA=MA.getFrameExtents();if(n.multiply(RA),r.copy(MA.mapSize),(n.x>C||n.y>C)&&(n.x>C&&(r.x=Math.floor(C/RA.x),n.x=r.x*RA.x,MA.mapSize.x=r.x),n.y>C&&(r.y=Math.floor(C/RA.y),n.y=r.y*RA.y,MA.mapSize.y=r.y)),MA.map===null||Ze===!0||CA===!0){const Ye=this.type!==Q?{minFilter:Ee,magFilter:Ee}:{};MA.map!==null&&MA.map.dispose(),MA.map=new ei(n.x,n.y,Ye),MA.map.texture.name=fA.name+".shadowMap",MA.camera.updateProjectionMatrix()}o.setRenderTarget(MA.map),o.clear();const FA=MA.getViewportCount();for(let Ye=0;Ye<FA;Ye++){const dA=MA.getViewport(Ye);g.set(r.x*dA.x,r.y*dA.y,r.x*dA.z,r.y*dA.w),pe.viewport(g),MA.updateMatrices(fA,Ye),t=MA.getFrustum(),le(te,Ae,MA.camera,fA,this.type)}MA.isPointLightShadow!==!0&&this.type===Q&&L(MA,Ae),MA.needsUpdate=!1}N=this.type,_.needsUpdate=!1,o.setRenderTarget(ye,ge,Me)}}function bS(o,e,A){const t=A.isWebGL2,n=new function(){let oe=!1;const Te=new zt;let cA=null;const SA=new zt(0,0,0,0);return{setMask:function(hA){cA===hA||oe||(o.colorMask(hA,hA,hA,hA),cA=hA)},setLocked:function(hA){oe=hA},setClear:function(hA,KA,HA,_A,Ct){Ct===!0&&(hA*=_A,KA*=_A,HA*=_A),Te.set(hA,KA,HA,_A),SA.equals(Te)===!1&&(o.clearColor(hA,KA,HA,_A),SA.copy(Te))},reset:function(){oe=!1,cA=null,SA.set(-1,0,0,0)}}},r=new function(){let oe=!1,Te=null,cA=null,SA=null;return{setTest:function(hA){hA?XA(o.DEPTH_TEST):ce(o.DEPTH_TEST)},setMask:function(hA){Te===hA||oe||(o.depthMask(hA),Te=hA)},setFunc:function(hA){if(cA!==hA){switch(hA){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)}cA=hA}},setLocked:function(hA){oe=hA},setClear:function(hA){SA!==hA&&(o.clearDepth(hA),SA=hA)},reset:function(){oe=!1,Te=null,cA=null,SA=null}}},g=new function(){let oe=!1,Te=null,cA=null,SA=null,hA=null,KA=null,HA=null,_A=null,Ct=null;return{setTest:function(ht){oe||(ht?XA(o.STENCIL_TEST):ce(o.STENCIL_TEST))},setMask:function(ht){Te===ht||oe||(o.stencilMask(ht),Te=ht)},setFunc:function(ht,J,$){cA===ht&&SA===J&&hA===$||(o.stencilFunc(ht,J,$),cA=ht,SA=J,hA=$)},setOp:function(ht,J,$){KA===ht&&HA===J&&_A===$||(o.stencilOp(ht,J,$),KA=ht,HA=J,_A=$)},setLocked:function(ht){oe=ht},setClear:function(ht){Ct!==ht&&(o.clearStencil(ht),Ct=ht)},reset:function(){oe=!1,Te=null,cA=null,SA=null,hA=null,KA=null,HA=null,_A=null,Ct=null}}},h=new WeakMap,u=new WeakMap;let c={},C={},E=new WeakMap,p=[],w=null,k=!1,R=null,_=null,N=null,L=null,G=null,le=null,ne=null,te=!1,Ae=null,ye=null,ge=null,Me=null,pe=null;const Ze=o.getParameter(o.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let CA=!1,QA=0;const VA=o.getParameter(o.VERSION);VA.indexOf("WebGL")!==-1?(QA=parseFloat(/^WebGL (\d)/.exec(VA)[1]),CA=QA>=1):VA.indexOf("OpenGL ES")!==-1&&(QA=parseFloat(/^OpenGL ES (\d)/.exec(VA)[1]),CA=QA>=2);let fA=null,MA={};const RA=o.getParameter(o.SCISSOR_BOX),FA=o.getParameter(o.VIEWPORT),Ye=new zt().fromArray(RA),dA=new zt().fromArray(FA);function bA(oe,Te,cA,SA){const hA=new Uint8Array(4),KA=o.createTexture();o.bindTexture(oe,KA),o.texParameteri(oe,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(oe,o.TEXTURE_MAG_FILTER,o.NEAREST);for(let HA=0;HA<cA;HA++)!t||oe!==o.TEXTURE_3D&&oe!==o.TEXTURE_2D_ARRAY?o.texImage2D(Te+HA,0,o.RGBA,1,1,0,o.RGBA,o.UNSIGNED_BYTE,hA):o.texImage3D(Te,0,o.RGBA,1,1,SA,0,o.RGBA,o.UNSIGNED_BYTE,hA);return KA}const gA={};function XA(oe){c[oe]!==!0&&(o.enable(oe),c[oe]=!0)}function ce(oe){c[oe]!==!1&&(o.disable(oe),c[oe]=!1)}gA[o.TEXTURE_2D]=bA(o.TEXTURE_2D,o.TEXTURE_2D,1),gA[o.TEXTURE_CUBE_MAP]=bA(o.TEXTURE_CUBE_MAP,o.TEXTURE_CUBE_MAP_POSITIVE_X,6),t&&(gA[o.TEXTURE_2D_ARRAY]=bA(o.TEXTURE_2D_ARRAY,o.TEXTURE_2D_ARRAY,1,1),gA[o.TEXTURE_3D]=bA(o.TEXTURE_3D,o.TEXTURE_3D,1,1)),n.setClear(0,0,0,1),r.setClear(1),g.setClear(0),XA(o.DEPTH_TEST),r.setFunc(3),_e(!1),BA(1),XA(o.CULL_FACE),je(0);const Ie={[S]:o.FUNC_ADD,101:o.FUNC_SUBTRACT,102:o.FUNC_REVERSE_SUBTRACT};if(t)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,cA,SA,hA,KA,HA,_A){if(oe!==0){if(k===!1&&(XA(o.BLEND),k=!0),oe===5)hA=hA||Te,KA=KA||cA,HA=HA||SA,Te===_&&hA===G||(o.blendEquationSeparate(Ie[Te],Ie[hA]),_=Te,G=hA),cA===N&&SA===L&&KA===le&&HA===ne||(o.blendFuncSeparate(Se[cA],Se[SA],Se[KA],Se[HA]),N=cA,L=SA,le=KA,ne=HA),R=oe,te=!1;else if(oe!==R||_A!==te){if(_===S&&G===S||(o.blendEquation(o.FUNC_ADD),_=S,G=S),_A)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,te=_A}}else k===!0&&(ce(o.BLEND),k=!1)}function _e(oe){Ae!==oe&&(oe?o.frontFace(o.CW):o.frontFace(o.CCW),Ae=oe)}function BA(oe){oe!==0?(XA(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,cA){oe?(XA(o.POLYGON_OFFSET_FILL),Me===Te&&pe===cA||(o.polygonOffset(Te,cA),Me=Te,pe=cA)):ce(o.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:r,stencil:g},enable:XA,disable:ce,bindFramebuffer:function(oe,Te){return C[oe]!==Te&&(o.bindFramebuffer(oe,Te),C[oe]=Te,t&&(oe===o.DRAW_FRAMEBUFFER&&(C[o.FRAMEBUFFER]=Te),oe===o.FRAMEBUFFER&&(C[o.DRAW_FRAMEBUFFER]=Te)),!0)},drawBuffers:function(oe,Te){let cA=p,SA=!1;if(oe)if(cA=E.get(Te),cA===void 0&&(cA=[],E.set(Te,cA)),oe.isWebGLMultipleRenderTargets){const hA=oe.texture;if(cA.length!==hA.length||cA[0]!==o.COLOR_ATTACHMENT0){for(let KA=0,HA=hA.length;KA<HA;KA++)cA[KA]=o.COLOR_ATTACHMENT0+KA;cA.length=hA.length,SA=!0}}else cA[0]!==o.COLOR_ATTACHMENT0&&(cA[0]=o.COLOR_ATTACHMENT0,SA=!0);else cA[0]!==o.BACK&&(cA[0]=o.BACK,SA=!0);SA&&(A.isWebGL2?o.drawBuffers(cA):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(cA))},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):XA(o.CULL_FACE);let cA=oe.side===v;Te&&(cA=!cA),_e(cA),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 SA=oe.stencilWrite;g.setTest(SA),SA&&(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?XA(o.SAMPLE_ALPHA_TO_COVERAGE):ce(o.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:_e,setCullFace:BA,setLineWidth:function(oe){oe!==ge&&(CA&&o.lineWidth(oe),ge=oe)},setPolygonOffset:ke,setScissorTest:function(oe){oe?XA(o.SCISSOR_TEST):ce(o.SCISSOR_TEST)},activeTexture:function(oe){oe===void 0&&(oe=o.TEXTURE0+Ze-1),fA!==oe&&(o.activeTexture(oe),fA=oe)},bindTexture:function(oe,Te,cA){cA===void 0&&(cA=fA===null?o.TEXTURE0+Ze-1:fA);let SA=MA[cA];SA===void 0&&(SA={type:void 0,texture:void 0},MA[cA]=SA),SA.type===oe&&SA.texture===Te||(fA!==cA&&(o.activeTexture(cA),fA=cA),o.bindTexture(oe,Te||gA[oe]),SA.type=oe,SA.texture=Te)},unbindTexture:function(){const oe=MA[fA];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 cA=u.get(Te);cA===void 0&&(cA=new WeakMap,u.set(Te,cA));let SA=cA.get(oe);SA===void 0&&(SA=o.getUniformBlockIndex(Te,oe.name),cA.set(oe,SA))},uniformBlockBinding:function(oe,Te){const cA=u.get(Te).get(oe);h.get(Te)!==cA&&(o.uniformBlockBinding(Te,cA,oe.__bindingPointIndex),h.set(Te,cA))},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){dA.equals(oe)===!1&&(o.viewport(oe.x,oe.y,oe.z,oe.w),dA.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),t===!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={},fA=null,MA={},C={},E=new WeakMap,p=[],w=null,k=!1,R=null,_=null,N=null,L=null,G=null,le=null,ne=null,te=!1,Ae=null,ye=null,ge=null,Me=null,pe=null,Ye.set(0,0,o.canvas.width,o.canvas.height),dA.set(0,0,o.canvas.width,o.canvas.height),n.reset(),r.reset(),g.reset()}}}function _S(o,e,A,t,n,r,g){const h=n.isWebGL2,u=(n.maxTextures,n.maxCubemapSize),c=n.maxTextureSize,C=n.maxSamples,E=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 BA=Ie?Fr:Math.floor,ke=BA(_e*ce.width),oe=BA(_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!==Ee&&ce.minFilter!==Qe}function ne(ce){o.generateMipmap(ce)}function te(ce,Ie,Se,je,_e=!1){if(h===!1)return Ie;if(ce!==null&&o[ce]!==void 0)return o[ce];let BA=Ie;return Ie===o.RED&&(Se===o.FLOAT&&(BA=o.R32F),Se===o.HALF_FLOAT&&(BA=o.R16F),Se===o.UNSIGNED_BYTE&&(BA=o.R8)),Ie===o.RG&&(Se===o.FLOAT&&(BA=o.RG32F),Se===o.HALF_FLOAT&&(BA=o.RG16F),Se===o.UNSIGNED_BYTE&&(BA=o.RG8)),Ie===o.RGBA&&(Se===o.FLOAT&&(BA=o.RGBA32F),Se===o.HALF_FLOAT&&(BA=o.RGBA16F),Se===o.UNSIGNED_BYTE&&(BA=je===ie&&_e===!1?o.SRGB8_ALPHA8:o.RGBA8),Se===o.UNSIGNED_SHORT_4_4_4_4&&(BA=o.RGBA4),Se===o.UNSIGNED_SHORT_5_5_5_1&&(BA=o.RGB5_A1)),BA!==o.R16F&&BA!==o.R32F&&BA!==o.RG16F&&BA!==o.RG32F&&BA!==o.RGBA16F&&BA!==o.RGBA32F||e.get("EXT_color_buffer_float"),BA}function Ae(ce,Ie,Se){return le(ce,Se)===!0||ce.isFramebufferTexture&&ce.minFilter!==Ee&&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===Ee||ce===qe||ce===me?o.NEAREST:o.LINEAR}function ge(ce){const Ie=ce.target;Ie.removeEventListener("dispose",ge),(function(Se){const je=t.get(Se);if(je.__webglInit===void 0)return;const _e=Se.source,BA=R.get(_e);if(BA){const ke=BA[je.__cacheKey];ke.usedTimes--,ke.usedTimes===0&&pe(Se),Object.keys(BA).length===0&&R.delete(_e)}t.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=t.get(Se),BA=t.get(je);if(BA.__webglTexture!==void 0&&(o.deleteTexture(BA.__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=t.get(je[ke]);Te.__webglTexture&&(o.deleteTexture(Te.__webglTexture),g.memory.textures--),t.remove(je[ke])}t.remove(je),t.remove(Se)})(Ie)}function pe(ce){const Ie=t.get(ce);o.deleteTexture(Ie.__webglTexture);const Se=ce.source;delete R.get(Se)[Ie.__cacheKey],g.memory.textures--}let Ze=0;function CA(ce,Ie){const Se=t.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 RA(Se,ce,Ie)}}A.bindTexture(o.TEXTURE_2D,Se.__webglTexture,o.TEXTURE0+Ie)}const QA={[Ce]:o.REPEAT,[ee]:o.CLAMP_TO_EDGE,[Fe]:o.MIRRORED_REPEAT},VA={[Ee]:o.NEAREST,[qe]:o.NEAREST_MIPMAP_NEAREST,[me]:o.NEAREST_MIPMAP_LINEAR,[Qe]:o.LINEAR,[AA]:o.LINEAR_MIPMAP_NEAREST,[se]:o.LINEAR_MIPMAP_LINEAR};function fA(ce,Ie,Se){if(Se?(o.texParameteri(ce,o.TEXTURE_WRAP_S,QA[Ie.wrapS]),o.texParameteri(ce,o.TEXTURE_WRAP_T,QA[Ie.wrapT]),ce!==o.TEXTURE_3D&&ce!==o.TEXTURE_2D_ARRAY||o.texParameteri(ce,o.TEXTURE_WRAP_R,QA[Ie.wrapR]),o.texParameteri(ce,o.TEXTURE_MAG_FILTER,VA[Ie.magFilter]),o.texParameteri(ce,o.TEXTURE_MIN_FILTER,VA[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!==Ee&&Ie.minFilter),e.has("EXT_texture_filter_anisotropic")===!0){const je=e.get("EXT_texture_filter_anisotropic");if(Ie.magFilter===Ee||Ie.minFilter!==me&&Ie.minFilter!==se||Ie.type===De&&e.has("OES_texture_float_linear")===!1||h===!1&&Ie.type===mA&&e.has("OES_texture_half_float_linear")===!1)return;(Ie.anisotropy>1||t.get(Ie).__currentAnisotropy)&&(o.texParameterf(ce,je.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(Ie.anisotropy,n.getMaxAnisotropy())),t.get(Ie).__currentAnisotropy=Ie.anisotropy)}}function MA(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 BA=(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(BA!==ce.__cacheKey){_e[BA]===void 0&&(_e[BA]={texture:o.createTexture(),usedTimes:0},g.memory.textures++,Se=!0),_e[BA].usedTimes++;const ke=_e[ce.__cacheKey];ke!==void 0&&(_e[ce.__cacheKey].usedTimes--,ke.usedTimes===0&&pe(Ie)),ce.__cacheKey=BA,ce.__webglTexture=_e[BA].texture}return Se}function RA(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=MA(ce,Ie),BA=Ie.source;A.bindTexture(je,ce.__webglTexture,o.TEXTURE0+Se);const ke=t.get(BA);if(BA.version!==ke.__version||_e===!0){A.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!==Ee&&$.minFilter!==Qe)})(Ie)&&G(Ie.image)===!1;let Te=L(Ie.image,oe,!1,c);Te=XA(Ie,Te);const cA=G(Te)||h,SA=r.convert(Ie.format,Ie.colorSpace);let hA,KA=r.convert(Ie.type),HA=te(Ie.internalFormat,SA,KA,Ie.colorSpace);fA(je,Ie,cA);const _A=Ie.mipmaps,Ct=h&&Ie.isVideoTexture!==!0,ht=ke.__version===void 0||_e===!0,J=Ae(Ie,Te,cA);if(Ie.isDepthTexture)HA=o.DEPTH_COMPONENT,h?HA=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===sA&&HA===o.DEPTH_COMPONENT&&Ie.type!==1012&&Ie.type!==U&&(Ie.type=U,KA=r.convert(Ie.type)),Ie.format===TA&&HA===o.DEPTH_COMPONENT&&(HA=o.DEPTH_STENCIL,Ie.type!==He&&(Ie.type=He,KA=r.convert(Ie.type))),ht&&(Ct?A.texStorage2D(o.TEXTURE_2D,1,HA,Te.width,Te.height):A.texImage2D(o.TEXTURE_2D,0,HA,Te.width,Te.height,0,SA,KA,null));else if(Ie.isDataTexture)if(_A.length>0&&cA){Ct&&ht&&A.texStorage2D(o.TEXTURE_2D,J,HA,_A[0].width,_A[0].height);for(let $=0,xe=_A.length;$<xe;$++)hA=_A[$],Ct?A.texSubImage2D(o.TEXTURE_2D,$,0,0,hA.width,hA.height,SA,KA,hA.data):A.texImage2D(o.TEXTURE_2D,$,HA,hA.width,hA.height,0,SA,KA,hA.data);Ie.generateMipmaps=!1}else Ct?(ht&&A.texStorage2D(o.TEXTURE_2D,J,HA,Te.width,Te.height),A.texSubImage2D(o.TEXTURE_2D,0,0,0,Te.width,Te.height,SA,KA,Te.data)):A.texImage2D(o.TEXTURE_2D,0,HA,Te.width,Te.height,0,SA,KA,Te.data);else if(Ie.isCompressedTexture)if(Ie.isCompressedArrayTexture){Ct&&ht&&A.texStorage3D(o.TEXTURE_2D_ARRAY,J,HA,_A[0].width,_A[0].height,Te.depth);for(let $=0,xe=_A.length;$<xe;$++)hA=_A[$],Ie.format!==kA?SA!==null&&(Ct?A.compressedTexSubImage3D(o.TEXTURE_2D_ARRAY,$,0,0,0,hA.width,hA.height,Te.depth,SA,hA.data,0,0):A.compressedTexImage3D(o.TEXTURE_2D_ARRAY,$,HA,hA.width,hA.height,Te.depth,0,hA.data,0,0)):Ct?A.texSubImage3D(o.TEXTURE_2D_ARRAY,$,0,0,0,hA.width,hA.height,Te.depth,SA,KA,hA.data):A.texImage3D(o.TEXTURE_2D_ARRAY,$,HA,hA.width,hA.height,Te.depth,0,SA,KA,hA.data)}else{Ct&&ht&&A.texStorage2D(o.TEXTURE_2D,J,HA,_A[0].width,_A[0].height);for(let $=0,xe=_A.length;$<xe;$++)hA=_A[$],Ie.format!==kA?SA!==null&&(Ct?A.compressedTexSubImage2D(o.TEXTURE_2D,$,0,0,hA.width,hA.height,SA,hA.data):A.compressedTexImage2D(o.TEXTURE_2D,$,HA,hA.width,hA.height,0,hA.data)):Ct?A.texSubImage2D(o.TEXTURE_2D,$,0,0,hA.width,hA.height,SA,KA,hA.data):A.texImage2D(o.TEXTURE_2D,$,HA,hA.width,hA.height,0,SA,KA,hA.data)}else if(Ie.isDataArrayTexture)Ct?(ht&&A.texStorage3D(o.TEXTURE_2D_ARRAY,J,HA,Te.width,Te.height,Te.depth),A.texSubImage3D(o.TEXTURE_2D_ARRAY,0,0,0,0,Te.width,Te.height,Te.depth,SA,KA,Te.data)):A.texImage3D(o.TEXTURE_2D_ARRAY,0,HA,Te.width,Te.height,Te.depth,0,SA,KA,Te.data);else if(Ie.isData3DTexture)Ct?(ht&&A.texStorage3D(o.TEXTURE_3D,J,HA,Te.width,Te.height,Te.depth),A.texSubImage3D(o.TEXTURE_3D,0,0,0,0,Te.width,Te.height,Te.depth,SA,KA,Te.data)):A.texImage3D(o.TEXTURE_3D,0,HA,Te.width,Te.height,Te.depth,0,SA,KA,Te.data);else if(Ie.isFramebufferTexture){if(ht)if(Ct)A.texStorage2D(o.TEXTURE_2D,J,HA,Te.width,Te.height);else{let $=Te.width,xe=Te.height;for(let rA=0;rA<J;rA++)A.texImage2D(o.TEXTURE_2D,rA,HA,$,xe,0,SA,KA,null),$>>=1,xe>>=1}}else if(_A.length>0&&cA){Ct&&ht&&A.texStorage2D(o.TEXTURE_2D,J,HA,_A[0].width,_A[0].height);for(let $=0,xe=_A.length;$<xe;$++)hA=_A[$],Ct?A.texSubImage2D(o.TEXTURE_2D,$,0,0,SA,KA,hA):A.texImage2D(o.TEXTURE_2D,$,HA,SA,KA,hA);Ie.generateMipmaps=!1}else Ct?(ht&&A.texStorage2D(o.TEXTURE_2D,J,HA,Te.width,Te.height),A.texSubImage2D(o.TEXTURE_2D,0,0,0,SA,KA,Te)):A.texImage2D(o.TEXTURE_2D,0,HA,SA,KA,Te);le(Ie,cA)&&ne(je),ke.__version=BA.version,Ie.onUpdate&&Ie.onUpdate(Ie)}ce.__version=Ie.version}function FA(ce,Ie,Se,je,_e){const BA=r.convert(Se.format,Se.colorSpace),ke=r.convert(Se.type),oe=te(Se.internalFormat,BA,ke,Se.colorSpace);t.get(Ie).__hasExternalTextures||(_e===o.TEXTURE_3D||_e===o.TEXTURE_2D_ARRAY?A.texImage3D(_e,0,oe,Ie.width,Ie.height,Ie.depth,0,BA,ke,null):A.texImage2D(_e,0,oe,Ie.width,Ie.height,0,BA,ke,null)),A.bindFramebuffer(o.FRAMEBUFFER,ce),gA(Ie)?E.framebufferTexture2DMultisampleEXT(o.FRAMEBUFFER,je,_e,t.get(Se).__webglTexture,0,bA(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,t.get(Se).__webglTexture,0),A.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||gA(Ie)){const _e=Ie.depthTexture;_e&&_e.isDepthTexture&&(_e.type===De?je=o.DEPTH_COMPONENT32F:_e.type===U&&(je=o.DEPTH_COMPONENT24));const BA=bA(Ie);gA(Ie)?E.renderbufferStorageMultisampleEXT(o.RENDERBUFFER,BA,je,Ie.width,Ie.height):o.renderbufferStorageMultisample(o.RENDERBUFFER,BA,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=bA(Ie);Se&&gA(Ie)===!1?o.renderbufferStorageMultisample(o.RENDERBUFFER,je,o.DEPTH24_STENCIL8,Ie.width,Ie.height):gA(Ie)?E.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 BA=je[_e],ke=r.convert(BA.format,BA.colorSpace),oe=r.convert(BA.type),Te=te(BA.internalFormat,ke,oe,BA.colorSpace),cA=bA(Ie);Se&&gA(Ie)===!1?o.renderbufferStorageMultisample(o.RENDERBUFFER,cA,Te,Ie.width,Ie.height):gA(Ie)?E.renderbufferStorageMultisampleEXT(o.RENDERBUFFER,cA,Te,Ie.width,Ie.height):o.renderbufferStorage(o.RENDERBUFFER,Te,Ie.width,Ie.height)}}o.bindRenderbuffer(o.RENDERBUFFER,null)}function dA(ce){const Ie=t.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(A.bindFramebuffer(o.FRAMEBUFFER,je),!_e.depthTexture||!_e.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");t.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),CA(_e.depthTexture,0);const BA=t.get(_e.depthTexture).__webglTexture,ke=bA(_e);if(_e.depthTexture.format===sA)gA(_e)?E.framebufferTexture2DMultisampleEXT(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.TEXTURE_2D,BA,0,ke):o.framebufferTexture2D(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.TEXTURE_2D,BA,0);else{if(_e.depthTexture.format!==TA)throw new Error("Unknown depthTexture format");gA(_e)?E.framebufferTexture2DMultisampleEXT(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.TEXTURE_2D,BA,0,ke):o.framebufferTexture2D(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.TEXTURE_2D,BA,0)}})(Ie.__webglFramebuffer,ce)}else if(Se){Ie.__webglDepthbuffer=[];for(let je=0;je<6;je++)A.bindFramebuffer(o.FRAMEBUFFER,Ie.__webglFramebuffer[je]),Ie.__webglDepthbuffer[je]=o.createRenderbuffer(),Ye(Ie.__webglDepthbuffer[je],ce,!1)}else A.bindFramebuffer(o.FRAMEBUFFER,Ie.__webglFramebuffer),Ie.__webglDepthbuffer=o.createRenderbuffer(),Ye(Ie.__webglDepthbuffer,ce,!1);A.bindFramebuffer(o.FRAMEBUFFER,null)}function bA(ce){return Math.min(C,ce.samples)}function gA(ce){const Ie=t.get(ce);return h&&ce.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&Ie.__useRenderToTexture!==!1}function XA(ce,Ie){const Se=ce.colorSpace,je=ce.format;return ce.type,ce.isCompressedTexture===!0||ce.format===Ne||Se!==V&&Se!==Be&&Se===ie&&h===!1&&(e.has("EXT_sRGB")===!0&&je===kA?(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=CA,this.setTexture2DArray=function(ce,Ie){const Se=t.get(ce);ce.version>0&&Se.__version!==ce.version?RA(Se,ce,Ie):A.bindTexture(o.TEXTURE_2D_ARRAY,Se.__webglTexture,o.TEXTURE0+Ie)},this.setTexture3D=function(ce,Ie){const Se=t.get(ce);ce.version>0&&Se.__version!==ce.version?RA(Se,ce,Ie):A.bindTexture(o.TEXTURE_3D,Se.__webglTexture,o.TEXTURE0+Ie)},this.setTextureCube=function(ce,Ie){const Se=t.get(ce);ce.version>0&&Se.__version!==ce.version?(function(je,_e,BA){if(_e.image.length!==6)return;const ke=MA(je,_e),oe=_e.source;A.bindTexture(o.TEXTURE_CUBE_MAP,je.__webglTexture,o.TEXTURE0+BA);const Te=t.get(oe);if(oe.version!==Te.__version||ke===!0){A.activeTexture(o.TEXTURE0+BA),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 cA=_e.isCompressedTexture||_e.image[0].isCompressedTexture,SA=_e.image[0]&&_e.image[0].isDataTexture,hA=[];for(let $e=0;$e<6;$e++)hA[$e]=cA||SA?SA?_e.image[$e].image:_e.image[$e]:L(_e.image[$e],!1,!0,u),hA[$e]=XA(_e,hA[$e]);const KA=hA[0],HA=G(KA)||h,_A=r.convert(_e.format,_e.colorSpace),Ct=r.convert(_e.type),ht=te(_e.internalFormat,_A,Ct,_e.colorSpace),J=h&&_e.isVideoTexture!==!0,$=Te.__version===void 0||ke===!0;let xe,rA=Ae(_e,KA,HA);if(fA(o.TEXTURE_CUBE_MAP,_e,HA),cA){J&&$&&A.texStorage2D(o.TEXTURE_CUBE_MAP,rA,ht,KA.width,KA.height);for(let $e=0;$e<6;$e++){xe=hA[$e].mipmaps;for(let Re=0;Re<xe.length;Re++){const Pe=xe[Re];_e.format!==kA?_A!==null&&(J?A.compressedTexSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,0,0,Pe.width,Pe.height,_A,Pe.data):A.compressedTexImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,ht,Pe.width,Pe.height,0,Pe.data)):J?A.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,0,0,Pe.width,Pe.height,_A,Ct,Pe.data):A.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,ht,Pe.width,Pe.height,0,_A,Ct,Pe.data)}}}else{xe=_e.mipmaps,J&&$&&(xe.length>0&&rA++,A.texStorage2D(o.TEXTURE_CUBE_MAP,rA,ht,hA[0].width,hA[0].height));for(let $e=0;$e<6;$e++)if(SA){J?A.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,0,0,hA[$e].width,hA[$e].height,_A,Ct,hA[$e].data):A.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,ht,hA[$e].width,hA[$e].height,0,_A,Ct,hA[$e].data);for(let Re=0;Re<xe.length;Re++){const Pe=xe[Re].image[$e].image;J?A.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,0,0,Pe.width,Pe.height,_A,Ct,Pe.data):A.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,ht,Pe.width,Pe.height,0,_A,Ct,Pe.data)}}else{J?A.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,0,0,_A,Ct,hA[$e]):A.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,ht,_A,Ct,hA[$e]);for(let Re=0;Re<xe.length;Re++){const Pe=xe[Re];J?A.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,0,0,_A,Ct,Pe.image[$e]):A.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,ht,_A,Ct,Pe.image[$e])}}}le(_e,HA)&&ne(o.TEXTURE_CUBE_MAP),Te.__version=oe.version,_e.onUpdate&&_e.onUpdate(_e)}je.__version=_e.version})(Se,ce,Ie):A.bindTexture(o.TEXTURE_CUBE_MAP,Se.__webglTexture,o.TEXTURE0+Ie)},this.rebindTextures=function(ce,Ie,Se){const je=t.get(ce);Ie!==void 0&&FA(je.__webglFramebuffer,ce,ce.texture,o.COLOR_ATTACHMENT0,o.TEXTURE_2D),Se!==void 0&&dA(ce)},this.setupRenderTarget=function(ce){const Ie=ce.texture,Se=t.get(ce),je=t.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,BA=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(),BA&&n.drawBuffers){const oe=ce.texture;for(let Te=0,cA=oe.length;Te<cA;Te++){const SA=t.get(oe[Te]);SA.__webglTexture===void 0&&(SA.__webglTexture=o.createTexture(),g.memory.textures++)}}if(h&&ce.samples>0&&gA(ce)===!1){const oe=BA?Ie:[Ie];Se.__webglMultisampledFramebuffer=o.createFramebuffer(),Se.__webglColorRenderbuffer=[],A.bindFramebuffer(o.FRAMEBUFFER,Se.__webglMultisampledFramebuffer);for(let Te=0;Te<oe.length;Te++){const cA=oe[Te];Se.__webglColorRenderbuffer[Te]=o.createRenderbuffer(),o.bindRenderbuffer(o.RENDERBUFFER,Se.__webglColorRenderbuffer[Te]);const SA=r.convert(cA.format,cA.colorSpace),hA=r.convert(cA.type),KA=te(cA.internalFormat,SA,hA,cA.colorSpace,ce.isXRRenderTarget===!0),HA=bA(ce);o.renderbufferStorageMultisample(o.RENDERBUFFER,HA,KA,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)),A.bindFramebuffer(o.FRAMEBUFFER,null)}}if(_e){A.bindTexture(o.TEXTURE_CUBE_MAP,je.__webglTexture),fA(o.TEXTURE_CUBE_MAP,Ie,ke);for(let oe=0;oe<6;oe++)FA(Se.__webglFramebuffer[oe],ce,Ie,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+oe);le(Ie,ke)&&ne(o.TEXTURE_CUBE_MAP),A.unbindTexture()}else if(BA){const oe=ce.texture;for(let Te=0,cA=oe.length;Te<cA;Te++){const SA=oe[Te],hA=t.get(SA);A.bindTexture(o.TEXTURE_2D,hA.__webglTexture),fA(o.TEXTURE_2D,SA,ke),FA(Se.__webglFramebuffer,ce,SA,o.COLOR_ATTACHMENT0+Te,o.TEXTURE_2D),le(SA,ke)&&ne(o.TEXTURE_2D)}A.unbindTexture()}else{let oe=o.TEXTURE_2D;(ce.isWebGL3DRenderTarget||ce.isWebGLArrayRenderTarget)&&h&&(oe=ce.isWebGL3DRenderTarget?o.TEXTURE_3D:o.TEXTURE_2D_ARRAY),A.bindTexture(oe,je.__webglTexture),fA(oe,Ie,ke),FA(Se.__webglFramebuffer,ce,Ie,o.COLOR_ATTACHMENT0,oe),le(Ie,ke)&&ne(oe),A.unbindTexture()}ce.depthBuffer&&dA(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 BA=Se[je];if(le(BA,Ie)){const ke=ce.isWebGLCubeRenderTarget?o.TEXTURE_CUBE_MAP:o.TEXTURE_2D,oe=t.get(BA).__webglTexture;A.bindTexture(ke,oe),ne(ke),A.unbindTexture()}}},this.updateMultisampleRenderTarget=function(ce){if(h&&ce.samples>0&&gA(ce)===!1){const Ie=ce.isWebGLMultipleRenderTargets?ce.texture:[ce.texture],Se=ce.width,je=ce.height;let _e=o.COLOR_BUFFER_BIT;const BA=[],ke=ce.stencilBuffer?o.DEPTH_STENCIL_ATTACHMENT:o.DEPTH_ATTACHMENT,oe=t.get(ce),Te=ce.isWebGLMultipleRenderTargets===!0;if(Te)for(let cA=0;cA<Ie.length;cA++)A.bindFramebuffer(o.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0+cA,o.RENDERBUFFER,null),A.bindFramebuffer(o.FRAMEBUFFER,oe.__webglFramebuffer),o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0+cA,o.TEXTURE_2D,null,0);A.bindFramebuffer(o.READ_FRAMEBUFFER,oe.__webglMultisampledFramebuffer),A.bindFramebuffer(o.DRAW_FRAMEBUFFER,oe.__webglFramebuffer);for(let cA=0;cA<Ie.length;cA++){BA.push(o.COLOR_ATTACHMENT0+cA),ce.depthBuffer&&BA.push(ke);const SA=oe.__ignoreDepthValues!==void 0&&oe.__ignoreDepthValues;if(SA===!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[cA]),SA===!0&&(o.invalidateFramebuffer(o.READ_FRAMEBUFFER,[ke]),o.invalidateFramebuffer(o.DRAW_FRAMEBUFFER,[ke])),Te){const hA=t.get(Ie[cA]).__webglTexture;o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,hA,0)}o.blitFramebuffer(0,0,Se,je,0,0,Se,je,_e,o.NEAREST),p&&o.invalidateFramebuffer(o.READ_FRAMEBUFFER,BA)}if(A.bindFramebuffer(o.READ_FRAMEBUFFER,null),A.bindFramebuffer(o.DRAW_FRAMEBUFFER,null),Te)for(let cA=0;cA<Ie.length;cA++){A.bindFramebuffer(o.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0+cA,o.RENDERBUFFER,oe.__webglColorRenderbuffer[cA]);const SA=t.get(Ie[cA]).__webglTexture;A.bindFramebuffer(o.FRAMEBUFFER,oe.__webglFramebuffer),o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0+cA,o.TEXTURE_2D,SA,0)}A.bindFramebuffer(o.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=dA,this.setupFrameBufferTexture=FA,this.useMultisampledRTT=gA}function RS(o,e,A){const t=A.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===mA)return t?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===kA)return o.RGBA;if(n===1024)return o.LUMINANCE;if(n===1025)return o.LUMINANCE_ALPHA;if(n===sA)return o.DEPTH_COMPONENT;if(n===TA)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===jA||n===NA||n===W)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===jA)return g.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===NA)return g.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===W)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===jA)return g.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===NA)return g.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===W)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?t?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 NS extends Zi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Js extends gi{constructor(){super(),this.isGroup=!0,this.type="Group"}}const kS={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 A=this._hand;if(A)for(const t of e.hand.values())this._getHandJoint(A,t)}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,A,t){let n=null,r=null,g=null;const h=this._targetRay,u=this._grip,c=this._hand;if(e&&A.session.visibilityState!=="visible-blurred"){if(c&&e.hand){g=!0;for(const R of e.hand.values()){const _=A.getJointPose(R,t),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"],E=c.joints["thumb-tip"],p=C.position.distanceTo(E.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=A.getPose(e.gripSpace,t),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=A.getPose(e.targetRaySpace,t),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(kS)))}return h!==null&&(h.visible=n!==null),u!==null&&(u.visible=r!==null),c!==null&&(c.visible=g!==null),this}_getHandJoint(e,A){if(e.joints[A.jointName]===void 0){const t=new Js;t.matrixAutoUpdate=!1,t.visible=!1,e.joints[A.jointName]=t,e.add(t)}return e.joints[A.jointName]}}class FS extends Di{constructor(e,A,t,n,r,g,h,u,c,C){if((C=C!==void 0?C:sA)!==sA&&C!==TA)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");t===void 0&&C===sA&&(t=U),t===void 0&&C===TA&&(t=He),super(null,n,r,g,h,u,C,t,c),this.isDepthTexture=!0,this.image={width:e,height:A},this.magFilter=h!==void 0?h:Ee,this.minFilter=u!==void 0?u:Ee,this.flipY=!1,this.generateMipmaps=!1}}class LS extends uA{constructor(e,A){super();const t=this;let n=null,r=1,g=null,h="local-floor",u=1,c=null,C=null,E=null,p=null,w=null,k=null;const R=A.getContextAttributes();let _=null,N=null;const L=[],G=[],le=new Set,ne=new Map,te=new Zi;te.layers.enable(1),te.viewport=new zt;const Ae=new Zi;Ae.layers.enable(2),Ae.viewport=new zt;const ye=[te,Ae],ge=new NS;ge.layers.enable(1),ge.layers.enable(2);let Me=null,pe=null;function Ze(Ye){const dA=G.indexOf(Ye.inputSource);if(dA===-1)return;const bA=L[dA];bA!==void 0&&(bA.update(Ye.inputSource,Ye.frame,c||g),bA.dispatchEvent({type:Ye.type,data:Ye.inputSource}))}function CA(){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",CA),n.removeEventListener("inputsourceschange",QA);for(let Ye=0;Ye<L.length;Ye++){const dA=G[Ye];dA!==null&&(G[Ye]=null,L[Ye].disconnect(dA))}Me=null,pe=null,e.setRenderTarget(_),w=null,p=null,E=null,n=null,N=null,FA.stop(),t.isPresenting=!1,t.dispatchEvent({type:"sessionend"})}function QA(Ye){for(let dA=0;dA<Ye.removed.length;dA++){const bA=Ye.removed[dA],gA=G.indexOf(bA);gA>=0&&(G[gA]=null,L[gA].disconnect(bA))}for(let dA=0;dA<Ye.added.length;dA++){const bA=Ye.added[dA];let gA=G.indexOf(bA);if(gA===-1){for(let ce=0;ce<L.length;ce++){if(ce>=G.length){G.push(bA),gA=ce;break}if(G[ce]===null){G[ce]=bA,gA=ce;break}}if(gA===-1)break}const XA=L[gA];XA&&XA.connect(bA)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Ye){let dA=L[Ye];return dA===void 0&&(dA=new Kh,L[Ye]=dA),dA.getTargetRaySpace()},this.getControllerGrip=function(Ye){let dA=L[Ye];return dA===void 0&&(dA=new Kh,L[Ye]=dA),dA.getGripSpace()},this.getHand=function(Ye){let dA=L[Ye];return dA===void 0&&(dA=new Kh,L[Ye]=dA),dA.getHandSpace()},this.setFramebufferScaleFactor=function(Ye){r=Ye,t.isPresenting},this.setReferenceSpaceType=function(Ye){h=Ye,t.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 E},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",CA),n.addEventListener("inputsourceschange",QA),R.xrCompatible!==!0&&await A.makeXRCompatible(),n.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const dA={antialias:n.renderState.layers!==void 0||R.antialias,alpha:!0,depth:R.depth,stencil:R.stencil,framebufferScaleFactor:r};w=new XRWebGLLayer(n,A,dA),n.updateRenderState({baseLayer:w}),N=new ei(w.framebufferWidth,w.framebufferHeight,{format:kA,type:be,colorSpace:e.outputColorSpace,stencilBuffer:R.stencil})}else{let dA=null,bA=null,gA=null;R.depth&&(gA=R.stencil?A.DEPTH24_STENCIL8:A.DEPTH_COMPONENT24,dA=R.stencil?TA:sA,bA=R.stencil?He:U);const XA={colorFormat:A.RGBA8,depthFormat:gA,scaleFactor:r};E=new XRWebGLBinding(n,A),p=E.createProjectionLayer(XA),n.updateRenderState({layers:[p]}),N=new ei(p.textureWidth,p.textureHeight,{format:kA,type:be,depthTexture:new FS(p.textureWidth,p.textureHeight,bA,void 0,void 0,void 0,void 0,void 0,void 0,dA),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),FA.setContext(n),FA.start(),t.isPresenting=!0,t.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode};const VA=new re,fA=new re;function MA(Ye,dA){dA===null?Ye.matrixWorld.copy(Ye.matrix):Ye.matrixWorld.multiplyMatrices(dA.matrixWorld,Ye.matrix),Ye.matrixWorldInverse.copy(Ye.matrixWorld).invert()}this.updateCamera=function(Ye){if(n===null)return;ge.near=Ae.near=te.near=Ye.near,ge.far=Ae.far=te.far=Ye.far,Me===ge.near&&pe===ge.far||(n.updateRenderState({depthNear:ge.near,depthFar:ge.far}),Me=ge.near,pe=ge.far);const dA=Ye.parent,bA=ge.cameras;MA(ge,dA);for(let gA=0;gA<bA.length;gA++)MA(bA[gA],dA);bA.length===2?(function(gA,XA,ce){VA.setFromMatrixPosition(XA.matrixWorld),fA.setFromMatrixPosition(ce.matrixWorld);const Ie=VA.distanceTo(fA),Se=XA.projectionMatrix.elements,je=ce.projectionMatrix.elements,_e=Se[14]/(Se[10]-1),BA=Se[14]/(Se[10]+1),ke=(Se[9]+1)/Se[5],oe=(Se[9]-1)/Se[5],Te=(Se[8]-1)/Se[0],cA=(je[8]+1)/je[0],SA=_e*Te,hA=_e*cA,KA=Ie/(-Te+cA),HA=KA*-Te;XA.matrixWorld.decompose(gA.position,gA.quaternion,gA.scale),gA.translateX(HA),gA.translateZ(KA),gA.matrixWorld.compose(gA.position,gA.quaternion,gA.scale),gA.matrixWorldInverse.copy(gA.matrixWorld).invert();const _A=_e+KA,Ct=BA+KA,ht=SA-HA,J=hA+(Ie-HA),$=ke*BA/Ct*_A,xe=oe*BA/Ct*_A;gA.projectionMatrix.makePerspective(ht,J,$,xe,_A,Ct),gA.projectionMatrixInverse.copy(gA.projectionMatrix).invert()})(ge,te,Ae):ge.projectionMatrix.copy(te.projectionMatrix),(function(gA,XA,ce){ce===null?gA.matrix.copy(XA.matrixWorld):(gA.matrix.copy(ce.matrixWorld),gA.matrix.invert(),gA.matrix.multiply(XA.matrixWorld)),gA.matrix.decompose(gA.position,gA.quaternion,gA.scale),gA.updateMatrixWorld(!0);const Ie=gA.children;for(let Se=0,je=Ie.length;Se<je;Se++)Ie[Se].updateMatrixWorld(!0);gA.projectionMatrix.copy(XA.projectionMatrix),gA.projectionMatrixInverse.copy(XA.projectionMatrixInverse),gA.isPerspectiveCamera&&(gA.fov=2*Rt*Math.atan(1/gA.projectionMatrix.elements[5]),gA.zoom=1)})(Ye,ge,dA)},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 RA=null;const FA=new MB;FA.setAnimationLoop((function(Ye,dA){if(C=dA.getViewerPose(c||g),k=dA,C!==null){const bA=C.views;w!==null&&(e.setRenderTargetFramebuffer(N,w.framebuffer),e.setRenderTarget(N));let gA=!1;bA.length!==ge.cameras.length&&(ge.cameras.length=0,gA=!0);for(let XA=0;XA<bA.length;XA++){const ce=bA[XA];let Ie=null;if(w!==null)Ie=w.getViewport(ce);else{const je=E.getViewSubImage(p,ce);Ie=je.viewport,XA===0&&(e.setRenderTargetTextures(N,je.colorTexture,p.ignoreDepthValues?void 0:je.depthStencilTexture),e.setRenderTarget(N))}let Se=ye[XA];Se===void 0&&(Se=new Zi,Se.layers.enable(XA),Se.viewport=new zt,ye[XA]=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),XA===0&&(ge.matrix.copy(Se.matrix),ge.matrix.decompose(ge.position,ge.quaternion,ge.scale)),gA===!0&&ge.cameras.push(Se)}}for(let bA=0;bA<L.length;bA++){const gA=G[bA],XA=L[bA];gA!==null&&XA!==void 0&&XA.update(gA,dA,c||g)}if(RA&&RA(Ye,dA),dA.detectedPlanes){t.dispatchEvent({type:"planesdetected",data:dA.detectedPlanes});let bA=null;for(const gA of le)dA.detectedPlanes.has(gA)||(bA===null&&(bA=[]),bA.push(gA));if(bA!==null)for(const gA of bA)le.delete(gA),ne.delete(gA),t.dispatchEvent({type:"planeremoved",data:gA});for(const gA of dA.detectedPlanes)if(le.has(gA)){const XA=ne.get(gA);gA.lastChangedTime>XA&&(ne.set(gA,gA.lastChangedTime),t.dispatchEvent({type:"planechanged",data:gA}))}else le.add(gA),ne.set(gA,dA.lastChangedTime),t.dispatchEvent({type:"planeadded",data:gA})}k=null})),this.setAnimationLoop=function(Ye){RA=Ye},this.dispose=function(){}}}function GS(o,e){function A(n,r){n.matrixAutoUpdate===!0&&n.updateMatrix(),r.value.copy(n.matrix)}function t(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,A(r.map,n.mapTransform)),r.alphaMap&&(n.alphaMap.value=r.alphaMap,A(r.alphaMap,n.alphaMapTransform)),r.bumpMap&&(n.bumpMap.value=r.bumpMap,A(r.bumpMap,n.bumpMapTransform),n.bumpScale.value=r.bumpScale,r.side===v&&(n.bumpScale.value*=-1)),r.normalMap&&(n.normalMap.value=r.normalMap,A(r.normalMap,n.normalMapTransform),n.normalScale.value.copy(r.normalScale),r.side===v&&n.normalScale.value.negate()),r.displacementMap&&(n.displacementMap.value=r.displacementMap,A(r.displacementMap,n.displacementMapTransform),n.displacementScale.value=r.displacementScale,n.displacementBias.value=r.displacementBias),r.emissiveMap&&(n.emissiveMap.value=r.emissiveMap,A(r.emissiveMap,n.emissiveMapTransform)),r.specularMap&&(n.specularMap.value=r.specularMap,A(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,A(r.lightMap,n.lightMapTransform)}r.aoMap&&(n.aoMap.value=r.aoMap,n.aoMapIntensity.value=r.aoMapIntensity,A(r.aoMap,n.aoMapTransform))}return{refreshFogUniforms:function(n,r){r.color.getRGB(n.fogColor.value,yB(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?t(n,r):r.isMeshToonMaterial?(t(n,r),(function(c,C){C.gradientMap&&(c.gradientMap.value=C.gradientMap)})(n,r)):r.isMeshPhongMaterial?(t(n,r),(function(c,C){c.specular.value.copy(C.specular),c.shininess.value=Math.max(C.shininess,1e-4)})(n,r)):r.isMeshStandardMaterial?(t(n,r),(function(c,C){c.metalness.value=C.metalness,C.metalnessMap&&(c.metalnessMap.value=C.metalnessMap,A(C.metalnessMap,c.metalnessMapTransform)),c.roughness.value=C.roughness,C.roughnessMap&&(c.roughnessMap.value=C.roughnessMap,A(C.roughnessMap,c.roughnessMapTransform)),e.get(C).envMap&&(c.envMapIntensity.value=C.envMapIntensity)})(n,r),r.isMeshPhysicalMaterial&&(function(c,C,E){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,A(C.sheenColorMap,c.sheenColorMapTransform)),C.sheenRoughnessMap&&(c.sheenRoughnessMap.value=C.sheenRoughnessMap,A(C.sheenRoughnessMap,c.sheenRoughnessMapTransform))),C.clearcoat>0&&(c.clearcoat.value=C.clearcoat,c.clearcoatRoughness.value=C.clearcoatRoughness,C.clearcoatMap&&(c.clearcoatMap.value=C.clearcoatMap,A(C.clearcoatMap,c.clearcoatMapTransform)),C.clearcoatRoughnessMap&&(c.clearcoatRoughnessMap.value=C.clearcoatRoughnessMap,A(C.clearcoatRoughnessMap,c.clearcoatRoughnessMapTransform)),C.clearcoatNormalMap&&(c.clearcoatNormalMap.value=C.clearcoatNormalMap,A(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,A(C.iridescenceMap,c.iridescenceMapTransform)),C.iridescenceThicknessMap&&(c.iridescenceThicknessMap.value=C.iridescenceThicknessMap,A(C.iridescenceThicknessMap,c.iridescenceThicknessMapTransform))),C.transmission>0&&(c.transmission.value=C.transmission,c.transmissionSamplerMap.value=E.texture,c.transmissionSamplerSize.value.set(E.width,E.height),C.transmissionMap&&(c.transmissionMap.value=C.transmissionMap,A(C.transmissionMap,c.transmissionMapTransform)),c.thickness.value=C.thickness,C.thicknessMap&&(c.thicknessMap.value=C.thicknessMap,A(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,A(C.specularColorMap,c.specularColorMapTransform)),C.specularIntensityMap&&(c.specularIntensityMap.value=C.specularIntensityMap,A(C.specularIntensityMap,c.specularIntensityMapTransform))})(n,r,u)):r.isMeshMatcapMaterial?(t(n,r),(function(c,C){C.matcap&&(c.matcap.value=C.matcap)})(n,r)):r.isMeshDepthMaterial?t(n,r):r.isMeshDistanceMaterial?(t(n,r),(function(c,C){const E=e.get(C).light;c.referencePosition.value.setFromMatrixPosition(E.matrixWorld),c.nearDistance.value=E.shadow.camera.near,c.farDistance.value=E.shadow.camera.far})(n,r)):r.isMeshNormalMaterial?t(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,A(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,E,p){c.diffuse.value.copy(C.color),c.opacity.value=C.opacity,c.size.value=C.size*E,c.scale.value=.5*p,C.map&&(c.map.value=C.map,A(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,A(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 US(o,e,A,t){let n={},r={},g=[];const h=A.isWebGL2?o.getParameter(o.MAX_UNIFORM_BUFFER_BINDINGS):0;function u(E,p,w){const k=E.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(E){const p={boundary:0,storage:0};return typeof E=="number"?(p.boundary=4,p.storage=4):E.isVector2?(p.boundary=8,p.storage=8):E.isVector3||E.isColor?(p.boundary=16,p.storage=12):E.isVector4?(p.boundary=16,p.storage=16):E.isMatrix3?(p.boundary=48,p.storage=48):E.isMatrix4?(p.boundary=64,p.storage=64):E.isTexture,p}function C(E){const p=E.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(E,p){const w=p.program;t.uniformBlockBinding(E,w)},update:function(E,p){let w=n[E.id];w===void 0&&((function(_){const N=_.uniforms;let L=0;const G=16;let le=0;for(let ne=0,te=N.length;ne<te;ne++){const Ae=N[ne],ye={boundary:0,storage:0},ge=Array.isArray(Ae.value)?Ae.value:[Ae.value];for(let Me=0,pe=ge.length;Me<pe;Me++){const Ze=c(ge[Me]);ye.boundary+=Ze.boundary,ye.storage+=Ze.storage}Ae.__data=new Float32Array(ye.storage/Float32Array.BYTES_PER_ELEMENT),Ae.__offset=L,ne>0&&(le=L%G,le!==0&&G-le-ye.boundary<0&&(L+=G-le,Ae.__offset=L)),L+=ye.storage}le=L%G,le>0&&(L+=G-le),_.__size=L,_.__cache={}})(E),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})(E),n[E.id]=w,E.addEventListener("dispose",C));const k=p.program;t.updateUBOMapping(E,k);const R=e.render.frame;r[E.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 te=L[le];if(u(te,le,G)===!0){const Ae=te.__offset,ye=Array.isArray(te.value)?te.value:[te.value];let ge=0;for(let Me=0;Me<ye.length;Me++){const pe=ye[Me],Ze=c(pe);typeof pe=="number"?(te.__data[0]=pe,o.bufferSubData(o.UNIFORM_BUFFER,Ae+ge,te.__data)):pe.isMatrix3?(te.__data[0]=pe.elements[0],te.__data[1]=pe.elements[1],te.__data[2]=pe.elements[2],te.__data[3]=pe.elements[0],te.__data[4]=pe.elements[3],te.__data[5]=pe.elements[4],te.__data[6]=pe.elements[5],te.__data[7]=pe.elements[0],te.__data[8]=pe.elements[6],te.__data[9]=pe.elements[7],te.__data[10]=pe.elements[8],te.__data[11]=pe.elements[0]):(pe.toArray(te.__data,ge),ge+=Ze.storage/Float32Array.BYTES_PER_ELEMENT)}o.bufferSubData(o.UNIFORM_BUFFER,Ae,te.__data)}}o.bindBuffer(o.UNIFORM_BUFFER,null)})(E),r[E.id]=R)},dispose:function(){for(const E in n)o.deleteBuffer(n[E]);g=[],n={},r={}}}}function TS(){const o=wn("canvas");return o.style.display="block",o}class eE{constructor(e={}){const{canvas:A=TS(),context:t=null,depth:n=!0,stencil:r=!0,alpha:g=!1,antialias:h=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:c=!1,powerPreference:C="default",failIfMajorPerformanceCaveat:E=!1}=e;let p;this.isWebGLRenderer=!0,p=t!==null?t.getContextAttributes().alpha:g;let w=null,k=null;const R=[],_=[];this.domElement=A,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,te=-1,Ae=null;const ye=new zt,ge=new zt;let Me=null,pe=A.width,Ze=A.height,CA=1,QA=null,VA=null;const fA=new zt(0,0,pe,Ze),MA=new zt(0,0,pe,Ze);let RA=!1;const FA=new Th;let Ye=!1,dA=!1,bA=null;const gA=new xt,XA=new re,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ie(){return ne===null?CA:1}let Se,je,_e,BA,ke,oe,Te,cA,SA,hA,KA,HA,_A,Ct,ht,J,$,xe,rA,$e,Re,Pe,YA,WA,ve=t;function zA(he,eA){for(let EA=0;EA<he.length;EA++){const lA=he[EA],pA=A.getContext(lA,eA);if(pA!==null)return pA}return null}try{const he={alpha:!0,depth:n,stencil:r,antialias:h,premultipliedAlpha:u,preserveDrawingBuffer:c,powerPreference:C,failIfMajorPerformanceCaveat:E};if("setAttribute"in A&&A.setAttribute("data-engine",`three.js r${B}`),A.addEventListener("webglcontextlost",At,!1),A.addEventListener("webglcontextrestored",dt,!1),A.addEventListener("webglcontextcreationerror",PA,!1),ve===null){const eA=["webgl2","webgl","experimental-webgl"];if(N.isWebGL1Renderer===!0&&eA.shift(),ve=zA(eA,he),ve===null)throw zA(eA)?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 qA(){Se=new cM(ve),je=new aM(ve,Se,e),Se.init(je),Pe=new RS(ve,Se,je),_e=new bS(ve,Se,je),BA=new uM(ve),ke=new QS,oe=new _S(ve,Se,_e,ke,je,Pe,BA),Te=new gM(N),cA=new lM(N),SA=new iM(ve,je),YA=new rM(ve,Se,SA,je),hA=new hM(ve,SA,BA,YA),KA=new EM(ve,hA,SA,BA),rA=new BM(ve,je,oe),J=new oM(ke),HA=new ES(N,Te,cA,Se,je,YA,J),_A=new GS(N,ke),Ct=new pS,ht=new DS(Se,je),xe=new nM(N,Te,cA,_e,KA,p,u),$=new xS(N,KA,je),WA=new US(ve,BA,je,_e),$e=new sM(ve,Se,BA,je),Re=new IM(ve,Se,BA,je),BA.programs=HA.programs,N.capabilities=je,N.extensions=Se,N.properties=ke,N.renderLists=Ct,N.shadowMap=$,N.state=_e,N.info=BA}qA();const LA=new LS(N,ve);function At(he){he.preventDefault(),L=!0}function dt(){L=!1;const he=BA.autoReset,eA=$.enabled,EA=$.autoUpdate,lA=$.needsUpdate,pA=$.type;qA(),BA.autoReset=he,$.enabled=eA,$.autoUpdate=EA,$.needsUpdate=lA,$.type=pA}function PA(he){he.statusMessage}function st(he){const eA=he.target;eA.removeEventListener("dispose",st),(function(EA){(function(lA){const pA=ke.get(lA).programs;pA!==void 0&&(pA.forEach((function(et){HA.releaseProgram(et)})),lA.isShaderMaterial&&HA.releaseShaderCache(lA))})(EA),ke.remove(EA)})(eA)}this.xr=LA,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 CA},this.setPixelRatio=function(he){he!==void 0&&(CA=he,this.setSize(pe,Ze,!1))},this.getSize=function(he){return he.set(pe,Ze)},this.setSize=function(he,eA,EA=!0){LA.isPresenting||(pe=he,Ze=eA,A.width=Math.floor(he*CA),A.height=Math.floor(eA*CA),EA===!0&&(A.style.width=he+"px",A.style.height=eA+"px"),this.setViewport(0,0,he,eA))},this.getDrawingBufferSize=function(he){return he.set(pe*CA,Ze*CA).floor()},this.setDrawingBufferSize=function(he,eA,EA){pe=he,Ze=eA,CA=EA,A.width=Math.floor(he*EA),A.height=Math.floor(eA*EA),this.setViewport(0,0,he,eA)},this.getCurrentViewport=function(he){return he.copy(ye)},this.getViewport=function(he){return he.copy(fA)},this.setViewport=function(he,eA,EA,lA){he.isVector4?fA.set(he.x,he.y,he.z,he.w):fA.set(he,eA,EA,lA),_e.viewport(ye.copy(fA).multiplyScalar(CA).floor())},this.getScissor=function(he){return he.copy(MA)},this.setScissor=function(he,eA,EA,lA){he.isVector4?MA.set(he.x,he.y,he.z,he.w):MA.set(he,eA,EA,lA),_e.scissor(ge.copy(MA).multiplyScalar(CA).floor())},this.getScissorTest=function(){return RA},this.setScissorTest=function(he){_e.setScissorTest(RA=he)},this.setOpaqueSort=function(he){QA=he},this.setTransparentSort=function(he){VA=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,eA=!0,EA=!0){let lA=0;he&&(lA|=ve.COLOR_BUFFER_BIT),eA&&(lA|=ve.DEPTH_BUFFER_BIT),EA&&(lA|=ve.STENCIL_BUFFER_BIT),ve.clear(lA)},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(){A.removeEventListener("webglcontextlost",At,!1),A.removeEventListener("webglcontextrestored",dt,!1),A.removeEventListener("webglcontextcreationerror",PA,!1),Ct.dispose(),ht.dispose(),ke.dispose(),Te.dispose(),cA.dispose(),KA.dispose(),YA.dispose(),WA.dispose(),HA.dispose(),LA.dispose(),LA.removeEventListener("sessionstart",wt),LA.removeEventListener("sessionend",mi),bA&&(bA.dispose(),bA=null),qt.stop()},this.renderBufferDirect=function(he,eA,EA,lA,pA,et){eA===null&&(eA=ce);const It=pA.isMesh&&pA.matrixWorld.determinant()<0,Mt=(function(Vt,En,Li,pt,bi){En.isScene!==!0&&(En=ce),oe.resetTextureUnits();const NI=En.fog,Z_=pt.isMeshStandardMaterial?En.environment:null,j_=ne===null?N.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:V,Cc=(pt.isMeshStandardMaterial?cA:Te).get(pt.envMap||Z_),X_=pt.vertexColors===!0&&!!Li.attributes.color&&Li.attributes.color.itemSize===4,$_=!!pt.normalMap&&!!Li.attributes.tangent,eR=!!Li.morphAttributes.position,AR=!!Li.morphAttributes.normal,tR=!!Li.morphAttributes.color,iR=pt.toneMapped?N.toneMapping:F,UQ=Li.morphAttributes.position||Li.morphAttributes.normal||Li.morphAttributes.color,nR=UQ!==void 0?UQ.length:0,ii=ke.get(pt),rR=k.state.lights;if(Ye===!0&&(dA===!0||Vt!==Ae)){const Nn=Vt===Ae&&pt.id===te;J.setState(pt,Vt,Nn)}let jr=!1;pt.version===ii.__version?ii.needsLights&&ii.lightsStateVersion!==rR.state.version||ii.outputColorSpace!==j_||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||pt.fog===!0&&ii.fog!==NI?jr=!0:ii.numClippingPlanes===void 0||ii.numClippingPlanes===J.numPlanes&&ii.numIntersection===J.numIntersection?(ii.vertexAlphas!==X_||ii.vertexTangents!==$_||ii.morphTargets!==eR||ii.morphNormals!==AR||ii.morphColors!==tR||ii.toneMapping!==iR||je.isWebGL2===!0&&ii.morphTargetsCount!==nR)&&(jr=!0):jr=!0:jr=!0:jr=!0:(jr=!0,ii.__version=pt.version);let js=ii.currentProgram;jr===!0&&(js=Fi(pt,En,bi));let TQ=!1,ug=!1,kI=!1;const ln=js.getUniforms(),Xs=ii.uniforms;if(_e.useProgram(js.program)&&(TQ=!0,ug=!0,kI=!0),pt.id!==te&&(te=pt.id,ug=!0),TQ||Ae!==Vt){if(ln.setValue(ve,"projectionMatrix",Vt.projectionMatrix),je.logarithmicDepthBuffer&&ln.setValue(ve,"logDepthBufFC",2/(Math.log(Vt.far+1)/Math.LN2)),Ae!==Vt&&(Ae=Vt,ug=!0,kI=!0),pt.isShaderMaterial||pt.isMeshPhongMaterial||pt.isMeshToonMaterial||pt.isMeshStandardMaterial||pt.envMap){const Nn=ln.map.cameraPosition;Nn!==void 0&&Nn.setValue(ve,XA.setFromMatrixPosition(Vt.matrixWorld))}(pt.isMeshPhongMaterial||pt.isMeshToonMaterial||pt.isMeshLambertMaterial||pt.isMeshBasicMaterial||pt.isMeshStandardMaterial||pt.isShaderMaterial)&&ln.setValue(ve,"isOrthographic",Vt.isOrthographicCamera===!0),(pt.isMeshPhongMaterial||pt.isMeshToonMaterial||pt.isMeshLambertMaterial||pt.isMeshBasicMaterial||pt.isMeshStandardMaterial||pt.isShaderMaterial||pt.isShadowMaterial||bi.isSkinnedMesh)&&ln.setValue(ve,"viewMatrix",Vt.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 FI=Li.morphAttributes;(FI.position!==void 0||FI.normal!==void 0||FI.color!==void 0&&je.isWebGL2===!0)&&rA.update(bi,Li,js),(ug||ii.receiveShadow!==bi.receiveShadow)&&(ii.receiveShadow=bi.receiveShadow,ln.setValue(ve,"receiveShadow",bi.receiveShadow)),pt.isMeshGouraudMaterial&&pt.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=kI,(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),NI&&pt.fog===!0&&_A.refreshFogUniforms(Xs,NI),_A.refreshMaterialUniforms(Xs,pt,CA,Ze,bA),Hl.upload(ve,ii.uniformsList,Xs,oe));var mr,sr;if(pt.isShaderMaterial&&pt.uniformsNeedUpdate===!0&&(Hl.upload(ve,ii.uniformsList,Xs,oe),pt.uniformsNeedUpdate=!1),pt.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),pt.isShaderMaterial||pt.isRawShaderMaterial){const Nn=pt.uniformsGroups;for(let LI=0,sR=Nn.length;LI<sR;LI++)if(je.isWebGL2){const HQ=Nn[LI];WA.update(HQ,js),WA.bind(HQ,js)}}return js})(he,eA,EA,lA,pA);_e.setMaterial(lA,It);let Gt=EA.index,gt=1;lA.wireframe===!0&&(Gt=hA.getWireframeAttribute(EA),gt=2);const bt=EA.drawRange,_t=EA.attributes.position;let jt=bt.start*gt,Dt=(bt.start+bt.count)*gt;et!==null&&(jt=Math.max(jt,et.start*gt),Dt=Math.min(Dt,(et.start+et.count)*gt)),Gt!==null?(jt=Math.max(jt,0),Dt=Math.min(Dt,Gt.count)):_t!=null&&(jt=Math.max(jt,0),Dt=Math.min(Dt,_t.count));const Et=Dt-jt;if(Et<0||Et===1/0)return;let Xi;YA.setup(pA,lA,Mt,EA,Gt);let $t=$e;if(Gt!==null&&(Xi=SA.get(Gt),$t=Re,$t.setIndex(Xi)),pA.isMesh)lA.wireframe===!0?(_e.setLineWidth(lA.wireframeLinewidth*Ie()),$t.setMode(ve.LINES)):$t.setMode(ve.TRIANGLES);else if(pA.isLine){let Vt=lA.linewidth;Vt===void 0&&(Vt=1),_e.setLineWidth(Vt*Ie()),pA.isLineSegments?$t.setMode(ve.LINES):pA.isLineLoop?$t.setMode(ve.LINE_LOOP):$t.setMode(ve.LINE_STRIP)}else pA.isPoints?$t.setMode(ve.POINTS):pA.isSprite&&$t.setMode(ve.TRIANGLES);if(pA.isInstancedMesh)$t.renderInstances(jt,Et,pA.count);else if(EA.isInstancedBufferGeometry){const Vt=EA._maxInstanceCount!==void 0?EA._maxInstanceCount:1/0,En=Math.min(EA.instanceCount,Vt);$t.renderInstances(jt,Et,En)}else $t.render(jt,Et)},this.compile=function(he,eA){function EA(lA,pA,et){lA.transparent===!0&&lA.side===2&&lA.forceSinglePass===!1?(lA.side=v,lA.needsUpdate=!0,Fi(lA,pA,et),lA.side=m,lA.needsUpdate=!0,Fi(lA,pA,et),lA.side=2):Fi(lA,pA,et)}k=ht.get(he),k.init(),_.push(k),he.traverseVisible((function(lA){lA.isLight&&lA.layers.test(eA.layers)&&(k.pushLight(lA),lA.castShadow&&k.pushShadow(lA))})),k.setupLights(N.useLegacyLights),he.traverse((function(lA){const pA=lA.material;if(pA)if(Array.isArray(pA))for(let et=0;et<pA.length;et++)EA(pA[et],he,lA);else EA(pA,he,lA)})),_.pop(),k=null};let ot=null;function wt(){qt.stop()}function mi(){qt.start()}const qt=new MB;function ct(he,eA,EA,lA){if(he.visible===!1)return;if(he.layers.test(eA.layers)){if(he.isGroup)EA=he.renderOrder;else if(he.isLOD)he.autoUpdate===!0&&he.update(eA);else if(he.isLight)k.pushLight(he),he.castShadow&&k.pushShadow(he);else if(he.isSprite){if(!he.frustumCulled||FA.intersectsSprite(he)){lA&&XA.setFromMatrixPosition(he.matrixWorld).applyMatrix4(gA);const et=KA.update(he),It=he.material;It.visible&&w.push(he,et,It,EA,XA.z,null)}}else if((he.isMesh||he.isLine||he.isPoints)&&(!he.frustumCulled||FA.intersectsObject(he))){he.isSkinnedMesh&&he.skeleton.frame!==BA.render.frame&&(he.skeleton.update(),he.skeleton.frame=BA.render.frame);const et=KA.update(he),It=he.material;if(lA&&(et.boundingSphere===null&&et.computeBoundingSphere(),XA.copy(et.boundingSphere.center).applyMatrix4(he.matrixWorld).applyMatrix4(gA)),Array.isArray(It)){const Mt=et.groups;for(let Gt=0,gt=Mt.length;Gt<gt;Gt++){const bt=Mt[Gt],_t=It[bt.materialIndex];_t&&_t.visible&&w.push(he,et,_t,EA,XA.z,bt)}}else It.visible&&w.push(he,et,It,EA,XA.z,null)}}const pA=he.children;for(let et=0,It=pA.length;et<It;et++)ct(pA[et],eA,EA,lA)}function Ft(he,eA,EA,lA){const pA=he.opaque,et=he.transmissive,It=he.transparent;k.setupLightsView(EA),Ye===!0&&J.setGlobalState(N.clippingPlanes,EA),et.length>0&&(function(Mt,Gt,gt,bt){if(bA===null){const Et=je.isWebGL2;bA=new ei(1024,1024,{generateMipmaps:!0,type:Se.has("EXT_color_buffer_half_float")?mA:be,minFilter:se,samples:Et&&h===!0?4:0})}const _t=N.getRenderTarget();N.setRenderTarget(bA),N.clear();const jt=N.toneMapping;N.toneMapping=F,hi(Mt,gt,bt),oe.updateMultisampleRenderTarget(bA),oe.updateRenderTargetMipmap(bA);let Dt=!1;for(let Et=0,Xi=Gt.length;Et<Xi;Et++){const $t=Gt[Et],Vt=$t.object,En=$t.geometry,Li=$t.material,pt=$t.group;if(Li.side===2&&Vt.layers.test(bt.layers)){const bi=Li.side;Li.side=v,Li.needsUpdate=!0,ji(Vt,gt,bt,En,Li,pt),Li.side=bi,Li.needsUpdate=!0,Dt=!0}}Dt===!0&&(oe.updateMultisampleRenderTarget(bA),oe.updateRenderTargetMipmap(bA)),N.setRenderTarget(_t),N.toneMapping=jt})(pA,et,eA,EA),lA&&_e.viewport(ye.copy(lA)),pA.length>0&&hi(pA,eA,EA),et.length>0&&hi(et,eA,EA),It.length>0&&hi(It,eA,EA),_e.buffers.depth.setTest(!0),_e.buffers.depth.setMask(!0),_e.buffers.color.setMask(!0),_e.setPolygonOffset(!1)}function hi(he,eA,EA){const lA=eA.isScene===!0?eA.overrideMaterial:null;for(let pA=0,et=he.length;pA<et;pA++){const It=he[pA],Mt=It.object,Gt=It.geometry,gt=lA===null?It.material:lA,bt=It.group;Mt.layers.test(EA.layers)&&ji(Mt,eA,EA,Gt,gt,bt)}}function ji(he,eA,EA,lA,pA,et){he.onBeforeRender(N,eA,EA,lA,pA,et),he.modelViewMatrix.multiplyMatrices(EA.matrixWorldInverse,he.matrixWorld),he.normalMatrix.getNormalMatrix(he.modelViewMatrix),pA.onBeforeRender(N,eA,EA,lA,he,et),pA.transparent===!0&&pA.side===2&&pA.forceSinglePass===!1?(pA.side=v,pA.needsUpdate=!0,N.renderBufferDirect(EA,eA,lA,pA,he,et),pA.side=m,pA.needsUpdate=!0,N.renderBufferDirect(EA,eA,lA,pA,he,et),pA.side=2):N.renderBufferDirect(EA,eA,lA,pA,he,et),he.onAfterRender(N,eA,EA,lA,pA,et)}function Fi(he,eA,EA){eA.isScene!==!0&&(eA=ce);const lA=ke.get(he),pA=k.state.lights,et=k.state.shadowsArray,It=pA.state.version,Mt=HA.getParameters(he,pA.state,et,eA,EA),Gt=HA.getProgramCacheKey(Mt);let gt=lA.programs;lA.environment=he.isMeshStandardMaterial?eA.environment:null,lA.fog=eA.fog,lA.envMap=(he.isMeshStandardMaterial?cA:Te).get(he.envMap||lA.environment),gt===void 0&&(he.addEventListener("dispose",st),gt=new Map,lA.programs=gt);let bt=gt.get(Gt);if(bt!==void 0){if(lA.currentProgram===bt&&lA.lightsStateVersion===It)return vi(he,Mt),bt}else Mt.uniforms=HA.getUniforms(he),he.onBuild(EA,Mt,N),he.onBeforeCompile(Mt,N),bt=HA.acquireProgram(Mt,Gt),gt.set(Gt,bt),lA.uniforms=Mt.uniforms;const _t=lA.uniforms;(he.isShaderMaterial||he.isRawShaderMaterial)&&he.clipping!==!0||(_t.clippingPlanes=J.uniform),vi(he,Mt),lA.needsLights=(function(Et){return Et.isMeshLambertMaterial||Et.isMeshToonMaterial||Et.isMeshPhongMaterial||Et.isMeshStandardMaterial||Et.isShadowMaterial||Et.isShaderMaterial&&Et.lights===!0})(he),lA.lightsStateVersion=It,lA.needsLights&&(_t.ambientLightColor.value=pA.state.ambient,_t.lightProbe.value=pA.state.probe,_t.directionalLights.value=pA.state.directional,_t.directionalLightShadows.value=pA.state.directionalShadow,_t.spotLights.value=pA.state.spot,_t.spotLightShadows.value=pA.state.spotShadow,_t.rectAreaLights.value=pA.state.rectArea,_t.ltc_1.value=pA.state.rectAreaLTC1,_t.ltc_2.value=pA.state.rectAreaLTC2,_t.pointLights.value=pA.state.point,_t.pointLightShadows.value=pA.state.pointShadow,_t.hemisphereLights.value=pA.state.hemi,_t.directionalShadowMap.value=pA.state.directionalShadowMap,_t.directionalShadowMatrix.value=pA.state.directionalShadowMatrix,_t.spotShadowMap.value=pA.state.spotShadowMap,_t.spotLightMatrix.value=pA.state.spotLightMatrix,_t.spotLightMap.value=pA.state.spotLightMap,_t.pointShadowMap.value=pA.state.pointShadowMap,_t.pointShadowMatrix.value=pA.state.pointShadowMatrix);const jt=bt.getUniforms(),Dt=Hl.seqWithValue(jt.seq,_t);return lA.currentProgram=bt,lA.uniformsList=Dt,bt}function vi(he,eA){const EA=ke.get(he);EA.outputColorSpace=eA.outputColorSpace,EA.instancing=eA.instancing,EA.skinning=eA.skinning,EA.morphTargets=eA.morphTargets,EA.morphNormals=eA.morphNormals,EA.morphColors=eA.morphColors,EA.morphTargetsCount=eA.morphTargetsCount,EA.numClippingPlanes=eA.numClippingPlanes,EA.numIntersection=eA.numClipIntersection,EA.vertexAlphas=eA.vertexAlphas,EA.vertexTangents=eA.vertexTangents,EA.toneMapping=eA.toneMapping}qt.setAnimationLoop((function(he){ot&&ot(he)})),typeof self<"u"&&qt.setContext(self),this.setAnimationLoop=function(he){ot=he,LA.setAnimationLoop(he),he===null?qt.stop():qt.start()},LA.addEventListener("sessionstart",wt),LA.addEventListener("sessionend",mi),this.render=function(he,eA){if(eA!==void 0&&eA.isCamera!==!0||L===!0)return;he.matrixWorldAutoUpdate===!0&&he.updateMatrixWorld(),eA.parent===null&&eA.matrixWorldAutoUpdate===!0&&eA.updateMatrixWorld(),LA.enabled===!0&&LA.isPresenting===!0&&(LA.cameraAutoUpdate===!0&&LA.updateCamera(eA),eA=LA.getCamera()),he.isScene===!0&&he.onBeforeRender(N,he,eA,ne),k=ht.get(he,_.length),k.init(),_.push(k),gA.multiplyMatrices(eA.projectionMatrix,eA.matrixWorldInverse),FA.setFromProjectionMatrix(gA),dA=this.localClippingEnabled,Ye=J.init(this.clippingPlanes,dA),w=Ct.get(he,R.length),w.init(),R.push(w),ct(he,eA,0,N.sortObjects),w.finish(),N.sortObjects===!0&&w.sort(QA,VA),Ye===!0&&J.beginShadows();const EA=k.state.shadowsArray;if($.render(EA,he,eA),Ye===!0&&J.endShadows(),this.info.autoReset===!0&&this.info.reset(),xe.render(w,he),k.setupLights(N.useLegacyLights),eA.isArrayCamera){const lA=eA.cameras;for(let pA=0,et=lA.length;pA<et;pA++){const It=lA[pA];Ft(w,he,It,It.viewport)}}else Ft(w,he,eA);ne!==null&&(oe.updateMultisampleRenderTarget(ne),oe.updateRenderTargetMipmap(ne)),he.isScene===!0&&he.onAfterRender(N,he,eA),YA.resetDefaultState(),te=-1,Ae=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,eA,EA){ke.get(he.texture).__webglTexture=eA,ke.get(he.depthTexture).__webglTexture=EA;const lA=ke.get(he);lA.__hasExternalTextures=!0,lA.__hasExternalTextures&&(lA.__autoAllocateDepthBuffer=EA===void 0,lA.__autoAllocateDepthBuffer||Se.has("WEBGL_multisampled_render_to_texture")===!0&&(lA.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(he,eA){const EA=ke.get(he);EA.__webglFramebuffer=eA,EA.__useDefaultFramebuffer=eA===void 0},this.setRenderTarget=function(he,eA=0,EA=0){ne=he,G=eA,le=EA;let lA=!0,pA=null,et=!1,It=!1;if(he){const Mt=ke.get(he);Mt.__useDefaultFramebuffer!==void 0?(_e.bindFramebuffer(ve.FRAMEBUFFER,null),lA=!1):Mt.__webglFramebuffer===void 0?oe.setupRenderTarget(he):Mt.__hasExternalTextures&&oe.rebindTextures(he,ke.get(he.texture).__webglTexture,ke.get(he.depthTexture).__webglTexture);const Gt=he.texture;(Gt.isData3DTexture||Gt.isDataArrayTexture||Gt.isCompressedArrayTexture)&&(It=!0);const gt=ke.get(he).__webglFramebuffer;he.isWebGLCubeRenderTarget?(pA=gt[eA],et=!0):pA=je.isWebGL2&&he.samples>0&&oe.useMultisampledRTT(he)===!1?ke.get(he).__webglMultisampledFramebuffer:gt,ye.copy(he.viewport),ge.copy(he.scissor),Me=he.scissorTest}else ye.copy(fA).multiplyScalar(CA).floor(),ge.copy(MA).multiplyScalar(CA).floor(),Me=RA;if(_e.bindFramebuffer(ve.FRAMEBUFFER,pA)&&je.drawBuffers&&lA&&_e.drawBuffers(he,pA),_e.viewport(ye),_e.scissor(ge),_e.setScissorTest(Me),et){const Mt=ke.get(he.texture);ve.framebufferTexture2D(ve.FRAMEBUFFER,ve.COLOR_ATTACHMENT0,ve.TEXTURE_CUBE_MAP_POSITIVE_X+eA,Mt.__webglTexture,EA)}else if(It){const Mt=ke.get(he.texture),Gt=eA||0;ve.framebufferTextureLayer(ve.FRAMEBUFFER,ve.COLOR_ATTACHMENT0,Mt.__webglTexture,EA||0,Gt)}te=-1},this.readRenderTargetPixels=function(he,eA,EA,lA,pA,et,It){if(!he||!he.isWebGLRenderTarget)return;let Mt=ke.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&It!==void 0&&(Mt=Mt[It]),Mt){_e.bindFramebuffer(ve.FRAMEBUFFER,Mt);try{const Gt=he.texture,gt=Gt.format,bt=Gt.type;if(gt!==kA&&Pe.convert(gt)!==ve.getParameter(ve.IMPLEMENTATION_COLOR_READ_FORMAT))return;const _t=bt===mA&&(Se.has("EXT_color_buffer_half_float")||je.isWebGL2&&Se.has("EXT_color_buffer_float"));if(!(bt===be||Pe.convert(bt)===ve.getParameter(ve.IMPLEMENTATION_COLOR_READ_TYPE)||bt===De&&(je.isWebGL2||Se.has("OES_texture_float")||Se.has("WEBGL_color_buffer_float"))||_t))return;eA>=0&&eA<=he.width-lA&&EA>=0&&EA<=he.height-pA&&ve.readPixels(eA,EA,lA,pA,Pe.convert(gt),Pe.convert(bt),et)}finally{const Gt=ne!==null?ke.get(ne).__webglFramebuffer:null;_e.bindFramebuffer(ve.FRAMEBUFFER,Gt)}}},this.copyFramebufferToTexture=function(he,eA,EA=0){const lA=Math.pow(2,-EA),pA=Math.floor(eA.image.width*lA),et=Math.floor(eA.image.height*lA);oe.setTexture2D(eA,0),ve.copyTexSubImage2D(ve.TEXTURE_2D,EA,0,0,he.x,he.y,pA,et),_e.unbindTexture()},this.copyTextureToTexture=function(he,eA,EA,lA=0){const pA=eA.image.width,et=eA.image.height,It=Pe.convert(EA.format),Mt=Pe.convert(EA.type);oe.setTexture2D(EA,0),ve.pixelStorei(ve.UNPACK_FLIP_Y_WEBGL,EA.flipY),ve.pixelStorei(ve.UNPACK_PREMULTIPLY_ALPHA_WEBGL,EA.premultiplyAlpha),ve.pixelStorei(ve.UNPACK_ALIGNMENT,EA.unpackAlignment),eA.isDataTexture?ve.texSubImage2D(ve.TEXTURE_2D,lA,he.x,he.y,pA,et,It,Mt,eA.image.data):eA.isCompressedTexture?ve.compressedTexSubImage2D(ve.TEXTURE_2D,lA,he.x,he.y,eA.mipmaps[0].width,eA.mipmaps[0].height,It,eA.mipmaps[0].data):ve.texSubImage2D(ve.TEXTURE_2D,lA,he.x,he.y,It,Mt,eA.image),lA===0&&EA.generateMipmaps&&ve.generateMipmap(ve.TEXTURE_2D),_e.unbindTexture()},this.copyTextureToTexture3D=function(he,eA,EA,lA,pA=0){if(N.isWebGL1Renderer)return;const et=he.max.x-he.min.x+1,It=he.max.y-he.min.y+1,Mt=he.max.z-he.min.z+1,Gt=Pe.convert(lA.format),gt=Pe.convert(lA.type);let bt;if(lA.isData3DTexture)oe.setTexture3D(lA,0),bt=ve.TEXTURE_3D;else{if(!lA.isDataArrayTexture)return;oe.setTexture2DArray(lA,0),bt=ve.TEXTURE_2D_ARRAY}ve.pixelStorei(ve.UNPACK_FLIP_Y_WEBGL,lA.flipY),ve.pixelStorei(ve.UNPACK_PREMULTIPLY_ALPHA_WEBGL,lA.premultiplyAlpha),ve.pixelStorei(ve.UNPACK_ALIGNMENT,lA.unpackAlignment);const _t=ve.getParameter(ve.UNPACK_ROW_LENGTH),jt=ve.getParameter(ve.UNPACK_IMAGE_HEIGHT),Dt=ve.getParameter(ve.UNPACK_SKIP_PIXELS),Et=ve.getParameter(ve.UNPACK_SKIP_ROWS),Xi=ve.getParameter(ve.UNPACK_SKIP_IMAGES),$t=EA.isCompressedTexture?EA.mipmaps[0]:EA.image;ve.pixelStorei(ve.UNPACK_ROW_LENGTH,$t.width),ve.pixelStorei(ve.UNPACK_IMAGE_HEIGHT,$t.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),EA.isDataTexture||EA.isData3DTexture?ve.texSubImage3D(bt,pA,eA.x,eA.y,eA.z,et,It,Mt,Gt,gt,$t.data):EA.isCompressedArrayTexture?ve.compressedTexSubImage3D(bt,pA,eA.x,eA.y,eA.z,et,It,Mt,Gt,$t.data):ve.texSubImage3D(bt,pA,eA.x,eA.y,eA.z,et,It,Mt,Gt,gt,$t),ve.pixelStorei(ve.UNPACK_ROW_LENGTH,_t),ve.pixelStorei(ve.UNPACK_IMAGE_HEIGHT,jt),ve.pixelStorei(ve.UNPACK_SKIP_PIXELS,Dt),ve.pixelStorei(ve.UNPACK_SKIP_ROWS,Et),ve.pixelStorei(ve.UNPACK_SKIP_IMAGES,Xi),pA===0&&lA.generateMipmaps&&ve.generateMipmap(bt),_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(),YA.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:V}}(class extends eE{}).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,A){return super.copy(e,A),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 A=super.toJSON(e);return this.fog!==null&&(A.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(A.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(A.object.backgroundIntensity=this.backgroundIntensity),A}get autoUpdate(){return this.matrixWorldAutoUpdate}set autoUpdate(e){this.matrixWorldAutoUpdate=e}}class AE{constructor(e,A){this.isInterleavedBuffer=!0,this.array=e,this.stride=A,this.count=e!==void 0?e.length/A:0,this.usage=Ve,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=tt()}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,A,t){e*=this.stride,t*=A.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=A.array[t+n];return this}set(e,A=0){return this.array.set(e,A),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=tt()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const A=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),t=new this.constructor(A,this.stride);return t.setUsage(this.usage),t}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=tt()),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,A,t,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=A,this.offset=t,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 A=0,t=this.data.count;A<t;A++)on.fromBufferAttribute(this,A),on.applyMatrix4(e),this.setXYZ(A,on.x,on.y,on.z);return this}applyNormalMatrix(e){for(let A=0,t=this.count;A<t;A++)on.fromBufferAttribute(this,A),on.applyNormalMatrix(e),this.setXYZ(A,on.x,on.y,on.z);return this}transformDirection(e){for(let A=0,t=this.count;A<t;A++)on.fromBufferAttribute(this,A),on.transformDirection(e),this.setXYZ(A,on.x,on.y,on.z);return this}setX(e,A){return this.normalized&&(A=St(A,this.array)),this.data.array[e*this.data.stride+this.offset]=A,this}setY(e,A){return this.normalized&&(A=St(A,this.array)),this.data.array[e*this.data.stride+this.offset+1]=A,this}setZ(e,A){return this.normalized&&(A=St(A,this.array)),this.data.array[e*this.data.stride+this.offset+2]=A,this}setW(e,A){return this.normalized&&(A=St(A,this.array)),this.data.array[e*this.data.stride+this.offset+3]=A,this}getX(e){let A=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(A=nn(A,this.array)),A}getY(e){let A=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(A=nn(A,this.array)),A}getZ(e){let A=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(A=nn(A,this.array)),A}getW(e){let A=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(A=nn(A,this.array)),A}setXY(e,A,t){return e=e*this.data.stride+this.offset,this.normalized&&(A=St(A,this.array),t=St(t,this.array)),this.data.array[e+0]=A,this.data.array[e+1]=t,this}setXYZ(e,A,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(A=St(A,this.array),t=St(t,this.array),n=St(n,this.array)),this.data.array[e+0]=A,this.data.array[e+1]=t,this.data.array[e+2]=n,this}setXYZW(e,A,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(A=St(A,this.array),t=St(t,this.array),n=St(n,this.array),r=St(r,this.array)),this.data.array[e+0]=A,this.data.array[e+1]=t,this.data.array[e+2]=n,this.data.array[e+3]=r,this}clone(e){if(e===void 0){const A=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)A.push(this.data.array[n+r])}return new Wi(new this.array.constructor(A),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 A=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)A.push(this.data.array[n+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:A,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 tE extends Sn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new rt(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 GA,Yo=new GA,iE=new xt,Jl=new re,Po=new re,Yl=new re,nE=new GA,zh=new GA,rE=new GA;class HS extends gi{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",Ra===void 0){Ra=new bn;const A=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new AE(A,5);Ra.setIndex([0,1,2,0,2,3]),Ra.setAttribute("position",new Ho(t,3,0,!1)),Ra.setAttribute("uv",new Ho(t,2,3,!1))}this.geometry=Ra,this.material=e!==void 0?e:new tE,this.center=new GA(.5,.5)}raycast(e,A){e.camera,Na.setFromMatrixScale(this.matrixWorld),iE.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 t=this.material.rotation;let n,r;t!==0&&(r=Math.cos(t),n=Math.sin(t));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),nE.set(0,0),zh.set(1,0),rE.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||A.push({distance:u,point:Jo.clone(),uv:Hn.getInterpolation(Jo,Jl,Po,Yl,nE,zh,rE,new GA),face:null,object:this})}copy(e,A){return super.copy(e,A),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Pl(o,e,A,t,n,r){Fa.subVectors(o,A).addScalar(.5).multiply(t),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(iE)}const sE=new re,aE=new zt,oE=new zt,JS=new re,gE=new xt,La=new re;class YS extends Ut{constructor(e,A){super(e,A),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new xt,this.bindMatrixInverse=new xt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Mi),this.boundingBox.makeEmpty();const A=e.getAttribute("position");for(let t=0;t<A.count;t++)La.fromBufferAttribute(A,t),this.applyBoneTransform(t,La),this.boundingBox.expandByPoint(La)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ur),this.boundingSphere.makeEmpty();const A=e.getAttribute("position");for(let t=0;t<A.count;t++)La.fromBufferAttribute(A,t),this.applyBoneTransform(t,La),this.boundingSphere.expandByPoint(La)}copy(e,A){return super.copy(e,A),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}getVertexPosition(e,A){return super.getVertexPosition(e,A),this.applyBoneTransform(e,A),A}bind(e,A){this.skeleton=e,A===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),A=this.matrixWorld),this.bindMatrix.copy(A),this.bindMatrixInverse.copy(A).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new zt,A=this.geometry.attributes.skinWeight;for(let t=0,n=A.count;t<n;t++){e.fromBufferAttribute(A,t);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),A.setXYZW(t,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,A){const t=this.skeleton,n=this.geometry;aE.fromBufferAttribute(n.attributes.skinIndex,e),oE.fromBufferAttribute(n.attributes.skinWeight,e),sE.copy(A).applyMatrix4(this.bindMatrix),A.set(0,0,0);for(let r=0;r<4;r++){const g=oE.getComponent(r);if(g!==0){const h=aE.getComponent(r);gE.multiplyMatrices(t.bones[h].matrixWorld,t.boneInverses[h]),A.addScaledVector(JS.copy(sE).applyMatrix4(gE),g)}}return A.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,A){return this.applyBoneTransform(e,A)}}class lE extends gi{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Cs extends Di{constructor(e=null,A=1,t=1,n,r,g,h,u,c=1003,C=1003,E,p){super(null,g,h,u,c,C,n,r,E,p),this.isDataTexture=!0,this.image={data:e,width:A,height:t},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const cE=new xt,PS=new xt;class qh{constructor(e=[],A=[]){this.uuid=tt(),this.bones=e.slice(0),this.boneInverses=A,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const e=this.bones,A=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),A.length===0)this.calculateInverses();else if(e.length!==A.length){this.boneInverses=[];for(let t=0,n=this.bones.length;t<n;t++)this.boneInverses.push(new xt)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,A=this.bones.length;e<A;e++){const t=new xt;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,A=this.bones.length;e<A;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,A=this.bones.length;e<A;e++){const t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){const e=this.bones,A=this.boneInverses,t=this.boneMatrices,n=this.boneTexture;for(let r=0,g=e.length;r<g;r++){const h=e[r]?e[r].matrixWorld:PS;cE.multiplyMatrices(h,A[r]),cE.toArray(t,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 A=new Float32Array(e*e*4);A.set(this.boneMatrices);const t=new Cs(A,e,e,kA,De);return t.needsUpdate=!0,this.boneMatrices=A,this.boneTexture=t,this.boneTextureSize=e,this}getBoneByName(e){for(let A=0,t=this.bones.length;A<t;A++){const n=this.bones[A];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,A){this.uuid=e.uuid;for(let t=0,n=e.bones.length;t<n;t++){const r=e.bones[t];let g=A[r];g===void 0&&(g=new lE),this.bones.push(g),this.boneInverses.push(new xt().fromArray(e.boneInverses[t]))}return this.init(),this}toJSON(){const e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const A=this.bones,t=this.boneInverses;for(let n=0,r=A.length;n<r;n++){const g=A[n];e.bones.push(g.uuid);const h=t[n];e.boneInverses.push(h.toArray())}return e}}class hE extends Wi{constructor(e,A,t,n=1){super(e,A,t),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 xt,IE=new xt,Ol=[],uE=new Mi,OS=new xt,Oo=new Ut,Ko=new Ur;class KS extends Ut{constructor(e,A,t){super(e,A),this.isInstancedMesh=!0,this.instanceMatrix=new hE(new Float32Array(16*t),16),this.instanceColor=null,this.count=t,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<t;n++)this.setMatrixAt(n,OS)}computeBoundingBox(){const e=this.geometry,A=this.count;this.boundingBox===null&&(this.boundingBox=new Mi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let t=0;t<A;t++)this.getMatrixAt(t,Ga),uE.copy(e.boundingBox).applyMatrix4(Ga),this.boundingBox.union(uE)}computeBoundingSphere(){const e=this.geometry,A=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ur),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let t=0;t<A;t++)this.getMatrixAt(t,Ga),Ko.copy(e.boundingSphere).applyMatrix4(Ga),this.boundingSphere.union(Ko)}copy(e,A){return super.copy(e,A),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,A){A.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,A){A.fromArray(this.instanceMatrix.array,16*e)}raycast(e,A){const t=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(t),e.ray.intersectsSphere(Ko)!==!1))for(let r=0;r<n;r++){this.getMatrixAt(r,Ga),IE.multiplyMatrices(t,Ga),Oo.matrixWorld=IE,Oo.raycast(e,Ol);for(let g=0,h=Ol.length;g<h;g++){const u=Ol[g];u.instanceId=r,u.object=this,A.push(u)}Ol.length=0}}setColorAt(e,A){this.instanceColor===null&&(this.instanceColor=new hE(new Float32Array(3*this.instanceMatrix.count),3)),A.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,A){A.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class CE extends Sn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new rt(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 dE=new re,BE=new re,EE=new xt,Vh=new Lo,Kl=new Ur;class Wh extends gi{constructor(e=new bn,A=new CE){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=A,this.updateMorphTargets()}copy(e,A){return super.copy(e,A),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const A=e.attributes.position,t=[0];for(let n=1,r=A.count;n<r;n++)dE.fromBufferAttribute(A,n-1),BE.fromBufferAttribute(A,n),t[n]=t[n-1],t[n]+=dE.distanceTo(BE);e.setAttribute("lineDistance",new Cn(t,1))}return this}raycast(e,A){const t=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,g=t.drawRange;if(t.boundingSphere===null&&t.computeBoundingSphere(),Kl.copy(t.boundingSphere),Kl.applyMatrix4(n),Kl.radius+=r,e.ray.intersectsSphere(Kl)===!1)return;EE.copy(n).invert(),Vh.copy(e.ray).applyMatrix4(EE);const h=r/((this.scale.x+this.scale.y+this.scale.z)/3),u=h*h,c=new re,C=new re,E=new re,p=new re,w=this.isLineSegments?2:1,k=t.index,R=t.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),Vh.distanceSqToSegment(c,C,p,E)>u)continue;p.applyMatrix4(this.matrixWorld);const le=e.ray.origin.distanceTo(p);le<e.near||le>e.far||A.push({distance:le,point:E.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),Vh.distanceSqToSegment(c,C,p,E)>u)continue;p.applyMatrix4(this.matrixWorld);const L=e.ray.origin.distanceTo(p);L<e.near||L>e.far||A.push({distance:L,point:E.clone().applyMatrix4(this.matrixWorld),index:_,face:null,faceIndex:null,object:this})}}updateMorphTargets(){const e=this.geometry.morphAttributes,A=Object.keys(e);if(A.length>0){const t=e[A[0]];if(t!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=t.length;n<r;n++){const g=t[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[g]=n}}}}}const QE=new re,fE=new re;class zS extends Wh{constructor(e,A){super(e,A),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const A=e.attributes.position,t=[];for(let n=0,r=A.count;n<r;n+=2)QE.fromBufferAttribute(A,n),fE.fromBufferAttribute(A,n+1),t[n]=n===0?0:t[n-1],t[n+1]=t[n]+QE.distanceTo(fE);e.setAttribute("lineDistance",new Cn(t,1))}return this}}class qS extends Wh{constructor(e,A){super(e,A),this.isLineLoop=!0,this.type="LineLoop"}}class pE extends Sn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new rt(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 mE=new xt,Zh=new Lo,zl=new Ur,ql=new re;class VS extends gi{constructor(e=new bn,A=new pE){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=A,this.updateMorphTargets()}copy(e,A){return super.copy(e,A),this.material=e.material,this.geometry=e.geometry,this}raycast(e,A){const t=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,g=t.drawRange;if(t.boundingSphere===null&&t.computeBoundingSphere(),zl.copy(t.boundingSphere),zl.applyMatrix4(n),zl.radius+=r,e.ray.intersectsSphere(zl)===!1)return;mE.copy(n).invert(),Zh.copy(e.ray).applyMatrix4(mE);const h=r/((this.scale.x+this.scale.y+this.scale.z)/3),u=h*h,c=t.index,C=t.attributes.position;if(c!==null)for(let E=Math.max(0,g.start),p=Math.min(c.count,g.start+g.count);E<p;E++){const w=c.getX(E);ql.fromBufferAttribute(C,w),wE(ql,w,u,n,e,A,this)}else for(let E=Math.max(0,g.start),p=Math.min(C.count,g.start+g.count);E<p;E++)ql.fromBufferAttribute(C,E),wE(ql,E,u,n,e,A,this)}updateMorphTargets(){const e=this.geometry.morphAttributes,A=Object.keys(e);if(A.length>0){const t=e[A[0]];if(t!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=t.length;n<r;n++){const g=t[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[g]=n}}}}}function wE(o,e,A,t,n,r,g){const h=Zh.distanceSqToPoint(o);if(h<A){const u=new re;Zh.closestPointToPoint(o,u),u.applyMatrix4(t);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 yE extends Di{constructor(e,A,t,n,r,g,h,u,c){super(e,A,t,n,r,g,h,u,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Vl extends bn{constructor(e=1,A=32,t=16,n=0,r=2*Math.PI,g=0,h=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:A,heightSegments:t,phiStart:n,phiLength:r,thetaStart:g,thetaLength:h},A=Math.max(3,Math.floor(A)),t=Math.max(2,Math.floor(t));const u=Math.min(g+h,Math.PI);let c=0;const C=[],E=new re,p=new re,w=[],k=[],R=[],_=[];for(let N=0;N<=t;N++){const L=[],G=N/t;let le=0;N===0&&g===0?le=.5/A:N===t&&u===Math.PI&&(le=-.5/A);for(let ne=0;ne<=A;ne++){const te=ne/A;E.x=-e*Math.cos(n+te*r)*Math.sin(g+G*h),E.y=e*Math.cos(g+G*h),E.z=e*Math.sin(n+te*r)*Math.sin(g+G*h),k.push(E.x,E.y,E.z),p.copy(E).normalize(),R.push(p.x,p.y,p.z),_.push(te+le,1-G),L.push(c++)}C.push(L)}for(let N=0;N<t;N++)for(let L=0;L<A;L++){const G=C[N][L+1],le=C[N][L],ne=C[N+1][L],te=C[N+1][L+1];(N!==0||g>0)&&w.push(G,le,te),(N!==t-1||u<Math.PI)&&w.push(le,ne,te)}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 Vl(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 rt(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 rt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new GA(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 GA(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return yt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(A){this.ior=(1+.4*A)/(1-.4*A)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new rt(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 rt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new rt(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,A){return vE(o)?new o.constructor(o.subarray(e,A!==void 0?A:o.length)):o.slice(e,A)}function Wl(o,e,A){return!o||o.constructor===e?o:typeof e.BYTES_PER_ELEMENT=="number"?new e(o):Array.prototype.slice.call(o)}function vE(o){return ArrayBuffer.isView(o)&&!(o instanceof DataView)}function WS(o){const e=o.length,A=new Array(e);for(let t=0;t!==e;++t)A[t]=t;return A.sort((function(t,n){return o[t]-o[n]})),A}function DE(o,e,A){const t=o.length,n=new o.constructor(t);for(let r=0,g=0;g!==t;++r){const h=A[r]*e;for(let u=0;u!==e;++u)n[g++]=o[h+u]}return n}function ME(o,e,A,t){let n=1,r=o[0];for(;r!==void 0&&r[t]===void 0;)r=o[n++];if(r===void 0)return;let g=r[t];if(g!==void 0)if(Array.isArray(g))do g=r[t],g!==void 0&&(e.push(r.time),A.push.apply(A,g)),r=o[n++];while(r!==void 0);else if(g.toArray!==void 0)do g=r[t],g!==void 0&&(e.push(r.time),g.toArray(A,A.length)),r=o[n++];while(r!==void 0);else do g=r[t],g!==void 0&&(e.push(r.time),A.push(g)),r=o[n++];while(r!==void 0)}class zo{constructor(e,A,t,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new A.constructor(t),this.sampleValues=A,this.valueSize=t,this.settings=null,this.DefaultSettings_={}}evaluate(e){const A=this.parameterPositions;let t=this._cachedIndex,n=A[t],r=A[t-1];e:{A:{let g;t:{i:if(!(e<n)){for(let h=t+2;;){if(n===void 0){if(e<r)break i;return t=A.length,this._cachedIndex=t,this.copySampleValue_(t-1)}if(t===h)break;if(r=n,n=A[++t],e<n)break A}g=A.length;break t}if(e>=r)break e;{const h=A[1];e<h&&(t=2,r=h);for(let u=t-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(t===u)break;if(n=r,r=A[--t-1],e>=r)break A}g=t,t=0}}for(;t<g;){const h=t+g>>>1;e<A[h]?g=h:t=h+1}if(n=A[t],r=A[t-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return t=A.length,this._cachedIndex=t,this.copySampleValue_(t-1)}this._cachedIndex=t,this.intervalChanged_(t,r,n)}return this.interpolate_(t,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const A=this.resultBuffer,t=this.sampleValues,n=this.valueSize,r=e*n;for(let g=0;g!==n;++g)A[g]=t[r+g];return A}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class ZS extends zo{constructor(e,A,t,n){super(e,A,t,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:tA,endingEnd:tA}}intervalChanged_(e,A,t){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 aA:r=e,h=2*A-t;break;case DA:r=n.length-2,h=A+n[r]-n[r+1];break;default:r=e,h=t}if(u===void 0)switch(this.getSettings_().endingEnd){case aA:g=e,u=2*t-A;break;case DA:g=1,u=t+n[1]-n[0];break;default:g=e-1,u=A}const c=.5*(t-A),C=this.valueSize;this._weightPrev=c/(A-h),this._weightNext=c/(u-t),this._offsetPrev=r*C,this._offsetNext=g*C}interpolate_(e,A,t,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=e*h,c=u-h,C=this._offsetPrev,E=this._offsetNext,p=this._weightPrev,w=this._weightNext,k=(t-A)/(n-A),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[E+ne];return r}}class SE extends zo{constructor(e,A,t,n){super(e,A,t,n)}interpolate_(e,A,t,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=e*h,c=u-h,C=(t-A)/(n-A),E=1-C;for(let p=0;p!==h;++p)r[p]=g[c+p]*E+g[u+p]*C;return r}}class jS extends zo{constructor(e,A,t,n){super(e,A,t,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class Qr{constructor(e,A,t,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(A===void 0||A.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Wl(A,this.TimeBufferType),this.values=Wl(t,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const A=e.constructor;let t;if(A.toJSON!==this.toJSON)t=A.toJSON(e);else{t={name:e.name,times:Wl(e.times,Array),values:Wl(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(t.interpolation=n)}return t.type=e.ValueTypeName,t}InterpolantFactoryMethodDiscrete(e){return new jS(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new SE(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ZS(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let A;switch(e){case Ue:A=this.InterpolantFactoryMethodDiscrete;break;case Oe:A=this.InterpolantFactoryMethodLinear;break;case Ke:A=this.InterpolantFactoryMethodSmooth}if(A===void 0){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return this}return this.createInterpolant=A,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 A=this.times;for(let t=0,n=A.length;t!==n;++t)A[t]+=e}return this}scale(e){if(e!==1){const A=this.times;for(let t=0,n=A.length;t!==n;++t)A[t]*=e}return this}trim(e,A){const t=this.times,n=t.length;let r=0,g=n-1;for(;r!==n&&t[r]<e;)++r;for(;g!==-1&&t[g]>A;)--g;if(++g,r!==0||g!==n){r>=g&&(g=Math.max(g,1),r=g-1);const h=this.getValueSize();this.times=ds(t,r,g),this.values=ds(this.values,r*h,g*h)}return this}validate(){let e=!0;const A=this.getValueSize();A-Math.floor(A)!=0&&(e=!1);const t=this.times,n=this.values,r=t.length;r===0&&(e=!1);let g=null;for(let h=0;h!==r;h++){const u=t[h];if(typeof u=="number"&&isNaN(u)){e=!1;break}if(g!==null&&g>u){e=!1;break}g=u}if(n!==void 0&&vE(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),A=ds(this.values),t=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*t,E=C-t,p=C+t;for(let w=0;w!==t;++w){const k=A[C+w];if(k!==A[E+w]||k!==A[p+w]){u=!0;break}}}if(u){if(h!==g){e[g]=e[h];const C=h*t,E=g*t;for(let p=0;p!==t;++p)A[E+p]=A[C+p]}++g}}if(r>0){e[g]=e[r];for(let h=r*t,u=g*t,c=0;c!==t;++c)A[u+c]=A[h+c];++g}return g!==e.length?(this.times=ds(e,0,g),this.values=ds(A,0,g*t)):(this.times=e,this.values=A),this}clone(){const e=ds(this.times,0),A=ds(this.values,0),t=new this.constructor(this.name,e,A);return t.createInterpolant=this.createInterpolant,t}}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 xE extends Qr{}xE.prototype.ValueTypeName="color";class qo extends Qr{}qo.prototype.ValueTypeName="number";class XS extends zo{constructor(e,A,t,n){super(e,A,t,n)}interpolate_(e,A,t,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=(t-A)/(n-A);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 XS(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 Vo extends Qr{}Vo.prototype.ValueTypeName="vector";class jh{constructor(e,A=-1,t,n=2500){this.name=e,this.tracks=t,this.duration=A,this.blendMode=n,this.uuid=tt(),this.duration<0&&this.resetDuration()}static parse(e){const A=[],t=e.tracks,n=1/(e.fps||1);for(let g=0,h=t.length;g!==h;++g)A.push($S(t[g]).scale(n));const r=new this(e.name,e.duration,A,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const A=[],t=e.tracks,n={name:e.name,duration:e.duration,tracks:A,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,g=t.length;r!==g;++r)A.push(Qr.toJSON(t[r]));return n}static CreateFromMorphTargetSequence(e,A,t,n){const r=A.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=WS(u);u=DE(u,1,C),c=DE(c,1,C),n||u[0]!==0||(u.push(r),c.push(c[0])),g.push(new qo(".morphTargetInfluences["+A[h].name+"]",u,c).scale(1/t))}return new this(e,-1,g)}static findByName(e,A){let t=e;if(!Array.isArray(e)){const n=e;t=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<t.length;n++)if(t[n].name===A)return t[n];return null}static CreateClipsFromMorphTargetSequences(e,A,t){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 E=C[1];let p=n[E];p||(n[E]=p=[]),p.push(c)}}const g=[];for(const h in n)g.push(this.CreateFromMorphTargetSequence(h,n[h],A,t));return g}static parseAnimation(e,A){if(!e)return null;const t=function(C,E,p,w,k){if(p.length!==0){const R=[],_=[];ME(p,R,_,w),R.length!==0&&k.push(new C(E,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 E=c[C].keys;if(E&&E.length!==0)if(E[0].morphTargets){const p={};let w;for(w=0;w<E.length;w++)if(E[w].morphTargets)for(let k=0;k<E[w].morphTargets.length;k++)p[E[w].morphTargets[k]]=-1;for(const k in p){const R=[],_=[];for(let N=0;N!==E[w].morphTargets.length;++N){const L=E[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["+A[C].name+"]";t(Vo,p+".position",E,"pos",n),t(Os,p+".quaternion",E,"rot",n),t(Vo,p+".scale",E,"scl",n)}}return n.length===0?null:new this(r,u,n,h)}resetDuration(){let e=0;for(let A=0,t=this.tracks.length;A!==t;++A){const n=this.tracks[A];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 A=0;A<this.tracks.length;A++)e=e&&this.tracks[A].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let A=0;A<this.tracks.length;A++)e.push(this.tracks[A].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function $S(o){if(o.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=(function(A){switch(A.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return qo;case"vector":case"vector2":case"vector3":case"vector4":return Vo;case"color":return xE;case"quaternion":return Os;case"bool":case"boolean":return Ua;case"string":return Ta}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+A)})(o.type);if(o.times===void 0){const A=[],t=[];ME(o.keys,A,t,"value"),o.times=A,o.values=t}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 ex{constructor(e,A,t){const n=this;let r,g=!1,h=0,u=0;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=A,this.onError=t,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,E){return c.push(C,E),this},this.removeHandler=function(C){const E=c.indexOf(C);return E!==-1&&c.splice(E,2),this},this.getHandler=function(C){for(let E=0,p=c.length;E<p;E+=2){const w=c[E],k=c[E+1];if(w.global&&(w.lastIndex=0),w.test(C))return k}return null}}}const Ax=new ex;class Ja{constructor(e){this.manager=e!==void 0?e:Ax,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,A){const t=this;return new Promise((function(n,r){t.load(e,n,A,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 tx extends Error{constructor(e,A){super(e),this.response=A}}class Xh extends Ja{constructor(e){super(e)}load(e,A,t,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((()=>{A&&A(r),this.manager.itemEnd(e)}),0),r;if(Or[e]!==void 0)return void Or[e].push({onLoad:A,onProgress:t,onError:n});Or[e]=[],Or[e].push({onLoad:A,onProgress:t,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],E=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(){E.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 te=0,Ae=C.length;te<Ae;te++){const ye=C[te];ye.onProgress&&ye.onProgress(ne)}N.enqueue(le),L()}}))})()}});return new Response(_)}throw new tx(`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),E=C&&C[1]?C[1].toLowerCase():void 0,p=new TextDecoder(E);return c.arrayBuffer().then((w=>p.decode(w)))}}})).then((c=>{Ha.add(e,c);const C=Or[e];delete Or[e];for(let E=0,p=C.length;E<p;E++){const w=C[E];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 E=0,p=C.length;E<p;E++){const w=C[E];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 ix extends Ja{constructor(e){super(e)}load(e,A,t,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(){A&&A(g),r.manager.itemEnd(e)}),0),g;const h=wn("img");function u(){C(),Ha.add(e,this),A&&A(this),r.manager.itemEnd(e)}function c(E){C(),n&&n(E),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 nx extends Ja{constructor(e){super(e)}load(e,A,t,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,A&&A(g,c))}),t,n),g}}class Ya extends Ja{constructor(e){super(e)}load(e,A,t,n){const r=new Di,g=new ix(this.manager);return g.setCrossOrigin(this.crossOrigin),g.setPath(this.path),g.load(e,(function(h){r.image=h,r.needsUpdate=!0,A!==void 0&&A(r)}),t,n),r}}class Zl extends gi{constructor(e,A=1){super(),this.isLight=!0,this.type="Light",this.color=new rt(e),this.intensity=A}dispose(){}copy(e,A){return super.copy(e,A),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const A=super.toJSON(e);return A.object.color=this.color.getHex(),A.object.intensity=this.intensity,this.groundColor!==void 0&&(A.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(A.object.distance=this.distance),this.angle!==void 0&&(A.object.angle=this.angle),this.decay!==void 0&&(A.object.decay=this.decay),this.penumbra!==void 0&&(A.object.penumbra=this.penumbra),this.shadow!==void 0&&(A.object.shadow=this.shadow.toJSON()),A}}const $h=new xt,bE=new re,_E=new re;class eI{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new GA(512,512),this.map=null,this.mapPass=null,this.matrix=new xt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Th,this._frameExtents=new GA(1,1),this._viewportCount=1,this._viewports=[new zt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const A=this.camera,t=this.matrix;bE.setFromMatrixPosition(e.matrixWorld),A.position.copy(bE),_E.setFromMatrixPosition(e.target.matrixWorld),A.lookAt(_E),A.updateMatrixWorld(),$h.multiplyMatrices(A.projectionMatrix,A.matrixWorldInverse),this._frustum.setFromProjectionMatrix($h),t.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),t.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 rx extends eI{constructor(){super(new Zi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const A=this.camera,t=2*Rt*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=e.distance||A.far;t===A.fov&&n===A.aspect&&r===A.far||(A.fov=t,A.aspect=n,A.far=r,A.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class sx extends Zl{constructor(e,A,t=0,n=Math.PI/3,r=0,g=2){super(e,A),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gi.DEFAULT_UP),this.updateMatrix(),this.target=new gi,this.distance=t,this.angle=n,this.penumbra=r,this.decay=g,this.map=null,this.shadow=new rx}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,A){return super.copy(e,A),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 RE=new xt,Wo=new re,AI=new re;class ax extends eI{constructor(){super(new Zi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new GA(4,2),this._viewportCount=6,this._viewports=[new zt(2,1,1,1),new zt(0,1,1,1),new zt(3,1,1,1),new zt(1,1,1,1),new zt(3,0,1,1),new zt(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,A=0){const t=this.camera,n=this.matrix,r=e.distance||t.far;r!==t.far&&(t.far=r,t.updateProjectionMatrix()),Wo.setFromMatrixPosition(e.matrixWorld),t.position.copy(Wo),AI.copy(t.position),AI.add(this._cubeDirections[A]),t.up.copy(this._cubeUps[A]),t.lookAt(AI),t.updateMatrixWorld(),n.makeTranslation(-Wo.x,-Wo.y,-Wo.z),RE.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(RE)}}class ox extends Zl{constructor(e,A,t=0,n=2){super(e,A),this.isPointLight=!0,this.type="PointLight",this.distance=t,this.decay=n,this.shadow=new ax}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,A){return super.copy(e,A),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class gx extends eI{constructor(){super(new _n(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class NE extends Zl{constructor(e,A){super(e,A),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gi.DEFAULT_UP),this.updateMatrix(),this.target=new gi,this.shadow=new gx}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class lx extends Zl{constructor(e,A){super(e,A),this.isAmbientLight=!0,this.type="AmbientLight"}}class tI{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let A="";for(let t=0,n=e.length;t<n;t++)A+=String.fromCharCode(e[t]);try{return decodeURIComponent(escape(A))}catch{return A}}static extractUrlBase(e){const A=e.lastIndexOf("/");return A===-1?"./":e.slice(0,A+1)}static resolveURL(e,A){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(A)&&/^\//.test(e)&&(A=A.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:A+e)}}class cx extends Ja{constructor(e){super(e),this.isImageBitmapLoader=!0,this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,A,t,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(){A&&A(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),A&&A(u),r.manager.itemEnd(e)})).catch((function(u){n&&n(u),r.manager.itemError(e),r.manager.itemEnd(e)})),r.manager.itemStart(e)}}class hx{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=kE(),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 A=kE();e=(A-this.oldTime)/1e3,this.oldTime=A,this.elapsedTime+=e}return e}}function kE(){return(typeof performance>"u"?Date:performance).now()}class Ix{constructor(e,A,t){let n,r,g;switch(this.binding=e,this.valueSize=t,A){case"quaternion":n=this._slerp,r=this._slerpAdditive,g=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*t),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,g=this._setAdditiveIdentityOther,this.buffer=new Array(5*t);break;default:n=this._lerp,r=this._lerpAdditive,g=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*t)}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,A){const t=this.buffer,n=this.valueSize,r=e*n+n;let g=this.cumulativeWeight;if(g===0){for(let h=0;h!==n;++h)t[r+h]=t[h];g=A}else{g+=A;const h=A/g;this._mixBufferRegion(t,r,0,h,n)}this.cumulativeWeight=g}accumulateAdditive(e){const A=this.buffer,t=this.valueSize,n=t*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(A,n,0,e,t),this.cumulativeWeightAdditive+=e}apply(e){const A=this.valueSize,t=this.buffer,n=e*A+A,r=this.cumulativeWeight,g=this.cumulativeWeightAdditive,h=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const u=A*this._origIndex;this._mixBufferRegion(t,n,u,1-r,A)}g>0&&this._mixBufferRegionAdditive(t,n,this._addIndex*A,1,A);for(let u=A,c=A+A;u!==c;++u)if(t[u]!==t[u+A]){h.setValue(t,n);break}}saveOriginalState(){const e=this.binding,A=this.buffer,t=this.valueSize,n=t*this._origIndex;e.getValue(A,n);for(let r=t,g=n;r!==g;++r)A[r]=A[n+r%t];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,A=e+this.valueSize;for(let t=e;t<A;t++)this.buffer[t]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,A=this._addIndex*this.valueSize;for(let t=0;t<this.valueSize;t++)this.buffer[A+t]=this.buffer[e+t]}_select(e,A,t,n,r){if(n>=.5)for(let g=0;g!==r;++g)e[A+g]=e[t+g]}_slerp(e,A,t,n){Ui.slerpFlat(e,A,e,A,e,t,n)}_slerpAdditive(e,A,t,n,r){const g=this._workIndex*r;Ui.multiplyQuaternionsFlat(e,g,e,A,e,t),Ui.slerpFlat(e,A,e,A,e,g,n)}_lerp(e,A,t,n,r){const g=1-n;for(let h=0;h!==r;++h){const u=A+h;e[u]=e[u]*g+e[t+h]*n}}_lerpAdditive(e,A,t,n,r){for(let g=0;g!==r;++g){const h=A+g;e[h]=e[h]+e[t+g]*n}}}const iI="\\[\\]\\.:\\/",ux=new RegExp("["+iI+"]","g"),nI="[^"+iI+"]",Cx="[^"+iI.replace("\\.","")+"]",dx=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",nI)+/(WCOD+)?/.source.replace("WCOD",Cx)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",nI)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",nI)+"$"),Bx=["material","materials","bones","map"];class Zt{constructor(e,A,t){this.path=A,this.parsedPath=t||Zt.parseTrackName(A),this.node=Zt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,A,t){return e&&e.isAnimationObjectGroup?new Zt.Composite(e,A,t):new Zt(e,A,t)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(ux,"")}static parseTrackName(e){const A=dx.exec(e);if(A===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const t={nodeName:A[2],objectName:A[3],objectIndex:A[4],propertyName:A[5],propertyIndex:A[6]},n=t.nodeName&&t.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const r=t.nodeName.substring(n+1);Bx.indexOf(r)!==-1&&(t.nodeName=t.nodeName.substring(0,n),t.objectName=r)}if(t.propertyName===null||t.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return t}static findNode(e,A){if(A===void 0||A===""||A==="."||A===-1||A===e.name||A===e.uuid)return e;if(e.skeleton){const t=e.skeleton.getBoneByName(A);if(t!==void 0)return t}if(e.children){const t=function(r){for(let g=0;g<r.length;g++){const h=r[g];if(h.name===A||h.uuid===A)return h;const u=t(h.children);if(u)return u}return null},n=t(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,A){e[A]=this.targetObject[this.propertyName]}_getValue_array(e,A){const t=this.resolvedProperty;for(let n=0,r=t.length;n!==r;++n)e[A++]=t[n]}_getValue_arrayElement(e,A){e[A]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,A){this.resolvedProperty.toArray(e,A)}_setValue_direct(e,A){this.targetObject[this.propertyName]=e[A]}_setValue_direct_setNeedsUpdate(e,A){this.targetObject[this.propertyName]=e[A],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,A){this.targetObject[this.propertyName]=e[A],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,A){const t=this.resolvedProperty;for(let n=0,r=t.length;n!==r;++n)t[n]=e[A++]}_setValue_array_setNeedsUpdate(e,A){const t=this.resolvedProperty;for(let n=0,r=t.length;n!==r;++n)t[n]=e[A++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,A){const t=this.resolvedProperty;for(let n=0,r=t.length;n!==r;++n)t[n]=e[A++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,A){this.resolvedProperty[this.propertyIndex]=e[A]}_setValue_arrayElement_setNeedsUpdate(e,A){this.resolvedProperty[this.propertyIndex]=e[A],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,A){this.resolvedProperty[this.propertyIndex]=e[A],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,A){this.resolvedProperty.fromArray(e,A)}_setValue_fromArray_setNeedsUpdate(e,A){this.resolvedProperty.fromArray(e,A),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,A){this.resolvedProperty.fromArray(e,A),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,A){this.bind(),this.getValue(e,A)}_setValue_unbound(e,A){this.bind(),this.setValue(e,A)}bind(){let e=this.node;const A=this.parsedPath,t=A.objectName,n=A.propertyName;let r=A.propertyIndex;if(e||(e=Zt.findNode(this.rootNode,A.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void this.path;if(t){let c=A.objectIndex;switch(t){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[t]===void 0)return;e=e[t]}if(c!==void 0){if(e[c]===void 0)return;e=e[c]}}const g=e[n];if(g===void 0){A.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}}Zt.Composite=class{constructor(o,e,A){const t=A||Zt.parseTrackName(e);this._targetGroup=o,this._bindings=o.subscribe_(e,t)}getValue(o,e){this.bind();const A=this._targetGroup.nCachedObjects_,t=this._bindings[A];t!==void 0&&t.getValue(o,e)}setValue(o,e){const A=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=A.length;t!==n;++t)A[t].setValue(o,e)}bind(){const o=this._bindings;for(let e=this._targetGroup.nCachedObjects_,A=o.length;e!==A;++e)o[e].bind()}unbind(){const o=this._bindings;for(let e=this._targetGroup.nCachedObjects_,A=o.length;e!==A;++e)o[e].unbind()}},Zt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Zt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Zt.prototype.GetterByBindingType=[Zt.prototype._getValue_direct,Zt.prototype._getValue_array,Zt.prototype._getValue_arrayElement,Zt.prototype._getValue_toArray],Zt.prototype.SetterByBindingTypeAndVersioning=[[Zt.prototype._setValue_direct,Zt.prototype._setValue_direct_setNeedsUpdate,Zt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_array,Zt.prototype._setValue_array_setNeedsUpdate,Zt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_arrayElement,Zt.prototype._setValue_arrayElement_setNeedsUpdate,Zt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_fromArray,Zt.prototype._setValue_fromArray_setNeedsUpdate,Zt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Ex{constructor(e,A,t=null,n=A.blendMode){this._mixer=e,this._clip=A,this._localRoot=t,this.blendMode=n;const r=A.tracks,g=r.length,h=new Array(g),u={endingStart:tA,endingEnd:tA};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,A){return this.loop=e,this.repetitions=A,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,A,t){if(e.fadeOut(A),this.fadeIn(A),t){const n=this._clip.duration,r=e._clip.duration,g=r/n,h=n/r;e.warp(1,g,A),this.warp(h,1,A)}return this}crossFadeTo(e,A,t){return e.crossFadeFrom(this,A,t)}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,A,t){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+t,c[0]=e/g,c[1]=A/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,A,t,n){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(r!==null){const u=(e-r)*t;u<0||t===0?A=0:(this._startTime=null,A=t*u)}A*=this._updateTimeScale(e);const g=this._updateTime(A),h=this._updateWeight(e);if(h>0){const u=this._interpolants,c=this._propertyBindings;if(this.blendMode===2501)for(let C=0,E=u.length;C!==E;++C)u[C].evaluate(g),c[C].accumulateAdditive(h);else for(let C=0,E=u.length;C!==E;++C)u[C].evaluate(g),c[C].accumulate(n,h)}}_updateWeight(e){let A=0;if(this.enabled){A=this.weight;const t=this._weightInterpolant;if(t!==null){const n=t.evaluate(e)[0];A*=n,e>t.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=A,A}_updateTimeScale(e){let A=0;if(!this.paused){A=this.timeScale;const t=this._timeScaleInterpolant;t!==null&&(A*=t.evaluate(e)[0],e>t.parameterPositions[1]&&(this.stopWarping(),A===0?this.paused=!0:this.timeScale=A))}return this._effectiveTimeScale=A,A}_updateTime(e){const A=this._clip.duration,t=this.loop;let n=this.time+e,r=this._loopCount;const g=t===2202;if(e===0)return r===-1?n:g&&(1&r)==1?A-n:n;if(t===2200){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=A)n=A;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>=A||n<0){const h=Math.floor(n/A);n-=A*h,r+=Math.abs(h);const u=this.repetitions-r;if(u<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?A: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 A-n}return n}_setEndings(e,A,t){const n=this._interpolantSettings;t?(n.endingStart=aA,n.endingEnd=aA):(n.endingStart=e?this.zeroSlopeAtStart?aA:tA:DA,n.endingEnd=A?this.zeroSlopeAtEnd?aA:tA:DA)}_scheduleFading(e,A,t){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]=A,h[1]=r+e,u[1]=t,this}}const Qx=new Float32Array(1);class fx extends uA{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,A){const t=e._localRoot||this._root,n=e._clip.tracks,r=n.length,g=e._propertyBindings,h=e._interpolants,u=t.uuid,c=this._bindingsByRootAndName;let C=c[u];C===void 0&&(C={},c[u]=C);for(let E=0;E!==r;++E){const p=n[E],w=p.name;let k=C[w];if(k!==void 0)++k.referenceCount,g[E]=k;else{if(k=g[E],k!==void 0){k._cacheIndex===null&&(++k.referenceCount,this._addInactiveBinding(k,u,w));continue}const R=A&&A._propertyBindings[E].binding.parsedPath;k=new Ix(Zt.create(t,w,R),p.ValueTypeName,p.getValueSize()),++k.referenceCount,this._addInactiveBinding(k,u,w),g[E]=k}h[E].resultBuffer=k.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}const A=e._propertyBindings;for(let t=0,n=A.length;t!==n;++t){const r=A[t];r.useCount++==0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const A=e._propertyBindings;for(let t=0,n=A.length;t!==n;++t){const r=A[t];--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 A=e._cacheIndex;return A!==null&&A<this._nActiveActions}_addInactiveAction(e,A,t){const n=this._actions,r=this._actionsByClip;let g=r[A];if(g===void 0)g={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[A]=g;else{const h=g.knownActions;e._byClipCacheIndex=h.length,h.push(e)}e._cacheIndex=n.length,n.push(e),g.actionByRoot[t]=e}_removeInactiveAction(e){const A=this._actions,t=A[A.length-1],n=e._cacheIndex;t._cacheIndex=n,A[n]=t,A.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 A=e._propertyBindings;for(let t=0,n=A.length;t!==n;++t){const r=A[t];--r.referenceCount==0&&this._removeInactiveBinding(r)}}_lendAction(e){const A=this._actions,t=e._cacheIndex,n=this._nActiveActions++,r=A[n];e._cacheIndex=n,A[n]=e,r._cacheIndex=t,A[t]=r}_takeBackAction(e){const A=this._actions,t=e._cacheIndex,n=--this._nActiveActions,r=A[n];e._cacheIndex=n,A[n]=e,r._cacheIndex=t,A[t]=r}_addInactiveBinding(e,A,t){const n=this._bindingsByRootAndName,r=this._bindings;let g=n[A];g===void 0&&(g={},n[A]=g),g[t]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const A=this._bindings,t=e.binding,n=t.rootNode.uuid,r=t.path,g=this._bindingsByRootAndName,h=g[n],u=A[A.length-1],c=e._cacheIndex;u._cacheIndex=c,A[c]=u,A.pop(),delete h[r],Object.keys(h).length===0&&delete g[n]}_lendBinding(e){const A=this._bindings,t=e._cacheIndex,n=this._nActiveBindings++,r=A[n];e._cacheIndex=n,A[n]=e,r._cacheIndex=t,A[t]=r}_takeBackBinding(e){const A=this._bindings,t=e._cacheIndex,n=--this._nActiveBindings,r=A[n];e._cacheIndex=n,A[n]=e,r._cacheIndex=t,A[t]=r}_lendControlInterpolant(){const e=this._controlInterpolants,A=this._nActiveControlInterpolants++;let t=e[A];return t===void 0&&(t=new SE(new Float32Array(2),new Float32Array(2),1,Qx),t.__cacheIndex=A,e[A]=t),t}_takeBackControlInterpolant(e){const A=this._controlInterpolants,t=e.__cacheIndex,n=--this._nActiveControlInterpolants,r=A[n];e.__cacheIndex=n,A[n]=e,r.__cacheIndex=t,A[t]=r}clipAction(e,A,t){const n=A||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(t===void 0&&(t=g!==null?g.blendMode:yA),u!==void 0){const E=u.actionByRoot[r];if(E!==void 0&&E.blendMode===t)return E;c=u.knownActions[0],g===null&&(g=c._clip)}if(g===null)return null;const C=new Ex(this,g,A,t);return this._bindAction(C,c),this._addInactiveAction(C,h,r),C}existingAction(e,A){const t=A||this._root,n=t.uuid,r=typeof e=="string"?jh.findByName(t,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 A=this._nActiveActions-1;A>=0;--A)e[A].stop();return this}update(e){e*=this.timeScale;const A=this._actions,t=this._nActiveActions,n=this.time+=e,r=Math.sign(e),g=this._accuIndex^=1;for(let c=0;c!==t;++c)A[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 A=0;A<this._actions.length;A++)this._actions[A].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const A=this._actions,t=e.uuid,n=this._actionsByClip,r=n[t];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,E=A[A.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,E._cacheIndex=C,A[C]=E,A.pop(),this._removeInactiveBindingsForAction(c)}delete n[t]}}uncacheRoot(e){const A=e.uuid,t=this._actionsByClip;for(const r in t){const g=t[r].actionByRoot[A];g!==void 0&&(this._deactivateAction(g),this._removeInactiveAction(g))}const n=this._bindingsByRootAndName[A];if(n!==void 0)for(const r in n){const g=n[r];g.restoreOriginalState(),this._removeInactiveBinding(g)}}uncacheAction(e,A){const t=this.existingAction(e,A);t!==null&&(this._deactivateAction(t),this._removeInactiveAction(t))}}class Zo{constructor(e,A,t=0,n=1/0){this.ray=new Lo(e,A),this.near=t,this.far=n,this.camera=null,this.layers=new bh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,A){this.ray.set(e,A)}setFromCamera(e,A){A.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(A.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(A).sub(this.ray.origin).normalize(),this.camera=A):A.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(A.near+A.far)/(A.near-A.far)).unproject(A),this.ray.direction.set(0,0,-1).transformDirection(A.matrixWorld),this.camera=A):A.type}intersectObject(e,A=!0,t=[]){return rI(e,this,t,A),t.sort(FE),t}intersectObjects(e,A=!0,t=[]){for(let n=0,r=e.length;n<r;n++)rI(e[n],this,t,A);return t.sort(FE),t}}function FE(o,e){return o.distance-e.distance}function rI(o,e,A,t){if(o.layers.test(e.layers)&&o.raycast(e,A),t===!0){const n=o.children;for(let r=0,g=n.length;r<g;r++)rI(n[r],e,A,!0)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:B}})),typeof window<"u"&&(window.__THREE__||(window.__THREE__=B));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,A){e==="whitePoint"?this.whitePoint.set(A[0],A[1],A[2]):this[e]=A}static getKelvinRGB(e){const t=Math.floor((e-1e3)/1e3),n=t+1;if(t<0)return this.rgbValues[0].clone();if(n>=this.rgbValues.length)return this.rgbValues[this.rgbValues.length-1].clone();const r=(e-(t*1e3+1e3))/1e3;return this.rgbValues[t].clone().lerp(this.rgbValues[n],r)}showPopup(e){const A=document.createElement("div");A.style.position="absolute",A.style.top="50%",A.style.left="50%",A.style.transform="translate(-50%, -50%)",A.style.padding="10px",A.style.background="white",A.style.border="1px solid black",A.style.zIndex="1000",A.innerText=e,document.body.appendChild(A),setTimeout((()=>{document.body.removeChild(A)}),3e3)}enableGodMode(){window.addEventListener("keydown",(e=>{const A=new Date().getTime();if(e.key==="Enter")this.lastKeyPressTime=A;else if(this.lastKeyPressTime&&A-this.lastKeyPressTime<2e3){if(e.key==="p"||e.key==="P"){ae.EXPERIMENTAL_WEBASSEMBLY_QHDR_LOADER=!ae.EXPERIMENTAL_WEBASSEMBLY_QHDR_LOADER;const t=ae.EXPERIMENTAL_WEBASSEMBLY_QHDR_LOADER?"ON":"OFF";this.showPopup(`Experimental turboloader: ${t}`)}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 GA(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,A,t){const n=A-e;return e+(Math.abs(n)<=t?n:Math.sign(n)*t)}static lerpAngleRadians(e,A,t){const n=Math.PI;return e+((A-e+n+2*n)%(2*n)-n)*t}static lerpEuler(e,A,t){const n=new Mn;return n.x=this.lerpAngleRadians(e.x,A.x,t),n.y=this.lerpAngleRadians(e.y,A.y,t),n.z=this.lerpAngleRadians(e.z,A.z,t),n.order=e.order,n}}class px{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 A=jl.lerpAngleRadians(this.cameraSmooth.rotation.x,this.camera.rotation.x,e),t=jl.lerpAngleRadians(this.cameraSmooth.rotation.y,this.camera.rotation.y,e);this.cameraSmooth.rotation.set(A,t,0),this.cameraSmooth.position.copy(this.camera.position),this.camera.aspect=ae.getAspectRatio(),this.cameraSmooth.aspect=ae.getAspectRatio(),this.cameraSmooth.updateProjectionMatrix()}}class We{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(),We.keysState.set(e.code,!0),We.keysDown.set(e.code,!0))}static handleKeyUp(e){K.parent.matches(":hover")&&(e.preventDefault(),We.keysState.set(e.code,!1),We.keysUp.set(e.code,!0))}static handleInputDown(e,A,t){We.mouseButtonsState.set(e,!0),We.mouseButtonsDown.set(e,!0),We.mouseDownPosition.set(A,t),We.mouseDownTime=performance.now()}static handleMouseDown(e){We.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),We.lastTouchPosition.set(e.touches[0].clientX,e.touches[0].clientY)),e.touches.length===2){const A=e.touches[0].clientX-e.touches[1].clientX,t=e.touches[0].clientY-e.touches[1].clientY,n=Math.hypot(A,t);We.touchZoomDistanceEnd=We.touchZoomDistanceStart=n}}static handleInputUp(e,A,t){We.mouseButtonsState.set(e,!1),We.mouseButtonsUp.set(e,!0),We.mouseUpPosition.set(A,t),We.mouseUpTime=performance.now()}static handleMouseUp(e){We.handleInputUp(e.button,e.clientX,e.clientY)}static handleTouchEnd(e){const A=e.changedTouches[0];We.handleInputUp(0,A.clientX,A.clientY),We.touchZoomDistanceStart=0,We.touchZoomDistanceEnd=0}static handleInputMove(e,A,t,n){We.mousePosition.set(e,A),We.mouseDragDelta.x+=t*ae.dragScale.x,We.mouseDragDelta.y+=n*ae.dragScale.y}static handleMouseMove(e){We.handleInputMove(e.clientX,e.clientY,e.movementX,e.movementY)}static handleTouchMove(e){if(e.touches.length===1){const t=e.touches[0],n=t.clientX-We.lastTouchPosition.x,r=t.clientY-We.lastTouchPosition.y;We.handleInputMove(t.clientX,t.clientY,n,r),We.lastTouchPosition.set(t.clientX,t.clientY)}if(e.touches.length===2){const t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY,r=Math.hypot(t,n);We.touchZoomDistanceEnd=r;var A=We.touchZoomDistanceEnd-We.touchZoomDistanceStart;We.touchZoomDistanceStart=We.touchZoomDistanceEnd,We.mouseScrollDelta.set(0,-2*A)}}static handleMouseWheel(e){We.mouseScrollDelta.set(e.deltaX,e.deltaY)}static GetKey(e){return We.keysState.get(e)||!1}static GetKeyDown(e){return!!We.keysUp.get(e)}static GetKeyUp(e){return!!We.keysUp.get(e)}static GetMouseButton(e){return We.mouseButtonsState.get(e)||!1}static GetMouseButtonDown(e){return!!We.mouseButtonsState.get(e)}static GetMouseButtonUp(e){return!!We.mouseButtonsUp.get(e)}static get MousePositionLocal(){const e=K.canvas.getBoundingClientRect();return new GA(We.mousePosition.x-e.left,We.mousePosition.y-e.top)}static get MousePositionGlobal(){return We.mousePosition}static get MousePositionNormalized(){const e=K.canvas.getBoundingClientRect(),A=new GA(We.mousePosition.x-e.left,We.mousePosition.y-e.top);return new GA(A.x/e.width*2-1,-A.y/e.height*2+1)}static get MouseScrollDelta(){return We.mouseScrollDelta}static get MouseDragDelta(){return We.mouseDragDelta}static get MousePick(){return!(!We.GetMouseButtonUp(0)||We.mousePickConsumed||!We.isTapClick())&&(We.mousePickConsumed=!0,!0)}static isTapClick(){if(!We.GetMouseButtonUp(0))return!1;const e=We.mouseDownPosition.distanceTo(We.mouseUpPosition),A=We.mouseUpTime-We.mouseDownTime;return e<=We.maxTapMove&&A<=We.maxTapTime}static consumeMousePick(){We.mousePickConsumed=!0}static isMousePickPending(){return We.GetMouseButtonUp(0)&&!We.mousePickConsumed}static wasMouseButtonPressed(e){return We.mouseButtonsDown.get(e)||!1}static clientToNormalized(e,A){const t=K.canvas.getBoundingClientRect(),n=e-t.left,r=A-t.top;return new GA(n/t.width*2-1,-r/t.height*2+1)}static getMouseDownPositionNormalized(){return We.clientToNormalized(We.mouseDownPosition.x,We.mouseDownPosition.y)}static EndFrame(){We.mouseButtonsUp.set(0,!1),We.mouseButtonsUp.set(1,!1),We.mouseButtonsDown.set(0,!1),We.mouseButtonsDown.set(1,!1),We.keysUp.clear(),We.keysDown.clear(),We.mouseDragDelta.set(0,0),We.mouseScrollDelta.set(0,0)}static updateState(){}static applyState(){const e=1*K.deltaTime,A=K.userData.camera.rotation.y;if(new re(Math.sin(A),0,Math.cos(A)),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),We.GetMouseButton(0)&&!We.consumeDrag&&!ae.NAVIGATION_MARKERS_WHITELIST_MODE&&!ae.NAVIGATION_MARKERS_EDIT_MODE){let t=K.userData.camera.fov/300;K.userData.camera.rotation.x+=We.mouseDragDelta.y*t*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+=We.mouseDragDelta.x*t*.8*yi.DEG2RAD}We.mouseScrollDelta.y!=0&&(K.userData.camera.fov=yi.clamp(K.userData.camera.fov+.1*We.mouseScrollDelta.y,ae.MIN_FOV,ae.MAX_FOV),K.userData.camera.updateProjectionMatrix())}static update(){We.GetMouseButton(0)||(We.mousePickConsumed=!1),this.updateState(),this.applyState()}}function LE(o,e){if(e===0)return o;if(e===2||e===1){let A=o.getIndex();if(A===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),A=o.getIndex()}const t=A.count-2,n=[];if(e===2)for(let g=1;g<=t;g++)n.push(A.getX(0)),n.push(A.getX(g)),n.push(A.getX(g+1));else for(let g=0;g<t;g++)g%2==0?(n.push(A.getX(g)),n.push(A.getX(g+1)),n.push(A.getX(g+2))):(n.push(A.getX(g+2)),n.push(A.getX(g+1)),n.push(A.getX(g)));n.length;const r=o.clone();return r.setIndex(n),r.clearGroups(),r}return o}We.keysState=new Map,We.keysUp=new Map,We.keysDown=new Map,We.mouseButtonsState=new Map,We.mouseButtonsUp=new Map,We.mouseButtonsDown=new Map,We.mousePosition=new GA,We.mouseScrollDelta=new GA,We.mouseDragDelta=new GA,We.mouseDownPosition=new GA,We.mouseUpPosition=new GA,We.mouseDownTime=0,We.mouseUpTime=0,We.maxTapTime=200,We.maxTapMove=5,We.lastTouchPosition=new GA,We.consumeDrag=!1,We.mousePickConsumed=!1;class sI extends Ja{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(A){return new Dx(A)})),this.register((function(A){return new Nx(A)})),this.register((function(A){return new kx(A)})),this.register((function(A){return new Fx(A)})),this.register((function(A){return new Sx(A)})),this.register((function(A){return new xx(A)})),this.register((function(A){return new bx(A)})),this.register((function(A){return new _x(A)})),this.register((function(A){return new vx(A)})),this.register((function(A){return new Rx(A)})),this.register((function(A){return new Mx(A)})),this.register((function(A){return new wx(A)})),this.register((function(A){return new Lx(A)})),this.register((function(A){return new Gx(A)}))}load(e,A,t,n){const r=this;let g;g=this.resourcePath!==""?this.resourcePath:this.path!==""?this.path:tI.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){A(C),r.manager.itemEnd(e)}),h)}catch(C){h(C)}}),t,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,A,t,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))===GE){try{g[Ht.KHR_BINARY_GLTF]=new Hx(e)}catch(C){return void(n&&n(C))}r=JSON.parse(g[Ht.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 $x(r,{path:A||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 E=this.pluginCallbacks[C](c);h[E.name]=E,g[E.name]=!0}if(r.extensionsUsed)for(let C=0;C<r.extensionsUsed.length;++C){const E=r.extensionsUsed[C],p=r.extensionsRequired||[];switch(E){case Ht.KHR_MATERIALS_UNLIT:g[E]=new yx;break;case Ht.KHR_DRACO_MESH_COMPRESSION:g[E]=new Jx(r,this.dracoLoader);break;case Ht.KHR_TEXTURE_TRANSFORM:g[E]=new Yx;break;case Ht.KHR_MESH_QUANTIZATION:g[E]=new Px;break;default:p.indexOf(E)>=0&&h[E]}}c.setExtensions(g),c.setPlugins(h),c.parse(t,n)}parseAsync(e,A){const t=this;return new Promise((function(n,r){t.parse(e,A,n,r)}))}}function mx(){let o={};return{get:function(e){return o[e]},add:function(e,A){o[e]=A},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const Ht={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 wx{constructor(e){this.parser=e,this.name=Ht.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,A=this.parser.json.nodes||[];for(let t=0,n=A.length;t<n;t++){const r=A[t];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 A=this.parser,t="light:"+e;let n=A.cache.get(t);if(n)return n;const r=A.json,g=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let h;const u=new rt(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 NE(u),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new ox(u),h.distance=c;break;case"spot":h=new sx(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,Bs(h,g),g.intensity!==void 0&&(h.intensity=g.intensity),h.name=A.createUniqueName(g.name||"light_"+e),n=Promise.resolve(h),A.cache.add(t,n),n}getDependency(e,A){if(e==="light")return this._loadLight(A)}createNodeAttachment(e){const A=this,t=this.parser,n=t.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then((function(g){return t._getNodeRef(A.cache,r,g)}))}}class yx{constructor(){this.name=Ht.KHR_MATERIALS_UNLIT}getMaterialType(){return Ji}extendParams(e,A,t){const n=[];e.color=new rt(1,1,1),e.opacity=1;const r=A.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(t.assignTexture(e,"map",r.baseColorTexture,ie))}return Promise.all(n)}}class vx{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,A){const t=this.parser.json.materials[e];if(!t.extensions||!t.extensions[this.name])return Promise.resolve();const n=t.extensions[this.name].emissiveStrength;return n!==void 0&&(A.emissiveIntensity=n),Promise.resolve()}}class Dx{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const A=this.parser.json.materials[e];return A.extensions&&A.extensions[this.name]?Ps:null}extendMaterialParams(e,A){const t=this.parser,n=t.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&&(A.clearcoat=g.clearcoatFactor),g.clearcoatTexture!==void 0&&r.push(t.assignTexture(A,"clearcoatMap",g.clearcoatTexture)),g.clearcoatRoughnessFactor!==void 0&&(A.clearcoatRoughness=g.clearcoatRoughnessFactor),g.clearcoatRoughnessTexture!==void 0&&r.push(t.assignTexture(A,"clearcoatRoughnessMap",g.clearcoatRoughnessTexture)),g.clearcoatNormalTexture!==void 0&&(r.push(t.assignTexture(A,"clearcoatNormalMap",g.clearcoatNormalTexture)),g.clearcoatNormalTexture.scale!==void 0)){const h=g.clearcoatNormalTexture.scale;A.clearcoatNormalScale=new GA(h,h)}return Promise.all(r)}}class Mx{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const A=this.parser.json.materials[e];return A.extensions&&A.extensions[this.name]?Ps:null}extendMaterialParams(e,A){const t=this.parser,n=t.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&&(A.iridescence=g.iridescenceFactor),g.iridescenceTexture!==void 0&&r.push(t.assignTexture(A,"iridescenceMap",g.iridescenceTexture)),g.iridescenceIor!==void 0&&(A.iridescenceIOR=g.iridescenceIor),A.iridescenceThicknessRange===void 0&&(A.iridescenceThicknessRange=[100,400]),g.iridescenceThicknessMinimum!==void 0&&(A.iridescenceThicknessRange[0]=g.iridescenceThicknessMinimum),g.iridescenceThicknessMaximum!==void 0&&(A.iridescenceThicknessRange[1]=g.iridescenceThicknessMaximum),g.iridescenceThicknessTexture!==void 0&&r.push(t.assignTexture(A,"iridescenceThicknessMap",g.iridescenceThicknessTexture)),Promise.all(r)}}class Sx{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_SHEEN}getMaterialType(e){const A=this.parser.json.materials[e];return A.extensions&&A.extensions[this.name]?Ps:null}extendMaterialParams(e,A){const t=this.parser,n=t.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];A.sheenColor=new rt(0,0,0),A.sheenRoughness=0,A.sheen=1;const g=n.extensions[this.name];return g.sheenColorFactor!==void 0&&A.sheenColor.fromArray(g.sheenColorFactor),g.sheenRoughnessFactor!==void 0&&(A.sheenRoughness=g.sheenRoughnessFactor),g.sheenColorTexture!==void 0&&r.push(t.assignTexture(A,"sheenColorMap",g.sheenColorTexture,ie)),g.sheenRoughnessTexture!==void 0&&r.push(t.assignTexture(A,"sheenRoughnessMap",g.sheenRoughnessTexture)),Promise.all(r)}}class xx{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const A=this.parser.json.materials[e];return A.extensions&&A.extensions[this.name]?Ps:null}extendMaterialParams(e,A){const t=this.parser,n=t.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&&(A.transmission=g.transmissionFactor),g.transmissionTexture!==void 0&&r.push(t.assignTexture(A,"transmissionMap",g.transmissionTexture)),Promise.all(r)}}class bx{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_VOLUME}getMaterialType(e){const A=this.parser.json.materials[e];return A.extensions&&A.extensions[this.name]?Ps:null}extendMaterialParams(e,A){const t=this.parser,n=t.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],g=n.extensions[this.name];A.thickness=g.thicknessFactor!==void 0?g.thicknessFactor:0,g.thicknessTexture!==void 0&&r.push(t.assignTexture(A,"thicknessMap",g.thicknessTexture)),A.attenuationDistance=g.attenuationDistance||1/0;const h=g.attenuationColor||[1,1,1];return A.attenuationColor=new rt(h[0],h[1],h[2]),Promise.all(r)}}class _x{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_IOR}getMaterialType(e){const A=this.parser.json.materials[e];return A.extensions&&A.extensions[this.name]?Ps:null}extendMaterialParams(e,A){const t=this.parser.json.materials[e];if(!t.extensions||!t.extensions[this.name])return Promise.resolve();const n=t.extensions[this.name];return A.ior=n.ior!==void 0?n.ior:1.5,Promise.resolve()}}class Rx{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_SPECULAR}getMaterialType(e){const A=this.parser.json.materials[e];return A.extensions&&A.extensions[this.name]?Ps:null}extendMaterialParams(e,A){const t=this.parser,n=t.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],g=n.extensions[this.name];A.specularIntensity=g.specularFactor!==void 0?g.specularFactor:1,g.specularTexture!==void 0&&r.push(t.assignTexture(A,"specularIntensityMap",g.specularTexture));const h=g.specularColorFactor||[1,1,1];return A.specularColor=new rt(h[0],h[1],h[2]),g.specularColorTexture!==void 0&&r.push(t.assignTexture(A,"specularColorMap",g.specularColorTexture,ie)),Promise.all(r)}}class Nx{constructor(e){this.parser=e,this.name=Ht.KHR_TEXTURE_BASISU}loadTexture(e){const A=this.parser,t=A.json,n=t.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],g=A.options.ktx2Loader;if(!g){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return A.loadTextureImage(e,r.source,g)}}class kx{constructor(e){this.parser=e,this.name=Ht.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const A=this.name,t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[A])return null;const g=r.extensions[A],h=n.images[g.source];let u=t.textureLoader;if(h.uri){const c=t.options.manager.getHandler(h.uri);c!==null&&(u=c)}return this.detectSupport().then((function(c){if(c)return t.loadTextureImage(e,g.source,u);if(n.extensionsRequired&&n.extensionsRequired.indexOf(A)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return t.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const A=new Image;A.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",A.onload=A.onerror=function(){e(A.height===1)}}))),this.isSupported}}class Fx{constructor(e){this.parser=e,this.name=Ht.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const A=this.name,t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[A])return null;const g=r.extensions[A],h=n.images[g.source];let u=t.textureLoader;if(h.uri){const c=t.options.manager.getHandler(h.uri);c!==null&&(u=c)}return this.detectSupport().then((function(c){if(c)return t.loadTextureImage(e,g.source,u);if(n.extensionsRequired&&n.extensionsRequired.indexOf(A)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return t.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const A=new Image;A.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",A.onload=A.onerror=function(){e(A.height===1)}}))),this.isSupported}}class Lx{constructor(e){this.name=Ht.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const A=this.parser.json,t=A.bufferViews[e];if(t.extensions&&t.extensions[this.name]){const n=t.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),g=this.parser.options.meshoptDecoder;if(!g||!g.supported){if(A.extensionsRequired&&A.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,E=n.byteStride,p=new Uint8Array(h,u,c);return g.decodeGltfBufferAsync?g.decodeGltfBufferAsync(C,E,p,n.mode,n.filter).then((function(w){return w.buffer})):g.ready.then((function(){const w=new ArrayBuffer(C*E);return g.decodeGltfBuffer(new Uint8Array(w),C,E,p,n.mode,n.filter),w}))}))}return null}}class Gx{constructor(e){this.name=Ht.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const A=this.parser.json,t=A.nodes[e];if(!t.extensions||!t.extensions[this.name]||t.mesh===void 0)return null;const n=A.meshes[t.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=t.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],E=u[0].count,p=[];for(const w of C){const k=new xt,R=new re,_=new Ui,N=new re(1,1,1),L=new KS(w.geometry,w.material,E);for(let G=0;G<E;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 GE="glTF",Ux=1313821514,Tx=5130562;class Hx{constructor(e){this.name=Ht.KHR_BINARY_GLTF,this.content=null,this.body=null;const A=new DataView(e,0,12),t=new TextDecoder;if(this.header={magic:t.decode(new Uint8Array(e.slice(0,4))),version:A.getUint32(4,!0),length:A.getUint32(8,!0)},this.header.magic!==GE)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===Ux){const c=new Uint8Array(e,12+g,h);this.content=t.decode(c)}else if(u===Tx){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 Jx{constructor(e,A){if(!A)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Ht.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=A,this.dracoLoader.preload()}decodePrimitive(e,A){const t=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 E=oI[C]||C.toLowerCase();h[E]=g[C]}for(const C in e.attributes){const E=oI[C]||C.toLowerCase();if(g[C]!==void 0){const p=t.accessors[e.attributes[C]],w=Pa[p.componentType];c[E]=w.name,u[E]=p.normalized===!0}}return A.getDependency("bufferView",r).then((function(C){return new Promise((function(E){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)}E(p)}),h,c)}))}))}}class Yx{constructor(){this.name=Ht.KHR_TEXTURE_TRANSFORM}extendTexture(e,A){return(A.texCoord!==void 0&&A.texCoord!==e.channel||A.offset!==void 0||A.rotation!==void 0||A.scale!==void 0)&&(e=e.clone(),A.texCoord!==void 0&&(e.channel=A.texCoord),A.offset!==void 0&&e.offset.fromArray(A.offset),A.rotation!==void 0&&(e.rotation=A.rotation),A.scale!==void 0&&e.repeat.fromArray(A.scale),e.needsUpdate=!0),e}}class Px{constructor(){this.name=Ht.KHR_MESH_QUANTIZATION}}class UE extends zo{constructor(e,A,t,n){super(e,A,t,n)}copySampleValue_(e){const A=this.resultBuffer,t=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let g=0;g!==n;g++)A[g]=t[r+g];return A}interpolate_(e,A,t,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=2*h,c=3*h,C=n-A,E=(t-A)/C,p=E*E,w=p*E,k=e*c,R=k-c,_=-2*w+3*p,N=w-p,L=1-_,G=N-p+E;for(let le=0;le!==h;le++){const ne=g[R+le+h],te=g[R+le+u]*C,Ae=g[k+le+h],ye=g[k+le]*C;r[le]=L*ne+G*te+_*Ae+N*ye}return r}}const Ox=new Ui;class Kx extends UE{interpolate_(e,A,t,n){const r=super.interpolate_(e,A,t,n);return Ox.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},TE={9728:Ee,9729:Qe,9984:qe,9985:AA,9986:me,9987:se},HE={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"},zx={CUBICSPLINE:void 0,LINEAR:Oe,STEP:Ue},qx="OPAQUE",Vx="MASK",Wx="BLEND";function jo(o,e,A){for(const t in A.extensions)o[t]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[t]=A.extensions[t])}function Bs(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):e.extras)}function Zx(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let A=0,t=e.weights.length;A<t;A++)o.morphTargetInfluences[A]=e.weights[A];if(e.extras&&Array.isArray(e.extras.targetNames)){const A=e.extras.targetNames;if(o.morphTargetInfluences.length===A.length){o.morphTargetDictionary={};for(let t=0,n=A.length;t<n;t++)o.morphTargetDictionary[A[t]]=t}}}function jx(o){const e=o.extensions&&o.extensions[Ht.KHR_DRACO_MESH_COMPRESSION];let A;return A=e?"draco:"+e.bufferView+":"+e.indices+":"+JE(e.attributes):o.indices+":"+JE(o.attributes)+":"+o.mode,A}function JE(o){let e="";const A=Object.keys(o).sort();for(let t=0,n=A.length;t<n;t++)e+=A[t]+":"+o[A[t]]+";";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 Xx=new xt;class $x{constructor(e={},A={}){this.json=e,this.extensions={},this.plugins={},this.options=A,this.cache=new mx,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 t=!1,n=!1,r=-1;typeof navigator<"u"&&(t=/^((?!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"||t||n&&r<98?this.textureLoader=new Ya(this.options.manager):this.textureLoader=new cx(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,A){const t=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([t.getDependencies("scene"),t.getDependencies("animation"),t.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:t,userData:{}};jo(r,h,n),Bs(h,n),Promise.all(t._invokeAll((function(u){return u.afterRoot&&u.afterRoot(h)}))).then((function(){e(h)}))})).catch(A)}_markDefs(){const e=this.json.nodes||[],A=this.json.skins||[],t=this.json.meshes||[];for(let n=0,r=A.length;n<r;n++){const g=A[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&&(t[g.mesh].isSkinnedMesh=!0)),g.camera!==void 0&&this._addNodeRef(this.cameraCache,g.camera)}}_addNodeRef(e,A){A!==void 0&&(e.refs[A]===void 0&&(e.refs[A]=e.uses[A]=0),e.refs[A]++)}_getNodeRef(e,A,t){if(e.refs[A]<=1)return t;const n=t.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(t,n),n.name+="_instance_"+e.uses[A]++,n}_invokeOne(e){const A=Object.values(this.plugins);A.push(this);for(let t=0;t<A.length;t++){const n=e(A[t]);if(n)return n}return null}_invokeAll(e){const A=Object.values(this.plugins);A.unshift(this);const t=[];for(let n=0;n<A.length;n++){const r=e(A[n]);r&&t.push(r)}return t}getDependency(e,A){const t=e+":"+A;let n=this.cache.get(t);if(!n){switch(e){case"scene":n=this.loadScene(A);break;case"node":n=this._invokeOne((function(r){return r.loadNode&&r.loadNode(A)}));break;case"mesh":n=this._invokeOne((function(r){return r.loadMesh&&r.loadMesh(A)}));break;case"accessor":n=this.loadAccessor(A);break;case"bufferView":n=this._invokeOne((function(r){return r.loadBufferView&&r.loadBufferView(A)}));break;case"buffer":n=this.loadBuffer(A);break;case"material":n=this._invokeOne((function(r){return r.loadMaterial&&r.loadMaterial(A)}));break;case"texture":n=this._invokeOne((function(r){return r.loadTexture&&r.loadTexture(A)}));break;case"skin":n=this.loadSkin(A);break;case"animation":n=this._invokeOne((function(r){return r.loadAnimation&&r.loadAnimation(A)}));break;case"camera":n=this.loadCamera(A);break;default:if(n=this._invokeOne((function(r){return r!=this&&r.getDependency&&r.getDependency(e,A)})),!n)throw new Error("Unknown type: "+e)}this.cache.add(t,n)}return n}getDependencies(e){let A=this.cache.get(e);if(!A){const t=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];A=Promise.all(n.map((function(r,g){return t.getDependency(e,g)}))),this.cache.add(e,A)}return A}loadBuffer(e){const A=this.json.buffers[e],t=this.fileLoader;if(A.type&&A.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+A.type+" buffer type is not supported.");if(A.uri===void 0&&e===0)return Promise.resolve(this.extensions[Ht.KHR_BINARY_GLTF].body);const n=this.options;return new Promise((function(r,g){t.load(tI.resolveURL(A.uri,n.path),r,void 0,(function(){g(new Error('THREE.GLTFLoader: Failed to load buffer "'+A.uri+'".'))}))}))}loadBufferView(e){const A=this.json.bufferViews[e];return this.getDependency("buffer",A.buffer).then((function(t){const n=A.byteLength||0,r=A.byteOffset||0;return t.slice(r,r+n)}))}loadAccessor(e){const A=this,t=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 Wi(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,E=C*u,p=n.byteOffset||0,w=n.bufferView!==void 0?t.bufferViews[n.bufferView].byteStride:void 0,k=n.normalized===!0;let R,_;if(w&&w!==E){const N=Math.floor(p/w),L="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+N+":"+n.count;let G=A.cache.get(L);G||(R=new c(h,N*w,n.count*w/C),G=new AE(R,w/C),A.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 Wi(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),te=new c(g[2],le,n.sparse.count*u);h!==null&&(_=new Wi(_.array.slice(),_.itemSize,_.normalized));for(let Ae=0,ye=ne.length;Ae<ye;Ae++){const ge=ne[Ae];if(_.setX(ge,te[Ae*u]),u>=2&&_.setY(ge,te[Ae*u+1]),u>=3&&_.setZ(ge,te[Ae*u+2]),u>=4&&_.setW(ge,te[Ae*u+3]),u>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return _}))}loadTexture(e){const A=this.json,t=this.options,n=A.textures[e].source,r=A.images[n];let g=this.textureLoader;if(r.uri){const h=t.manager.getHandler(r.uri);h!==null&&(g=h)}return this.loadTextureImage(e,n,g)}loadTextureImage(e,A,t){const n=this,r=this.json,g=r.textures[e],h=r.images[A],u=(h.uri||h.bufferView)+":"+g.sampler;if(this.textureCache[u])return this.textureCache[u];const c=this.loadImageSource(A,t).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 E=(r.samplers||{})[g.sampler]||{};return C.magFilter=TE[E.magFilter]||Qe,C.minFilter=TE[E.minFilter]||se,C.wrapS=HE[E.wrapS]||Ce,C.wrapT=HE[E.wrapT]||Ce,n.associations.set(C,{textures:e}),C})).catch((function(){return null}));return this.textureCache[u]=c,c}loadImageSource(e,A){const t=this,n=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((E=>E.clone()));const g=n.images[e],h=self.URL||self.webkitURL;let u=g.uri||"",c=!1;if(g.bufferView!==void 0)u=t.getDependency("bufferView",g.bufferView).then((function(E){c=!0;const p=new Blob([E],{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(E){return new Promise((function(p,w){let k=p;A.isImageBitmapLoader===!0&&(k=function(R){const _=new Di(R);_.needsUpdate=!0,p(_)}),A.load(tI.resolveURL(E,r.path),k,void 0,w)}))})).then((function(E){var p;return c===!0&&h.revokeObjectURL(u),E.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"),E})).catch((function(E){throw E}));return this.sourceCache[e]=C,C}assignTexture(e,A,t,n){const r=this;return this.getDependency("texture",t.index).then((function(g){if(!g)return null;if(t.texCoord!==void 0&&t.texCoord>0&&((g=g.clone()).channel=t.texCoord),r.extensions[Ht.KHR_TEXTURE_TRANSFORM]){const h=t.extensions!==void 0?t.extensions[Ht.KHR_TEXTURE_TRANSFORM]:void 0;if(h){const u=r.associations.get(g);g=r.extensions[Ht.KHR_TEXTURE_TRANSFORM].extendTexture(g,h),r.associations.set(g,u)}}return n!==void 0&&(g.colorSpace=n),e[A]=g,g}))}assignFinalMaterial(e){const A=e.geometry;let t=e.material;const n=A.attributes.tangent===void 0,r=A.attributes.color!==void 0,g=A.attributes.normal===void 0;if(e.isPoints){const h="PointsMaterial:"+t.uuid;let u=this.cache.get(h);u||(u=new pE,Sn.prototype.copy.call(u,t),u.color.copy(t.color),u.map=t.map,u.sizeAttenuation=!1,this.cache.add(h,u)),t=u}else if(e.isLine){const h="LineBasicMaterial:"+t.uuid;let u=this.cache.get(h);u||(u=new CE,Sn.prototype.copy.call(u,t),u.color.copy(t.color),u.map=t.map,this.cache.add(h,u)),t=u}if(n||r||g){let h="ClonedMaterial:"+t.uuid+":";n&&(h+="derivative-tangents:"),r&&(h+="vertex-colors:"),g&&(h+="flat-shading:");let u=this.cache.get(h);u||(u=t.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(t))),t=u}e.material=t}getMaterialType(){return Ys}loadMaterial(e){const A=this,t=this.json,n=this.extensions,r=t.materials[e];let g;const h={},u=[];if((r.extensions||{})[Ht.KHR_MATERIALS_UNLIT]){const C=n[Ht.KHR_MATERIALS_UNLIT];g=C.getMaterialType(),u.push(C.extendParams(h,r,A))}else{const C=r.pbrMetallicRoughness||{};if(h.color=new rt(1,1,1),h.opacity=1,Array.isArray(C.baseColorFactor)){const E=C.baseColorFactor;h.color.fromArray(E),h.opacity=E[3]}C.baseColorTexture!==void 0&&u.push(A.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(A.assignTexture(h,"metalnessMap",C.metallicRoughnessTexture)),u.push(A.assignTexture(h,"roughnessMap",C.metallicRoughnessTexture))),g=this._invokeOne((function(E){return E.getMaterialType&&E.getMaterialType(e)})),u.push(Promise.all(this._invokeAll((function(E){return E.extendMaterialParams&&E.extendMaterialParams(e,h)}))))}r.doubleSided===!0&&(h.side=2);const c=r.alphaMode||qx;if(c===Wx?(h.transparent=!0,h.depthWrite=!1):(h.transparent=!1,c===Vx&&(h.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&g!==Ji&&(u.push(A.assignTexture(h,"normalMap",r.normalTexture)),h.normalScale=new GA(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(A.assignTexture(h,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(h.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&g!==Ji&&(h.emissive=new rt().fromArray(r.emissiveFactor)),r.emissiveTexture!==void 0&&g!==Ji&&u.push(A.assignTexture(h,"emissiveMap",r.emissiveTexture,ie)),Promise.all(u).then((function(){const C=new g(h);return r.name&&(C.name=r.name),Bs(C,r),A.associations.set(C,{materials:e}),r.extensions&&jo(n,C,r),C}))}createUniqueName(e){const A=Zt.sanitizeNodeName(e||"");let t=A;for(let n=1;this.nodeNamesUsed[t];++n)t=A+"_"+n;return this.nodeNamesUsed[t]=!0,t}loadGeometries(e){const A=this,t=this.extensions,n=this.primitiveCache;function r(h){return t[Ht.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(h,A).then((function(u){return YE(u,h,A)}))}const g=[];for(let h=0,u=e.length;h<u;h++){const c=e[h],C=jx(c),E=n[C];if(E)g.push(E.promise);else{let p;p=c.extensions&&c.extensions[Ht.KHR_DRACO_MESH_COMPRESSION]?r(c):YE(new bn,c,A),n[C]={primitive:c,promise:p},g.push(p)}}return Promise.all(g)}loadMesh(e){const A=this,t=this.json,n=this.extensions,r=t.meshes[e],g=r.primitives,h=[];for(let c=0,C=g.length;c<C;c++){const E=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(E)}var u;return h.push(A.loadGeometries(g)),Promise.all(h).then((function(c){const C=c.slice(0,c.length-1),E=c[c.length-1],p=[];for(let k=0,R=E.length;k<R;k++){const _=E[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 YS(_,G):new Ut(_,G),L.isSkinnedMesh===!0&&L.normalizeSkinWeights(),N.mode===Yn.TRIANGLE_STRIP?L.geometry=LE(L.geometry,1):N.mode===Yn.TRIANGLE_FAN&&(L.geometry=LE(L.geometry,2));else if(N.mode===Yn.LINES)L=new zS(_,G);else if(N.mode===Yn.LINE_STRIP)L=new Wh(_,G);else if(N.mode===Yn.LINE_LOOP)L=new qS(_,G);else{if(N.mode!==Yn.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+N.mode);L=new VS(_,G)}Object.keys(L.geometry.morphAttributes).length>0&&Zx(L,r),L.name=A.createUniqueName(r.name||"mesh_"+e),Bs(L,r),N.extensions&&jo(n,L,N),A.assignFinalMaterial(L),p.push(L)}for(let k=0,R=p.length;k<R;k++)A.associations.set(p[k],{meshes:e,primitives:k});if(p.length===1)return p[0];const w=new Js;A.associations.set(w,{meshes:e});for(let k=0,R=p.length;k<R;k++)w.add(p[k]);return w}))}loadCamera(e){let A;const t=this.json.cameras[e],n=t[t.type];if(n)return t.type==="perspective"?A=new Zi(yi.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):t.type==="orthographic"&&(A=new _n(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),t.name&&(A.name=this.createUniqueName(t.name)),Bs(A,t),Promise.resolve(A)}loadSkin(e){const A=this.json.skins[e],t=[];for(let n=0,r=A.joints.length;n<r;n++)t.push(this._loadNodeShallow(A.joints[n]));return A.inverseBindMatrices!==void 0?t.push(this.getDependency("accessor",A.inverseBindMatrices)):t.push(null),Promise.all(t).then((function(n){const r=n.pop(),g=n,h=[],u=[];for(let c=0,C=g.length;c<C;c++){const E=g[c];if(E){h.push(E);const p=new xt;r!==null&&p.fromArray(r.array,16*c),u.push(p)}else A.joints[c]}return new qh(h,u)}))}loadAnimation(e){const A=this.json.animations[e],t=A.name?A.name:"animation_"+e,n=[],r=[],g=[],h=[],u=[];for(let c=0,C=A.channels.length;c<C;c++){const E=A.channels[c],p=A.samplers[E.sampler],w=E.target,k=w.node,R=A.parameters!==void 0?A.parameters[p.input]:p.input,_=A.parameters!==void 0?A.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],E=c[1],p=c[2],w=c[3],k=c[4],R=[];for(let _=0,N=C.length;_<N;_++){const L=C[_],G=E[_],le=p[_],ne=w[_],te=k[_];if(L===void 0)continue;let Ae;switch(L.updateMatrix(),Oa[te.path]){case Oa.weights:Ae=qo;break;case Oa.rotation:Ae=Os;break;default:Ae=Vo}const ye=L.name?L.name:L.uuid,ge=ne.interpolation!==void 0?zx[ne.interpolation]:Oe,Me=[];Oa[te.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),CA=new Float32Array(pe.length);for(let QA=0,VA=pe.length;QA<VA;QA++)CA[QA]=pe[QA]*Ze;pe=CA}for(let Ze=0,CA=Me.length;Ze<CA;Ze++){const QA=new Ae(Me[Ze]+"."+Oa[te.path],G.array,pe,ge);ne.interpolation==="CUBICSPLINE"&&(QA.createInterpolant=function(VA){return new(this instanceof Os?Kx:UE)(this.times,this.values,this.getValueSize()/3,VA)},QA.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),R.push(QA)}}return new jh(t,void 0,R)}))}createNodeMesh(e){const A=this.json,t=this,n=A.nodes[e];return n.mesh===void 0?null:t.getDependency("mesh",n.mesh).then((function(r){const g=t._getNodeRef(t.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 A=this,t=this.json.nodes[e],n=A._loadNodeShallow(e),r=[],g=t.children||[];for(let u=0,c=g.length;u<c;u++)r.push(A.getDependency("node",g[u]));const h=t.skin===void 0?Promise.resolve(null):A.getDependency("skin",t.skin);return Promise.all([n,Promise.all(r),h]).then((function(u){const c=u[0],C=u[1],E=u[2];E!==null&&c.traverse((function(p){p.isSkinnedMesh&&p.bind(E,Xx)}));for(let p=0,w=C.length;p<w;p++)c.add(C[p]);return c}))}_loadNodeShallow(e){const A=this.json,t=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=A.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 lE:c.length>1?new Js:c.length===1?c[0]:new gi,C!==c[0])for(let E=0,p=c.length;E<p;E++)C.add(c[E]);if(r.name&&(C.userData.name=r.name,C.name=g),Bs(C,r),r.extensions&&jo(t,C,r),r.matrix!==void 0){const E=new xt;E.fromArray(r.matrix),C.applyMatrix4(E)}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 A=this.extensions,t=this.json.scenes[e],n=this,r=new Js;t.name&&(r.name=n.createUniqueName(t.name)),Bs(r,t),t.extensions&&jo(A,r,t);const g=t.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[E,p]of n.associations)(E instanceof Sn||E instanceof Di)&&C.set(E,p);return c.traverse((E=>{const p=n.associations.get(E);p!=null&&C.set(E,p)})),C})(r),r}))}}function YE(o,e,A){const t=e.attributes,n=[];function r(g,h){return A.getDependency("accessor",g).then((function(u){o.setAttribute(h,u)}))}for(const g in t){const h=oI[g]||g.toLowerCase();h in o.attributes||n.push(r(t[g],h))}if(e.indices!==void 0&&!o.index){const g=A.getDependency("accessor",e.indices).then((function(h){o.setIndex(h)}));n.push(g)}return Bs(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 E=h.targets;if(E!==void 0){const w=new re,k=new re;for(let R=0,_=E.length;R<_;R++){const N=E[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,A),Promise.all(n).then((function(){return e.targets!==void 0?(function(g,h,u){let c=!1,C=!1,E=!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&&(E=!0),c&&C&&E)break}if(!c&&!C&&!E)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(E){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),E&&(g.morphAttributes.color=L),g.morphTargetsRelative=!0,g}))})(o,e.targets,A):o}))}var lI=function(o,e,A,t){return new(A||(A=Promise))((function(n,r){function g(c){try{u(t.next(c))}catch(C){r(C)}}function h(c){try{u(t.throw(c))}catch(C){r(C)}}function u(c){var C;c.done?n(c.value):(C=c.value,C instanceof A?C:new A((function(E){E(C)}))).then(g,h)}u((t=t.apply(o,[])).next())}))};class eb{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(((A,t)=>{this.loader.load(e,(n=>{this.modelCache.set(e,n.scene),A(n)}),void 0,t)}))).scene}))}loadTexture(e,A=!1){return lI(this,void 0,void 0,(function*(){if(this.textureCache.has(e))return this.textureCache.get(e);{let t=yield new Promise(((n,r)=>{new Ya().load(e,n,void 0,r)}));return A&&(t.minFilter=Ee,t.magFilter=Ee),this.textureCache.set(e,t),t}}))}loadTexturedPlaneModel(e,A,t=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}:${t.x.toFixed(2)},${t.y.toFixed(2)},${t.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);A instanceof ti?A.uniforms.map.value=u:A instanceof Ji&&(A.map=u),c.applyMatrix4(new xt().makeRotationX(-Math.PI/2).multiply(new xt().makeScale(n.x,n.y,n.z))),c.applyMatrix4(new xt().makeTranslation(t.x,t.y,t.z)),g=new Ut(c,A),this.modelCache.set(h,g)}return g.clone()}))}dispose(){this.modelCache.forEach((e=>{e.traverse((A=>{if(A.isMesh){const t=A;t.geometry.dispose(),Array.isArray(t.material)?t.material.forEach((n=>{n instanceof Sn&&n.dispose()})):t.material instanceof Sn&&t.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 A=e%360;return A>180?A-=360:A<-180&&(A+=360),A}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)}}function PE(o){return!!o&&Object.keys(o).length>0}function Ab(o){const{model:e,homePosition:A,sourceEye:t,offsets:n,targetId:r}=o;if(!PE(n))return void e.position.copy(A);const g=(function(h){if(!h)return null;const u=h.split(",").map(Number);return u.length!==3||u.some((c=>!Number.isFinite(c)))?null:new re(u[0],u[1],u[2])})(n[r]);g?e.position.copy(t).add(g):e.position.copy(A)}function cI(o,e){o.position.copy(e)}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),this.markerOffsets=(function(A){if(!A||typeof A!="object"||Array.isArray(A))return;const t={};for(const[n,r]of Object.entries(A))typeof r=="string"&&r.trim()&&(t[n]=r);return Object.keys(t).length>0?t:void 0})(e.markerOffsets)}static hasWhitelist(e){var A;return!!(!((A=e?.whitelist)===null||A===void 0)&&A.length)}static parseWhitelist(e){return Array.isArray(e.whitelist)?e.whitelist.filter((A=>typeof A=="string")):Array.isArray(e.overrides)?e.overrides.filter((A=>A?.display&&A.cameraId)).map((A=>A.cameraId)):[]}toggleWhitelistMarker(e){this.whitelist||(this.whitelist=[]);const A=this.whitelist.indexOf(e);return A>=0?(this.whitelist.splice(A,1),!1):(this.whitelist.push(e),!0)}removeWhitelistMarker(e){var A;!((A=this.whitelist)===null||A===void 0)&&A.length&&(this.whitelist=this.whitelist.filter((t=>t!==e)))}clearWhitelist(){this.whitelist=[]}mergeWhitelist(e){this.whitelist||(this.whitelist=[]);const A=new Set(this.whitelist);for(const t of e)A.has(t)||(this.whitelist.push(t),A.add(t))}toVector3(e){const A=e.split(",").map(Number);return new re(A[0],A[1],A[2])}}class Ks{constructor(e){var A,t;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=(A=e.sourceCameraId)!==null&&A!==void 0?A:"";const n=(t=e.position)!==null&&t!==void 0?t: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,A){return A==="up"?e+1:e-1}static isValidTargetFloor(e,A,t){return t===Ks.expectedTargetFloorLevel(e,A)}}class tb{constructor(e){this.id=e.id;const A=e.position.split(",").map(Number);this.position=new re(A[0],A[1],A[2]);const t=e.rotation?e.rotation.split(",").map(Number):[0,0,0];this.rotation=new Mn(t[0],t[1],t[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 ib=function(o,e,A,t){return new(A||(A=Promise))((function(n,r){function g(c){try{u(t.next(c))}catch(C){r(C)}}function h(c){try{u(t.throw(c))}catch(C){r(C)}}function u(c){var C;c.done?n(c.value):(C=c.value,C instanceof A?C:new A((function(E){E(C)}))).then(g,h)}u((t=t.apply(o,[])).next())}))};class hI{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((A=>new Xo(A))),Array.isArray(e.floorTransitions)?this.floorTransitions=e.floorTransitions.map((A=>new Ks(A))):this.floorTransitions=[],e.hasOwnProperty("interactiveObjects")&&Array.isArray(e.interactiveObjects)?this.interactiveObjects=e.interactiveObjects.map((A=>new tb(A))):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 ib(this,void 0,void 0,(function*(){try{const A=yield K.fetch(e),t=yield A.json();return new hI(t)}catch(A){throw A}}))}}class OE{constructor(){this.needMaterialUpdate=!0,this.layers=[]}addLayer(e){this.layers.push(e),this.needMaterialUpdate=!0}removeLayer(e){const A=this.layers.indexOf(e);A!==-1&&this.layers.splice(A,1),this.needMaterialUpdate=!0}getActiveLayersCount(){let e=0;for(let A=0;A<this.layers.length;A++)this.layers[A].isActive&&e++;return e}clearLayers(){this.layers=[],this.needMaterialUpdate=!0}}class nb{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 Ut(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 ti({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 Wi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const R=new Ut(k,p),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=f;let N=this.type;function L(ne,te){const Ae=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(te,null,Ae,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(te,null,Ae,w,R,null)}function G(ne,te,Ae,ye){let ge=null;const Me=Ae.isPointLight===!0?ne.customDistanceMaterial:ne.customDepthMaterial;if(Me!==void 0)ge=Me;else if(ge=Ae.isPointLight===!0?u:h,o.localClippingEnabled&&te.clipShadows===!0&&Array.isArray(te.clippingPlanes)&&te.clippingPlanes.length!==0||te.displacementMap&&te.displacementScale!==0||te.alphaMap&&te.alphaTest>0||te.map&&te.alphaTest>0){const pe=ge.uuid,Ze=te.uuid;let CA=c[pe];CA===void 0&&(CA={},c[pe]=CA);let QA=CA[Ze];QA===void 0&&(QA=ge.clone(),CA[Ze]=QA),ge=QA}return ge.visible=te.visible,ge.wireframe=te.wireframe,ge.side=ye===Q?te.shadowSide!==null?te.shadowSide:te.side:te.shadowSide!==null?te.shadowSide:E[te.side],ge.alphaMap=te.alphaMap,ge.alphaTest=te.alphaTest,ge.map=te.map,ge.clipShadows=te.clipShadows,ge.clippingPlanes=te.clippingPlanes,ge.clipIntersection=te.clipIntersection,ge.displacementMap=te.displacementMap,ge.displacementScale=te.displacementScale,ge.displacementBias=te.displacementBias,ge.wireframeLinewidth=te.wireframeLinewidth,ge.linewidth=te.linewidth,Ae.isPointLight===!0&&ge.isMeshDistanceMaterial===!0&&(o.properties.get(ge).light=Ae),ge}function le(ne,te,Ae,ye,ge){if(ne.visible===!1)return;if(ne.layers.test(te.layers)&&(ne.isMesh||ne.isLine||ne.isPoints)&&(ne.castShadow||ne.receiveShadow&&ge===Q)&&(!ne.frustumCulled||t.intersectsObject(ne))){ne.modelViewMatrix.multiplyMatrices(Ae.matrixWorldInverse,ne.matrixWorld);const pe=e.update(ne),Ze=ne.material;if(Array.isArray(Ze)){const CA=pe.groups;for(let QA=0,VA=CA.length;QA<VA;QA++){const fA=CA[QA],MA=Ze[fA.materialIndex];if(MA&&MA.visible){const RA=G(ne,MA,ye,ge);o.renderBufferDirect(Ae,null,pe,RA,ne,fA)}}}else if(Ze.visible){const CA=G(ne,Ze,ye,ge);o.renderBufferDirect(Ae,null,pe,CA,ne,null)}}const Me=ne.children;for(let pe=0,Ze=Me.length;pe<Ze;pe++)le(Me[pe],te,Ae,ye,ge)}this.render=function(ne,te,Ae){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,CA=N===Q&&this.type!==Q;for(let QA=0,VA=ne.length;QA<VA;QA++){const fA=ne[QA],MA=fA.shadow;if(MA===void 0||MA.autoUpdate===!1&&MA.needsUpdate===!1)continue;n.copy(MA.mapSize);const RA=MA.getFrameExtents();if(n.multiply(RA),r.copy(MA.mapSize),(n.x>C||n.y>C)&&(n.x>C&&(r.x=Math.floor(C/RA.x),n.x=r.x*RA.x,MA.mapSize.x=r.x),n.y>C&&(r.y=Math.floor(C/RA.y),n.y=r.y*RA.y,MA.mapSize.y=r.y)),MA.map===null||Ze===!0||CA===!0){const Ye=this.type!==Q?{minFilter:Ee,magFilter:Ee}:{};MA.map!==null&&MA.map.dispose(),MA.map=new ei(n.x,n.y,Ye),MA.map.texture.name=fA.name+".shadowMap",MA.camera.updateProjectionMatrix()}o.setRenderTarget(MA.map),o.clear();const FA=MA.getViewportCount();for(let Ye=0;Ye<FA;Ye++){const dA=MA.getViewport(Ye);g.set(r.x*dA.x,r.y*dA.y,r.x*dA.z,r.y*dA.w),pe.viewport(g),MA.updateMatrices(fA,Ye),t=MA.getFrustum(),le(te,Ae,MA.camera,fA,this.type)}MA.isPointLightShadow!==!0&&this.type===Q&&L(MA,Ae),MA.needsUpdate=!1}N=this.type,_.needsUpdate=!1,o.setRenderTarget(ye,ge,Me)}}function bS(o,e,A){const t=A.isWebGL2,n=new function(){let oe=!1;const Te=new zt;let cA=null;const SA=new zt(0,0,0,0);return{setMask:function(hA){cA===hA||oe||(o.colorMask(hA,hA,hA,hA),cA=hA)},setLocked:function(hA){oe=hA},setClear:function(hA,KA,HA,_A,Ct){Ct===!0&&(hA*=_A,KA*=_A,HA*=_A),Te.set(hA,KA,HA,_A),SA.equals(Te)===!1&&(o.clearColor(hA,KA,HA,_A),SA.copy(Te))},reset:function(){oe=!1,cA=null,SA.set(-1,0,0,0)}}},r=new function(){let oe=!1,Te=null,cA=null,SA=null;return{setTest:function(hA){hA?XA(o.DEPTH_TEST):ce(o.DEPTH_TEST)},setMask:function(hA){Te===hA||oe||(o.depthMask(hA),Te=hA)},setFunc:function(hA){if(cA!==hA){switch(hA){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)}cA=hA}},setLocked:function(hA){oe=hA},setClear:function(hA){SA!==hA&&(o.clearDepth(hA),SA=hA)},reset:function(){oe=!1,Te=null,cA=null,SA=null}}},g=new function(){let oe=!1,Te=null,cA=null,SA=null,hA=null,KA=null,HA=null,_A=null,Ct=null;return{setTest:function(ht){oe||(ht?XA(o.STENCIL_TEST):ce(o.STENCIL_TEST))},setMask:function(ht){Te===ht||oe||(o.stencilMask(ht),Te=ht)},setFunc:function(ht,J,$){cA===ht&&SA===J&&hA===$||(o.stencilFunc(ht,J,$),cA=ht,SA=J,hA=$)},setOp:function(ht,J,$){KA===ht&&HA===J&&_A===$||(o.stencilOp(ht,J,$),KA=ht,HA=J,_A=$)},setLocked:function(ht){oe=ht},setClear:function(ht){Ct!==ht&&(o.clearStencil(ht),Ct=ht)},reset:function(){oe=!1,Te=null,cA=null,SA=null,hA=null,KA=null,HA=null,_A=null,Ct=null}}},h=new WeakMap,u=new WeakMap;let c={},C={},E=new WeakMap,p=[],w=null,k=!1,R=null,_=null,N=null,L=null,G=null,le=null,ne=null,te=!1,Ae=null,ye=null,ge=null,Me=null,pe=null;const Ze=o.getParameter(o.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let CA=!1,QA=0;const VA=o.getParameter(o.VERSION);VA.indexOf("WebGL")!==-1?(QA=parseFloat(/^WebGL (\d)/.exec(VA)[1]),CA=QA>=1):VA.indexOf("OpenGL ES")!==-1&&(QA=parseFloat(/^OpenGL ES (\d)/.exec(VA)[1]),CA=QA>=2);let fA=null,MA={};const RA=o.getParameter(o.SCISSOR_BOX),FA=o.getParameter(o.VIEWPORT),Ye=new zt().fromArray(RA),dA=new zt().fromArray(FA);function bA(oe,Te,cA,SA){const hA=new Uint8Array(4),KA=o.createTexture();o.bindTexture(oe,KA),o.texParameteri(oe,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(oe,o.TEXTURE_MAG_FILTER,o.NEAREST);for(let HA=0;HA<cA;HA++)!t||oe!==o.TEXTURE_3D&&oe!==o.TEXTURE_2D_ARRAY?o.texImage2D(Te+HA,0,o.RGBA,1,1,0,o.RGBA,o.UNSIGNED_BYTE,hA):o.texImage3D(Te,0,o.RGBA,1,1,SA,0,o.RGBA,o.UNSIGNED_BYTE,hA);return KA}const gA={};function XA(oe){c[oe]!==!0&&(o.enable(oe),c[oe]=!0)}function ce(oe){c[oe]!==!1&&(o.disable(oe),c[oe]=!1)}gA[o.TEXTURE_2D]=bA(o.TEXTURE_2D,o.TEXTURE_2D,1),gA[o.TEXTURE_CUBE_MAP]=bA(o.TEXTURE_CUBE_MAP,o.TEXTURE_CUBE_MAP_POSITIVE_X,6),t&&(gA[o.TEXTURE_2D_ARRAY]=bA(o.TEXTURE_2D_ARRAY,o.TEXTURE_2D_ARRAY,1,1),gA[o.TEXTURE_3D]=bA(o.TEXTURE_3D,o.TEXTURE_3D,1,1)),n.setClear(0,0,0,1),r.setClear(1),g.setClear(0),XA(o.DEPTH_TEST),r.setFunc(3),_e(!1),BA(1),XA(o.CULL_FACE),je(0);const Ie={[S]:o.FUNC_ADD,101:o.FUNC_SUBTRACT,102:o.FUNC_REVERSE_SUBTRACT};if(t)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,cA,SA,hA,KA,HA,_A){if(oe!==0){if(k===!1&&(XA(o.BLEND),k=!0),oe===5)hA=hA||Te,KA=KA||cA,HA=HA||SA,Te===_&&hA===G||(o.blendEquationSeparate(Ie[Te],Ie[hA]),_=Te,G=hA),cA===N&&SA===L&&KA===le&&HA===ne||(o.blendFuncSeparate(Se[cA],Se[SA],Se[KA],Se[HA]),N=cA,L=SA,le=KA,ne=HA),R=oe,te=!1;else if(oe!==R||_A!==te){if(_===S&&G===S||(o.blendEquation(o.FUNC_ADD),_=S,G=S),_A)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,te=_A}}else k===!0&&(ce(o.BLEND),k=!1)}function _e(oe){Ae!==oe&&(oe?o.frontFace(o.CW):o.frontFace(o.CCW),Ae=oe)}function BA(oe){oe!==0?(XA(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,cA){oe?(XA(o.POLYGON_OFFSET_FILL),Me===Te&&pe===cA||(o.polygonOffset(Te,cA),Me=Te,pe=cA)):ce(o.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:r,stencil:g},enable:XA,disable:ce,bindFramebuffer:function(oe,Te){return C[oe]!==Te&&(o.bindFramebuffer(oe,Te),C[oe]=Te,t&&(oe===o.DRAW_FRAMEBUFFER&&(C[o.FRAMEBUFFER]=Te),oe===o.FRAMEBUFFER&&(C[o.DRAW_FRAMEBUFFER]=Te)),!0)},drawBuffers:function(oe,Te){let cA=p,SA=!1;if(oe)if(cA=E.get(Te),cA===void 0&&(cA=[],E.set(Te,cA)),oe.isWebGLMultipleRenderTargets){const hA=oe.texture;if(cA.length!==hA.length||cA[0]!==o.COLOR_ATTACHMENT0){for(let KA=0,HA=hA.length;KA<HA;KA++)cA[KA]=o.COLOR_ATTACHMENT0+KA;cA.length=hA.length,SA=!0}}else cA[0]!==o.COLOR_ATTACHMENT0&&(cA[0]=o.COLOR_ATTACHMENT0,SA=!0);else cA[0]!==o.BACK&&(cA[0]=o.BACK,SA=!0);SA&&(A.isWebGL2?o.drawBuffers(cA):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(cA))},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):XA(o.CULL_FACE);let cA=oe.side===v;Te&&(cA=!cA),_e(cA),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 SA=oe.stencilWrite;g.setTest(SA),SA&&(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?XA(o.SAMPLE_ALPHA_TO_COVERAGE):ce(o.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:_e,setCullFace:BA,setLineWidth:function(oe){oe!==ge&&(CA&&o.lineWidth(oe),ge=oe)},setPolygonOffset:ke,setScissorTest:function(oe){oe?XA(o.SCISSOR_TEST):ce(o.SCISSOR_TEST)},activeTexture:function(oe){oe===void 0&&(oe=o.TEXTURE0+Ze-1),fA!==oe&&(o.activeTexture(oe),fA=oe)},bindTexture:function(oe,Te,cA){cA===void 0&&(cA=fA===null?o.TEXTURE0+Ze-1:fA);let SA=MA[cA];SA===void 0&&(SA={type:void 0,texture:void 0},MA[cA]=SA),SA.type===oe&&SA.texture===Te||(fA!==cA&&(o.activeTexture(cA),fA=cA),o.bindTexture(oe,Te||gA[oe]),SA.type=oe,SA.texture=Te)},unbindTexture:function(){const oe=MA[fA];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 cA=u.get(Te);cA===void 0&&(cA=new WeakMap,u.set(Te,cA));let SA=cA.get(oe);SA===void 0&&(SA=o.getUniformBlockIndex(Te,oe.name),cA.set(oe,SA))},uniformBlockBinding:function(oe,Te){const cA=u.get(Te).get(oe);h.get(Te)!==cA&&(o.uniformBlockBinding(Te,cA,oe.__bindingPointIndex),h.set(Te,cA))},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){dA.equals(oe)===!1&&(o.viewport(oe.x,oe.y,oe.z,oe.w),dA.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),t===!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={},fA=null,MA={},C={},E=new WeakMap,p=[],w=null,k=!1,R=null,_=null,N=null,L=null,G=null,le=null,ne=null,te=!1,Ae=null,ye=null,ge=null,Me=null,pe=null,Ye.set(0,0,o.canvas.width,o.canvas.height),dA.set(0,0,o.canvas.width,o.canvas.height),n.reset(),r.reset(),g.reset()}}}function _S(o,e,A,t,n,r,g){const h=n.isWebGL2,u=(n.maxTextures,n.maxCubemapSize),c=n.maxTextureSize,C=n.maxSamples,E=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 BA=Ie?Fr:Math.floor,ke=BA(_e*ce.width),oe=BA(_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!==Ee&&ce.minFilter!==Qe}function ne(ce){o.generateMipmap(ce)}function te(ce,Ie,Se,je,_e=!1){if(h===!1)return Ie;if(ce!==null&&o[ce]!==void 0)return o[ce];let BA=Ie;return Ie===o.RED&&(Se===o.FLOAT&&(BA=o.R32F),Se===o.HALF_FLOAT&&(BA=o.R16F),Se===o.UNSIGNED_BYTE&&(BA=o.R8)),Ie===o.RG&&(Se===o.FLOAT&&(BA=o.RG32F),Se===o.HALF_FLOAT&&(BA=o.RG16F),Se===o.UNSIGNED_BYTE&&(BA=o.RG8)),Ie===o.RGBA&&(Se===o.FLOAT&&(BA=o.RGBA32F),Se===o.HALF_FLOAT&&(BA=o.RGBA16F),Se===o.UNSIGNED_BYTE&&(BA=je===ie&&_e===!1?o.SRGB8_ALPHA8:o.RGBA8),Se===o.UNSIGNED_SHORT_4_4_4_4&&(BA=o.RGBA4),Se===o.UNSIGNED_SHORT_5_5_5_1&&(BA=o.RGB5_A1)),BA!==o.R16F&&BA!==o.R32F&&BA!==o.RG16F&&BA!==o.RG32F&&BA!==o.RGBA16F&&BA!==o.RGBA32F||e.get("EXT_color_buffer_float"),BA}function Ae(ce,Ie,Se){return le(ce,Se)===!0||ce.isFramebufferTexture&&ce.minFilter!==Ee&&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===Ee||ce===qe||ce===me?o.NEAREST:o.LINEAR}function ge(ce){const Ie=ce.target;Ie.removeEventListener("dispose",ge),(function(Se){const je=t.get(Se);if(je.__webglInit===void 0)return;const _e=Se.source,BA=R.get(_e);if(BA){const ke=BA[je.__cacheKey];ke.usedTimes--,ke.usedTimes===0&&pe(Se),Object.keys(BA).length===0&&R.delete(_e)}t.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=t.get(Se),BA=t.get(je);if(BA.__webglTexture!==void 0&&(o.deleteTexture(BA.__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=t.get(je[ke]);Te.__webglTexture&&(o.deleteTexture(Te.__webglTexture),g.memory.textures--),t.remove(je[ke])}t.remove(je),t.remove(Se)})(Ie)}function pe(ce){const Ie=t.get(ce);o.deleteTexture(Ie.__webglTexture);const Se=ce.source;delete R.get(Se)[Ie.__cacheKey],g.memory.textures--}let Ze=0;function CA(ce,Ie){const Se=t.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 RA(Se,ce,Ie)}}A.bindTexture(o.TEXTURE_2D,Se.__webglTexture,o.TEXTURE0+Ie)}const QA={[Ce]:o.REPEAT,[ee]:o.CLAMP_TO_EDGE,[Fe]:o.MIRRORED_REPEAT},VA={[Ee]:o.NEAREST,[qe]:o.NEAREST_MIPMAP_NEAREST,[me]:o.NEAREST_MIPMAP_LINEAR,[Qe]:o.LINEAR,[AA]:o.LINEAR_MIPMAP_NEAREST,[se]:o.LINEAR_MIPMAP_LINEAR};function fA(ce,Ie,Se){if(Se?(o.texParameteri(ce,o.TEXTURE_WRAP_S,QA[Ie.wrapS]),o.texParameteri(ce,o.TEXTURE_WRAP_T,QA[Ie.wrapT]),ce!==o.TEXTURE_3D&&ce!==o.TEXTURE_2D_ARRAY||o.texParameteri(ce,o.TEXTURE_WRAP_R,QA[Ie.wrapR]),o.texParameteri(ce,o.TEXTURE_MAG_FILTER,VA[Ie.magFilter]),o.texParameteri(ce,o.TEXTURE_MIN_FILTER,VA[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!==Ee&&Ie.minFilter),e.has("EXT_texture_filter_anisotropic")===!0){const je=e.get("EXT_texture_filter_anisotropic");if(Ie.magFilter===Ee||Ie.minFilter!==me&&Ie.minFilter!==se||Ie.type===De&&e.has("OES_texture_float_linear")===!1||h===!1&&Ie.type===mA&&e.has("OES_texture_half_float_linear")===!1)return;(Ie.anisotropy>1||t.get(Ie).__currentAnisotropy)&&(o.texParameterf(ce,je.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(Ie.anisotropy,n.getMaxAnisotropy())),t.get(Ie).__currentAnisotropy=Ie.anisotropy)}}function MA(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 BA=(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(BA!==ce.__cacheKey){_e[BA]===void 0&&(_e[BA]={texture:o.createTexture(),usedTimes:0},g.memory.textures++,Se=!0),_e[BA].usedTimes++;const ke=_e[ce.__cacheKey];ke!==void 0&&(_e[ce.__cacheKey].usedTimes--,ke.usedTimes===0&&pe(Ie)),ce.__cacheKey=BA,ce.__webglTexture=_e[BA].texture}return Se}function RA(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=MA(ce,Ie),BA=Ie.source;A.bindTexture(je,ce.__webglTexture,o.TEXTURE0+Se);const ke=t.get(BA);if(BA.version!==ke.__version||_e===!0){A.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!==Ee&&$.minFilter!==Qe)})(Ie)&&G(Ie.image)===!1;let Te=L(Ie.image,oe,!1,c);Te=XA(Ie,Te);const cA=G(Te)||h,SA=r.convert(Ie.format,Ie.colorSpace);let hA,KA=r.convert(Ie.type),HA=te(Ie.internalFormat,SA,KA,Ie.colorSpace);fA(je,Ie,cA);const _A=Ie.mipmaps,Ct=h&&Ie.isVideoTexture!==!0,ht=ke.__version===void 0||_e===!0,J=Ae(Ie,Te,cA);if(Ie.isDepthTexture)HA=o.DEPTH_COMPONENT,h?HA=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===sA&&HA===o.DEPTH_COMPONENT&&Ie.type!==1012&&Ie.type!==U&&(Ie.type=U,KA=r.convert(Ie.type)),Ie.format===TA&&HA===o.DEPTH_COMPONENT&&(HA=o.DEPTH_STENCIL,Ie.type!==He&&(Ie.type=He,KA=r.convert(Ie.type))),ht&&(Ct?A.texStorage2D(o.TEXTURE_2D,1,HA,Te.width,Te.height):A.texImage2D(o.TEXTURE_2D,0,HA,Te.width,Te.height,0,SA,KA,null));else if(Ie.isDataTexture)if(_A.length>0&&cA){Ct&&ht&&A.texStorage2D(o.TEXTURE_2D,J,HA,_A[0].width,_A[0].height);for(let $=0,xe=_A.length;$<xe;$++)hA=_A[$],Ct?A.texSubImage2D(o.TEXTURE_2D,$,0,0,hA.width,hA.height,SA,KA,hA.data):A.texImage2D(o.TEXTURE_2D,$,HA,hA.width,hA.height,0,SA,KA,hA.data);Ie.generateMipmaps=!1}else Ct?(ht&&A.texStorage2D(o.TEXTURE_2D,J,HA,Te.width,Te.height),A.texSubImage2D(o.TEXTURE_2D,0,0,0,Te.width,Te.height,SA,KA,Te.data)):A.texImage2D(o.TEXTURE_2D,0,HA,Te.width,Te.height,0,SA,KA,Te.data);else if(Ie.isCompressedTexture)if(Ie.isCompressedArrayTexture){Ct&&ht&&A.texStorage3D(o.TEXTURE_2D_ARRAY,J,HA,_A[0].width,_A[0].height,Te.depth);for(let $=0,xe=_A.length;$<xe;$++)hA=_A[$],Ie.format!==kA?SA!==null&&(Ct?A.compressedTexSubImage3D(o.TEXTURE_2D_ARRAY,$,0,0,0,hA.width,hA.height,Te.depth,SA,hA.data,0,0):A.compressedTexImage3D(o.TEXTURE_2D_ARRAY,$,HA,hA.width,hA.height,Te.depth,0,hA.data,0,0)):Ct?A.texSubImage3D(o.TEXTURE_2D_ARRAY,$,0,0,0,hA.width,hA.height,Te.depth,SA,KA,hA.data):A.texImage3D(o.TEXTURE_2D_ARRAY,$,HA,hA.width,hA.height,Te.depth,0,SA,KA,hA.data)}else{Ct&&ht&&A.texStorage2D(o.TEXTURE_2D,J,HA,_A[0].width,_A[0].height);for(let $=0,xe=_A.length;$<xe;$++)hA=_A[$],Ie.format!==kA?SA!==null&&(Ct?A.compressedTexSubImage2D(o.TEXTURE_2D,$,0,0,hA.width,hA.height,SA,hA.data):A.compressedTexImage2D(o.TEXTURE_2D,$,HA,hA.width,hA.height,0,hA.data)):Ct?A.texSubImage2D(o.TEXTURE_2D,$,0,0,hA.width,hA.height,SA,KA,hA.data):A.texImage2D(o.TEXTURE_2D,$,HA,hA.width,hA.height,0,SA,KA,hA.data)}else if(Ie.isDataArrayTexture)Ct?(ht&&A.texStorage3D(o.TEXTURE_2D_ARRAY,J,HA,Te.width,Te.height,Te.depth),A.texSubImage3D(o.TEXTURE_2D_ARRAY,0,0,0,0,Te.width,Te.height,Te.depth,SA,KA,Te.data)):A.texImage3D(o.TEXTURE_2D_ARRAY,0,HA,Te.width,Te.height,Te.depth,0,SA,KA,Te.data);else if(Ie.isData3DTexture)Ct?(ht&&A.texStorage3D(o.TEXTURE_3D,J,HA,Te.width,Te.height,Te.depth),A.texSubImage3D(o.TEXTURE_3D,0,0,0,0,Te.width,Te.height,Te.depth,SA,KA,Te.data)):A.texImage3D(o.TEXTURE_3D,0,HA,Te.width,Te.height,Te.depth,0,SA,KA,Te.data);else if(Ie.isFramebufferTexture){if(ht)if(Ct)A.texStorage2D(o.TEXTURE_2D,J,HA,Te.width,Te.height);else{let $=Te.width,xe=Te.height;for(let rA=0;rA<J;rA++)A.texImage2D(o.TEXTURE_2D,rA,HA,$,xe,0,SA,KA,null),$>>=1,xe>>=1}}else if(_A.length>0&&cA){Ct&&ht&&A.texStorage2D(o.TEXTURE_2D,J,HA,_A[0].width,_A[0].height);for(let $=0,xe=_A.length;$<xe;$++)hA=_A[$],Ct?A.texSubImage2D(o.TEXTURE_2D,$,0,0,SA,KA,hA):A.texImage2D(o.TEXTURE_2D,$,HA,SA,KA,hA);Ie.generateMipmaps=!1}else Ct?(ht&&A.texStorage2D(o.TEXTURE_2D,J,HA,Te.width,Te.height),A.texSubImage2D(o.TEXTURE_2D,0,0,0,SA,KA,Te)):A.texImage2D(o.TEXTURE_2D,0,HA,SA,KA,Te);le(Ie,cA)&&ne(je),ke.__version=BA.version,Ie.onUpdate&&Ie.onUpdate(Ie)}ce.__version=Ie.version}function FA(ce,Ie,Se,je,_e){const BA=r.convert(Se.format,Se.colorSpace),ke=r.convert(Se.type),oe=te(Se.internalFormat,BA,ke,Se.colorSpace);t.get(Ie).__hasExternalTextures||(_e===o.TEXTURE_3D||_e===o.TEXTURE_2D_ARRAY?A.texImage3D(_e,0,oe,Ie.width,Ie.height,Ie.depth,0,BA,ke,null):A.texImage2D(_e,0,oe,Ie.width,Ie.height,0,BA,ke,null)),A.bindFramebuffer(o.FRAMEBUFFER,ce),gA(Ie)?E.framebufferTexture2DMultisampleEXT(o.FRAMEBUFFER,je,_e,t.get(Se).__webglTexture,0,bA(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,t.get(Se).__webglTexture,0),A.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||gA(Ie)){const _e=Ie.depthTexture;_e&&_e.isDepthTexture&&(_e.type===De?je=o.DEPTH_COMPONENT32F:_e.type===U&&(je=o.DEPTH_COMPONENT24));const BA=bA(Ie);gA(Ie)?E.renderbufferStorageMultisampleEXT(o.RENDERBUFFER,BA,je,Ie.width,Ie.height):o.renderbufferStorageMultisample(o.RENDERBUFFER,BA,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=bA(Ie);Se&&gA(Ie)===!1?o.renderbufferStorageMultisample(o.RENDERBUFFER,je,o.DEPTH24_STENCIL8,Ie.width,Ie.height):gA(Ie)?E.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 BA=je[_e],ke=r.convert(BA.format,BA.colorSpace),oe=r.convert(BA.type),Te=te(BA.internalFormat,ke,oe,BA.colorSpace),cA=bA(Ie);Se&&gA(Ie)===!1?o.renderbufferStorageMultisample(o.RENDERBUFFER,cA,Te,Ie.width,Ie.height):gA(Ie)?E.renderbufferStorageMultisampleEXT(o.RENDERBUFFER,cA,Te,Ie.width,Ie.height):o.renderbufferStorage(o.RENDERBUFFER,Te,Ie.width,Ie.height)}}o.bindRenderbuffer(o.RENDERBUFFER,null)}function dA(ce){const Ie=t.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(A.bindFramebuffer(o.FRAMEBUFFER,je),!_e.depthTexture||!_e.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");t.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),CA(_e.depthTexture,0);const BA=t.get(_e.depthTexture).__webglTexture,ke=bA(_e);if(_e.depthTexture.format===sA)gA(_e)?E.framebufferTexture2DMultisampleEXT(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.TEXTURE_2D,BA,0,ke):o.framebufferTexture2D(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.TEXTURE_2D,BA,0);else{if(_e.depthTexture.format!==TA)throw new Error("Unknown depthTexture format");gA(_e)?E.framebufferTexture2DMultisampleEXT(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.TEXTURE_2D,BA,0,ke):o.framebufferTexture2D(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.TEXTURE_2D,BA,0)}})(Ie.__webglFramebuffer,ce)}else if(Se){Ie.__webglDepthbuffer=[];for(let je=0;je<6;je++)A.bindFramebuffer(o.FRAMEBUFFER,Ie.__webglFramebuffer[je]),Ie.__webglDepthbuffer[je]=o.createRenderbuffer(),Ye(Ie.__webglDepthbuffer[je],ce,!1)}else A.bindFramebuffer(o.FRAMEBUFFER,Ie.__webglFramebuffer),Ie.__webglDepthbuffer=o.createRenderbuffer(),Ye(Ie.__webglDepthbuffer,ce,!1);A.bindFramebuffer(o.FRAMEBUFFER,null)}function bA(ce){return Math.min(C,ce.samples)}function gA(ce){const Ie=t.get(ce);return h&&ce.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&Ie.__useRenderToTexture!==!1}function XA(ce,Ie){const Se=ce.colorSpace,je=ce.format;return ce.type,ce.isCompressedTexture===!0||ce.format===Ne||Se!==V&&Se!==Be&&Se===ie&&h===!1&&(e.has("EXT_sRGB")===!0&&je===kA?(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=CA,this.setTexture2DArray=function(ce,Ie){const Se=t.get(ce);ce.version>0&&Se.__version!==ce.version?RA(Se,ce,Ie):A.bindTexture(o.TEXTURE_2D_ARRAY,Se.__webglTexture,o.TEXTURE0+Ie)},this.setTexture3D=function(ce,Ie){const Se=t.get(ce);ce.version>0&&Se.__version!==ce.version?RA(Se,ce,Ie):A.bindTexture(o.TEXTURE_3D,Se.__webglTexture,o.TEXTURE0+Ie)},this.setTextureCube=function(ce,Ie){const Se=t.get(ce);ce.version>0&&Se.__version!==ce.version?(function(je,_e,BA){if(_e.image.length!==6)return;const ke=MA(je,_e),oe=_e.source;A.bindTexture(o.TEXTURE_CUBE_MAP,je.__webglTexture,o.TEXTURE0+BA);const Te=t.get(oe);if(oe.version!==Te.__version||ke===!0){A.activeTexture(o.TEXTURE0+BA),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 cA=_e.isCompressedTexture||_e.image[0].isCompressedTexture,SA=_e.image[0]&&_e.image[0].isDataTexture,hA=[];for(let $e=0;$e<6;$e++)hA[$e]=cA||SA?SA?_e.image[$e].image:_e.image[$e]:L(_e.image[$e],!1,!0,u),hA[$e]=XA(_e,hA[$e]);const KA=hA[0],HA=G(KA)||h,_A=r.convert(_e.format,_e.colorSpace),Ct=r.convert(_e.type),ht=te(_e.internalFormat,_A,Ct,_e.colorSpace),J=h&&_e.isVideoTexture!==!0,$=Te.__version===void 0||ke===!0;let xe,rA=Ae(_e,KA,HA);if(fA(o.TEXTURE_CUBE_MAP,_e,HA),cA){J&&$&&A.texStorage2D(o.TEXTURE_CUBE_MAP,rA,ht,KA.width,KA.height);for(let $e=0;$e<6;$e++){xe=hA[$e].mipmaps;for(let Re=0;Re<xe.length;Re++){const Pe=xe[Re];_e.format!==kA?_A!==null&&(J?A.compressedTexSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,0,0,Pe.width,Pe.height,_A,Pe.data):A.compressedTexImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,ht,Pe.width,Pe.height,0,Pe.data)):J?A.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,0,0,Pe.width,Pe.height,_A,Ct,Pe.data):A.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re,ht,Pe.width,Pe.height,0,_A,Ct,Pe.data)}}}else{xe=_e.mipmaps,J&&$&&(xe.length>0&&rA++,A.texStorage2D(o.TEXTURE_CUBE_MAP,rA,ht,hA[0].width,hA[0].height));for(let $e=0;$e<6;$e++)if(SA){J?A.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,0,0,hA[$e].width,hA[$e].height,_A,Ct,hA[$e].data):A.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,ht,hA[$e].width,hA[$e].height,0,_A,Ct,hA[$e].data);for(let Re=0;Re<xe.length;Re++){const Pe=xe[Re].image[$e].image;J?A.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,0,0,Pe.width,Pe.height,_A,Ct,Pe.data):A.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,ht,Pe.width,Pe.height,0,_A,Ct,Pe.data)}}else{J?A.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,0,0,_A,Ct,hA[$e]):A.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,0,ht,_A,Ct,hA[$e]);for(let Re=0;Re<xe.length;Re++){const Pe=xe[Re];J?A.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,0,0,_A,Ct,Pe.image[$e]):A.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Re+1,ht,_A,Ct,Pe.image[$e])}}}le(_e,HA)&&ne(o.TEXTURE_CUBE_MAP),Te.__version=oe.version,_e.onUpdate&&_e.onUpdate(_e)}je.__version=_e.version})(Se,ce,Ie):A.bindTexture(o.TEXTURE_CUBE_MAP,Se.__webglTexture,o.TEXTURE0+Ie)},this.rebindTextures=function(ce,Ie,Se){const je=t.get(ce);Ie!==void 0&&FA(je.__webglFramebuffer,ce,ce.texture,o.COLOR_ATTACHMENT0,o.TEXTURE_2D),Se!==void 0&&dA(ce)},this.setupRenderTarget=function(ce){const Ie=ce.texture,Se=t.get(ce),je=t.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,BA=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(),BA&&n.drawBuffers){const oe=ce.texture;for(let Te=0,cA=oe.length;Te<cA;Te++){const SA=t.get(oe[Te]);SA.__webglTexture===void 0&&(SA.__webglTexture=o.createTexture(),g.memory.textures++)}}if(h&&ce.samples>0&&gA(ce)===!1){const oe=BA?Ie:[Ie];Se.__webglMultisampledFramebuffer=o.createFramebuffer(),Se.__webglColorRenderbuffer=[],A.bindFramebuffer(o.FRAMEBUFFER,Se.__webglMultisampledFramebuffer);for(let Te=0;Te<oe.length;Te++){const cA=oe[Te];Se.__webglColorRenderbuffer[Te]=o.createRenderbuffer(),o.bindRenderbuffer(o.RENDERBUFFER,Se.__webglColorRenderbuffer[Te]);const SA=r.convert(cA.format,cA.colorSpace),hA=r.convert(cA.type),KA=te(cA.internalFormat,SA,hA,cA.colorSpace,ce.isXRRenderTarget===!0),HA=bA(ce);o.renderbufferStorageMultisample(o.RENDERBUFFER,HA,KA,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)),A.bindFramebuffer(o.FRAMEBUFFER,null)}}if(_e){A.bindTexture(o.TEXTURE_CUBE_MAP,je.__webglTexture),fA(o.TEXTURE_CUBE_MAP,Ie,ke);for(let oe=0;oe<6;oe++)FA(Se.__webglFramebuffer[oe],ce,Ie,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+oe);le(Ie,ke)&&ne(o.TEXTURE_CUBE_MAP),A.unbindTexture()}else if(BA){const oe=ce.texture;for(let Te=0,cA=oe.length;Te<cA;Te++){const SA=oe[Te],hA=t.get(SA);A.bindTexture(o.TEXTURE_2D,hA.__webglTexture),fA(o.TEXTURE_2D,SA,ke),FA(Se.__webglFramebuffer,ce,SA,o.COLOR_ATTACHMENT0+Te,o.TEXTURE_2D),le(SA,ke)&&ne(o.TEXTURE_2D)}A.unbindTexture()}else{let oe=o.TEXTURE_2D;(ce.isWebGL3DRenderTarget||ce.isWebGLArrayRenderTarget)&&h&&(oe=ce.isWebGL3DRenderTarget?o.TEXTURE_3D:o.TEXTURE_2D_ARRAY),A.bindTexture(oe,je.__webglTexture),fA(oe,Ie,ke),FA(Se.__webglFramebuffer,ce,Ie,o.COLOR_ATTACHMENT0,oe),le(Ie,ke)&&ne(oe),A.unbindTexture()}ce.depthBuffer&&dA(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 BA=Se[je];if(le(BA,Ie)){const ke=ce.isWebGLCubeRenderTarget?o.TEXTURE_CUBE_MAP:o.TEXTURE_2D,oe=t.get(BA).__webglTexture;A.bindTexture(ke,oe),ne(ke),A.unbindTexture()}}},this.updateMultisampleRenderTarget=function(ce){if(h&&ce.samples>0&&gA(ce)===!1){const Ie=ce.isWebGLMultipleRenderTargets?ce.texture:[ce.texture],Se=ce.width,je=ce.height;let _e=o.COLOR_BUFFER_BIT;const BA=[],ke=ce.stencilBuffer?o.DEPTH_STENCIL_ATTACHMENT:o.DEPTH_ATTACHMENT,oe=t.get(ce),Te=ce.isWebGLMultipleRenderTargets===!0;if(Te)for(let cA=0;cA<Ie.length;cA++)A.bindFramebuffer(o.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0+cA,o.RENDERBUFFER,null),A.bindFramebuffer(o.FRAMEBUFFER,oe.__webglFramebuffer),o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0+cA,o.TEXTURE_2D,null,0);A.bindFramebuffer(o.READ_FRAMEBUFFER,oe.__webglMultisampledFramebuffer),A.bindFramebuffer(o.DRAW_FRAMEBUFFER,oe.__webglFramebuffer);for(let cA=0;cA<Ie.length;cA++){BA.push(o.COLOR_ATTACHMENT0+cA),ce.depthBuffer&&BA.push(ke);const SA=oe.__ignoreDepthValues!==void 0&&oe.__ignoreDepthValues;if(SA===!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[cA]),SA===!0&&(o.invalidateFramebuffer(o.READ_FRAMEBUFFER,[ke]),o.invalidateFramebuffer(o.DRAW_FRAMEBUFFER,[ke])),Te){const hA=t.get(Ie[cA]).__webglTexture;o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,hA,0)}o.blitFramebuffer(0,0,Se,je,0,0,Se,je,_e,o.NEAREST),p&&o.invalidateFramebuffer(o.READ_FRAMEBUFFER,BA)}if(A.bindFramebuffer(o.READ_FRAMEBUFFER,null),A.bindFramebuffer(o.DRAW_FRAMEBUFFER,null),Te)for(let cA=0;cA<Ie.length;cA++){A.bindFramebuffer(o.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0+cA,o.RENDERBUFFER,oe.__webglColorRenderbuffer[cA]);const SA=t.get(Ie[cA]).__webglTexture;A.bindFramebuffer(o.FRAMEBUFFER,oe.__webglFramebuffer),o.framebufferTexture2D(o.DRAW_FRAMEBUFFER,o.COLOR_ATTACHMENT0+cA,o.TEXTURE_2D,SA,0)}A.bindFramebuffer(o.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=dA,this.setupFrameBufferTexture=FA,this.useMultisampledRTT=gA}function RS(o,e,A){const t=A.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===mA)return t?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===kA)return o.RGBA;if(n===1024)return o.LUMINANCE;if(n===1025)return o.LUMINANCE_ALPHA;if(n===sA)return o.DEPTH_COMPONENT;if(n===TA)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===jA||n===NA||n===W)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===jA)return g.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===NA)return g.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===W)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===jA)return g.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===NA)return g.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===W)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?t?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 NS extends Zi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Js extends gi{constructor(){super(),this.isGroup=!0,this.type="Group"}}const kS={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 A=this._hand;if(A)for(const t of e.hand.values())this._getHandJoint(A,t)}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,A,t){let n=null,r=null,g=null;const h=this._targetRay,u=this._grip,c=this._hand;if(e&&A.session.visibilityState!=="visible-blurred"){if(c&&e.hand){g=!0;for(const R of e.hand.values()){const _=A.getJointPose(R,t),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"],E=c.joints["thumb-tip"],p=C.position.distanceTo(E.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=A.getPose(e.gripSpace,t),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=A.getPose(e.targetRaySpace,t),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(kS)))}return h!==null&&(h.visible=n!==null),u!==null&&(u.visible=r!==null),c!==null&&(c.visible=g!==null),this}_getHandJoint(e,A){if(e.joints[A.jointName]===void 0){const t=new Js;t.matrixAutoUpdate=!1,t.visible=!1,e.joints[A.jointName]=t,e.add(t)}return e.joints[A.jointName]}}class FS extends Di{constructor(e,A,t,n,r,g,h,u,c,C){if((C=C!==void 0?C:sA)!==sA&&C!==TA)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");t===void 0&&C===sA&&(t=U),t===void 0&&C===TA&&(t=He),super(null,n,r,g,h,u,C,t,c),this.isDepthTexture=!0,this.image={width:e,height:A},this.magFilter=h!==void 0?h:Ee,this.minFilter=u!==void 0?u:Ee,this.flipY=!1,this.generateMipmaps=!1}}class LS extends uA{constructor(e,A){super();const t=this;let n=null,r=1,g=null,h="local-floor",u=1,c=null,C=null,E=null,p=null,w=null,k=null;const R=A.getContextAttributes();let _=null,N=null;const L=[],G=[],le=new Set,ne=new Map,te=new Zi;te.layers.enable(1),te.viewport=new zt;const Ae=new Zi;Ae.layers.enable(2),Ae.viewport=new zt;const ye=[te,Ae],ge=new NS;ge.layers.enable(1),ge.layers.enable(2);let Me=null,pe=null;function Ze(Ye){const dA=G.indexOf(Ye.inputSource);if(dA===-1)return;const bA=L[dA];bA!==void 0&&(bA.update(Ye.inputSource,Ye.frame,c||g),bA.dispatchEvent({type:Ye.type,data:Ye.inputSource}))}function CA(){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",CA),n.removeEventListener("inputsourceschange",QA);for(let Ye=0;Ye<L.length;Ye++){const dA=G[Ye];dA!==null&&(G[Ye]=null,L[Ye].disconnect(dA))}Me=null,pe=null,e.setRenderTarget(_),w=null,p=null,E=null,n=null,N=null,FA.stop(),t.isPresenting=!1,t.dispatchEvent({type:"sessionend"})}function QA(Ye){for(let dA=0;dA<Ye.removed.length;dA++){const bA=Ye.removed[dA],gA=G.indexOf(bA);gA>=0&&(G[gA]=null,L[gA].disconnect(bA))}for(let dA=0;dA<Ye.added.length;dA++){const bA=Ye.added[dA];let gA=G.indexOf(bA);if(gA===-1){for(let ce=0;ce<L.length;ce++){if(ce>=G.length){G.push(bA),gA=ce;break}if(G[ce]===null){G[ce]=bA,gA=ce;break}}if(gA===-1)break}const XA=L[gA];XA&&XA.connect(bA)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Ye){let dA=L[Ye];return dA===void 0&&(dA=new Kh,L[Ye]=dA),dA.getTargetRaySpace()},this.getControllerGrip=function(Ye){let dA=L[Ye];return dA===void 0&&(dA=new Kh,L[Ye]=dA),dA.getGripSpace()},this.getHand=function(Ye){let dA=L[Ye];return dA===void 0&&(dA=new Kh,L[Ye]=dA),dA.getHandSpace()},this.setFramebufferScaleFactor=function(Ye){r=Ye,t.isPresenting},this.setReferenceSpaceType=function(Ye){h=Ye,t.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 E},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",CA),n.addEventListener("inputsourceschange",QA),R.xrCompatible!==!0&&await A.makeXRCompatible(),n.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const dA={antialias:n.renderState.layers!==void 0||R.antialias,alpha:!0,depth:R.depth,stencil:R.stencil,framebufferScaleFactor:r};w=new XRWebGLLayer(n,A,dA),n.updateRenderState({baseLayer:w}),N=new ei(w.framebufferWidth,w.framebufferHeight,{format:kA,type:be,colorSpace:e.outputColorSpace,stencilBuffer:R.stencil})}else{let dA=null,bA=null,gA=null;R.depth&&(gA=R.stencil?A.DEPTH24_STENCIL8:A.DEPTH_COMPONENT24,dA=R.stencil?TA:sA,bA=R.stencil?He:U);const XA={colorFormat:A.RGBA8,depthFormat:gA,scaleFactor:r};E=new XRWebGLBinding(n,A),p=E.createProjectionLayer(XA),n.updateRenderState({layers:[p]}),N=new ei(p.textureWidth,p.textureHeight,{format:kA,type:be,depthTexture:new FS(p.textureWidth,p.textureHeight,bA,void 0,void 0,void 0,void 0,void 0,void 0,dA),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),FA.setContext(n),FA.start(),t.isPresenting=!0,t.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode};const VA=new re,fA=new re;function MA(Ye,dA){dA===null?Ye.matrixWorld.copy(Ye.matrix):Ye.matrixWorld.multiplyMatrices(dA.matrixWorld,Ye.matrix),Ye.matrixWorldInverse.copy(Ye.matrixWorld).invert()}this.updateCamera=function(Ye){if(n===null)return;ge.near=Ae.near=te.near=Ye.near,ge.far=Ae.far=te.far=Ye.far,Me===ge.near&&pe===ge.far||(n.updateRenderState({depthNear:ge.near,depthFar:ge.far}),Me=ge.near,pe=ge.far);const dA=Ye.parent,bA=ge.cameras;MA(ge,dA);for(let gA=0;gA<bA.length;gA++)MA(bA[gA],dA);bA.length===2?(function(gA,XA,ce){VA.setFromMatrixPosition(XA.matrixWorld),fA.setFromMatrixPosition(ce.matrixWorld);const Ie=VA.distanceTo(fA),Se=XA.projectionMatrix.elements,je=ce.projectionMatrix.elements,_e=Se[14]/(Se[10]-1),BA=Se[14]/(Se[10]+1),ke=(Se[9]+1)/Se[5],oe=(Se[9]-1)/Se[5],Te=(Se[8]-1)/Se[0],cA=(je[8]+1)/je[0],SA=_e*Te,hA=_e*cA,KA=Ie/(-Te+cA),HA=KA*-Te;XA.matrixWorld.decompose(gA.position,gA.quaternion,gA.scale),gA.translateX(HA),gA.translateZ(KA),gA.matrixWorld.compose(gA.position,gA.quaternion,gA.scale),gA.matrixWorldInverse.copy(gA.matrixWorld).invert();const _A=_e+KA,Ct=BA+KA,ht=SA-HA,J=hA+(Ie-HA),$=ke*BA/Ct*_A,xe=oe*BA/Ct*_A;gA.projectionMatrix.makePerspective(ht,J,$,xe,_A,Ct),gA.projectionMatrixInverse.copy(gA.projectionMatrix).invert()})(ge,te,Ae):ge.projectionMatrix.copy(te.projectionMatrix),(function(gA,XA,ce){ce===null?gA.matrix.copy(XA.matrixWorld):(gA.matrix.copy(ce.matrixWorld),gA.matrix.invert(),gA.matrix.multiply(XA.matrixWorld)),gA.matrix.decompose(gA.position,gA.quaternion,gA.scale),gA.updateMatrixWorld(!0);const Ie=gA.children;for(let Se=0,je=Ie.length;Se<je;Se++)Ie[Se].updateMatrixWorld(!0);gA.projectionMatrix.copy(XA.projectionMatrix),gA.projectionMatrixInverse.copy(XA.projectionMatrixInverse),gA.isPerspectiveCamera&&(gA.fov=2*Rt*Math.atan(1/gA.projectionMatrix.elements[5]),gA.zoom=1)})(Ye,ge,dA)},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 RA=null;const FA=new MB;FA.setAnimationLoop((function(Ye,dA){if(C=dA.getViewerPose(c||g),k=dA,C!==null){const bA=C.views;w!==null&&(e.setRenderTargetFramebuffer(N,w.framebuffer),e.setRenderTarget(N));let gA=!1;bA.length!==ge.cameras.length&&(ge.cameras.length=0,gA=!0);for(let XA=0;XA<bA.length;XA++){const ce=bA[XA];let Ie=null;if(w!==null)Ie=w.getViewport(ce);else{const je=E.getViewSubImage(p,ce);Ie=je.viewport,XA===0&&(e.setRenderTargetTextures(N,je.colorTexture,p.ignoreDepthValues?void 0:je.depthStencilTexture),e.setRenderTarget(N))}let Se=ye[XA];Se===void 0&&(Se=new Zi,Se.layers.enable(XA),Se.viewport=new zt,ye[XA]=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),XA===0&&(ge.matrix.copy(Se.matrix),ge.matrix.decompose(ge.position,ge.quaternion,ge.scale)),gA===!0&&ge.cameras.push(Se)}}for(let bA=0;bA<L.length;bA++){const gA=G[bA],XA=L[bA];gA!==null&&XA!==void 0&&XA.update(gA,dA,c||g)}if(RA&&RA(Ye,dA),dA.detectedPlanes){t.dispatchEvent({type:"planesdetected",data:dA.detectedPlanes});let bA=null;for(const gA of le)dA.detectedPlanes.has(gA)||(bA===null&&(bA=[]),bA.push(gA));if(bA!==null)for(const gA of bA)le.delete(gA),ne.delete(gA),t.dispatchEvent({type:"planeremoved",data:gA});for(const gA of dA.detectedPlanes)if(le.has(gA)){const XA=ne.get(gA);gA.lastChangedTime>XA&&(ne.set(gA,gA.lastChangedTime),t.dispatchEvent({type:"planechanged",data:gA}))}else le.add(gA),ne.set(gA,dA.lastChangedTime),t.dispatchEvent({type:"planeadded",data:gA})}k=null})),this.setAnimationLoop=function(Ye){RA=Ye},this.dispose=function(){}}}function GS(o,e){function A(n,r){n.matrixAutoUpdate===!0&&n.updateMatrix(),r.value.copy(n.matrix)}function t(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,A(r.map,n.mapTransform)),r.alphaMap&&(n.alphaMap.value=r.alphaMap,A(r.alphaMap,n.alphaMapTransform)),r.bumpMap&&(n.bumpMap.value=r.bumpMap,A(r.bumpMap,n.bumpMapTransform),n.bumpScale.value=r.bumpScale,r.side===v&&(n.bumpScale.value*=-1)),r.normalMap&&(n.normalMap.value=r.normalMap,A(r.normalMap,n.normalMapTransform),n.normalScale.value.copy(r.normalScale),r.side===v&&n.normalScale.value.negate()),r.displacementMap&&(n.displacementMap.value=r.displacementMap,A(r.displacementMap,n.displacementMapTransform),n.displacementScale.value=r.displacementScale,n.displacementBias.value=r.displacementBias),r.emissiveMap&&(n.emissiveMap.value=r.emissiveMap,A(r.emissiveMap,n.emissiveMapTransform)),r.specularMap&&(n.specularMap.value=r.specularMap,A(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,A(r.lightMap,n.lightMapTransform)}r.aoMap&&(n.aoMap.value=r.aoMap,n.aoMapIntensity.value=r.aoMapIntensity,A(r.aoMap,n.aoMapTransform))}return{refreshFogUniforms:function(n,r){r.color.getRGB(n.fogColor.value,yB(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?t(n,r):r.isMeshToonMaterial?(t(n,r),(function(c,C){C.gradientMap&&(c.gradientMap.value=C.gradientMap)})(n,r)):r.isMeshPhongMaterial?(t(n,r),(function(c,C){c.specular.value.copy(C.specular),c.shininess.value=Math.max(C.shininess,1e-4)})(n,r)):r.isMeshStandardMaterial?(t(n,r),(function(c,C){c.metalness.value=C.metalness,C.metalnessMap&&(c.metalnessMap.value=C.metalnessMap,A(C.metalnessMap,c.metalnessMapTransform)),c.roughness.value=C.roughness,C.roughnessMap&&(c.roughnessMap.value=C.roughnessMap,A(C.roughnessMap,c.roughnessMapTransform)),e.get(C).envMap&&(c.envMapIntensity.value=C.envMapIntensity)})(n,r),r.isMeshPhysicalMaterial&&(function(c,C,E){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,A(C.sheenColorMap,c.sheenColorMapTransform)),C.sheenRoughnessMap&&(c.sheenRoughnessMap.value=C.sheenRoughnessMap,A(C.sheenRoughnessMap,c.sheenRoughnessMapTransform))),C.clearcoat>0&&(c.clearcoat.value=C.clearcoat,c.clearcoatRoughness.value=C.clearcoatRoughness,C.clearcoatMap&&(c.clearcoatMap.value=C.clearcoatMap,A(C.clearcoatMap,c.clearcoatMapTransform)),C.clearcoatRoughnessMap&&(c.clearcoatRoughnessMap.value=C.clearcoatRoughnessMap,A(C.clearcoatRoughnessMap,c.clearcoatRoughnessMapTransform)),C.clearcoatNormalMap&&(c.clearcoatNormalMap.value=C.clearcoatNormalMap,A(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,A(C.iridescenceMap,c.iridescenceMapTransform)),C.iridescenceThicknessMap&&(c.iridescenceThicknessMap.value=C.iridescenceThicknessMap,A(C.iridescenceThicknessMap,c.iridescenceThicknessMapTransform))),C.transmission>0&&(c.transmission.value=C.transmission,c.transmissionSamplerMap.value=E.texture,c.transmissionSamplerSize.value.set(E.width,E.height),C.transmissionMap&&(c.transmissionMap.value=C.transmissionMap,A(C.transmissionMap,c.transmissionMapTransform)),c.thickness.value=C.thickness,C.thicknessMap&&(c.thicknessMap.value=C.thicknessMap,A(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,A(C.specularColorMap,c.specularColorMapTransform)),C.specularIntensityMap&&(c.specularIntensityMap.value=C.specularIntensityMap,A(C.specularIntensityMap,c.specularIntensityMapTransform))})(n,r,u)):r.isMeshMatcapMaterial?(t(n,r),(function(c,C){C.matcap&&(c.matcap.value=C.matcap)})(n,r)):r.isMeshDepthMaterial?t(n,r):r.isMeshDistanceMaterial?(t(n,r),(function(c,C){const E=e.get(C).light;c.referencePosition.value.setFromMatrixPosition(E.matrixWorld),c.nearDistance.value=E.shadow.camera.near,c.farDistance.value=E.shadow.camera.far})(n,r)):r.isMeshNormalMaterial?t(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,A(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,E,p){c.diffuse.value.copy(C.color),c.opacity.value=C.opacity,c.size.value=C.size*E,c.scale.value=.5*p,C.map&&(c.map.value=C.map,A(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,A(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 US(o,e,A,t){let n={},r={},g=[];const h=A.isWebGL2?o.getParameter(o.MAX_UNIFORM_BUFFER_BINDINGS):0;function u(E,p,w){const k=E.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(E){const p={boundary:0,storage:0};return typeof E=="number"?(p.boundary=4,p.storage=4):E.isVector2?(p.boundary=8,p.storage=8):E.isVector3||E.isColor?(p.boundary=16,p.storage=12):E.isVector4?(p.boundary=16,p.storage=16):E.isMatrix3?(p.boundary=48,p.storage=48):E.isMatrix4?(p.boundary=64,p.storage=64):E.isTexture,p}function C(E){const p=E.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(E,p){const w=p.program;t.uniformBlockBinding(E,w)},update:function(E,p){let w=n[E.id];w===void 0&&((function(_){const N=_.uniforms;let L=0;const G=16;let le=0;for(let ne=0,te=N.length;ne<te;ne++){const Ae=N[ne],ye={boundary:0,storage:0},ge=Array.isArray(Ae.value)?Ae.value:[Ae.value];for(let Me=0,pe=ge.length;Me<pe;Me++){const Ze=c(ge[Me]);ye.boundary+=Ze.boundary,ye.storage+=Ze.storage}Ae.__data=new Float32Array(ye.storage/Float32Array.BYTES_PER_ELEMENT),Ae.__offset=L,ne>0&&(le=L%G,le!==0&&G-le-ye.boundary<0&&(L+=G-le,Ae.__offset=L)),L+=ye.storage}le=L%G,le>0&&(L+=G-le),_.__size=L,_.__cache={}})(E),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})(E),n[E.id]=w,E.addEventListener("dispose",C));const k=p.program;t.updateUBOMapping(E,k);const R=e.render.frame;r[E.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 te=L[le];if(u(te,le,G)===!0){const Ae=te.__offset,ye=Array.isArray(te.value)?te.value:[te.value];let ge=0;for(let Me=0;Me<ye.length;Me++){const pe=ye[Me],Ze=c(pe);typeof pe=="number"?(te.__data[0]=pe,o.bufferSubData(o.UNIFORM_BUFFER,Ae+ge,te.__data)):pe.isMatrix3?(te.__data[0]=pe.elements[0],te.__data[1]=pe.elements[1],te.__data[2]=pe.elements[2],te.__data[3]=pe.elements[0],te.__data[4]=pe.elements[3],te.__data[5]=pe.elements[4],te.__data[6]=pe.elements[5],te.__data[7]=pe.elements[0],te.__data[8]=pe.elements[6],te.__data[9]=pe.elements[7],te.__data[10]=pe.elements[8],te.__data[11]=pe.elements[0]):(pe.toArray(te.__data,ge),ge+=Ze.storage/Float32Array.BYTES_PER_ELEMENT)}o.bufferSubData(o.UNIFORM_BUFFER,Ae,te.__data)}}o.bindBuffer(o.UNIFORM_BUFFER,null)})(E),r[E.id]=R)},dispose:function(){for(const E in n)o.deleteBuffer(n[E]);g=[],n={},r={}}}}function TS(){const o=wn("canvas");return o.style.display="block",o}class eE{constructor(e={}){const{canvas:A=TS(),context:t=null,depth:n=!0,stencil:r=!0,alpha:g=!1,antialias:h=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:c=!1,powerPreference:C="default",failIfMajorPerformanceCaveat:E=!1}=e;let p;this.isWebGLRenderer=!0,p=t!==null?t.getContextAttributes().alpha:g;let w=null,k=null;const R=[],_=[];this.domElement=A,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,te=-1,Ae=null;const ye=new zt,ge=new zt;let Me=null,pe=A.width,Ze=A.height,CA=1,QA=null,VA=null;const fA=new zt(0,0,pe,Ze),MA=new zt(0,0,pe,Ze);let RA=!1;const FA=new Th;let Ye=!1,dA=!1,bA=null;const gA=new xt,XA=new re,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ie(){return ne===null?CA:1}let Se,je,_e,BA,ke,oe,Te,cA,SA,hA,KA,HA,_A,Ct,ht,J,$,xe,rA,$e,Re,Pe,YA,WA,ve=t;function zA(he,eA){for(let EA=0;EA<he.length;EA++){const lA=he[EA],pA=A.getContext(lA,eA);if(pA!==null)return pA}return null}try{const he={alpha:!0,depth:n,stencil:r,antialias:h,premultipliedAlpha:u,preserveDrawingBuffer:c,powerPreference:C,failIfMajorPerformanceCaveat:E};if("setAttribute"in A&&A.setAttribute("data-engine",`three.js r${B}`),A.addEventListener("webglcontextlost",At,!1),A.addEventListener("webglcontextrestored",dt,!1),A.addEventListener("webglcontextcreationerror",PA,!1),ve===null){const eA=["webgl2","webgl","experimental-webgl"];if(N.isWebGL1Renderer===!0&&eA.shift(),ve=zA(eA,he),ve===null)throw zA(eA)?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 qA(){Se=new cM(ve),je=new aM(ve,Se,e),Se.init(je),Pe=new RS(ve,Se,je),_e=new bS(ve,Se,je),BA=new uM(ve),ke=new QS,oe=new _S(ve,Se,_e,ke,je,Pe,BA),Te=new gM(N),cA=new lM(N),SA=new iM(ve,je),YA=new rM(ve,Se,SA,je),hA=new hM(ve,SA,BA,YA),KA=new EM(ve,hA,SA,BA),rA=new BM(ve,je,oe),J=new oM(ke),HA=new ES(N,Te,cA,Se,je,YA,J),_A=new GS(N,ke),Ct=new pS,ht=new DS(Se,je),xe=new nM(N,Te,cA,_e,KA,p,u),$=new xS(N,KA,je),WA=new US(ve,BA,je,_e),$e=new sM(ve,Se,BA,je),Re=new IM(ve,Se,BA,je),BA.programs=HA.programs,N.capabilities=je,N.extensions=Se,N.properties=ke,N.renderLists=Ct,N.shadowMap=$,N.state=_e,N.info=BA}qA();const LA=new LS(N,ve);function At(he){he.preventDefault(),L=!0}function dt(){L=!1;const he=BA.autoReset,eA=$.enabled,EA=$.autoUpdate,lA=$.needsUpdate,pA=$.type;qA(),BA.autoReset=he,$.enabled=eA,$.autoUpdate=EA,$.needsUpdate=lA,$.type=pA}function PA(he){he.statusMessage}function st(he){const eA=he.target;eA.removeEventListener("dispose",st),(function(EA){(function(lA){const pA=ke.get(lA).programs;pA!==void 0&&(pA.forEach((function(et){HA.releaseProgram(et)})),lA.isShaderMaterial&&HA.releaseShaderCache(lA))})(EA),ke.remove(EA)})(eA)}this.xr=LA,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 CA},this.setPixelRatio=function(he){he!==void 0&&(CA=he,this.setSize(pe,Ze,!1))},this.getSize=function(he){return he.set(pe,Ze)},this.setSize=function(he,eA,EA=!0){LA.isPresenting||(pe=he,Ze=eA,A.width=Math.floor(he*CA),A.height=Math.floor(eA*CA),EA===!0&&(A.style.width=he+"px",A.style.height=eA+"px"),this.setViewport(0,0,he,eA))},this.getDrawingBufferSize=function(he){return he.set(pe*CA,Ze*CA).floor()},this.setDrawingBufferSize=function(he,eA,EA){pe=he,Ze=eA,CA=EA,A.width=Math.floor(he*EA),A.height=Math.floor(eA*EA),this.setViewport(0,0,he,eA)},this.getCurrentViewport=function(he){return he.copy(ye)},this.getViewport=function(he){return he.copy(fA)},this.setViewport=function(he,eA,EA,lA){he.isVector4?fA.set(he.x,he.y,he.z,he.w):fA.set(he,eA,EA,lA),_e.viewport(ye.copy(fA).multiplyScalar(CA).floor())},this.getScissor=function(he){return he.copy(MA)},this.setScissor=function(he,eA,EA,lA){he.isVector4?MA.set(he.x,he.y,he.z,he.w):MA.set(he,eA,EA,lA),_e.scissor(ge.copy(MA).multiplyScalar(CA).floor())},this.getScissorTest=function(){return RA},this.setScissorTest=function(he){_e.setScissorTest(RA=he)},this.setOpaqueSort=function(he){QA=he},this.setTransparentSort=function(he){VA=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,eA=!0,EA=!0){let lA=0;he&&(lA|=ve.COLOR_BUFFER_BIT),eA&&(lA|=ve.DEPTH_BUFFER_BIT),EA&&(lA|=ve.STENCIL_BUFFER_BIT),ve.clear(lA)},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(){A.removeEventListener("webglcontextlost",At,!1),A.removeEventListener("webglcontextrestored",dt,!1),A.removeEventListener("webglcontextcreationerror",PA,!1),Ct.dispose(),ht.dispose(),ke.dispose(),Te.dispose(),cA.dispose(),KA.dispose(),YA.dispose(),WA.dispose(),HA.dispose(),LA.dispose(),LA.removeEventListener("sessionstart",wt),LA.removeEventListener("sessionend",mi),bA&&(bA.dispose(),bA=null),qt.stop()},this.renderBufferDirect=function(he,eA,EA,lA,pA,et){eA===null&&(eA=ce);const It=pA.isMesh&&pA.matrixWorld.determinant()<0,Mt=(function(Vt,En,Li,pt,bi){En.isScene!==!0&&(En=ce),oe.resetTextureUnits();const NI=En.fog,Z_=pt.isMeshStandardMaterial?En.environment:null,j_=ne===null?N.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:V,Cc=(pt.isMeshStandardMaterial?cA:Te).get(pt.envMap||Z_),X_=pt.vertexColors===!0&&!!Li.attributes.color&&Li.attributes.color.itemSize===4,$_=!!pt.normalMap&&!!Li.attributes.tangent,eR=!!Li.morphAttributes.position,AR=!!Li.morphAttributes.normal,tR=!!Li.morphAttributes.color,iR=pt.toneMapped?N.toneMapping:F,UQ=Li.morphAttributes.position||Li.morphAttributes.normal||Li.morphAttributes.color,nR=UQ!==void 0?UQ.length:0,ii=ke.get(pt),rR=k.state.lights;if(Ye===!0&&(dA===!0||Vt!==Ae)){const Nn=Vt===Ae&&pt.id===te;J.setState(pt,Vt,Nn)}let jr=!1;pt.version===ii.__version?ii.needsLights&&ii.lightsStateVersion!==rR.state.version||ii.outputColorSpace!==j_||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||pt.fog===!0&&ii.fog!==NI?jr=!0:ii.numClippingPlanes===void 0||ii.numClippingPlanes===J.numPlanes&&ii.numIntersection===J.numIntersection?(ii.vertexAlphas!==X_||ii.vertexTangents!==$_||ii.morphTargets!==eR||ii.morphNormals!==AR||ii.morphColors!==tR||ii.toneMapping!==iR||je.isWebGL2===!0&&ii.morphTargetsCount!==nR)&&(jr=!0):jr=!0:jr=!0:jr=!0:(jr=!0,ii.__version=pt.version);let js=ii.currentProgram;jr===!0&&(js=Fi(pt,En,bi));let TQ=!1,ug=!1,kI=!1;const ln=js.getUniforms(),Xs=ii.uniforms;if(_e.useProgram(js.program)&&(TQ=!0,ug=!0,kI=!0),pt.id!==te&&(te=pt.id,ug=!0),TQ||Ae!==Vt){if(ln.setValue(ve,"projectionMatrix",Vt.projectionMatrix),je.logarithmicDepthBuffer&&ln.setValue(ve,"logDepthBufFC",2/(Math.log(Vt.far+1)/Math.LN2)),Ae!==Vt&&(Ae=Vt,ug=!0,kI=!0),pt.isShaderMaterial||pt.isMeshPhongMaterial||pt.isMeshToonMaterial||pt.isMeshStandardMaterial||pt.envMap){const Nn=ln.map.cameraPosition;Nn!==void 0&&Nn.setValue(ve,XA.setFromMatrixPosition(Vt.matrixWorld))}(pt.isMeshPhongMaterial||pt.isMeshToonMaterial||pt.isMeshLambertMaterial||pt.isMeshBasicMaterial||pt.isMeshStandardMaterial||pt.isShaderMaterial)&&ln.setValue(ve,"isOrthographic",Vt.isOrthographicCamera===!0),(pt.isMeshPhongMaterial||pt.isMeshToonMaterial||pt.isMeshLambertMaterial||pt.isMeshBasicMaterial||pt.isMeshStandardMaterial||pt.isShaderMaterial||pt.isShadowMaterial||bi.isSkinnedMesh)&&ln.setValue(ve,"viewMatrix",Vt.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 FI=Li.morphAttributes;(FI.position!==void 0||FI.normal!==void 0||FI.color!==void 0&&je.isWebGL2===!0)&&rA.update(bi,Li,js),(ug||ii.receiveShadow!==bi.receiveShadow)&&(ii.receiveShadow=bi.receiveShadow,ln.setValue(ve,"receiveShadow",bi.receiveShadow)),pt.isMeshGouraudMaterial&&pt.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=kI,(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),NI&&pt.fog===!0&&_A.refreshFogUniforms(Xs,NI),_A.refreshMaterialUniforms(Xs,pt,CA,Ze,bA),Hl.upload(ve,ii.uniformsList,Xs,oe));var mr,sr;if(pt.isShaderMaterial&&pt.uniformsNeedUpdate===!0&&(Hl.upload(ve,ii.uniformsList,Xs,oe),pt.uniformsNeedUpdate=!1),pt.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),pt.isShaderMaterial||pt.isRawShaderMaterial){const Nn=pt.uniformsGroups;for(let LI=0,sR=Nn.length;LI<sR;LI++)if(je.isWebGL2){const HQ=Nn[LI];WA.update(HQ,js),WA.bind(HQ,js)}}return js})(he,eA,EA,lA,pA);_e.setMaterial(lA,It);let Gt=EA.index,gt=1;lA.wireframe===!0&&(Gt=hA.getWireframeAttribute(EA),gt=2);const bt=EA.drawRange,_t=EA.attributes.position;let jt=bt.start*gt,Dt=(bt.start+bt.count)*gt;et!==null&&(jt=Math.max(jt,et.start*gt),Dt=Math.min(Dt,(et.start+et.count)*gt)),Gt!==null?(jt=Math.max(jt,0),Dt=Math.min(Dt,Gt.count)):_t!=null&&(jt=Math.max(jt,0),Dt=Math.min(Dt,_t.count));const Et=Dt-jt;if(Et<0||Et===1/0)return;let Xi;YA.setup(pA,lA,Mt,EA,Gt);let $t=$e;if(Gt!==null&&(Xi=SA.get(Gt),$t=Re,$t.setIndex(Xi)),pA.isMesh)lA.wireframe===!0?(_e.setLineWidth(lA.wireframeLinewidth*Ie()),$t.setMode(ve.LINES)):$t.setMode(ve.TRIANGLES);else if(pA.isLine){let Vt=lA.linewidth;Vt===void 0&&(Vt=1),_e.setLineWidth(Vt*Ie()),pA.isLineSegments?$t.setMode(ve.LINES):pA.isLineLoop?$t.setMode(ve.LINE_LOOP):$t.setMode(ve.LINE_STRIP)}else pA.isPoints?$t.setMode(ve.POINTS):pA.isSprite&&$t.setMode(ve.TRIANGLES);if(pA.isInstancedMesh)$t.renderInstances(jt,Et,pA.count);else if(EA.isInstancedBufferGeometry){const Vt=EA._maxInstanceCount!==void 0?EA._maxInstanceCount:1/0,En=Math.min(EA.instanceCount,Vt);$t.renderInstances(jt,Et,En)}else $t.render(jt,Et)},this.compile=function(he,eA){function EA(lA,pA,et){lA.transparent===!0&&lA.side===2&&lA.forceSinglePass===!1?(lA.side=v,lA.needsUpdate=!0,Fi(lA,pA,et),lA.side=m,lA.needsUpdate=!0,Fi(lA,pA,et),lA.side=2):Fi(lA,pA,et)}k=ht.get(he),k.init(),_.push(k),he.traverseVisible((function(lA){lA.isLight&&lA.layers.test(eA.layers)&&(k.pushLight(lA),lA.castShadow&&k.pushShadow(lA))})),k.setupLights(N.useLegacyLights),he.traverse((function(lA){const pA=lA.material;if(pA)if(Array.isArray(pA))for(let et=0;et<pA.length;et++)EA(pA[et],he,lA);else EA(pA,he,lA)})),_.pop(),k=null};let ot=null;function wt(){qt.stop()}function mi(){qt.start()}const qt=new MB;function ct(he,eA,EA,lA){if(he.visible===!1)return;if(he.layers.test(eA.layers)){if(he.isGroup)EA=he.renderOrder;else if(he.isLOD)he.autoUpdate===!0&&he.update(eA);else if(he.isLight)k.pushLight(he),he.castShadow&&k.pushShadow(he);else if(he.isSprite){if(!he.frustumCulled||FA.intersectsSprite(he)){lA&&XA.setFromMatrixPosition(he.matrixWorld).applyMatrix4(gA);const et=KA.update(he),It=he.material;It.visible&&w.push(he,et,It,EA,XA.z,null)}}else if((he.isMesh||he.isLine||he.isPoints)&&(!he.frustumCulled||FA.intersectsObject(he))){he.isSkinnedMesh&&he.skeleton.frame!==BA.render.frame&&(he.skeleton.update(),he.skeleton.frame=BA.render.frame);const et=KA.update(he),It=he.material;if(lA&&(et.boundingSphere===null&&et.computeBoundingSphere(),XA.copy(et.boundingSphere.center).applyMatrix4(he.matrixWorld).applyMatrix4(gA)),Array.isArray(It)){const Mt=et.groups;for(let Gt=0,gt=Mt.length;Gt<gt;Gt++){const bt=Mt[Gt],_t=It[bt.materialIndex];_t&&_t.visible&&w.push(he,et,_t,EA,XA.z,bt)}}else It.visible&&w.push(he,et,It,EA,XA.z,null)}}const pA=he.children;for(let et=0,It=pA.length;et<It;et++)ct(pA[et],eA,EA,lA)}function Ft(he,eA,EA,lA){const pA=he.opaque,et=he.transmissive,It=he.transparent;k.setupLightsView(EA),Ye===!0&&J.setGlobalState(N.clippingPlanes,EA),et.length>0&&(function(Mt,Gt,gt,bt){if(bA===null){const Et=je.isWebGL2;bA=new ei(1024,1024,{generateMipmaps:!0,type:Se.has("EXT_color_buffer_half_float")?mA:be,minFilter:se,samples:Et&&h===!0?4:0})}const _t=N.getRenderTarget();N.setRenderTarget(bA),N.clear();const jt=N.toneMapping;N.toneMapping=F,hi(Mt,gt,bt),oe.updateMultisampleRenderTarget(bA),oe.updateRenderTargetMipmap(bA);let Dt=!1;for(let Et=0,Xi=Gt.length;Et<Xi;Et++){const $t=Gt[Et],Vt=$t.object,En=$t.geometry,Li=$t.material,pt=$t.group;if(Li.side===2&&Vt.layers.test(bt.layers)){const bi=Li.side;Li.side=v,Li.needsUpdate=!0,ji(Vt,gt,bt,En,Li,pt),Li.side=bi,Li.needsUpdate=!0,Dt=!0}}Dt===!0&&(oe.updateMultisampleRenderTarget(bA),oe.updateRenderTargetMipmap(bA)),N.setRenderTarget(_t),N.toneMapping=jt})(pA,et,eA,EA),lA&&_e.viewport(ye.copy(lA)),pA.length>0&&hi(pA,eA,EA),et.length>0&&hi(et,eA,EA),It.length>0&&hi(It,eA,EA),_e.buffers.depth.setTest(!0),_e.buffers.depth.setMask(!0),_e.buffers.color.setMask(!0),_e.setPolygonOffset(!1)}function hi(he,eA,EA){const lA=eA.isScene===!0?eA.overrideMaterial:null;for(let pA=0,et=he.length;pA<et;pA++){const It=he[pA],Mt=It.object,Gt=It.geometry,gt=lA===null?It.material:lA,bt=It.group;Mt.layers.test(EA.layers)&&ji(Mt,eA,EA,Gt,gt,bt)}}function ji(he,eA,EA,lA,pA,et){he.onBeforeRender(N,eA,EA,lA,pA,et),he.modelViewMatrix.multiplyMatrices(EA.matrixWorldInverse,he.matrixWorld),he.normalMatrix.getNormalMatrix(he.modelViewMatrix),pA.onBeforeRender(N,eA,EA,lA,he,et),pA.transparent===!0&&pA.side===2&&pA.forceSinglePass===!1?(pA.side=v,pA.needsUpdate=!0,N.renderBufferDirect(EA,eA,lA,pA,he,et),pA.side=m,pA.needsUpdate=!0,N.renderBufferDirect(EA,eA,lA,pA,he,et),pA.side=2):N.renderBufferDirect(EA,eA,lA,pA,he,et),he.onAfterRender(N,eA,EA,lA,pA,et)}function Fi(he,eA,EA){eA.isScene!==!0&&(eA=ce);const lA=ke.get(he),pA=k.state.lights,et=k.state.shadowsArray,It=pA.state.version,Mt=HA.getParameters(he,pA.state,et,eA,EA),Gt=HA.getProgramCacheKey(Mt);let gt=lA.programs;lA.environment=he.isMeshStandardMaterial?eA.environment:null,lA.fog=eA.fog,lA.envMap=(he.isMeshStandardMaterial?cA:Te).get(he.envMap||lA.environment),gt===void 0&&(he.addEventListener("dispose",st),gt=new Map,lA.programs=gt);let bt=gt.get(Gt);if(bt!==void 0){if(lA.currentProgram===bt&&lA.lightsStateVersion===It)return vi(he,Mt),bt}else Mt.uniforms=HA.getUniforms(he),he.onBuild(EA,Mt,N),he.onBeforeCompile(Mt,N),bt=HA.acquireProgram(Mt,Gt),gt.set(Gt,bt),lA.uniforms=Mt.uniforms;const _t=lA.uniforms;(he.isShaderMaterial||he.isRawShaderMaterial)&&he.clipping!==!0||(_t.clippingPlanes=J.uniform),vi(he,Mt),lA.needsLights=(function(Et){return Et.isMeshLambertMaterial||Et.isMeshToonMaterial||Et.isMeshPhongMaterial||Et.isMeshStandardMaterial||Et.isShadowMaterial||Et.isShaderMaterial&&Et.lights===!0})(he),lA.lightsStateVersion=It,lA.needsLights&&(_t.ambientLightColor.value=pA.state.ambient,_t.lightProbe.value=pA.state.probe,_t.directionalLights.value=pA.state.directional,_t.directionalLightShadows.value=pA.state.directionalShadow,_t.spotLights.value=pA.state.spot,_t.spotLightShadows.value=pA.state.spotShadow,_t.rectAreaLights.value=pA.state.rectArea,_t.ltc_1.value=pA.state.rectAreaLTC1,_t.ltc_2.value=pA.state.rectAreaLTC2,_t.pointLights.value=pA.state.point,_t.pointLightShadows.value=pA.state.pointShadow,_t.hemisphereLights.value=pA.state.hemi,_t.directionalShadowMap.value=pA.state.directionalShadowMap,_t.directionalShadowMatrix.value=pA.state.directionalShadowMatrix,_t.spotShadowMap.value=pA.state.spotShadowMap,_t.spotLightMatrix.value=pA.state.spotLightMatrix,_t.spotLightMap.value=pA.state.spotLightMap,_t.pointShadowMap.value=pA.state.pointShadowMap,_t.pointShadowMatrix.value=pA.state.pointShadowMatrix);const jt=bt.getUniforms(),Dt=Hl.seqWithValue(jt.seq,_t);return lA.currentProgram=bt,lA.uniformsList=Dt,bt}function vi(he,eA){const EA=ke.get(he);EA.outputColorSpace=eA.outputColorSpace,EA.instancing=eA.instancing,EA.skinning=eA.skinning,EA.morphTargets=eA.morphTargets,EA.morphNormals=eA.morphNormals,EA.morphColors=eA.morphColors,EA.morphTargetsCount=eA.morphTargetsCount,EA.numClippingPlanes=eA.numClippingPlanes,EA.numIntersection=eA.numClipIntersection,EA.vertexAlphas=eA.vertexAlphas,EA.vertexTangents=eA.vertexTangents,EA.toneMapping=eA.toneMapping}qt.setAnimationLoop((function(he){ot&&ot(he)})),typeof self<"u"&&qt.setContext(self),this.setAnimationLoop=function(he){ot=he,LA.setAnimationLoop(he),he===null?qt.stop():qt.start()},LA.addEventListener("sessionstart",wt),LA.addEventListener("sessionend",mi),this.render=function(he,eA){if(eA!==void 0&&eA.isCamera!==!0||L===!0)return;he.matrixWorldAutoUpdate===!0&&he.updateMatrixWorld(),eA.parent===null&&eA.matrixWorldAutoUpdate===!0&&eA.updateMatrixWorld(),LA.enabled===!0&&LA.isPresenting===!0&&(LA.cameraAutoUpdate===!0&&LA.updateCamera(eA),eA=LA.getCamera()),he.isScene===!0&&he.onBeforeRender(N,he,eA,ne),k=ht.get(he,_.length),k.init(),_.push(k),gA.multiplyMatrices(eA.projectionMatrix,eA.matrixWorldInverse),FA.setFromProjectionMatrix(gA),dA=this.localClippingEnabled,Ye=J.init(this.clippingPlanes,dA),w=Ct.get(he,R.length),w.init(),R.push(w),ct(he,eA,0,N.sortObjects),w.finish(),N.sortObjects===!0&&w.sort(QA,VA),Ye===!0&&J.beginShadows();const EA=k.state.shadowsArray;if($.render(EA,he,eA),Ye===!0&&J.endShadows(),this.info.autoReset===!0&&this.info.reset(),xe.render(w,he),k.setupLights(N.useLegacyLights),eA.isArrayCamera){const lA=eA.cameras;for(let pA=0,et=lA.length;pA<et;pA++){const It=lA[pA];Ft(w,he,It,It.viewport)}}else Ft(w,he,eA);ne!==null&&(oe.updateMultisampleRenderTarget(ne),oe.updateRenderTargetMipmap(ne)),he.isScene===!0&&he.onAfterRender(N,he,eA),YA.resetDefaultState(),te=-1,Ae=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,eA,EA){ke.get(he.texture).__webglTexture=eA,ke.get(he.depthTexture).__webglTexture=EA;const lA=ke.get(he);lA.__hasExternalTextures=!0,lA.__hasExternalTextures&&(lA.__autoAllocateDepthBuffer=EA===void 0,lA.__autoAllocateDepthBuffer||Se.has("WEBGL_multisampled_render_to_texture")===!0&&(lA.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(he,eA){const EA=ke.get(he);EA.__webglFramebuffer=eA,EA.__useDefaultFramebuffer=eA===void 0},this.setRenderTarget=function(he,eA=0,EA=0){ne=he,G=eA,le=EA;let lA=!0,pA=null,et=!1,It=!1;if(he){const Mt=ke.get(he);Mt.__useDefaultFramebuffer!==void 0?(_e.bindFramebuffer(ve.FRAMEBUFFER,null),lA=!1):Mt.__webglFramebuffer===void 0?oe.setupRenderTarget(he):Mt.__hasExternalTextures&&oe.rebindTextures(he,ke.get(he.texture).__webglTexture,ke.get(he.depthTexture).__webglTexture);const Gt=he.texture;(Gt.isData3DTexture||Gt.isDataArrayTexture||Gt.isCompressedArrayTexture)&&(It=!0);const gt=ke.get(he).__webglFramebuffer;he.isWebGLCubeRenderTarget?(pA=gt[eA],et=!0):pA=je.isWebGL2&&he.samples>0&&oe.useMultisampledRTT(he)===!1?ke.get(he).__webglMultisampledFramebuffer:gt,ye.copy(he.viewport),ge.copy(he.scissor),Me=he.scissorTest}else ye.copy(fA).multiplyScalar(CA).floor(),ge.copy(MA).multiplyScalar(CA).floor(),Me=RA;if(_e.bindFramebuffer(ve.FRAMEBUFFER,pA)&&je.drawBuffers&&lA&&_e.drawBuffers(he,pA),_e.viewport(ye),_e.scissor(ge),_e.setScissorTest(Me),et){const Mt=ke.get(he.texture);ve.framebufferTexture2D(ve.FRAMEBUFFER,ve.COLOR_ATTACHMENT0,ve.TEXTURE_CUBE_MAP_POSITIVE_X+eA,Mt.__webglTexture,EA)}else if(It){const Mt=ke.get(he.texture),Gt=eA||0;ve.framebufferTextureLayer(ve.FRAMEBUFFER,ve.COLOR_ATTACHMENT0,Mt.__webglTexture,EA||0,Gt)}te=-1},this.readRenderTargetPixels=function(he,eA,EA,lA,pA,et,It){if(!he||!he.isWebGLRenderTarget)return;let Mt=ke.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&It!==void 0&&(Mt=Mt[It]),Mt){_e.bindFramebuffer(ve.FRAMEBUFFER,Mt);try{const Gt=he.texture,gt=Gt.format,bt=Gt.type;if(gt!==kA&&Pe.convert(gt)!==ve.getParameter(ve.IMPLEMENTATION_COLOR_READ_FORMAT))return;const _t=bt===mA&&(Se.has("EXT_color_buffer_half_float")||je.isWebGL2&&Se.has("EXT_color_buffer_float"));if(!(bt===be||Pe.convert(bt)===ve.getParameter(ve.IMPLEMENTATION_COLOR_READ_TYPE)||bt===De&&(je.isWebGL2||Se.has("OES_texture_float")||Se.has("WEBGL_color_buffer_float"))||_t))return;eA>=0&&eA<=he.width-lA&&EA>=0&&EA<=he.height-pA&&ve.readPixels(eA,EA,lA,pA,Pe.convert(gt),Pe.convert(bt),et)}finally{const Gt=ne!==null?ke.get(ne).__webglFramebuffer:null;_e.bindFramebuffer(ve.FRAMEBUFFER,Gt)}}},this.copyFramebufferToTexture=function(he,eA,EA=0){const lA=Math.pow(2,-EA),pA=Math.floor(eA.image.width*lA),et=Math.floor(eA.image.height*lA);oe.setTexture2D(eA,0),ve.copyTexSubImage2D(ve.TEXTURE_2D,EA,0,0,he.x,he.y,pA,et),_e.unbindTexture()},this.copyTextureToTexture=function(he,eA,EA,lA=0){const pA=eA.image.width,et=eA.image.height,It=Pe.convert(EA.format),Mt=Pe.convert(EA.type);oe.setTexture2D(EA,0),ve.pixelStorei(ve.UNPACK_FLIP_Y_WEBGL,EA.flipY),ve.pixelStorei(ve.UNPACK_PREMULTIPLY_ALPHA_WEBGL,EA.premultiplyAlpha),ve.pixelStorei(ve.UNPACK_ALIGNMENT,EA.unpackAlignment),eA.isDataTexture?ve.texSubImage2D(ve.TEXTURE_2D,lA,he.x,he.y,pA,et,It,Mt,eA.image.data):eA.isCompressedTexture?ve.compressedTexSubImage2D(ve.TEXTURE_2D,lA,he.x,he.y,eA.mipmaps[0].width,eA.mipmaps[0].height,It,eA.mipmaps[0].data):ve.texSubImage2D(ve.TEXTURE_2D,lA,he.x,he.y,It,Mt,eA.image),lA===0&&EA.generateMipmaps&&ve.generateMipmap(ve.TEXTURE_2D),_e.unbindTexture()},this.copyTextureToTexture3D=function(he,eA,EA,lA,pA=0){if(N.isWebGL1Renderer)return;const et=he.max.x-he.min.x+1,It=he.max.y-he.min.y+1,Mt=he.max.z-he.min.z+1,Gt=Pe.convert(lA.format),gt=Pe.convert(lA.type);let bt;if(lA.isData3DTexture)oe.setTexture3D(lA,0),bt=ve.TEXTURE_3D;else{if(!lA.isDataArrayTexture)return;oe.setTexture2DArray(lA,0),bt=ve.TEXTURE_2D_ARRAY}ve.pixelStorei(ve.UNPACK_FLIP_Y_WEBGL,lA.flipY),ve.pixelStorei(ve.UNPACK_PREMULTIPLY_ALPHA_WEBGL,lA.premultiplyAlpha),ve.pixelStorei(ve.UNPACK_ALIGNMENT,lA.unpackAlignment);const _t=ve.getParameter(ve.UNPACK_ROW_LENGTH),jt=ve.getParameter(ve.UNPACK_IMAGE_HEIGHT),Dt=ve.getParameter(ve.UNPACK_SKIP_PIXELS),Et=ve.getParameter(ve.UNPACK_SKIP_ROWS),Xi=ve.getParameter(ve.UNPACK_SKIP_IMAGES),$t=EA.isCompressedTexture?EA.mipmaps[0]:EA.image;ve.pixelStorei(ve.UNPACK_ROW_LENGTH,$t.width),ve.pixelStorei(ve.UNPACK_IMAGE_HEIGHT,$t.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),EA.isDataTexture||EA.isData3DTexture?ve.texSubImage3D(bt,pA,eA.x,eA.y,eA.z,et,It,Mt,Gt,gt,$t.data):EA.isCompressedArrayTexture?ve.compressedTexSubImage3D(bt,pA,eA.x,eA.y,eA.z,et,It,Mt,Gt,$t.data):ve.texSubImage3D(bt,pA,eA.x,eA.y,eA.z,et,It,Mt,Gt,gt,$t),ve.pixelStorei(ve.UNPACK_ROW_LENGTH,_t),ve.pixelStorei(ve.UNPACK_IMAGE_HEIGHT,jt),ve.pixelStorei(ve.UNPACK_SKIP_PIXELS,Dt),ve.pixelStorei(ve.UNPACK_SKIP_ROWS,Et),ve.pixelStorei(ve.UNPACK_SKIP_IMAGES,Xi),pA===0&&lA.generateMipmaps&&ve.generateMipmap(bt),_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(),YA.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:V}}(class extends eE{}).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,A){return super.copy(e,A),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 A=super.toJSON(e);return this.fog!==null&&(A.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(A.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(A.object.backgroundIntensity=this.backgroundIntensity),A}get autoUpdate(){return this.matrixWorldAutoUpdate}set autoUpdate(e){this.matrixWorldAutoUpdate=e}}class AE{constructor(e,A){this.isInterleavedBuffer=!0,this.array=e,this.stride=A,this.count=e!==void 0?e.length/A:0,this.usage=Ve,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=tt()}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,A,t){e*=this.stride,t*=A.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=A.array[t+n];return this}set(e,A=0){return this.array.set(e,A),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=tt()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const A=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),t=new this.constructor(A,this.stride);return t.setUsage(this.usage),t}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=tt()),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,A,t,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=A,this.offset=t,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 A=0,t=this.data.count;A<t;A++)on.fromBufferAttribute(this,A),on.applyMatrix4(e),this.setXYZ(A,on.x,on.y,on.z);return this}applyNormalMatrix(e){for(let A=0,t=this.count;A<t;A++)on.fromBufferAttribute(this,A),on.applyNormalMatrix(e),this.setXYZ(A,on.x,on.y,on.z);return this}transformDirection(e){for(let A=0,t=this.count;A<t;A++)on.fromBufferAttribute(this,A),on.transformDirection(e),this.setXYZ(A,on.x,on.y,on.z);return this}setX(e,A){return this.normalized&&(A=St(A,this.array)),this.data.array[e*this.data.stride+this.offset]=A,this}setY(e,A){return this.normalized&&(A=St(A,this.array)),this.data.array[e*this.data.stride+this.offset+1]=A,this}setZ(e,A){return this.normalized&&(A=St(A,this.array)),this.data.array[e*this.data.stride+this.offset+2]=A,this}setW(e,A){return this.normalized&&(A=St(A,this.array)),this.data.array[e*this.data.stride+this.offset+3]=A,this}getX(e){let A=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(A=nn(A,this.array)),A}getY(e){let A=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(A=nn(A,this.array)),A}getZ(e){let A=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(A=nn(A,this.array)),A}getW(e){let A=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(A=nn(A,this.array)),A}setXY(e,A,t){return e=e*this.data.stride+this.offset,this.normalized&&(A=St(A,this.array),t=St(t,this.array)),this.data.array[e+0]=A,this.data.array[e+1]=t,this}setXYZ(e,A,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(A=St(A,this.array),t=St(t,this.array),n=St(n,this.array)),this.data.array[e+0]=A,this.data.array[e+1]=t,this.data.array[e+2]=n,this}setXYZW(e,A,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(A=St(A,this.array),t=St(t,this.array),n=St(n,this.array),r=St(r,this.array)),this.data.array[e+0]=A,this.data.array[e+1]=t,this.data.array[e+2]=n,this.data.array[e+3]=r,this}clone(e){if(e===void 0){const A=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)A.push(this.data.array[n+r])}return new Wi(new this.array.constructor(A),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 A=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)A.push(this.data.array[n+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:A,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 tE extends Sn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new rt(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 GA,Yo=new GA,iE=new xt,Jl=new re,Po=new re,Yl=new re,nE=new GA,zh=new GA,rE=new GA;class HS extends gi{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",Ra===void 0){Ra=new bn;const A=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new AE(A,5);Ra.setIndex([0,1,2,0,2,3]),Ra.setAttribute("position",new Ho(t,3,0,!1)),Ra.setAttribute("uv",new Ho(t,2,3,!1))}this.geometry=Ra,this.material=e!==void 0?e:new tE,this.center=new GA(.5,.5)}raycast(e,A){e.camera,Na.setFromMatrixScale(this.matrixWorld),iE.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 t=this.material.rotation;let n,r;t!==0&&(r=Math.cos(t),n=Math.sin(t));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),nE.set(0,0),zh.set(1,0),rE.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||A.push({distance:u,point:Jo.clone(),uv:Hn.getInterpolation(Jo,Jl,Po,Yl,nE,zh,rE,new GA),face:null,object:this})}copy(e,A){return super.copy(e,A),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Pl(o,e,A,t,n,r){Fa.subVectors(o,A).addScalar(.5).multiply(t),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(iE)}const sE=new re,aE=new zt,oE=new zt,JS=new re,gE=new xt,La=new re;class YS extends Ut{constructor(e,A){super(e,A),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new xt,this.bindMatrixInverse=new xt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Mi),this.boundingBox.makeEmpty();const A=e.getAttribute("position");for(let t=0;t<A.count;t++)La.fromBufferAttribute(A,t),this.applyBoneTransform(t,La),this.boundingBox.expandByPoint(La)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ur),this.boundingSphere.makeEmpty();const A=e.getAttribute("position");for(let t=0;t<A.count;t++)La.fromBufferAttribute(A,t),this.applyBoneTransform(t,La),this.boundingSphere.expandByPoint(La)}copy(e,A){return super.copy(e,A),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}getVertexPosition(e,A){return super.getVertexPosition(e,A),this.applyBoneTransform(e,A),A}bind(e,A){this.skeleton=e,A===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),A=this.matrixWorld),this.bindMatrix.copy(A),this.bindMatrixInverse.copy(A).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new zt,A=this.geometry.attributes.skinWeight;for(let t=0,n=A.count;t<n;t++){e.fromBufferAttribute(A,t);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),A.setXYZW(t,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,A){const t=this.skeleton,n=this.geometry;aE.fromBufferAttribute(n.attributes.skinIndex,e),oE.fromBufferAttribute(n.attributes.skinWeight,e),sE.copy(A).applyMatrix4(this.bindMatrix),A.set(0,0,0);for(let r=0;r<4;r++){const g=oE.getComponent(r);if(g!==0){const h=aE.getComponent(r);gE.multiplyMatrices(t.bones[h].matrixWorld,t.boneInverses[h]),A.addScaledVector(JS.copy(sE).applyMatrix4(gE),g)}}return A.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,A){return this.applyBoneTransform(e,A)}}class lE extends gi{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Cs extends Di{constructor(e=null,A=1,t=1,n,r,g,h,u,c=1003,C=1003,E,p){super(null,g,h,u,c,C,n,r,E,p),this.isDataTexture=!0,this.image={data:e,width:A,height:t},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const cE=new xt,PS=new xt;class qh{constructor(e=[],A=[]){this.uuid=tt(),this.bones=e.slice(0),this.boneInverses=A,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const e=this.bones,A=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),A.length===0)this.calculateInverses();else if(e.length!==A.length){this.boneInverses=[];for(let t=0,n=this.bones.length;t<n;t++)this.boneInverses.push(new xt)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,A=this.bones.length;e<A;e++){const t=new xt;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,A=this.bones.length;e<A;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,A=this.bones.length;e<A;e++){const t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){const e=this.bones,A=this.boneInverses,t=this.boneMatrices,n=this.boneTexture;for(let r=0,g=e.length;r<g;r++){const h=e[r]?e[r].matrixWorld:PS;cE.multiplyMatrices(h,A[r]),cE.toArray(t,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 A=new Float32Array(e*e*4);A.set(this.boneMatrices);const t=new Cs(A,e,e,kA,De);return t.needsUpdate=!0,this.boneMatrices=A,this.boneTexture=t,this.boneTextureSize=e,this}getBoneByName(e){for(let A=0,t=this.bones.length;A<t;A++){const n=this.bones[A];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,A){this.uuid=e.uuid;for(let t=0,n=e.bones.length;t<n;t++){const r=e.bones[t];let g=A[r];g===void 0&&(g=new lE),this.bones.push(g),this.boneInverses.push(new xt().fromArray(e.boneInverses[t]))}return this.init(),this}toJSON(){const e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const A=this.bones,t=this.boneInverses;for(let n=0,r=A.length;n<r;n++){const g=A[n];e.bones.push(g.uuid);const h=t[n];e.boneInverses.push(h.toArray())}return e}}class hE extends Wi{constructor(e,A,t,n=1){super(e,A,t),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 xt,IE=new xt,Ol=[],uE=new Mi,OS=new xt,Oo=new Ut,Ko=new Ur;class KS extends Ut{constructor(e,A,t){super(e,A),this.isInstancedMesh=!0,this.instanceMatrix=new hE(new Float32Array(16*t),16),this.instanceColor=null,this.count=t,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<t;n++)this.setMatrixAt(n,OS)}computeBoundingBox(){const e=this.geometry,A=this.count;this.boundingBox===null&&(this.boundingBox=new Mi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let t=0;t<A;t++)this.getMatrixAt(t,Ga),uE.copy(e.boundingBox).applyMatrix4(Ga),this.boundingBox.union(uE)}computeBoundingSphere(){const e=this.geometry,A=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ur),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let t=0;t<A;t++)this.getMatrixAt(t,Ga),Ko.copy(e.boundingSphere).applyMatrix4(Ga),this.boundingSphere.union(Ko)}copy(e,A){return super.copy(e,A),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,A){A.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,A){A.fromArray(this.instanceMatrix.array,16*e)}raycast(e,A){const t=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(t),e.ray.intersectsSphere(Ko)!==!1))for(let r=0;r<n;r++){this.getMatrixAt(r,Ga),IE.multiplyMatrices(t,Ga),Oo.matrixWorld=IE,Oo.raycast(e,Ol);for(let g=0,h=Ol.length;g<h;g++){const u=Ol[g];u.instanceId=r,u.object=this,A.push(u)}Ol.length=0}}setColorAt(e,A){this.instanceColor===null&&(this.instanceColor=new hE(new Float32Array(3*this.instanceMatrix.count),3)),A.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,A){A.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class CE extends Sn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new rt(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 dE=new re,BE=new re,EE=new xt,Vh=new Lo,Kl=new Ur;class Wh extends gi{constructor(e=new bn,A=new CE){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=A,this.updateMorphTargets()}copy(e,A){return super.copy(e,A),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const A=e.attributes.position,t=[0];for(let n=1,r=A.count;n<r;n++)dE.fromBufferAttribute(A,n-1),BE.fromBufferAttribute(A,n),t[n]=t[n-1],t[n]+=dE.distanceTo(BE);e.setAttribute("lineDistance",new Cn(t,1))}return this}raycast(e,A){const t=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,g=t.drawRange;if(t.boundingSphere===null&&t.computeBoundingSphere(),Kl.copy(t.boundingSphere),Kl.applyMatrix4(n),Kl.radius+=r,e.ray.intersectsSphere(Kl)===!1)return;EE.copy(n).invert(),Vh.copy(e.ray).applyMatrix4(EE);const h=r/((this.scale.x+this.scale.y+this.scale.z)/3),u=h*h,c=new re,C=new re,E=new re,p=new re,w=this.isLineSegments?2:1,k=t.index,R=t.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),Vh.distanceSqToSegment(c,C,p,E)>u)continue;p.applyMatrix4(this.matrixWorld);const le=e.ray.origin.distanceTo(p);le<e.near||le>e.far||A.push({distance:le,point:E.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),Vh.distanceSqToSegment(c,C,p,E)>u)continue;p.applyMatrix4(this.matrixWorld);const L=e.ray.origin.distanceTo(p);L<e.near||L>e.far||A.push({distance:L,point:E.clone().applyMatrix4(this.matrixWorld),index:_,face:null,faceIndex:null,object:this})}}updateMorphTargets(){const e=this.geometry.morphAttributes,A=Object.keys(e);if(A.length>0){const t=e[A[0]];if(t!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=t.length;n<r;n++){const g=t[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[g]=n}}}}}const QE=new re,fE=new re;class zS extends Wh{constructor(e,A){super(e,A),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const A=e.attributes.position,t=[];for(let n=0,r=A.count;n<r;n+=2)QE.fromBufferAttribute(A,n),fE.fromBufferAttribute(A,n+1),t[n]=n===0?0:t[n-1],t[n+1]=t[n]+QE.distanceTo(fE);e.setAttribute("lineDistance",new Cn(t,1))}return this}}class qS extends Wh{constructor(e,A){super(e,A),this.isLineLoop=!0,this.type="LineLoop"}}class pE extends Sn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new rt(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 mE=new xt,Zh=new Lo,zl=new Ur,ql=new re;class VS extends gi{constructor(e=new bn,A=new pE){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=A,this.updateMorphTargets()}copy(e,A){return super.copy(e,A),this.material=e.material,this.geometry=e.geometry,this}raycast(e,A){const t=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,g=t.drawRange;if(t.boundingSphere===null&&t.computeBoundingSphere(),zl.copy(t.boundingSphere),zl.applyMatrix4(n),zl.radius+=r,e.ray.intersectsSphere(zl)===!1)return;mE.copy(n).invert(),Zh.copy(e.ray).applyMatrix4(mE);const h=r/((this.scale.x+this.scale.y+this.scale.z)/3),u=h*h,c=t.index,C=t.attributes.position;if(c!==null)for(let E=Math.max(0,g.start),p=Math.min(c.count,g.start+g.count);E<p;E++){const w=c.getX(E);ql.fromBufferAttribute(C,w),wE(ql,w,u,n,e,A,this)}else for(let E=Math.max(0,g.start),p=Math.min(C.count,g.start+g.count);E<p;E++)ql.fromBufferAttribute(C,E),wE(ql,E,u,n,e,A,this)}updateMorphTargets(){const e=this.geometry.morphAttributes,A=Object.keys(e);if(A.length>0){const t=e[A[0]];if(t!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=t.length;n<r;n++){const g=t[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[g]=n}}}}}function wE(o,e,A,t,n,r,g){const h=Zh.distanceSqToPoint(o);if(h<A){const u=new re;Zh.closestPointToPoint(o,u),u.applyMatrix4(t);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 yE extends Di{constructor(e,A,t,n,r,g,h,u,c){super(e,A,t,n,r,g,h,u,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Vl extends bn{constructor(e=1,A=32,t=16,n=0,r=2*Math.PI,g=0,h=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:A,heightSegments:t,phiStart:n,phiLength:r,thetaStart:g,thetaLength:h},A=Math.max(3,Math.floor(A)),t=Math.max(2,Math.floor(t));const u=Math.min(g+h,Math.PI);let c=0;const C=[],E=new re,p=new re,w=[],k=[],R=[],_=[];for(let N=0;N<=t;N++){const L=[],G=N/t;let le=0;N===0&&g===0?le=.5/A:N===t&&u===Math.PI&&(le=-.5/A);for(let ne=0;ne<=A;ne++){const te=ne/A;E.x=-e*Math.cos(n+te*r)*Math.sin(g+G*h),E.y=e*Math.cos(g+G*h),E.z=e*Math.sin(n+te*r)*Math.sin(g+G*h),k.push(E.x,E.y,E.z),p.copy(E).normalize(),R.push(p.x,p.y,p.z),_.push(te+le,1-G),L.push(c++)}C.push(L)}for(let N=0;N<t;N++)for(let L=0;L<A;L++){const G=C[N][L+1],le=C[N][L],ne=C[N+1][L],te=C[N+1][L+1];(N!==0||g>0)&&w.push(G,le,te),(N!==t-1||u<Math.PI)&&w.push(le,ne,te)}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 Vl(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 rt(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 rt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new GA(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 GA(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return yt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(A){this.ior=(1+.4*A)/(1-.4*A)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new rt(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 rt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new rt(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,A){return vE(o)?new o.constructor(o.subarray(e,A!==void 0?A:o.length)):o.slice(e,A)}function Wl(o,e,A){return!o||o.constructor===e?o:typeof e.BYTES_PER_ELEMENT=="number"?new e(o):Array.prototype.slice.call(o)}function vE(o){return ArrayBuffer.isView(o)&&!(o instanceof DataView)}function WS(o){const e=o.length,A=new Array(e);for(let t=0;t!==e;++t)A[t]=t;return A.sort((function(t,n){return o[t]-o[n]})),A}function DE(o,e,A){const t=o.length,n=new o.constructor(t);for(let r=0,g=0;g!==t;++r){const h=A[r]*e;for(let u=0;u!==e;++u)n[g++]=o[h+u]}return n}function ME(o,e,A,t){let n=1,r=o[0];for(;r!==void 0&&r[t]===void 0;)r=o[n++];if(r===void 0)return;let g=r[t];if(g!==void 0)if(Array.isArray(g))do g=r[t],g!==void 0&&(e.push(r.time),A.push.apply(A,g)),r=o[n++];while(r!==void 0);else if(g.toArray!==void 0)do g=r[t],g!==void 0&&(e.push(r.time),g.toArray(A,A.length)),r=o[n++];while(r!==void 0);else do g=r[t],g!==void 0&&(e.push(r.time),A.push(g)),r=o[n++];while(r!==void 0)}class zo{constructor(e,A,t,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new A.constructor(t),this.sampleValues=A,this.valueSize=t,this.settings=null,this.DefaultSettings_={}}evaluate(e){const A=this.parameterPositions;let t=this._cachedIndex,n=A[t],r=A[t-1];e:{A:{let g;t:{i:if(!(e<n)){for(let h=t+2;;){if(n===void 0){if(e<r)break i;return t=A.length,this._cachedIndex=t,this.copySampleValue_(t-1)}if(t===h)break;if(r=n,n=A[++t],e<n)break A}g=A.length;break t}if(e>=r)break e;{const h=A[1];e<h&&(t=2,r=h);for(let u=t-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(t===u)break;if(n=r,r=A[--t-1],e>=r)break A}g=t,t=0}}for(;t<g;){const h=t+g>>>1;e<A[h]?g=h:t=h+1}if(n=A[t],r=A[t-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return t=A.length,this._cachedIndex=t,this.copySampleValue_(t-1)}this._cachedIndex=t,this.intervalChanged_(t,r,n)}return this.interpolate_(t,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const A=this.resultBuffer,t=this.sampleValues,n=this.valueSize,r=e*n;for(let g=0;g!==n;++g)A[g]=t[r+g];return A}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class ZS extends zo{constructor(e,A,t,n){super(e,A,t,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:tA,endingEnd:tA}}intervalChanged_(e,A,t){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 aA:r=e,h=2*A-t;break;case DA:r=n.length-2,h=A+n[r]-n[r+1];break;default:r=e,h=t}if(u===void 0)switch(this.getSettings_().endingEnd){case aA:g=e,u=2*t-A;break;case DA:g=1,u=t+n[1]-n[0];break;default:g=e-1,u=A}const c=.5*(t-A),C=this.valueSize;this._weightPrev=c/(A-h),this._weightNext=c/(u-t),this._offsetPrev=r*C,this._offsetNext=g*C}interpolate_(e,A,t,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=e*h,c=u-h,C=this._offsetPrev,E=this._offsetNext,p=this._weightPrev,w=this._weightNext,k=(t-A)/(n-A),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[E+ne];return r}}class SE extends zo{constructor(e,A,t,n){super(e,A,t,n)}interpolate_(e,A,t,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=e*h,c=u-h,C=(t-A)/(n-A),E=1-C;for(let p=0;p!==h;++p)r[p]=g[c+p]*E+g[u+p]*C;return r}}class jS extends zo{constructor(e,A,t,n){super(e,A,t,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class Qr{constructor(e,A,t,n){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(A===void 0||A.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Wl(A,this.TimeBufferType),this.values=Wl(t,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const A=e.constructor;let t;if(A.toJSON!==this.toJSON)t=A.toJSON(e);else{t={name:e.name,times:Wl(e.times,Array),values:Wl(e.values,Array)};const n=e.getInterpolation();n!==e.DefaultInterpolation&&(t.interpolation=n)}return t.type=e.ValueTypeName,t}InterpolantFactoryMethodDiscrete(e){return new jS(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new SE(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ZS(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let A;switch(e){case Ue:A=this.InterpolantFactoryMethodDiscrete;break;case Oe:A=this.InterpolantFactoryMethodLinear;break;case Ke:A=this.InterpolantFactoryMethodSmooth}if(A===void 0){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return this}return this.createInterpolant=A,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 A=this.times;for(let t=0,n=A.length;t!==n;++t)A[t]+=e}return this}scale(e){if(e!==1){const A=this.times;for(let t=0,n=A.length;t!==n;++t)A[t]*=e}return this}trim(e,A){const t=this.times,n=t.length;let r=0,g=n-1;for(;r!==n&&t[r]<e;)++r;for(;g!==-1&&t[g]>A;)--g;if(++g,r!==0||g!==n){r>=g&&(g=Math.max(g,1),r=g-1);const h=this.getValueSize();this.times=ds(t,r,g),this.values=ds(this.values,r*h,g*h)}return this}validate(){let e=!0;const A=this.getValueSize();A-Math.floor(A)!=0&&(e=!1);const t=this.times,n=this.values,r=t.length;r===0&&(e=!1);let g=null;for(let h=0;h!==r;h++){const u=t[h];if(typeof u=="number"&&isNaN(u)){e=!1;break}if(g!==null&&g>u){e=!1;break}g=u}if(n!==void 0&&vE(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),A=ds(this.values),t=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*t,E=C-t,p=C+t;for(let w=0;w!==t;++w){const k=A[C+w];if(k!==A[E+w]||k!==A[p+w]){u=!0;break}}}if(u){if(h!==g){e[g]=e[h];const C=h*t,E=g*t;for(let p=0;p!==t;++p)A[E+p]=A[C+p]}++g}}if(r>0){e[g]=e[r];for(let h=r*t,u=g*t,c=0;c!==t;++c)A[u+c]=A[h+c];++g}return g!==e.length?(this.times=ds(e,0,g),this.values=ds(A,0,g*t)):(this.times=e,this.values=A),this}clone(){const e=ds(this.times,0),A=ds(this.values,0),t=new this.constructor(this.name,e,A);return t.createInterpolant=this.createInterpolant,t}}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 xE extends Qr{}xE.prototype.ValueTypeName="color";class qo extends Qr{}qo.prototype.ValueTypeName="number";class XS extends zo{constructor(e,A,t,n){super(e,A,t,n)}interpolate_(e,A,t,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=(t-A)/(n-A);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 XS(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 Vo extends Qr{}Vo.prototype.ValueTypeName="vector";class jh{constructor(e,A=-1,t,n=2500){this.name=e,this.tracks=t,this.duration=A,this.blendMode=n,this.uuid=tt(),this.duration<0&&this.resetDuration()}static parse(e){const A=[],t=e.tracks,n=1/(e.fps||1);for(let g=0,h=t.length;g!==h;++g)A.push($S(t[g]).scale(n));const r=new this(e.name,e.duration,A,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const A=[],t=e.tracks,n={name:e.name,duration:e.duration,tracks:A,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,g=t.length;r!==g;++r)A.push(Qr.toJSON(t[r]));return n}static CreateFromMorphTargetSequence(e,A,t,n){const r=A.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=WS(u);u=DE(u,1,C),c=DE(c,1,C),n||u[0]!==0||(u.push(r),c.push(c[0])),g.push(new qo(".morphTargetInfluences["+A[h].name+"]",u,c).scale(1/t))}return new this(e,-1,g)}static findByName(e,A){let t=e;if(!Array.isArray(e)){const n=e;t=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<t.length;n++)if(t[n].name===A)return t[n];return null}static CreateClipsFromMorphTargetSequences(e,A,t){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 E=C[1];let p=n[E];p||(n[E]=p=[]),p.push(c)}}const g=[];for(const h in n)g.push(this.CreateFromMorphTargetSequence(h,n[h],A,t));return g}static parseAnimation(e,A){if(!e)return null;const t=function(C,E,p,w,k){if(p.length!==0){const R=[],_=[];ME(p,R,_,w),R.length!==0&&k.push(new C(E,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 E=c[C].keys;if(E&&E.length!==0)if(E[0].morphTargets){const p={};let w;for(w=0;w<E.length;w++)if(E[w].morphTargets)for(let k=0;k<E[w].morphTargets.length;k++)p[E[w].morphTargets[k]]=-1;for(const k in p){const R=[],_=[];for(let N=0;N!==E[w].morphTargets.length;++N){const L=E[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["+A[C].name+"]";t(Vo,p+".position",E,"pos",n),t(Os,p+".quaternion",E,"rot",n),t(Vo,p+".scale",E,"scl",n)}}return n.length===0?null:new this(r,u,n,h)}resetDuration(){let e=0;for(let A=0,t=this.tracks.length;A!==t;++A){const n=this.tracks[A];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 A=0;A<this.tracks.length;A++)e=e&&this.tracks[A].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let A=0;A<this.tracks.length;A++)e.push(this.tracks[A].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function $S(o){if(o.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=(function(A){switch(A.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return qo;case"vector":case"vector2":case"vector3":case"vector4":return Vo;case"color":return xE;case"quaternion":return Os;case"bool":case"boolean":return Ua;case"string":return Ta}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+A)})(o.type);if(o.times===void 0){const A=[],t=[];ME(o.keys,A,t,"value"),o.times=A,o.values=t}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 ex{constructor(e,A,t){const n=this;let r,g=!1,h=0,u=0;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=A,this.onError=t,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,E){return c.push(C,E),this},this.removeHandler=function(C){const E=c.indexOf(C);return E!==-1&&c.splice(E,2),this},this.getHandler=function(C){for(let E=0,p=c.length;E<p;E+=2){const w=c[E],k=c[E+1];if(w.global&&(w.lastIndex=0),w.test(C))return k}return null}}}const Ax=new ex;class Ja{constructor(e){this.manager=e!==void 0?e:Ax,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,A){const t=this;return new Promise((function(n,r){t.load(e,n,A,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 tx extends Error{constructor(e,A){super(e),this.response=A}}class Xh extends Ja{constructor(e){super(e)}load(e,A,t,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((()=>{A&&A(r),this.manager.itemEnd(e)}),0),r;if(Or[e]!==void 0)return void Or[e].push({onLoad:A,onProgress:t,onError:n});Or[e]=[],Or[e].push({onLoad:A,onProgress:t,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],E=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(){E.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 te=0,Ae=C.length;te<Ae;te++){const ye=C[te];ye.onProgress&&ye.onProgress(ne)}N.enqueue(le),L()}}))})()}});return new Response(_)}throw new tx(`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),E=C&&C[1]?C[1].toLowerCase():void 0,p=new TextDecoder(E);return c.arrayBuffer().then((w=>p.decode(w)))}}})).then((c=>{Ha.add(e,c);const C=Or[e];delete Or[e];for(let E=0,p=C.length;E<p;E++){const w=C[E];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 E=0,p=C.length;E<p;E++){const w=C[E];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 ix extends Ja{constructor(e){super(e)}load(e,A,t,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(){A&&A(g),r.manager.itemEnd(e)}),0),g;const h=wn("img");function u(){C(),Ha.add(e,this),A&&A(this),r.manager.itemEnd(e)}function c(E){C(),n&&n(E),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 nx extends Ja{constructor(e){super(e)}load(e,A,t,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,A&&A(g,c))}),t,n),g}}class Ya extends Ja{constructor(e){super(e)}load(e,A,t,n){const r=new Di,g=new ix(this.manager);return g.setCrossOrigin(this.crossOrigin),g.setPath(this.path),g.load(e,(function(h){r.image=h,r.needsUpdate=!0,A!==void 0&&A(r)}),t,n),r}}class Zl extends gi{constructor(e,A=1){super(),this.isLight=!0,this.type="Light",this.color=new rt(e),this.intensity=A}dispose(){}copy(e,A){return super.copy(e,A),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const A=super.toJSON(e);return A.object.color=this.color.getHex(),A.object.intensity=this.intensity,this.groundColor!==void 0&&(A.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(A.object.distance=this.distance),this.angle!==void 0&&(A.object.angle=this.angle),this.decay!==void 0&&(A.object.decay=this.decay),this.penumbra!==void 0&&(A.object.penumbra=this.penumbra),this.shadow!==void 0&&(A.object.shadow=this.shadow.toJSON()),A}}const $h=new xt,bE=new re,_E=new re;class eI{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new GA(512,512),this.map=null,this.mapPass=null,this.matrix=new xt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Th,this._frameExtents=new GA(1,1),this._viewportCount=1,this._viewports=[new zt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const A=this.camera,t=this.matrix;bE.setFromMatrixPosition(e.matrixWorld),A.position.copy(bE),_E.setFromMatrixPosition(e.target.matrixWorld),A.lookAt(_E),A.updateMatrixWorld(),$h.multiplyMatrices(A.projectionMatrix,A.matrixWorldInverse),this._frustum.setFromProjectionMatrix($h),t.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),t.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 rx extends eI{constructor(){super(new Zi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const A=this.camera,t=2*Rt*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=e.distance||A.far;t===A.fov&&n===A.aspect&&r===A.far||(A.fov=t,A.aspect=n,A.far=r,A.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class sx extends Zl{constructor(e,A,t=0,n=Math.PI/3,r=0,g=2){super(e,A),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gi.DEFAULT_UP),this.updateMatrix(),this.target=new gi,this.distance=t,this.angle=n,this.penumbra=r,this.decay=g,this.map=null,this.shadow=new rx}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,A){return super.copy(e,A),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 RE=new xt,Wo=new re,AI=new re;class ax extends eI{constructor(){super(new Zi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new GA(4,2),this._viewportCount=6,this._viewports=[new zt(2,1,1,1),new zt(0,1,1,1),new zt(3,1,1,1),new zt(1,1,1,1),new zt(3,0,1,1),new zt(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,A=0){const t=this.camera,n=this.matrix,r=e.distance||t.far;r!==t.far&&(t.far=r,t.updateProjectionMatrix()),Wo.setFromMatrixPosition(e.matrixWorld),t.position.copy(Wo),AI.copy(t.position),AI.add(this._cubeDirections[A]),t.up.copy(this._cubeUps[A]),t.lookAt(AI),t.updateMatrixWorld(),n.makeTranslation(-Wo.x,-Wo.y,-Wo.z),RE.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(RE)}}class ox extends Zl{constructor(e,A,t=0,n=2){super(e,A),this.isPointLight=!0,this.type="PointLight",this.distance=t,this.decay=n,this.shadow=new ax}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,A){return super.copy(e,A),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class gx extends eI{constructor(){super(new _n(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class NE extends Zl{constructor(e,A){super(e,A),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gi.DEFAULT_UP),this.updateMatrix(),this.target=new gi,this.shadow=new gx}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class lx extends Zl{constructor(e,A){super(e,A),this.isAmbientLight=!0,this.type="AmbientLight"}}class tI{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let A="";for(let t=0,n=e.length;t<n;t++)A+=String.fromCharCode(e[t]);try{return decodeURIComponent(escape(A))}catch{return A}}static extractUrlBase(e){const A=e.lastIndexOf("/");return A===-1?"./":e.slice(0,A+1)}static resolveURL(e,A){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(A)&&/^\//.test(e)&&(A=A.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:A+e)}}class cx extends Ja{constructor(e){super(e),this.isImageBitmapLoader=!0,this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,A,t,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(){A&&A(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),A&&A(u),r.manager.itemEnd(e)})).catch((function(u){n&&n(u),r.manager.itemError(e),r.manager.itemEnd(e)})),r.manager.itemStart(e)}}class hx{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=kE(),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 A=kE();e=(A-this.oldTime)/1e3,this.oldTime=A,this.elapsedTime+=e}return e}}function kE(){return(typeof performance>"u"?Date:performance).now()}class Ix{constructor(e,A,t){let n,r,g;switch(this.binding=e,this.valueSize=t,A){case"quaternion":n=this._slerp,r=this._slerpAdditive,g=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*t),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,g=this._setAdditiveIdentityOther,this.buffer=new Array(5*t);break;default:n=this._lerp,r=this._lerpAdditive,g=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*t)}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,A){const t=this.buffer,n=this.valueSize,r=e*n+n;let g=this.cumulativeWeight;if(g===0){for(let h=0;h!==n;++h)t[r+h]=t[h];g=A}else{g+=A;const h=A/g;this._mixBufferRegion(t,r,0,h,n)}this.cumulativeWeight=g}accumulateAdditive(e){const A=this.buffer,t=this.valueSize,n=t*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(A,n,0,e,t),this.cumulativeWeightAdditive+=e}apply(e){const A=this.valueSize,t=this.buffer,n=e*A+A,r=this.cumulativeWeight,g=this.cumulativeWeightAdditive,h=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const u=A*this._origIndex;this._mixBufferRegion(t,n,u,1-r,A)}g>0&&this._mixBufferRegionAdditive(t,n,this._addIndex*A,1,A);for(let u=A,c=A+A;u!==c;++u)if(t[u]!==t[u+A]){h.setValue(t,n);break}}saveOriginalState(){const e=this.binding,A=this.buffer,t=this.valueSize,n=t*this._origIndex;e.getValue(A,n);for(let r=t,g=n;r!==g;++r)A[r]=A[n+r%t];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,A=e+this.valueSize;for(let t=e;t<A;t++)this.buffer[t]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,A=this._addIndex*this.valueSize;for(let t=0;t<this.valueSize;t++)this.buffer[A+t]=this.buffer[e+t]}_select(e,A,t,n,r){if(n>=.5)for(let g=0;g!==r;++g)e[A+g]=e[t+g]}_slerp(e,A,t,n){Ui.slerpFlat(e,A,e,A,e,t,n)}_slerpAdditive(e,A,t,n,r){const g=this._workIndex*r;Ui.multiplyQuaternionsFlat(e,g,e,A,e,t),Ui.slerpFlat(e,A,e,A,e,g,n)}_lerp(e,A,t,n,r){const g=1-n;for(let h=0;h!==r;++h){const u=A+h;e[u]=e[u]*g+e[t+h]*n}}_lerpAdditive(e,A,t,n,r){for(let g=0;g!==r;++g){const h=A+g;e[h]=e[h]+e[t+g]*n}}}const iI="\\[\\]\\.:\\/",ux=new RegExp("["+iI+"]","g"),nI="[^"+iI+"]",Cx="[^"+iI.replace("\\.","")+"]",dx=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",nI)+/(WCOD+)?/.source.replace("WCOD",Cx)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",nI)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",nI)+"$"),Bx=["material","materials","bones","map"];class Zt{constructor(e,A,t){this.path=A,this.parsedPath=t||Zt.parseTrackName(A),this.node=Zt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,A,t){return e&&e.isAnimationObjectGroup?new Zt.Composite(e,A,t):new Zt(e,A,t)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(ux,"")}static parseTrackName(e){const A=dx.exec(e);if(A===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const t={nodeName:A[2],objectName:A[3],objectIndex:A[4],propertyName:A[5],propertyIndex:A[6]},n=t.nodeName&&t.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const r=t.nodeName.substring(n+1);Bx.indexOf(r)!==-1&&(t.nodeName=t.nodeName.substring(0,n),t.objectName=r)}if(t.propertyName===null||t.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return t}static findNode(e,A){if(A===void 0||A===""||A==="."||A===-1||A===e.name||A===e.uuid)return e;if(e.skeleton){const t=e.skeleton.getBoneByName(A);if(t!==void 0)return t}if(e.children){const t=function(r){for(let g=0;g<r.length;g++){const h=r[g];if(h.name===A||h.uuid===A)return h;const u=t(h.children);if(u)return u}return null},n=t(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,A){e[A]=this.targetObject[this.propertyName]}_getValue_array(e,A){const t=this.resolvedProperty;for(let n=0,r=t.length;n!==r;++n)e[A++]=t[n]}_getValue_arrayElement(e,A){e[A]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,A){this.resolvedProperty.toArray(e,A)}_setValue_direct(e,A){this.targetObject[this.propertyName]=e[A]}_setValue_direct_setNeedsUpdate(e,A){this.targetObject[this.propertyName]=e[A],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,A){this.targetObject[this.propertyName]=e[A],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,A){const t=this.resolvedProperty;for(let n=0,r=t.length;n!==r;++n)t[n]=e[A++]}_setValue_array_setNeedsUpdate(e,A){const t=this.resolvedProperty;for(let n=0,r=t.length;n!==r;++n)t[n]=e[A++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,A){const t=this.resolvedProperty;for(let n=0,r=t.length;n!==r;++n)t[n]=e[A++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,A){this.resolvedProperty[this.propertyIndex]=e[A]}_setValue_arrayElement_setNeedsUpdate(e,A){this.resolvedProperty[this.propertyIndex]=e[A],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,A){this.resolvedProperty[this.propertyIndex]=e[A],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,A){this.resolvedProperty.fromArray(e,A)}_setValue_fromArray_setNeedsUpdate(e,A){this.resolvedProperty.fromArray(e,A),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,A){this.resolvedProperty.fromArray(e,A),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,A){this.bind(),this.getValue(e,A)}_setValue_unbound(e,A){this.bind(),this.setValue(e,A)}bind(){let e=this.node;const A=this.parsedPath,t=A.objectName,n=A.propertyName;let r=A.propertyIndex;if(e||(e=Zt.findNode(this.rootNode,A.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void this.path;if(t){let c=A.objectIndex;switch(t){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[t]===void 0)return;e=e[t]}if(c!==void 0){if(e[c]===void 0)return;e=e[c]}}const g=e[n];if(g===void 0){A.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}}Zt.Composite=class{constructor(o,e,A){const t=A||Zt.parseTrackName(e);this._targetGroup=o,this._bindings=o.subscribe_(e,t)}getValue(o,e){this.bind();const A=this._targetGroup.nCachedObjects_,t=this._bindings[A];t!==void 0&&t.getValue(o,e)}setValue(o,e){const A=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=A.length;t!==n;++t)A[t].setValue(o,e)}bind(){const o=this._bindings;for(let e=this._targetGroup.nCachedObjects_,A=o.length;e!==A;++e)o[e].bind()}unbind(){const o=this._bindings;for(let e=this._targetGroup.nCachedObjects_,A=o.length;e!==A;++e)o[e].unbind()}},Zt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Zt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Zt.prototype.GetterByBindingType=[Zt.prototype._getValue_direct,Zt.prototype._getValue_array,Zt.prototype._getValue_arrayElement,Zt.prototype._getValue_toArray],Zt.prototype.SetterByBindingTypeAndVersioning=[[Zt.prototype._setValue_direct,Zt.prototype._setValue_direct_setNeedsUpdate,Zt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_array,Zt.prototype._setValue_array_setNeedsUpdate,Zt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_arrayElement,Zt.prototype._setValue_arrayElement_setNeedsUpdate,Zt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_fromArray,Zt.prototype._setValue_fromArray_setNeedsUpdate,Zt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Ex{constructor(e,A,t=null,n=A.blendMode){this._mixer=e,this._clip=A,this._localRoot=t,this.blendMode=n;const r=A.tracks,g=r.length,h=new Array(g),u={endingStart:tA,endingEnd:tA};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,A){return this.loop=e,this.repetitions=A,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,A,t){if(e.fadeOut(A),this.fadeIn(A),t){const n=this._clip.duration,r=e._clip.duration,g=r/n,h=n/r;e.warp(1,g,A),this.warp(h,1,A)}return this}crossFadeTo(e,A,t){return e.crossFadeFrom(this,A,t)}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,A,t){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+t,c[0]=e/g,c[1]=A/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,A,t,n){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(r!==null){const u=(e-r)*t;u<0||t===0?A=0:(this._startTime=null,A=t*u)}A*=this._updateTimeScale(e);const g=this._updateTime(A),h=this._updateWeight(e);if(h>0){const u=this._interpolants,c=this._propertyBindings;if(this.blendMode===2501)for(let C=0,E=u.length;C!==E;++C)u[C].evaluate(g),c[C].accumulateAdditive(h);else for(let C=0,E=u.length;C!==E;++C)u[C].evaluate(g),c[C].accumulate(n,h)}}_updateWeight(e){let A=0;if(this.enabled){A=this.weight;const t=this._weightInterpolant;if(t!==null){const n=t.evaluate(e)[0];A*=n,e>t.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=A,A}_updateTimeScale(e){let A=0;if(!this.paused){A=this.timeScale;const t=this._timeScaleInterpolant;t!==null&&(A*=t.evaluate(e)[0],e>t.parameterPositions[1]&&(this.stopWarping(),A===0?this.paused=!0:this.timeScale=A))}return this._effectiveTimeScale=A,A}_updateTime(e){const A=this._clip.duration,t=this.loop;let n=this.time+e,r=this._loopCount;const g=t===2202;if(e===0)return r===-1?n:g&&(1&r)==1?A-n:n;if(t===2200){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=A)n=A;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>=A||n<0){const h=Math.floor(n/A);n-=A*h,r+=Math.abs(h);const u=this.repetitions-r;if(u<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?A: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 A-n}return n}_setEndings(e,A,t){const n=this._interpolantSettings;t?(n.endingStart=aA,n.endingEnd=aA):(n.endingStart=e?this.zeroSlopeAtStart?aA:tA:DA,n.endingEnd=A?this.zeroSlopeAtEnd?aA:tA:DA)}_scheduleFading(e,A,t){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]=A,h[1]=r+e,u[1]=t,this}}const Qx=new Float32Array(1);class fx extends uA{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,A){const t=e._localRoot||this._root,n=e._clip.tracks,r=n.length,g=e._propertyBindings,h=e._interpolants,u=t.uuid,c=this._bindingsByRootAndName;let C=c[u];C===void 0&&(C={},c[u]=C);for(let E=0;E!==r;++E){const p=n[E],w=p.name;let k=C[w];if(k!==void 0)++k.referenceCount,g[E]=k;else{if(k=g[E],k!==void 0){k._cacheIndex===null&&(++k.referenceCount,this._addInactiveBinding(k,u,w));continue}const R=A&&A._propertyBindings[E].binding.parsedPath;k=new Ix(Zt.create(t,w,R),p.ValueTypeName,p.getValueSize()),++k.referenceCount,this._addInactiveBinding(k,u,w),g[E]=k}h[E].resultBuffer=k.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}const A=e._propertyBindings;for(let t=0,n=A.length;t!==n;++t){const r=A[t];r.useCount++==0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const A=e._propertyBindings;for(let t=0,n=A.length;t!==n;++t){const r=A[t];--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 A=e._cacheIndex;return A!==null&&A<this._nActiveActions}_addInactiveAction(e,A,t){const n=this._actions,r=this._actionsByClip;let g=r[A];if(g===void 0)g={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[A]=g;else{const h=g.knownActions;e._byClipCacheIndex=h.length,h.push(e)}e._cacheIndex=n.length,n.push(e),g.actionByRoot[t]=e}_removeInactiveAction(e){const A=this._actions,t=A[A.length-1],n=e._cacheIndex;t._cacheIndex=n,A[n]=t,A.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 A=e._propertyBindings;for(let t=0,n=A.length;t!==n;++t){const r=A[t];--r.referenceCount==0&&this._removeInactiveBinding(r)}}_lendAction(e){const A=this._actions,t=e._cacheIndex,n=this._nActiveActions++,r=A[n];e._cacheIndex=n,A[n]=e,r._cacheIndex=t,A[t]=r}_takeBackAction(e){const A=this._actions,t=e._cacheIndex,n=--this._nActiveActions,r=A[n];e._cacheIndex=n,A[n]=e,r._cacheIndex=t,A[t]=r}_addInactiveBinding(e,A,t){const n=this._bindingsByRootAndName,r=this._bindings;let g=n[A];g===void 0&&(g={},n[A]=g),g[t]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const A=this._bindings,t=e.binding,n=t.rootNode.uuid,r=t.path,g=this._bindingsByRootAndName,h=g[n],u=A[A.length-1],c=e._cacheIndex;u._cacheIndex=c,A[c]=u,A.pop(),delete h[r],Object.keys(h).length===0&&delete g[n]}_lendBinding(e){const A=this._bindings,t=e._cacheIndex,n=this._nActiveBindings++,r=A[n];e._cacheIndex=n,A[n]=e,r._cacheIndex=t,A[t]=r}_takeBackBinding(e){const A=this._bindings,t=e._cacheIndex,n=--this._nActiveBindings,r=A[n];e._cacheIndex=n,A[n]=e,r._cacheIndex=t,A[t]=r}_lendControlInterpolant(){const e=this._controlInterpolants,A=this._nActiveControlInterpolants++;let t=e[A];return t===void 0&&(t=new SE(new Float32Array(2),new Float32Array(2),1,Qx),t.__cacheIndex=A,e[A]=t),t}_takeBackControlInterpolant(e){const A=this._controlInterpolants,t=e.__cacheIndex,n=--this._nActiveControlInterpolants,r=A[n];e.__cacheIndex=n,A[n]=e,r.__cacheIndex=t,A[t]=r}clipAction(e,A,t){const n=A||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(t===void 0&&(t=g!==null?g.blendMode:yA),u!==void 0){const E=u.actionByRoot[r];if(E!==void 0&&E.blendMode===t)return E;c=u.knownActions[0],g===null&&(g=c._clip)}if(g===null)return null;const C=new Ex(this,g,A,t);return this._bindAction(C,c),this._addInactiveAction(C,h,r),C}existingAction(e,A){const t=A||this._root,n=t.uuid,r=typeof e=="string"?jh.findByName(t,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 A=this._nActiveActions-1;A>=0;--A)e[A].stop();return this}update(e){e*=this.timeScale;const A=this._actions,t=this._nActiveActions,n=this.time+=e,r=Math.sign(e),g=this._accuIndex^=1;for(let c=0;c!==t;++c)A[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 A=0;A<this._actions.length;A++)this._actions[A].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const A=this._actions,t=e.uuid,n=this._actionsByClip,r=n[t];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,E=A[A.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,E._cacheIndex=C,A[C]=E,A.pop(),this._removeInactiveBindingsForAction(c)}delete n[t]}}uncacheRoot(e){const A=e.uuid,t=this._actionsByClip;for(const r in t){const g=t[r].actionByRoot[A];g!==void 0&&(this._deactivateAction(g),this._removeInactiveAction(g))}const n=this._bindingsByRootAndName[A];if(n!==void 0)for(const r in n){const g=n[r];g.restoreOriginalState(),this._removeInactiveBinding(g)}}uncacheAction(e,A){const t=this.existingAction(e,A);t!==null&&(this._deactivateAction(t),this._removeInactiveAction(t))}}class Zo{constructor(e,A,t=0,n=1/0){this.ray=new Lo(e,A),this.near=t,this.far=n,this.camera=null,this.layers=new bh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,A){this.ray.set(e,A)}setFromCamera(e,A){A.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(A.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(A).sub(this.ray.origin).normalize(),this.camera=A):A.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(A.near+A.far)/(A.near-A.far)).unproject(A),this.ray.direction.set(0,0,-1).transformDirection(A.matrixWorld),this.camera=A):A.type}intersectObject(e,A=!0,t=[]){return rI(e,this,t,A),t.sort(FE),t}intersectObjects(e,A=!0,t=[]){for(let n=0,r=e.length;n<r;n++)rI(e[n],this,t,A);return t.sort(FE),t}}function FE(o,e){return o.distance-e.distance}function rI(o,e,A,t){if(o.layers.test(e.layers)&&o.raycast(e,A),t===!0){const n=o.children;for(let r=0,g=n.length;r<g;r++)rI(n[r],e,A,!0)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:B}})),typeof window<"u"&&(window.__THREE__||(window.__THREE__=B));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,A){e==="whitePoint"?this.whitePoint.set(A[0],A[1],A[2]):this[e]=A}static getKelvinRGB(e){const t=Math.floor((e-1e3)/1e3),n=t+1;if(t<0)return this.rgbValues[0].clone();if(n>=this.rgbValues.length)return this.rgbValues[this.rgbValues.length-1].clone();const r=(e-(t*1e3+1e3))/1e3;return this.rgbValues[t].clone().lerp(this.rgbValues[n],r)}showPopup(e){const A=document.createElement("div");A.style.position="absolute",A.style.top="50%",A.style.left="50%",A.style.transform="translate(-50%, -50%)",A.style.padding="10px",A.style.background="white",A.style.border="1px solid black",A.style.zIndex="1000",A.innerText=e,document.body.appendChild(A),setTimeout((()=>{document.body.removeChild(A)}),3e3)}enableGodMode(){window.addEventListener("keydown",(e=>{const A=new Date().getTime();if(e.key==="Enter")this.lastKeyPressTime=A;else if(this.lastKeyPressTime&&A-this.lastKeyPressTime<2e3){if(e.key==="p"||e.key==="P"){ae.EXPERIMENTAL_WEBASSEMBLY_QHDR_LOADER=!ae.EXPERIMENTAL_WEBASSEMBLY_QHDR_LOADER;const t=ae.EXPERIMENTAL_WEBASSEMBLY_QHDR_LOADER?"ON":"OFF";this.showPopup(`Experimental turboloader: ${t}`)}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 GA(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,A,t){const n=A-e;return e+(Math.abs(n)<=t?n:Math.sign(n)*t)}static lerpAngleRadians(e,A,t){const n=Math.PI;return e+((A-e+n+2*n)%(2*n)-n)*t}static lerpEuler(e,A,t){const n=new Mn;return n.x=this.lerpAngleRadians(e.x,A.x,t),n.y=this.lerpAngleRadians(e.y,A.y,t),n.z=this.lerpAngleRadians(e.z,A.z,t),n.order=e.order,n}}class px{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 A=jl.lerpAngleRadians(this.cameraSmooth.rotation.x,this.camera.rotation.x,e),t=jl.lerpAngleRadians(this.cameraSmooth.rotation.y,this.camera.rotation.y,e);this.cameraSmooth.rotation.set(A,t,0),this.cameraSmooth.position.copy(this.camera.position),this.camera.aspect=ae.getAspectRatio(),this.cameraSmooth.aspect=ae.getAspectRatio(),this.cameraSmooth.updateProjectionMatrix()}}class We{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(),We.keysState.set(e.code,!0),We.keysDown.set(e.code,!0))}static handleKeyUp(e){K.parent.matches(":hover")&&(e.preventDefault(),We.keysState.set(e.code,!1),We.keysUp.set(e.code,!0))}static handleInputDown(e,A,t){We.mouseButtonsState.set(e,!0),We.mouseButtonsDown.set(e,!0),We.mouseDownPosition.set(A,t),We.mouseDownTime=performance.now()}static handleMouseDown(e){We.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),We.lastTouchPosition.set(e.touches[0].clientX,e.touches[0].clientY)),e.touches.length===2){const A=e.touches[0].clientX-e.touches[1].clientX,t=e.touches[0].clientY-e.touches[1].clientY,n=Math.hypot(A,t);We.touchZoomDistanceEnd=We.touchZoomDistanceStart=n}}static handleInputUp(e,A,t){We.mouseButtonsState.set(e,!1),We.mouseButtonsUp.set(e,!0),We.mouseUpPosition.set(A,t),We.mouseUpTime=performance.now()}static handleMouseUp(e){We.handleInputUp(e.button,e.clientX,e.clientY)}static handleTouchEnd(e){const A=e.changedTouches[0];We.handleInputUp(0,A.clientX,A.clientY),We.touchZoomDistanceStart=0,We.touchZoomDistanceEnd=0}static handleInputMove(e,A,t,n){We.mousePosition.set(e,A),We.mouseDragDelta.x+=t*ae.dragScale.x,We.mouseDragDelta.y+=n*ae.dragScale.y}static handleMouseMove(e){We.handleInputMove(e.clientX,e.clientY,e.movementX,e.movementY)}static handleTouchMove(e){if(e.touches.length===1){const t=e.touches[0],n=t.clientX-We.lastTouchPosition.x,r=t.clientY-We.lastTouchPosition.y;We.handleInputMove(t.clientX,t.clientY,n,r),We.lastTouchPosition.set(t.clientX,t.clientY)}if(e.touches.length===2){const t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY,r=Math.hypot(t,n);We.touchZoomDistanceEnd=r;var A=We.touchZoomDistanceEnd-We.touchZoomDistanceStart;We.touchZoomDistanceStart=We.touchZoomDistanceEnd,We.mouseScrollDelta.set(0,-2*A)}}static handleMouseWheel(e){We.mouseScrollDelta.set(e.deltaX,e.deltaY)}static GetKey(e){return We.keysState.get(e)||!1}static GetKeyDown(e){return!!We.keysUp.get(e)}static GetKeyUp(e){return!!We.keysUp.get(e)}static GetMouseButton(e){return We.mouseButtonsState.get(e)||!1}static GetMouseButtonDown(e){return!!We.mouseButtonsState.get(e)}static GetMouseButtonUp(e){return!!We.mouseButtonsUp.get(e)}static get MousePositionLocal(){const e=K.canvas.getBoundingClientRect();return new GA(We.mousePosition.x-e.left,We.mousePosition.y-e.top)}static get MousePositionGlobal(){return We.mousePosition}static get MousePositionNormalized(){const e=K.canvas.getBoundingClientRect(),A=new GA(We.mousePosition.x-e.left,We.mousePosition.y-e.top);return new GA(A.x/e.width*2-1,-A.y/e.height*2+1)}static get MouseScrollDelta(){return We.mouseScrollDelta}static get MouseDragDelta(){return We.mouseDragDelta}static get MousePick(){return!(!We.GetMouseButtonUp(0)||We.mousePickConsumed||!We.isTapClick())&&(We.mousePickConsumed=!0,!0)}static isTapClick(){if(!We.GetMouseButtonUp(0))return!1;const e=We.mouseDownPosition.distanceTo(We.mouseUpPosition),A=We.mouseUpTime-We.mouseDownTime;return e<=We.maxTapMove&&A<=We.maxTapTime}static consumeMousePick(){We.mousePickConsumed=!0}static isMousePickPending(){return We.GetMouseButtonUp(0)&&!We.mousePickConsumed}static wasMouseButtonPressed(e){return We.mouseButtonsDown.get(e)||!1}static clientToNormalized(e,A){const t=K.canvas.getBoundingClientRect(),n=e-t.left,r=A-t.top;return new GA(n/t.width*2-1,-r/t.height*2+1)}static getMouseDownPositionNormalized(){return We.clientToNormalized(We.mouseDownPosition.x,We.mouseDownPosition.y)}static EndFrame(){We.mouseButtonsUp.set(0,!1),We.mouseButtonsUp.set(1,!1),We.mouseButtonsDown.set(0,!1),We.mouseButtonsDown.set(1,!1),We.keysUp.clear(),We.keysDown.clear(),We.mouseDragDelta.set(0,0),We.mouseScrollDelta.set(0,0)}static updateState(){}static applyState(){const e=1*K.deltaTime,A=K.userData.camera.rotation.y;if(new re(Math.sin(A),0,Math.cos(A)),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),We.GetMouseButton(0)&&!We.consumeDrag&&!ae.NAVIGATION_MARKERS_WHITELIST_MODE&&!ae.NAVIGATION_MARKERS_EDIT_MODE){let t=K.userData.camera.fov/300;K.userData.camera.rotation.x+=We.mouseDragDelta.y*t*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+=We.mouseDragDelta.x*t*.8*yi.DEG2RAD}We.mouseScrollDelta.y!=0&&(K.userData.camera.fov=yi.clamp(K.userData.camera.fov+.1*We.mouseScrollDelta.y,ae.MIN_FOV,ae.MAX_FOV),K.userData.camera.updateProjectionMatrix())}static update(){We.GetMouseButton(0)||(We.mousePickConsumed=!1),this.updateState(),this.applyState()}}function LE(o,e){if(e===0)return o;if(e===2||e===1){let A=o.getIndex();if(A===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),A=o.getIndex()}const t=A.count-2,n=[];if(e===2)for(let g=1;g<=t;g++)n.push(A.getX(0)),n.push(A.getX(g)),n.push(A.getX(g+1));else for(let g=0;g<t;g++)g%2==0?(n.push(A.getX(g)),n.push(A.getX(g+1)),n.push(A.getX(g+2))):(n.push(A.getX(g+2)),n.push(A.getX(g+1)),n.push(A.getX(g)));n.length;const r=o.clone();return r.setIndex(n),r.clearGroups(),r}return o}We.keysState=new Map,We.keysUp=new Map,We.keysDown=new Map,We.mouseButtonsState=new Map,We.mouseButtonsUp=new Map,We.mouseButtonsDown=new Map,We.mousePosition=new GA,We.mouseScrollDelta=new GA,We.mouseDragDelta=new GA,We.mouseDownPosition=new GA,We.mouseUpPosition=new GA,We.mouseDownTime=0,We.mouseUpTime=0,We.maxTapTime=200,We.maxTapMove=5,We.lastTouchPosition=new GA,We.consumeDrag=!1,We.mousePickConsumed=!1;class sI extends Ja{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(A){return new Dx(A)})),this.register((function(A){return new Nx(A)})),this.register((function(A){return new kx(A)})),this.register((function(A){return new Fx(A)})),this.register((function(A){return new Sx(A)})),this.register((function(A){return new xx(A)})),this.register((function(A){return new bx(A)})),this.register((function(A){return new _x(A)})),this.register((function(A){return new vx(A)})),this.register((function(A){return new Rx(A)})),this.register((function(A){return new Mx(A)})),this.register((function(A){return new wx(A)})),this.register((function(A){return new Lx(A)})),this.register((function(A){return new Gx(A)}))}load(e,A,t,n){const r=this;let g;g=this.resourcePath!==""?this.resourcePath:this.path!==""?this.path:tI.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){A(C),r.manager.itemEnd(e)}),h)}catch(C){h(C)}}),t,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,A,t,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))===GE){try{g[Ht.KHR_BINARY_GLTF]=new Hx(e)}catch(C){return void(n&&n(C))}r=JSON.parse(g[Ht.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 $x(r,{path:A||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 E=this.pluginCallbacks[C](c);h[E.name]=E,g[E.name]=!0}if(r.extensionsUsed)for(let C=0;C<r.extensionsUsed.length;++C){const E=r.extensionsUsed[C],p=r.extensionsRequired||[];switch(E){case Ht.KHR_MATERIALS_UNLIT:g[E]=new yx;break;case Ht.KHR_DRACO_MESH_COMPRESSION:g[E]=new Jx(r,this.dracoLoader);break;case Ht.KHR_TEXTURE_TRANSFORM:g[E]=new Yx;break;case Ht.KHR_MESH_QUANTIZATION:g[E]=new Px;break;default:p.indexOf(E)>=0&&h[E]}}c.setExtensions(g),c.setPlugins(h),c.parse(t,n)}parseAsync(e,A){const t=this;return new Promise((function(n,r){t.parse(e,A,n,r)}))}}function mx(){let o={};return{get:function(e){return o[e]},add:function(e,A){o[e]=A},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const Ht={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 wx{constructor(e){this.parser=e,this.name=Ht.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,A=this.parser.json.nodes||[];for(let t=0,n=A.length;t<n;t++){const r=A[t];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 A=this.parser,t="light:"+e;let n=A.cache.get(t);if(n)return n;const r=A.json,g=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let h;const u=new rt(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 NE(u),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new ox(u),h.distance=c;break;case"spot":h=new sx(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,Bs(h,g),g.intensity!==void 0&&(h.intensity=g.intensity),h.name=A.createUniqueName(g.name||"light_"+e),n=Promise.resolve(h),A.cache.add(t,n),n}getDependency(e,A){if(e==="light")return this._loadLight(A)}createNodeAttachment(e){const A=this,t=this.parser,n=t.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then((function(g){return t._getNodeRef(A.cache,r,g)}))}}class yx{constructor(){this.name=Ht.KHR_MATERIALS_UNLIT}getMaterialType(){return Ji}extendParams(e,A,t){const n=[];e.color=new rt(1,1,1),e.opacity=1;const r=A.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(t.assignTexture(e,"map",r.baseColorTexture,ie))}return Promise.all(n)}}class vx{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,A){const t=this.parser.json.materials[e];if(!t.extensions||!t.extensions[this.name])return Promise.resolve();const n=t.extensions[this.name].emissiveStrength;return n!==void 0&&(A.emissiveIntensity=n),Promise.resolve()}}class Dx{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const A=this.parser.json.materials[e];return A.extensions&&A.extensions[this.name]?Ps:null}extendMaterialParams(e,A){const t=this.parser,n=t.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&&(A.clearcoat=g.clearcoatFactor),g.clearcoatTexture!==void 0&&r.push(t.assignTexture(A,"clearcoatMap",g.clearcoatTexture)),g.clearcoatRoughnessFactor!==void 0&&(A.clearcoatRoughness=g.clearcoatRoughnessFactor),g.clearcoatRoughnessTexture!==void 0&&r.push(t.assignTexture(A,"clearcoatRoughnessMap",g.clearcoatRoughnessTexture)),g.clearcoatNormalTexture!==void 0&&(r.push(t.assignTexture(A,"clearcoatNormalMap",g.clearcoatNormalTexture)),g.clearcoatNormalTexture.scale!==void 0)){const h=g.clearcoatNormalTexture.scale;A.clearcoatNormalScale=new GA(h,h)}return Promise.all(r)}}class Mx{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const A=this.parser.json.materials[e];return A.extensions&&A.extensions[this.name]?Ps:null}extendMaterialParams(e,A){const t=this.parser,n=t.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&&(A.iridescence=g.iridescenceFactor),g.iridescenceTexture!==void 0&&r.push(t.assignTexture(A,"iridescenceMap",g.iridescenceTexture)),g.iridescenceIor!==void 0&&(A.iridescenceIOR=g.iridescenceIor),A.iridescenceThicknessRange===void 0&&(A.iridescenceThicknessRange=[100,400]),g.iridescenceThicknessMinimum!==void 0&&(A.iridescenceThicknessRange[0]=g.iridescenceThicknessMinimum),g.iridescenceThicknessMaximum!==void 0&&(A.iridescenceThicknessRange[1]=g.iridescenceThicknessMaximum),g.iridescenceThicknessTexture!==void 0&&r.push(t.assignTexture(A,"iridescenceThicknessMap",g.iridescenceThicknessTexture)),Promise.all(r)}}class Sx{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_SHEEN}getMaterialType(e){const A=this.parser.json.materials[e];return A.extensions&&A.extensions[this.name]?Ps:null}extendMaterialParams(e,A){const t=this.parser,n=t.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];A.sheenColor=new rt(0,0,0),A.sheenRoughness=0,A.sheen=1;const g=n.extensions[this.name];return g.sheenColorFactor!==void 0&&A.sheenColor.fromArray(g.sheenColorFactor),g.sheenRoughnessFactor!==void 0&&(A.sheenRoughness=g.sheenRoughnessFactor),g.sheenColorTexture!==void 0&&r.push(t.assignTexture(A,"sheenColorMap",g.sheenColorTexture,ie)),g.sheenRoughnessTexture!==void 0&&r.push(t.assignTexture(A,"sheenRoughnessMap",g.sheenRoughnessTexture)),Promise.all(r)}}class xx{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const A=this.parser.json.materials[e];return A.extensions&&A.extensions[this.name]?Ps:null}extendMaterialParams(e,A){const t=this.parser,n=t.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&&(A.transmission=g.transmissionFactor),g.transmissionTexture!==void 0&&r.push(t.assignTexture(A,"transmissionMap",g.transmissionTexture)),Promise.all(r)}}class bx{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_VOLUME}getMaterialType(e){const A=this.parser.json.materials[e];return A.extensions&&A.extensions[this.name]?Ps:null}extendMaterialParams(e,A){const t=this.parser,n=t.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],g=n.extensions[this.name];A.thickness=g.thicknessFactor!==void 0?g.thicknessFactor:0,g.thicknessTexture!==void 0&&r.push(t.assignTexture(A,"thicknessMap",g.thicknessTexture)),A.attenuationDistance=g.attenuationDistance||1/0;const h=g.attenuationColor||[1,1,1];return A.attenuationColor=new rt(h[0],h[1],h[2]),Promise.all(r)}}class _x{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_IOR}getMaterialType(e){const A=this.parser.json.materials[e];return A.extensions&&A.extensions[this.name]?Ps:null}extendMaterialParams(e,A){const t=this.parser.json.materials[e];if(!t.extensions||!t.extensions[this.name])return Promise.resolve();const n=t.extensions[this.name];return A.ior=n.ior!==void 0?n.ior:1.5,Promise.resolve()}}class Rx{constructor(e){this.parser=e,this.name=Ht.KHR_MATERIALS_SPECULAR}getMaterialType(e){const A=this.parser.json.materials[e];return A.extensions&&A.extensions[this.name]?Ps:null}extendMaterialParams(e,A){const t=this.parser,n=t.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],g=n.extensions[this.name];A.specularIntensity=g.specularFactor!==void 0?g.specularFactor:1,g.specularTexture!==void 0&&r.push(t.assignTexture(A,"specularIntensityMap",g.specularTexture));const h=g.specularColorFactor||[1,1,1];return A.specularColor=new rt(h[0],h[1],h[2]),g.specularColorTexture!==void 0&&r.push(t.assignTexture(A,"specularColorMap",g.specularColorTexture,ie)),Promise.all(r)}}class Nx{constructor(e){this.parser=e,this.name=Ht.KHR_TEXTURE_BASISU}loadTexture(e){const A=this.parser,t=A.json,n=t.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],g=A.options.ktx2Loader;if(!g){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return A.loadTextureImage(e,r.source,g)}}class kx{constructor(e){this.parser=e,this.name=Ht.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const A=this.name,t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[A])return null;const g=r.extensions[A],h=n.images[g.source];let u=t.textureLoader;if(h.uri){const c=t.options.manager.getHandler(h.uri);c!==null&&(u=c)}return this.detectSupport().then((function(c){if(c)return t.loadTextureImage(e,g.source,u);if(n.extensionsRequired&&n.extensionsRequired.indexOf(A)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return t.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const A=new Image;A.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",A.onload=A.onerror=function(){e(A.height===1)}}))),this.isSupported}}class Fx{constructor(e){this.parser=e,this.name=Ht.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const A=this.name,t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[A])return null;const g=r.extensions[A],h=n.images[g.source];let u=t.textureLoader;if(h.uri){const c=t.options.manager.getHandler(h.uri);c!==null&&(u=c)}return this.detectSupport().then((function(c){if(c)return t.loadTextureImage(e,g.source,u);if(n.extensionsRequired&&n.extensionsRequired.indexOf(A)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return t.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const A=new Image;A.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",A.onload=A.onerror=function(){e(A.height===1)}}))),this.isSupported}}class Lx{constructor(e){this.name=Ht.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const A=this.parser.json,t=A.bufferViews[e];if(t.extensions&&t.extensions[this.name]){const n=t.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),g=this.parser.options.meshoptDecoder;if(!g||!g.supported){if(A.extensionsRequired&&A.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,E=n.byteStride,p=new Uint8Array(h,u,c);return g.decodeGltfBufferAsync?g.decodeGltfBufferAsync(C,E,p,n.mode,n.filter).then((function(w){return w.buffer})):g.ready.then((function(){const w=new ArrayBuffer(C*E);return g.decodeGltfBuffer(new Uint8Array(w),C,E,p,n.mode,n.filter),w}))}))}return null}}class Gx{constructor(e){this.name=Ht.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const A=this.parser.json,t=A.nodes[e];if(!t.extensions||!t.extensions[this.name]||t.mesh===void 0)return null;const n=A.meshes[t.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=t.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],E=u[0].count,p=[];for(const w of C){const k=new xt,R=new re,_=new Ui,N=new re(1,1,1),L=new KS(w.geometry,w.material,E);for(let G=0;G<E;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 GE="glTF",Ux=1313821514,Tx=5130562;class Hx{constructor(e){this.name=Ht.KHR_BINARY_GLTF,this.content=null,this.body=null;const A=new DataView(e,0,12),t=new TextDecoder;if(this.header={magic:t.decode(new Uint8Array(e.slice(0,4))),version:A.getUint32(4,!0),length:A.getUint32(8,!0)},this.header.magic!==GE)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===Ux){const c=new Uint8Array(e,12+g,h);this.content=t.decode(c)}else if(u===Tx){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 Jx{constructor(e,A){if(!A)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Ht.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=A,this.dracoLoader.preload()}decodePrimitive(e,A){const t=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 E=oI[C]||C.toLowerCase();h[E]=g[C]}for(const C in e.attributes){const E=oI[C]||C.toLowerCase();if(g[C]!==void 0){const p=t.accessors[e.attributes[C]],w=Pa[p.componentType];c[E]=w.name,u[E]=p.normalized===!0}}return A.getDependency("bufferView",r).then((function(C){return new Promise((function(E){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)}E(p)}),h,c)}))}))}}class Yx{constructor(){this.name=Ht.KHR_TEXTURE_TRANSFORM}extendTexture(e,A){return(A.texCoord!==void 0&&A.texCoord!==e.channel||A.offset!==void 0||A.rotation!==void 0||A.scale!==void 0)&&(e=e.clone(),A.texCoord!==void 0&&(e.channel=A.texCoord),A.offset!==void 0&&e.offset.fromArray(A.offset),A.rotation!==void 0&&(e.rotation=A.rotation),A.scale!==void 0&&e.repeat.fromArray(A.scale),e.needsUpdate=!0),e}}class Px{constructor(){this.name=Ht.KHR_MESH_QUANTIZATION}}class UE extends zo{constructor(e,A,t,n){super(e,A,t,n)}copySampleValue_(e){const A=this.resultBuffer,t=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let g=0;g!==n;g++)A[g]=t[r+g];return A}interpolate_(e,A,t,n){const r=this.resultBuffer,g=this.sampleValues,h=this.valueSize,u=2*h,c=3*h,C=n-A,E=(t-A)/C,p=E*E,w=p*E,k=e*c,R=k-c,_=-2*w+3*p,N=w-p,L=1-_,G=N-p+E;for(let le=0;le!==h;le++){const ne=g[R+le+h],te=g[R+le+u]*C,Ae=g[k+le+h],ye=g[k+le]*C;r[le]=L*ne+G*te+_*Ae+N*ye}return r}}const Ox=new Ui;class Kx extends UE{interpolate_(e,A,t,n){const r=super.interpolate_(e,A,t,n);return Ox.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},TE={9728:Ee,9729:Qe,9984:qe,9985:AA,9986:me,9987:se},HE={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"},zx={CUBICSPLINE:void 0,LINEAR:Oe,STEP:Ue},qx="OPAQUE",Vx="MASK",Wx="BLEND";function jo(o,e,A){for(const t in A.extensions)o[t]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[t]=A.extensions[t])}function Bs(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):e.extras)}function Zx(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let A=0,t=e.weights.length;A<t;A++)o.morphTargetInfluences[A]=e.weights[A];if(e.extras&&Array.isArray(e.extras.targetNames)){const A=e.extras.targetNames;if(o.morphTargetInfluences.length===A.length){o.morphTargetDictionary={};for(let t=0,n=A.length;t<n;t++)o.morphTargetDictionary[A[t]]=t}}}function jx(o){const e=o.extensions&&o.extensions[Ht.KHR_DRACO_MESH_COMPRESSION];let A;return A=e?"draco:"+e.bufferView+":"+e.indices+":"+JE(e.attributes):o.indices+":"+JE(o.attributes)+":"+o.mode,A}function JE(o){let e="";const A=Object.keys(o).sort();for(let t=0,n=A.length;t<n;t++)e+=A[t]+":"+o[A[t]]+";";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 Xx=new xt;class $x{constructor(e={},A={}){this.json=e,this.extensions={},this.plugins={},this.options=A,this.cache=new mx,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 t=!1,n=!1,r=-1;typeof navigator<"u"&&(t=/^((?!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"||t||n&&r<98?this.textureLoader=new Ya(this.options.manager):this.textureLoader=new cx(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,A){const t=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([t.getDependencies("scene"),t.getDependencies("animation"),t.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:t,userData:{}};jo(r,h,n),Bs(h,n),Promise.all(t._invokeAll((function(u){return u.afterRoot&&u.afterRoot(h)}))).then((function(){e(h)}))})).catch(A)}_markDefs(){const e=this.json.nodes||[],A=this.json.skins||[],t=this.json.meshes||[];for(let n=0,r=A.length;n<r;n++){const g=A[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&&(t[g.mesh].isSkinnedMesh=!0)),g.camera!==void 0&&this._addNodeRef(this.cameraCache,g.camera)}}_addNodeRef(e,A){A!==void 0&&(e.refs[A]===void 0&&(e.refs[A]=e.uses[A]=0),e.refs[A]++)}_getNodeRef(e,A,t){if(e.refs[A]<=1)return t;const n=t.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(t,n),n.name+="_instance_"+e.uses[A]++,n}_invokeOne(e){const A=Object.values(this.plugins);A.push(this);for(let t=0;t<A.length;t++){const n=e(A[t]);if(n)return n}return null}_invokeAll(e){const A=Object.values(this.plugins);A.unshift(this);const t=[];for(let n=0;n<A.length;n++){const r=e(A[n]);r&&t.push(r)}return t}getDependency(e,A){const t=e+":"+A;let n=this.cache.get(t);if(!n){switch(e){case"scene":n=this.loadScene(A);break;case"node":n=this._invokeOne((function(r){return r.loadNode&&r.loadNode(A)}));break;case"mesh":n=this._invokeOne((function(r){return r.loadMesh&&r.loadMesh(A)}));break;case"accessor":n=this.loadAccessor(A);break;case"bufferView":n=this._invokeOne((function(r){return r.loadBufferView&&r.loadBufferView(A)}));break;case"buffer":n=this.loadBuffer(A);break;case"material":n=this._invokeOne((function(r){return r.loadMaterial&&r.loadMaterial(A)}));break;case"texture":n=this._invokeOne((function(r){return r.loadTexture&&r.loadTexture(A)}));break;case"skin":n=this.loadSkin(A);break;case"animation":n=this._invokeOne((function(r){return r.loadAnimation&&r.loadAnimation(A)}));break;case"camera":n=this.loadCamera(A);break;default:if(n=this._invokeOne((function(r){return r!=this&&r.getDependency&&r.getDependency(e,A)})),!n)throw new Error("Unknown type: "+e)}this.cache.add(t,n)}return n}getDependencies(e){let A=this.cache.get(e);if(!A){const t=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];A=Promise.all(n.map((function(r,g){return t.getDependency(e,g)}))),this.cache.add(e,A)}return A}loadBuffer(e){const A=this.json.buffers[e],t=this.fileLoader;if(A.type&&A.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+A.type+" buffer type is not supported.");if(A.uri===void 0&&e===0)return Promise.resolve(this.extensions[Ht.KHR_BINARY_GLTF].body);const n=this.options;return new Promise((function(r,g){t.load(tI.resolveURL(A.uri,n.path),r,void 0,(function(){g(new Error('THREE.GLTFLoader: Failed to load buffer "'+A.uri+'".'))}))}))}loadBufferView(e){const A=this.json.bufferViews[e];return this.getDependency("buffer",A.buffer).then((function(t){const n=A.byteLength||0,r=A.byteOffset||0;return t.slice(r,r+n)}))}loadAccessor(e){const A=this,t=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 Wi(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,E=C*u,p=n.byteOffset||0,w=n.bufferView!==void 0?t.bufferViews[n.bufferView].byteStride:void 0,k=n.normalized===!0;let R,_;if(w&&w!==E){const N=Math.floor(p/w),L="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+N+":"+n.count;let G=A.cache.get(L);G||(R=new c(h,N*w,n.count*w/C),G=new AE(R,w/C),A.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 Wi(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),te=new c(g[2],le,n.sparse.count*u);h!==null&&(_=new Wi(_.array.slice(),_.itemSize,_.normalized));for(let Ae=0,ye=ne.length;Ae<ye;Ae++){const ge=ne[Ae];if(_.setX(ge,te[Ae*u]),u>=2&&_.setY(ge,te[Ae*u+1]),u>=3&&_.setZ(ge,te[Ae*u+2]),u>=4&&_.setW(ge,te[Ae*u+3]),u>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return _}))}loadTexture(e){const A=this.json,t=this.options,n=A.textures[e].source,r=A.images[n];let g=this.textureLoader;if(r.uri){const h=t.manager.getHandler(r.uri);h!==null&&(g=h)}return this.loadTextureImage(e,n,g)}loadTextureImage(e,A,t){const n=this,r=this.json,g=r.textures[e],h=r.images[A],u=(h.uri||h.bufferView)+":"+g.sampler;if(this.textureCache[u])return this.textureCache[u];const c=this.loadImageSource(A,t).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 E=(r.samplers||{})[g.sampler]||{};return C.magFilter=TE[E.magFilter]||Qe,C.minFilter=TE[E.minFilter]||se,C.wrapS=HE[E.wrapS]||Ce,C.wrapT=HE[E.wrapT]||Ce,n.associations.set(C,{textures:e}),C})).catch((function(){return null}));return this.textureCache[u]=c,c}loadImageSource(e,A){const t=this,n=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then((E=>E.clone()));const g=n.images[e],h=self.URL||self.webkitURL;let u=g.uri||"",c=!1;if(g.bufferView!==void 0)u=t.getDependency("bufferView",g.bufferView).then((function(E){c=!0;const p=new Blob([E],{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(E){return new Promise((function(p,w){let k=p;A.isImageBitmapLoader===!0&&(k=function(R){const _=new Di(R);_.needsUpdate=!0,p(_)}),A.load(tI.resolveURL(E,r.path),k,void 0,w)}))})).then((function(E){var p;return c===!0&&h.revokeObjectURL(u),E.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"),E})).catch((function(E){throw E}));return this.sourceCache[e]=C,C}assignTexture(e,A,t,n){const r=this;return this.getDependency("texture",t.index).then((function(g){if(!g)return null;if(t.texCoord!==void 0&&t.texCoord>0&&((g=g.clone()).channel=t.texCoord),r.extensions[Ht.KHR_TEXTURE_TRANSFORM]){const h=t.extensions!==void 0?t.extensions[Ht.KHR_TEXTURE_TRANSFORM]:void 0;if(h){const u=r.associations.get(g);g=r.extensions[Ht.KHR_TEXTURE_TRANSFORM].extendTexture(g,h),r.associations.set(g,u)}}return n!==void 0&&(g.colorSpace=n),e[A]=g,g}))}assignFinalMaterial(e){const A=e.geometry;let t=e.material;const n=A.attributes.tangent===void 0,r=A.attributes.color!==void 0,g=A.attributes.normal===void 0;if(e.isPoints){const h="PointsMaterial:"+t.uuid;let u=this.cache.get(h);u||(u=new pE,Sn.prototype.copy.call(u,t),u.color.copy(t.color),u.map=t.map,u.sizeAttenuation=!1,this.cache.add(h,u)),t=u}else if(e.isLine){const h="LineBasicMaterial:"+t.uuid;let u=this.cache.get(h);u||(u=new CE,Sn.prototype.copy.call(u,t),u.color.copy(t.color),u.map=t.map,this.cache.add(h,u)),t=u}if(n||r||g){let h="ClonedMaterial:"+t.uuid+":";n&&(h+="derivative-tangents:"),r&&(h+="vertex-colors:"),g&&(h+="flat-shading:");let u=this.cache.get(h);u||(u=t.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(t))),t=u}e.material=t}getMaterialType(){return Ys}loadMaterial(e){const A=this,t=this.json,n=this.extensions,r=t.materials[e];let g;const h={},u=[];if((r.extensions||{})[Ht.KHR_MATERIALS_UNLIT]){const C=n[Ht.KHR_MATERIALS_UNLIT];g=C.getMaterialType(),u.push(C.extendParams(h,r,A))}else{const C=r.pbrMetallicRoughness||{};if(h.color=new rt(1,1,1),h.opacity=1,Array.isArray(C.baseColorFactor)){const E=C.baseColorFactor;h.color.fromArray(E),h.opacity=E[3]}C.baseColorTexture!==void 0&&u.push(A.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(A.assignTexture(h,"metalnessMap",C.metallicRoughnessTexture)),u.push(A.assignTexture(h,"roughnessMap",C.metallicRoughnessTexture))),g=this._invokeOne((function(E){return E.getMaterialType&&E.getMaterialType(e)})),u.push(Promise.all(this._invokeAll((function(E){return E.extendMaterialParams&&E.extendMaterialParams(e,h)}))))}r.doubleSided===!0&&(h.side=2);const c=r.alphaMode||qx;if(c===Wx?(h.transparent=!0,h.depthWrite=!1):(h.transparent=!1,c===Vx&&(h.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&g!==Ji&&(u.push(A.assignTexture(h,"normalMap",r.normalTexture)),h.normalScale=new GA(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(A.assignTexture(h,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(h.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&g!==Ji&&(h.emissive=new rt().fromArray(r.emissiveFactor)),r.emissiveTexture!==void 0&&g!==Ji&&u.push(A.assignTexture(h,"emissiveMap",r.emissiveTexture,ie)),Promise.all(u).then((function(){const C=new g(h);return r.name&&(C.name=r.name),Bs(C,r),A.associations.set(C,{materials:e}),r.extensions&&jo(n,C,r),C}))}createUniqueName(e){const A=Zt.sanitizeNodeName(e||"");let t=A;for(let n=1;this.nodeNamesUsed[t];++n)t=A+"_"+n;return this.nodeNamesUsed[t]=!0,t}loadGeometries(e){const A=this,t=this.extensions,n=this.primitiveCache;function r(h){return t[Ht.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(h,A).then((function(u){return YE(u,h,A)}))}const g=[];for(let h=0,u=e.length;h<u;h++){const c=e[h],C=jx(c),E=n[C];if(E)g.push(E.promise);else{let p;p=c.extensions&&c.extensions[Ht.KHR_DRACO_MESH_COMPRESSION]?r(c):YE(new bn,c,A),n[C]={primitive:c,promise:p},g.push(p)}}return Promise.all(g)}loadMesh(e){const A=this,t=this.json,n=this.extensions,r=t.meshes[e],g=r.primitives,h=[];for(let c=0,C=g.length;c<C;c++){const E=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(E)}var u;return h.push(A.loadGeometries(g)),Promise.all(h).then((function(c){const C=c.slice(0,c.length-1),E=c[c.length-1],p=[];for(let k=0,R=E.length;k<R;k++){const _=E[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 YS(_,G):new Ut(_,G),L.isSkinnedMesh===!0&&L.normalizeSkinWeights(),N.mode===Yn.TRIANGLE_STRIP?L.geometry=LE(L.geometry,1):N.mode===Yn.TRIANGLE_FAN&&(L.geometry=LE(L.geometry,2));else if(N.mode===Yn.LINES)L=new zS(_,G);else if(N.mode===Yn.LINE_STRIP)L=new Wh(_,G);else if(N.mode===Yn.LINE_LOOP)L=new qS(_,G);else{if(N.mode!==Yn.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+N.mode);L=new VS(_,G)}Object.keys(L.geometry.morphAttributes).length>0&&Zx(L,r),L.name=A.createUniqueName(r.name||"mesh_"+e),Bs(L,r),N.extensions&&jo(n,L,N),A.assignFinalMaterial(L),p.push(L)}for(let k=0,R=p.length;k<R;k++)A.associations.set(p[k],{meshes:e,primitives:k});if(p.length===1)return p[0];const w=new Js;A.associations.set(w,{meshes:e});for(let k=0,R=p.length;k<R;k++)w.add(p[k]);return w}))}loadCamera(e){let A;const t=this.json.cameras[e],n=t[t.type];if(n)return t.type==="perspective"?A=new Zi(yi.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):t.type==="orthographic"&&(A=new _n(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),t.name&&(A.name=this.createUniqueName(t.name)),Bs(A,t),Promise.resolve(A)}loadSkin(e){const A=this.json.skins[e],t=[];for(let n=0,r=A.joints.length;n<r;n++)t.push(this._loadNodeShallow(A.joints[n]));return A.inverseBindMatrices!==void 0?t.push(this.getDependency("accessor",A.inverseBindMatrices)):t.push(null),Promise.all(t).then((function(n){const r=n.pop(),g=n,h=[],u=[];for(let c=0,C=g.length;c<C;c++){const E=g[c];if(E){h.push(E);const p=new xt;r!==null&&p.fromArray(r.array,16*c),u.push(p)}else A.joints[c]}return new qh(h,u)}))}loadAnimation(e){const A=this.json.animations[e],t=A.name?A.name:"animation_"+e,n=[],r=[],g=[],h=[],u=[];for(let c=0,C=A.channels.length;c<C;c++){const E=A.channels[c],p=A.samplers[E.sampler],w=E.target,k=w.node,R=A.parameters!==void 0?A.parameters[p.input]:p.input,_=A.parameters!==void 0?A.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],E=c[1],p=c[2],w=c[3],k=c[4],R=[];for(let _=0,N=C.length;_<N;_++){const L=C[_],G=E[_],le=p[_],ne=w[_],te=k[_];if(L===void 0)continue;let Ae;switch(L.updateMatrix(),Oa[te.path]){case Oa.weights:Ae=qo;break;case Oa.rotation:Ae=Os;break;default:Ae=Vo}const ye=L.name?L.name:L.uuid,ge=ne.interpolation!==void 0?zx[ne.interpolation]:Oe,Me=[];Oa[te.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),CA=new Float32Array(pe.length);for(let QA=0,VA=pe.length;QA<VA;QA++)CA[QA]=pe[QA]*Ze;pe=CA}for(let Ze=0,CA=Me.length;Ze<CA;Ze++){const QA=new Ae(Me[Ze]+"."+Oa[te.path],G.array,pe,ge);ne.interpolation==="CUBICSPLINE"&&(QA.createInterpolant=function(VA){return new(this instanceof Os?Kx:UE)(this.times,this.values,this.getValueSize()/3,VA)},QA.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),R.push(QA)}}return new jh(t,void 0,R)}))}createNodeMesh(e){const A=this.json,t=this,n=A.nodes[e];return n.mesh===void 0?null:t.getDependency("mesh",n.mesh).then((function(r){const g=t._getNodeRef(t.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 A=this,t=this.json.nodes[e],n=A._loadNodeShallow(e),r=[],g=t.children||[];for(let u=0,c=g.length;u<c;u++)r.push(A.getDependency("node",g[u]));const h=t.skin===void 0?Promise.resolve(null):A.getDependency("skin",t.skin);return Promise.all([n,Promise.all(r),h]).then((function(u){const c=u[0],C=u[1],E=u[2];E!==null&&c.traverse((function(p){p.isSkinnedMesh&&p.bind(E,Xx)}));for(let p=0,w=C.length;p<w;p++)c.add(C[p]);return c}))}_loadNodeShallow(e){const A=this.json,t=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=A.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 lE:c.length>1?new Js:c.length===1?c[0]:new gi,C!==c[0])for(let E=0,p=c.length;E<p;E++)C.add(c[E]);if(r.name&&(C.userData.name=r.name,C.name=g),Bs(C,r),r.extensions&&jo(t,C,r),r.matrix!==void 0){const E=new xt;E.fromArray(r.matrix),C.applyMatrix4(E)}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 A=this.extensions,t=this.json.scenes[e],n=this,r=new Js;t.name&&(r.name=n.createUniqueName(t.name)),Bs(r,t),t.extensions&&jo(A,r,t);const g=t.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[E,p]of n.associations)(E instanceof Sn||E instanceof Di)&&C.set(E,p);return c.traverse((E=>{const p=n.associations.get(E);p!=null&&C.set(E,p)})),C})(r),r}))}}function YE(o,e,A){const t=e.attributes,n=[];function r(g,h){return A.getDependency("accessor",g).then((function(u){o.setAttribute(h,u)}))}for(const g in t){const h=oI[g]||g.toLowerCase();h in o.attributes||n.push(r(t[g],h))}if(e.indices!==void 0&&!o.index){const g=A.getDependency("accessor",e.indices).then((function(h){o.setIndex(h)}));n.push(g)}return Bs(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 E=h.targets;if(E!==void 0){const w=new re,k=new re;for(let R=0,_=E.length;R<_;R++){const N=E[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,A),Promise.all(n).then((function(){return e.targets!==void 0?(function(g,h,u){let c=!1,C=!1,E=!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&&(E=!0),c&&C&&E)break}if(!c&&!C&&!E)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(E){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),E&&(g.morphAttributes.color=L),g.morphTargetsRelative=!0,g}))})(o,e.targets,A):o}))}var lI=function(o,e,A,t){return new(A||(A=Promise))((function(n,r){function g(c){try{u(t.next(c))}catch(C){r(C)}}function h(c){try{u(t.throw(c))}catch(C){r(C)}}function u(c){var C;c.done?n(c.value):(C=c.value,C instanceof A?C:new A((function(E){E(C)}))).then(g,h)}u((t=t.apply(o,[])).next())}))};class eb{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(((A,t)=>{this.loader.load(e,(n=>{this.modelCache.set(e,n.scene),A(n)}),void 0,t)}))).scene}))}loadTexture(e,A=!1){return lI(this,void 0,void 0,(function*(){if(this.textureCache.has(e))return this.textureCache.get(e);{let t=yield new Promise(((n,r)=>{new Ya().load(e,n,void 0,r)}));return A&&(t.minFilter=Ee,t.magFilter=Ee),this.textureCache.set(e,t),t}}))}loadTexturedPlaneModel(e,A,t=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}:${t.x.toFixed(2)},${t.y.toFixed(2)},${t.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);A instanceof ti?A.uniforms.map.value=u:A instanceof Ji&&(A.map=u),c.applyMatrix4(new xt().makeRotationX(-Math.PI/2).multiply(new xt().makeScale(n.x,n.y,n.z))),c.applyMatrix4(new xt().makeTranslation(t.x,t.y,t.z)),g=new Ut(c,A),this.modelCache.set(h,g)}return g.clone()}))}dispose(){this.modelCache.forEach((e=>{e.traverse((A=>{if(A.isMesh){const t=A;t.geometry.dispose(),Array.isArray(t.material)?t.material.forEach((n=>{n instanceof Sn&&n.dispose()})):t.material instanceof Sn&&t.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 A=e%360;return A>180?A-=360:A<-180&&(A+=360),A}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)}}function PE(o){return!!o&&Object.keys(o).length>0}function Ab(o){const{model:e,homePosition:A,sourceEye:t,offsets:n,targetId:r}=o;if(!PE(n))return void e.position.copy(A);const g=(function(h){if(!h)return null;const u=h.split(",").map(Number);return u.length!==3||u.some((c=>!Number.isFinite(c)))?null:new re(u[0],u[1],u[2])})(n[r]);g?e.position.set(t.x+g.x,A.y,t.z+g.z):e.position.copy(A)}function cI(o,e){o.position.copy(e)}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),this.markerOffsets=(function(A){if(!A||typeof A!="object"||Array.isArray(A))return;const t={};for(const[n,r]of Object.entries(A))typeof r=="string"&&r.trim()&&(t[n]=r);return Object.keys(t).length>0?t:void 0})(e.markerOffsets)}static hasWhitelist(e){var A;return!!(!((A=e?.whitelist)===null||A===void 0)&&A.length)}static parseWhitelist(e){return Array.isArray(e.whitelist)?e.whitelist.filter((A=>typeof A=="string")):Array.isArray(e.overrides)?e.overrides.filter((A=>A?.display&&A.cameraId)).map((A=>A.cameraId)):[]}toggleWhitelistMarker(e){this.whitelist||(this.whitelist=[]);const A=this.whitelist.indexOf(e);return A>=0?(this.whitelist.splice(A,1),!1):(this.whitelist.push(e),!0)}removeWhitelistMarker(e){var A;!((A=this.whitelist)===null||A===void 0)&&A.length&&(this.whitelist=this.whitelist.filter((t=>t!==e)))}clearWhitelist(){this.whitelist=[]}mergeWhitelist(e){this.whitelist||(this.whitelist=[]);const A=new Set(this.whitelist);for(const t of e)A.has(t)||(this.whitelist.push(t),A.add(t))}toVector3(e){const A=e.split(",").map(Number);return new re(A[0],A[1],A[2])}}class Ks{constructor(e){var A,t;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=(A=e.sourceCameraId)!==null&&A!==void 0?A:"";const n=(t=e.position)!==null&&t!==void 0?t: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,A){return A==="up"?e+1:e-1}static isValidTargetFloor(e,A,t){return t===Ks.expectedTargetFloorLevel(e,A)}}class tb{constructor(e){this.id=e.id;const A=e.position.split(",").map(Number);this.position=new re(A[0],A[1],A[2]);const t=e.rotation?e.rotation.split(",").map(Number):[0,0,0];this.rotation=new Mn(t[0],t[1],t[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 ib=function(o,e,A,t){return new(A||(A=Promise))((function(n,r){function g(c){try{u(t.next(c))}catch(C){r(C)}}function h(c){try{u(t.throw(c))}catch(C){r(C)}}function u(c){var C;c.done?n(c.value):(C=c.value,C instanceof A?C:new A((function(E){E(C)}))).then(g,h)}u((t=t.apply(o,[])).next())}))};class hI{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((A=>new Xo(A))),Array.isArray(e.floorTransitions)?this.floorTransitions=e.floorTransitions.map((A=>new Ks(A))):this.floorTransitions=[],e.hasOwnProperty("interactiveObjects")&&Array.isArray(e.interactiveObjects)?this.interactiveObjects=e.interactiveObjects.map((A=>new tb(A))):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 ib(this,void 0,void 0,(function*(){try{const A=yield K.fetch(e),t=yield A.json();return new hI(t)}catch(A){throw A}}))}}class OE{constructor(){this.needMaterialUpdate=!0,this.layers=[]}addLayer(e){this.layers.push(e),this.needMaterialUpdate=!0}removeLayer(e){const A=this.layers.indexOf(e);A!==-1&&this.layers.splice(A,1),this.needMaterialUpdate=!0}getActiveLayersCount(){let e=0;for(let A=0;A<this.layers.length;A++)this.layers[A].isActive&&e++;return e}clearLayers(){this.layers=[],this.needMaterialUpdate=!0}}class nb{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 Ut(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 ti({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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qispace/vue3-player",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.64",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"config": {
|
|
6
6
|
"tag-version-prefix": "v"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"release:patch": "git pull && npm version patch && git push && git push --tags"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@qispace/player-core": "^1.0.
|
|
47
|
+
"@qispace/player-core": "^1.0.118",
|
|
48
48
|
"@qispace/visuado-player-core": "^0.0.17",
|
|
49
49
|
"axios": "^1.6.7",
|
|
50
50
|
"three": "^0.163.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@mdi/font": "^7.4.47",
|
|
56
|
-
"@qispace/player-core": "^1.0.
|
|
56
|
+
"@qispace/player-core": "^1.0.118",
|
|
57
57
|
"@qispace/visuado-player-core": "^0.0.17",
|
|
58
58
|
"@types/node": "^20.11.19",
|
|
59
59
|
"@vitejs/plugin-vue": "^6.0.0",
|