@needle-tools/engine 4.1.0-alpha.12 → 4.1.0-alpha.13
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.
- package/CHANGELOG.md +3 -0
- package/dist/needle-engine.bundle.js +8 -8
- package/dist/needle-engine.bundle.light.js +8 -8
- package/dist/needle-engine.bundle.light.min.js +2 -2
- package/dist/needle-engine.bundle.light.umd.cjs +2 -2
- package/dist/needle-engine.bundle.min.js +2 -2
- package/dist/needle-engine.bundle.umd.cjs +2 -2
- package/dist/three.js +497 -497
- package/dist/three.light.js +497 -497
- package/dist/three.light.min.js +1 -1
- package/dist/three.light.umd.cjs +11 -11
- package/dist/three.min.js +1 -1
- package/dist/three.umd.cjs +11 -11
- package/dist/vendor.js +1317 -1319
- package/dist/vendor.light.js +1317 -1319
- package/dist/vendor.light.min.js +33 -33
- package/dist/vendor.light.umd.cjs +33 -33
- package/dist/vendor.min.js +33 -33
- package/dist/vendor.umd.cjs +33 -33
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/package.json +2 -2
- package/src/engine/codegen/register_types.ts +2 -2
- package/src/engine/xr/NeedleXRSession.ts +1 -1
package/dist/three.light.min.js
CHANGED
|
@@ -3844,7 +3844,7 @@ void main() {
|
|
|
3844
3844
|
|
|
3845
3845
|
}
|
|
3846
3846
|
|
|
3847
|
-
}`;class VR{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const r=new Wt,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Pr({vertexShader:OR,fragmentShader:FR,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ft(new pa(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class BR extends gr{constructor(e,t){super();const i=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,u=null,h=null,d=null,p=null,m=null;const v=new VR,f=t.getContextAttributes();let g=null,x=null;const y=[],_=[],I=new J;let b=null;const w=new di;w.layers.enable(1),w.viewport=new st;const C=new di;C.layers.enable(2),C.viewport=new st;const H=[w,C],M=new $p;M.layers.enable(1),M.layers.enable(2);let T=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(ie){let le=y[ie];return le===void 0&&(le=new Jp,y[ie]=le),le.getTargetRaySpace()},this.getControllerGrip=function(ie){let le=y[ie];return le===void 0&&(le=new Jp,y[ie]=le),le.getGripSpace()},this.getHand=function(ie){let le=y[ie];return le===void 0&&(le=new Jp,y[ie]=le),le.getHandSpace()};function j(ie){const le=_.indexOf(ie.inputSource);if(le===-1)return;const Te=y[le];Te!==void 0&&(Te.update(ie.inputSource,ie.frame,c||a),Te.dispatchEvent({type:ie.type,data:ie.inputSource}))}function Y(){r.removeEventListener("select",j),r.removeEventListener("selectstart",j),r.removeEventListener("selectend",j),r.removeEventListener("squeeze",j),r.removeEventListener("squeezestart",j),r.removeEventListener("squeezeend",j),r.removeEventListener("end",Y),r.removeEventListener("inputsourceschange",re);for(let ie=0;ie<y.length;ie++){const le=_[ie];le!==null&&(_[ie]=null,y[ie]&&y[ie].disconnect(le))}T=null,k=null,v.reset(),e.setRenderTarget(g),p=null,d=null,h=null,r=null,x=null,et.stop(),i.isPresenting=!1,e.setPixelRatio(b),e.setSize(I.width,I.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ie){s=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ie){o=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(ie){c=ie},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return h},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(ie){if(r=ie,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",j),r.addEventListener("selectstart",j),r.addEventListener("selectend",j),r.addEventListener("squeeze",j),r.addEventListener("squeezestart",j),r.addEventListener("squeezeend",j),r.addEventListener("end",Y),r.addEventListener("inputsourceschange",re),f.xrCompatible!==!0&&await t.makeXRCompatible(),b=e.getPixelRatio(),e.getSize(I),r.renderState.layers===void 0){const le={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,le),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),x=new Ir(p.framebufferWidth,p.framebufferHeight,{format:Ei,type:Wr,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}else{let le=null,Te=null,Se=null;f.depth&&(Se=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,le=f.stencil?qn:Xn,Te=f.stencil?jn:Nr);const Ye={colorFormat:t.RGBA8,depthFormat:Se,scaleFactor:s};h=new XRWebGLBinding(r,t),d=h.createProjectionLayer(Ye),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),x=new Ir(d.textureWidth,d.textureHeight,{format:Ei,type:Wr,depthTexture:new Fs(d.textureWidth,d.textureHeight,Te,void 0,void 0,void 0,void 0,void 0,void 0,le),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),et.setContext(r),et.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function re(ie){for(let le=0;le<ie.removed.length;le++){const Te=ie.removed[le],Se=_.indexOf(Te);Se>=0&&(_[Se]=null,y[Se]&&y[Se].disconnect(Te))}for(let le=0;le<ie.added.length;le++){const Te=ie.added[le];let Se=_.indexOf(Te);if(Se===-1){for(let We=0;We<y.length;We++)if(We>=_.length){_.push(Te),Se=We;break}else if(_[We]===null){_[We]=Te,Se=We;break}if(Se===-1)break}const Ye=y[Se];Ye&&Ye.connect(Te)}}const $=new N,he=new N;function Q(ie,le,Te){$.setFromMatrixPosition(le.matrixWorld),he.setFromMatrixPosition(Te.matrixWorld);const Se=$.distanceTo(he),Ye=le.projectionMatrix.elements,We=Te.projectionMatrix.elements,ot=Ye[14]/(Ye[10]-1),ce=Ye[14]/(Ye[10]+1),ue=(Ye[9]+1)/Ye[5],L=(Ye[9]-1)/Ye[5],He=(Ye[8]-1)/Ye[0],pe=(We[8]+1)/We[0],Ue=ot*He,we=ot*pe,$e=Se/(-He+pe),Be=$e*-He;if(le.matrixWorld.decompose(ie.position,ie.quaternion,ie.scale),ie.translateX(Be),ie.translateZ($e),ie.matrixWorld.compose(ie.position,ie.quaternion,ie.scale),ie.matrixWorldInverse.copy(ie.matrixWorld).invert(),Ye[10]===-1)ie.projectionMatrix.copy(le.projectionMatrix),ie.projectionMatrixInverse.copy(le.projectionMatrixInverse);else{const R=ot+$e,S=ce+$e,W=Ue-Be,ne=we+(Se-Be),de=ue*ce/S*R,se=L*ce/S*R;ie.projectionMatrix.makePerspective(W,ne,de,se,R,S),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert()}}function ye(ie,le){le===null?ie.matrixWorld.copy(ie.matrix):ie.matrixWorld.multiplyMatrices(le.matrixWorld,ie.matrix),ie.matrixWorldInverse.copy(ie.matrixWorld).invert()}this.updateCamera=function(ie){if(r===null)return;let le=ie.near,Te=ie.far;v.texture!==null&&(v.depthNear>0&&(le=v.depthNear),v.depthFar>0&&(Te=v.depthFar)),M.near=C.near=w.near=le,M.far=C.far=w.far=Te,(T!==M.near||k!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),T=M.near,k=M.far);const Se=ie.parent,Ye=M.cameras;ye(M,Se);for(let We=0;We<Ye.length;We++)ye(Ye[We],Se);Ye.length===2?Q(M,w,C):M.projectionMatrix.copy(w.projectionMatrix),be(ie,M,Se)};function be(ie,le,Te){Te===null?ie.matrix.copy(le.matrixWorld):(ie.matrix.copy(Te.matrixWorld),ie.matrix.invert(),ie.matrix.multiply(le.matrixWorld)),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.updateMatrixWorld(!0),ie.projectionMatrix.copy(le.projectionMatrix),ie.projectionMatrixInverse.copy(le.projectionMatrixInverse),ie.isPerspectiveCamera&&(ie.fov=Ea*2*Math.atan(1/ie.projectionMatrix.elements[5]),ie.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(ie){l=ie,d!==null&&(d.fixedFoveation=ie),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ie)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(M)};let Ve=null;function at(ie,le){if(u=le.getViewerPose(c||a),m=le,u!==null){const Te=u.views;p!==null&&(e.setRenderTargetFramebuffer(x,p.framebuffer),e.setRenderTarget(x));let Se=!1;Te.length!==M.cameras.length&&(M.cameras.length=0,Se=!0);for(let We=0;We<Te.length;We++){const ot=Te[We];let ce=null;if(p!==null)ce=p.getViewport(ot);else{const L=h.getViewSubImage(d,ot);ce=L.viewport,We===0&&(e.setRenderTargetTextures(x,L.colorTexture,d.ignoreDepthValues?void 0:L.depthStencilTexture),e.setRenderTarget(x))}let ue=H[We];ue===void 0&&(ue=new di,ue.layers.enable(We),ue.viewport=new st,H[We]=ue),ue.matrix.fromArray(ot.transform.matrix),ue.matrix.decompose(ue.position,ue.quaternion,ue.scale),ue.projectionMatrix.fromArray(ot.projectionMatrix),ue.projectionMatrixInverse.copy(ue.projectionMatrix).invert(),ue.viewport.set(ce.x,ce.y,ce.width,ce.height),We===0&&(M.matrix.copy(ue.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),Se===!0&&M.cameras.push(ue)}const Ye=r.enabledFeatures;if(Ye&&Ye.includes("depth-sensing")){const We=h.getDepthInformation(Te[0]);We&&We.isValid&&We.texture&&v.init(e,We,r.renderState)}}if(i.controllerAutoUpdate)for(let Te=0;Te<y.length;Te++){const Se=_[Te],Ye=y[Te];Se!==null&&Ye!==void 0&&Ye.update(Se,le,c||a)}Ve&&Ve(ie,le),le.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:le}),m=null}const et=new Lv;et.setAnimationLoop(at),this.setAnimationLoop=function(ie){Ve=ie},this.dispose=function(){}}}const Bs=new hr,zR=new Re;function kR(n,e){function t(f,g){f.matrixAutoUpdate===!0&&f.updateMatrix(),g.value.copy(f.matrix)}function i(f,g){g.color.getRGB(f.fogColor.value,Cv(n)),g.isFog?(f.fogNear.value=g.near,f.fogFar.value=g.far):g.isFogExp2&&(f.fogDensity.value=g.density)}function r(f,g,x,y,_){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(f,g):g.isMeshToonMaterial?(s(f,g),h(f,g)):g.isMeshPhongMaterial?(s(f,g),u(f,g)):g.isMeshStandardMaterial?(s(f,g),d(f,g),g.isMeshPhysicalMaterial&&p(f,g,_)):g.isMeshMatcapMaterial?(s(f,g),m(f,g)):g.isMeshDepthMaterial?s(f,g):g.isMeshDistanceMaterial?(s(f,g),v(f,g)):g.isMeshNormalMaterial?s(f,g):g.isLineBasicMaterial?(a(f,g),g.isLineDashedMaterial&&o(f,g)):g.isPointsMaterial?l(f,g,x,y):g.isSpriteMaterial?c(f,g):g.isShadowMaterial?(f.color.value.copy(g.color),f.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(f,g){f.opacity.value=g.opacity,g.color&&f.diffuse.value.copy(g.color),g.emissive&&f.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(f.map.value=g.map,t(g.map,f.mapTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.bumpMap&&(f.bumpMap.value=g.bumpMap,t(g.bumpMap,f.bumpMapTransform),f.bumpScale.value=g.bumpScale,g.side===si&&(f.bumpScale.value*=-1)),g.normalMap&&(f.normalMap.value=g.normalMap,t(g.normalMap,f.normalMapTransform),f.normalScale.value.copy(g.normalScale),g.side===si&&f.normalScale.value.negate()),g.displacementMap&&(f.displacementMap.value=g.displacementMap,t(g.displacementMap,f.displacementMapTransform),f.displacementScale.value=g.displacementScale,f.displacementBias.value=g.displacementBias),g.emissiveMap&&(f.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,f.emissiveMapTransform)),g.specularMap&&(f.specularMap.value=g.specularMap,t(g.specularMap,f.specularMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest);const x=e.get(g),y=x.envMap,_=x.envMapRotation;y&&(f.envMap.value=y,Bs.copy(_),Bs.x*=-1,Bs.y*=-1,Bs.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(Bs.y*=-1,Bs.z*=-1),f.envMapRotation.value.setFromMatrix4(zR.makeRotationFromEuler(Bs)),f.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=g.reflectivity,f.ior.value=g.ior,f.refractionRatio.value=g.refractionRatio),g.lightMap&&(f.lightMap.value=g.lightMap,f.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,f.lightMapTransform)),g.aoMap&&(f.aoMap.value=g.aoMap,f.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,f.aoMapTransform))}function a(f,g){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,g.map&&(f.map.value=g.map,t(g.map,f.mapTransform))}function o(f,g){f.dashSize.value=g.dashSize,f.totalSize.value=g.dashSize+g.gapSize,f.scale.value=g.scale}function l(f,g,x,y){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,f.size.value=g.size*x,f.scale.value=y*.5,g.map&&(f.map.value=g.map,t(g.map,f.uvTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest)}function c(f,g){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,f.rotation.value=g.rotation,g.map&&(f.map.value=g.map,t(g.map,f.mapTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest)}function u(f,g){f.specular.value.copy(g.specular),f.shininess.value=Math.max(g.shininess,1e-4)}function h(f,g){g.gradientMap&&(f.gradientMap.value=g.gradientMap)}function d(f,g){f.metalness.value=g.metalness,g.metalnessMap&&(f.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,f.metalnessMapTransform)),f.roughness.value=g.roughness,g.roughnessMap&&(f.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,f.roughnessMapTransform)),g.envMap&&(f.envMapIntensity.value=g.envMapIntensity)}function p(f,g,x){f.ior.value=g.ior,g.sheen>0&&(f.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),f.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(f.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,f.sheenColorMapTransform)),g.sheenRoughnessMap&&(f.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,f.sheenRoughnessMapTransform))),g.clearcoat>0&&(f.clearcoat.value=g.clearcoat,f.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(f.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,f.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(f.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===si&&f.clearcoatNormalScale.value.negate())),g.dispersion>0&&(f.dispersion.value=g.dispersion),g.iridescence>0&&(f.iridescence.value=g.iridescence,f.iridescenceIOR.value=g.iridescenceIOR,f.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(f.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,f.iridescenceMapTransform)),g.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),g.transmission>0&&(f.transmission.value=g.transmission,f.transmissionSamplerMap.value=x.texture,f.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(f.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,f.transmissionMapTransform)),f.thickness.value=g.thickness,g.thicknessMap&&(f.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=g.attenuationDistance,f.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(f.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(f.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=g.specularIntensity,f.specularColor.value.copy(g.specularColor),g.specularColorMap&&(f.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,f.specularColorMapTransform)),g.specularIntensityMap&&(f.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,f.specularIntensityMapTransform))}function m(f,g){g.matcap&&(f.matcap.value=g.matcap)}function v(f,g){const x=e.get(g).light;f.referencePosition.value.setFromMatrixPosition(x.matrixWorld),f.nearDistance.value=x.shadow.camera.near,f.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function HR(n,e,t,i){let r={},s={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,y){const _=y.program;i.uniformBlockBinding(x,_)}function c(x,y){let _=r[x.id];_===void 0&&(m(x),_=u(x),r[x.id]=_,x.addEventListener("dispose",f));const I=y.program;i.updateUBOMapping(x,I);const b=e.render.frame;s[x.id]!==b&&(d(x),s[x.id]=b)}function u(x){const y=h();x.__bindingPointIndex=y;const _=n.createBuffer(),I=x.__size,b=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,_),n.bufferData(n.UNIFORM_BUFFER,I,b),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,y,_),_}function h(){for(let x=0;x<o;x++)if(a.indexOf(x)===-1)return a.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){const y=r[x.id],_=x.uniforms,I=x.__cache;n.bindBuffer(n.UNIFORM_BUFFER,y);for(let b=0,w=_.length;b<w;b++){const C=Array.isArray(_[b])?_[b]:[_[b]];for(let H=0,M=C.length;H<M;H++){const T=C[H];if(p(T,b,H,I)===!0){const k=T.__offset,j=Array.isArray(T.value)?T.value:[T.value];let Y=0;for(let re=0;re<j.length;re++){const $=j[re],he=v($);typeof $=="number"||typeof $=="boolean"?(T.__data[0]=$,n.bufferSubData(n.UNIFORM_BUFFER,k+Y,T.__data)):$.isMatrix3?(T.__data[0]=$.elements[0],T.__data[1]=$.elements[1],T.__data[2]=$.elements[2],T.__data[3]=0,T.__data[4]=$.elements[3],T.__data[5]=$.elements[4],T.__data[6]=$.elements[5],T.__data[7]=0,T.__data[8]=$.elements[6],T.__data[9]=$.elements[7],T.__data[10]=$.elements[8],T.__data[11]=0):($.toArray(T.__data,Y),Y+=he.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,k,T.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function p(x,y,_,I){const b=x.value,w=y+"_"+_;if(I[w]===void 0)return typeof b=="number"||typeof b=="boolean"?I[w]=b:I[w]=b.clone(),!0;{const C=I[w];if(typeof b=="number"||typeof b=="boolean"){if(C!==b)return I[w]=b,!0}else if(C.equals(b)===!1)return C.copy(b),!0}return!1}function m(x){const y=x.uniforms;let _=0;const I=16;for(let w=0,C=y.length;w<C;w++){const H=Array.isArray(y[w])?y[w]:[y[w]];for(let M=0,T=H.length;M<T;M++){const k=H[M],j=Array.isArray(k.value)?k.value:[k.value];for(let Y=0,re=j.length;Y<re;Y++){const $=j[Y],he=v($),Q=_%I,ye=Q%he.boundary,be=Q+ye;_+=ye,be!==0&&I-be<he.storage&&(_+=I-be),k.__data=new Float32Array(he.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=_,_+=he.storage}}}const b=_%I;return b>0&&(_+=I-b),x.__size=_,x.__cache={},this}function v(x){const y={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(y.boundary=4,y.storage=4):x.isVector2?(y.boundary=8,y.storage=8):x.isVector3||x.isColor?(y.boundary=16,y.storage=12):x.isVector4?(y.boundary=16,y.storage=16):x.isMatrix3?(y.boundary=48,y.storage=48):x.isMatrix4?(y.boundary=64,y.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),y}function f(x){const y=x.target;y.removeEventListener("dispose",f);const _=a.indexOf(y.__bindingPointIndex);a.splice(_,1),n.deleteBuffer(r[y.id]),delete r[y.id],delete s[y.id]}function g(){for(const x in r)n.deleteBuffer(r[x]);a=[],r={},s={}}return{bind:l,update:c,dispose:g}}class oy{constructor(e={}){const{canvas:t=cv(),context:i=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let d;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=i.getContextAttributes().alpha}else d=a;const p=new Uint32Array(4),m=new Int32Array(4);let v=null,f=null;const g=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Fi,this.toneMapping=pr,this.toneMappingExposure=1;const y=this;let _=!1,I=0,b=0,w=null,C=-1,H=null;const M=new st,T=new st;let k=null;const j=new xe(0);let Y=0,re=t.width,$=t.height,he=1,Q=null,ye=null;const be=new st(0,0,re,$),Ve=new st(0,0,re,$);let at=!1;const et=new Ha;let ie=!1,le=!1;const Te=new Re,Se=new Re,Ye=new N,We=new st,ot={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ce=!1;function ue(){return w===null?he:1}let L=i;function He(A,B){return t.getContext(A,B)}try{const A={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Vn}`),t.addEventListener("webglcontextlost",oe,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",Ae,!1),L===null){const B="webgl2";if(L=He(B,A),L===null)throw He(B)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(A){throw console.error("THREE.WebGLRenderer: "+A.message),A}let pe,Ue,we,$e,Be,R,S,W,ne,de,se,ke,Ee,Pe,mt,ve,ze,tt,it,Oe,Mt,ut,Dt,O;function Ce(){pe=new YN(L),pe.init(),ut=new ay(L,pe),Ue=new GN(L,pe,e,ut),we=new NR(L),Ue.reverseDepthBuffer&&we.buffers.depth.setReversed(!0),$e=new KN(L),Be=new fR,R=new DR(L,pe,we,Be,Ue,ut,$e),S=new jN(y),W=new qN(y),ne=new sE(L),Dt=new kN(L,ne),de=new $N(L,ne,$e,Dt),se=new QN(L,de,ne,$e),it=new ZN(L,Ue,R),ve=new WN(Be),ke=new mR(y,S,W,pe,Ue,Dt,ve),Ee=new kR(y,Be),Pe=new vR,mt=new TR(pe),tt=new zN(y,S,W,we,se,d,l),ze=new ER(y,se,Ue),O=new HR(L,$e,Ue,we),Oe=new HN(L,pe,$e),Mt=new JN(L,pe,$e),$e.programs=ke.programs,y.capabilities=Ue,y.extensions=pe,y.properties=Be,y.renderLists=Pe,y.shadowMap=ze,y.state=we,y.info=$e}Ce();const ee=new BR(y,L);this.xr=ee,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const A=pe.get("WEBGL_lose_context");A&&A.loseContext()},this.forceContextRestore=function(){const A=pe.get("WEBGL_lose_context");A&&A.restoreContext()},this.getPixelRatio=function(){return he},this.setPixelRatio=function(A){A!==void 0&&(he=A,this.setSize(re,$,!1))},this.getSize=function(A){return A.set(re,$)},this.setSize=function(A,B,X=!0){if(ee.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}re=A,$=B,t.width=Math.floor(A*he),t.height=Math.floor(B*he),X===!0&&(t.style.width=A+"px",t.style.height=B+"px"),this.setViewport(0,0,A,B)},this.getDrawingBufferSize=function(A){return A.set(re*he,$*he).floor()},this.setDrawingBufferSize=function(A,B,X){re=A,$=B,he=X,t.width=Math.floor(A*X),t.height=Math.floor(B*X),this.setViewport(0,0,A,B)},this.getCurrentViewport=function(A){return A.copy(M)},this.getViewport=function(A){return A.copy(be)},this.setViewport=function(A,B,X,q){A.isVector4?be.set(A.x,A.y,A.z,A.w):be.set(A,B,X,q),we.viewport(M.copy(be).multiplyScalar(he).round())},this.getScissor=function(A){return A.copy(Ve)},this.setScissor=function(A,B,X,q){A.isVector4?Ve.set(A.x,A.y,A.z,A.w):Ve.set(A,B,X,q),we.scissor(T.copy(Ve).multiplyScalar(he).round())},this.getScissorTest=function(){return at},this.setScissorTest=function(A){we.setScissorTest(at=A)},this.setOpaqueSort=function(A){Q=A},this.setTransparentSort=function(A){ye=A},this.getClearColor=function(A){return A.copy(tt.getClearColor())},this.setClearColor=function(){tt.setClearColor.apply(tt,arguments)},this.getClearAlpha=function(){return tt.getClearAlpha()},this.setClearAlpha=function(){tt.setClearAlpha.apply(tt,arguments)},this.clear=function(A=!0,B=!0,X=!0){let q=0;if(A){let F=!1;if(w!==null){const me=w.texture.format;F=me===Vo||me===Fo||me===ya}if(F){const me=w.texture.type,Ie=me===Wr||me===Nr||me===_s||me===jn||me===Fc||me===Vc,Fe=tt.getClearColor(),Ge=tt.getClearAlpha(),Qe=Fe.r,Ze=Fe.g,Je=Fe.b;Ie?(p[0]=Qe,p[1]=Ze,p[2]=Je,p[3]=Ge,L.clearBufferuiv(L.COLOR,0,p)):(m[0]=Qe,m[1]=Ze,m[2]=Je,m[3]=Ge,L.clearBufferiv(L.COLOR,0,m))}else q|=L.COLOR_BUFFER_BIT}B&&(q|=L.DEPTH_BUFFER_BIT,L.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),X&&(q|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),L.clear(q)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",oe,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",Ae,!1),Pe.dispose(),mt.dispose(),Be.dispose(),S.dispose(),W.dispose(),se.dispose(),Dt.dispose(),O.dispose(),ke.dispose(),ee.dispose(),ee.removeEventListener("sessionstart",a0),ee.removeEventListener("sessionend",o0),vs.stop()};function oe(A){A.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),_=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),_=!1;const A=$e.autoReset,B=ze.enabled,X=ze.autoUpdate,q=ze.needsUpdate,F=ze.type;Ce(),$e.autoReset=A,ze.enabled=B,ze.autoUpdate=X,ze.needsUpdate=q,ze.type=F}function Ae(A){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",A.statusMessage)}function Ut(A){const B=A.target;B.removeEventListener("dispose",Ut),ni(B)}function ni(A){tr(A),Be.remove(A)}function tr(A){const B=Be.get(A).programs;B!==void 0&&(B.forEach(function(X){ke.releaseProgram(X)}),A.isShaderMaterial&&ke.releaseShaderCache(A))}this.renderBufferDirect=function(A,B,X,q,F,me){B===null&&(B=ot);const Ie=F.isMesh&&F.matrixWorld.determinant()<0,Fe=qS(A,B,X,q,F);we.setMaterial(q,Ie);let Ge=X.index,Qe=1;if(q.wireframe===!0){if(Ge=de.getWireframeAttribute(X),Ge===void 0)return;Qe=2}const Ze=X.drawRange,Je=X.attributes.position;let Rt=Ze.start*Qe,jt=(Ze.start+Ze.count)*Qe;me!==null&&(Rt=Math.max(Rt,me.start*Qe),jt=Math.min(jt,(me.start+me.count)*Qe)),Ge!==null?(Rt=Math.max(Rt,0),jt=Math.min(jt,Ge.count)):Je!=null&&(Rt=Math.max(Rt,0),jt=Math.min(jt,Je.count));const Qt=jt-Rt;if(Qt<0||Qt===1/0)return;Dt.setup(F,q,Fe,X,Ge);let ci,Ht=Oe;if(Ge!==null&&(ci=ne.get(Ge),Ht=Mt,Ht.setIndex(ci)),F.isMesh)q.wireframe===!0?(we.setLineWidth(q.wireframeLinewidth*ue()),Ht.setMode(L.LINES)):Ht.setMode(L.TRIANGLES);else if(F.isLine){let Xe=q.linewidth;Xe===void 0&&(Xe=1),we.setLineWidth(Xe*ue()),F.isLineSegments?Ht.setMode(L.LINES):F.isLineLoop?Ht.setMode(L.LINE_LOOP):Ht.setMode(L.LINE_STRIP)}else F.isPoints?Ht.setMode(L.POINTS):F.isSprite&&Ht.setMode(L.TRIANGLES);if(F.isBatchedMesh)if(F._multiDrawInstances!==null)Ht.renderMultiDrawInstances(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount,F._multiDrawInstances);else if(pe.get("WEBGL_multi_draw"))Ht.renderMultiDraw(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount);else{const Xe=F._multiDrawStarts,Wi=F._multiDrawCounts,ys=F._multiDrawCount,Hr=Ge?ne.get(Ge).bytesPerElement:1,fa=Be.get(q).currentProgram.getUniforms();for(let dr=0;dr<ys;dr++)fa.setValue(L,"_gl_DrawID",dr),Ht.render(Xe[dr]/Hr,Wi[dr])}else if(F.isInstancedMesh)Ht.renderInstances(Rt,Qt,F.count);else if(X.isInstancedBufferGeometry){const Xe=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,Wi=Math.min(X.instanceCount,Xe);Ht.renderInstances(Rt,Qt,Wi)}else Ht.render(Rt,Qt)};function At(A,B,X){A.transparent===!0&&A.side===Gr&&A.forceSinglePass===!1?(A.side=si,A.needsUpdate=!0,wc(A,B,X),A.side=an,A.needsUpdate=!0,wc(A,B,X),A.side=Gr):wc(A,B,X)}this.compile=function(A,B,X=null){X===null&&(X=A),f=mt.get(X),f.init(B),x.push(f),X.traverseVisible(function(F){F.isLight&&F.layers.test(B.layers)&&(f.pushLight(F),F.castShadow&&f.pushShadow(F))}),A!==X&&A.traverseVisible(function(F){F.isLight&&F.layers.test(B.layers)&&(f.pushLight(F),F.castShadow&&f.pushShadow(F))}),f.setupLights();const q=new Set;return A.traverse(function(F){if(!(F.isMesh||F.isPoints||F.isLine||F.isSprite))return;const me=F.material;if(me)if(Array.isArray(me))for(let Ie=0;Ie<me.length;Ie++){const Fe=me[Ie];At(Fe,X,F),q.add(Fe)}else At(me,X,F),q.add(me)}),x.pop(),f=null,q},this.compileAsync=function(A,B,X=null){const q=this.compile(A,B,X);return new Promise(F=>{function me(){if(q.forEach(function(Ie){Be.get(Ie).currentProgram.isReady()&&q.delete(Ie)}),q.size===0){F(A);return}setTimeout(me,10)}pe.get("KHR_parallel_shader_compile")!==null?me():setTimeout(me,10)})};let ir=null;function xn(A){ir&&ir(A)}function a0(){vs.stop()}function o0(){vs.start()}const vs=new Lv;vs.setAnimationLoop(xn),typeof self<"u"&&vs.setContext(self),this.setAnimationLoop=function(A){ir=A,ee.setAnimationLoop(A),A===null?vs.stop():vs.start()},ee.addEventListener("sessionstart",a0),ee.addEventListener("sessionend",o0),this.render=function(A,B){if(B!==void 0&&B.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(_===!0)return;if(A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld(),B.parent===null&&B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ee.enabled===!0&&ee.isPresenting===!0&&(ee.cameraAutoUpdate===!0&&ee.updateCamera(B),B=ee.getCamera()),A.isScene===!0&&A.onBeforeRender(y,A,B,w),f=mt.get(A,x.length),f.init(B),x.push(f),Se.multiplyMatrices(B.projectionMatrix,B.matrixWorldInverse),et.setFromProjectionMatrix(Se),le=this.localClippingEnabled,ie=ve.init(this.clippingPlanes,le),v=Pe.get(A,g.length),v.init(),g.push(v),ee.enabled===!0&&ee.isPresenting===!0){const me=y.xr.getDepthSensingMesh();me!==null&&zd(me,B,-1/0,y.sortObjects)}zd(A,B,0,y.sortObjects),v.finish(),y.sortObjects===!0&&v.sort(Q,ye),ce=ee.enabled===!1||ee.isPresenting===!1||ee.hasDepthSensing()===!1,ce&&tt.addToRenderList(v,A),this.info.render.frame++,ie===!0&&ve.beginShadows();const X=f.state.shadowsArray;ze.render(X,A,B),ie===!0&&ve.endShadows(),this.info.autoReset===!0&&this.info.reset();const q=v.opaque,F=v.transmissive;if(f.setupLights(),B.isArrayCamera){const me=B.cameras;if(F.length>0)for(let Ie=0,Fe=me.length;Ie<Fe;Ie++){const Ge=me[Ie];c0(q,F,A,Ge)}ce&&tt.render(A);for(let Ie=0,Fe=me.length;Ie<Fe;Ie++){const Ge=me[Ie];l0(v,A,Ge,Ge.viewport)}}else F.length>0&&c0(q,F,A,B),ce&&tt.render(A),l0(v,A,B);w!==null&&(R.updateMultisampleRenderTarget(w),R.updateRenderTargetMipmap(w)),A.isScene===!0&&A.onAfterRender(y,A,B),Dt.resetDefaultState(),C=-1,H=null,x.pop(),x.length>0?(f=x[x.length-1],ie===!0&&ve.setGlobalState(y.clippingPlanes,f.state.camera)):f=null,g.pop(),g.length>0?v=g[g.length-1]:v=null};function zd(A,B,X,q){if(A.visible===!1)return;if(A.layers.test(B.layers)){if(A.isGroup)X=A.renderOrder;else if(A.isLOD)A.autoUpdate===!0&&A.update(B);else if(A.isLight)f.pushLight(A),A.castShadow&&f.pushShadow(A);else if(A.isSprite){if(!A.frustumCulled||et.intersectsSprite(A)){q&&We.setFromMatrixPosition(A.matrixWorld).applyMatrix4(Se);const me=se.update(A),Ie=A.material;Ie.visible&&v.push(A,me,Ie,X,We.z,null)}}else if((A.isMesh||A.isLine||A.isPoints)&&(!A.frustumCulled||et.intersectsObject(A))){const me=se.update(A),Ie=A.material;if(q&&(A.boundingSphere!==void 0?(A.boundingSphere===null&&A.computeBoundingSphere(),We.copy(A.boundingSphere.center)):(me.boundingSphere===null&&me.computeBoundingSphere(),We.copy(me.boundingSphere.center)),We.applyMatrix4(A.matrixWorld).applyMatrix4(Se)),Array.isArray(Ie)){const Fe=me.groups;for(let Ge=0,Qe=Fe.length;Ge<Qe;Ge++){const Ze=Fe[Ge],Je=Ie[Ze.materialIndex];Je&&Je.visible&&v.push(A,me,Je,X,We.z,Ze)}}else Ie.visible&&v.push(A,me,Ie,X,We.z,null)}}const F=A.children;for(let me=0,Ie=F.length;me<Ie;me++)zd(F[me],B,X,q)}function l0(A,B,X,q){const F=A.opaque,me=A.transmissive,Ie=A.transparent;f.setupLightsView(X),ie===!0&&ve.setGlobalState(y.clippingPlanes,X),q&&we.viewport(M.copy(q)),F.length>0&&Sc(F,B,X),me.length>0&&Sc(me,B,X),Ie.length>0&&Sc(Ie,B,X),we.buffers.depth.setTest(!0),we.buffers.depth.setMask(!0),we.buffers.color.setMask(!0),we.setPolygonOffset(!1)}function c0(A,B,X,q){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[q.id]===void 0&&(f.state.transmissionRenderTarget[q.id]=new Ir(1,1,{generateMipmaps:!0,type:pe.has("EXT_color_buffer_half_float")||pe.has("EXT_color_buffer_float")?wi:Wr,minFilter:ji,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:vt.workingColorSpace}));const F=f.state.transmissionRenderTarget[q.id],me=q.viewport||M;F.setSize(me.z,me.w);const Ie=y.getRenderTarget();y.setRenderTarget(F),y.getClearColor(j),Y=y.getClearAlpha(),Y<1&&y.setClearColor(16777215,.5),y.clear(),ce&&tt.render(X);const Fe=y.toneMapping;y.toneMapping=pr;const Ge=q.viewport;if(q.viewport!==void 0&&(q.viewport=void 0),f.setupLightsView(q),ie===!0&&ve.setGlobalState(y.clippingPlanes,q),Sc(A,X,q),R.updateMultisampleRenderTarget(F),R.updateRenderTargetMipmap(F),pe.has("WEBGL_multisampled_render_to_texture")===!1){let Qe=!1;for(let Ze=0,Je=B.length;Ze<Je;Ze++){const Rt=B[Ze],jt=Rt.object,Qt=Rt.geometry,ci=Rt.material,Ht=Rt.group;if(ci.side===Gr&&jt.layers.test(q.layers)){const Xe=ci.side;ci.side=si,ci.needsUpdate=!0,u0(jt,X,q,Qt,ci,Ht),ci.side=Xe,ci.needsUpdate=!0,Qe=!0}}Qe===!0&&(R.updateMultisampleRenderTarget(F),R.updateRenderTargetMipmap(F))}y.setRenderTarget(Ie),y.setClearColor(j,Y),Ge!==void 0&&(q.viewport=Ge),y.toneMapping=Fe}function Sc(A,B,X){const q=B.isScene===!0?B.overrideMaterial:null;for(let F=0,me=A.length;F<me;F++){const Ie=A[F],Fe=Ie.object,Ge=Ie.geometry,Qe=q===null?Ie.material:q,Ze=Ie.group;Fe.layers.test(X.layers)&&u0(Fe,B,X,Ge,Qe,Ze)}}function u0(A,B,X,q,F,me){A.onBeforeRender(y,B,X,q,F,me),A.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,A.matrixWorld),A.normalMatrix.getNormalMatrix(A.modelViewMatrix),F.onBeforeRender(y,B,X,q,A,me),F.transparent===!0&&F.side===Gr&&F.forceSinglePass===!1?(F.side=si,F.needsUpdate=!0,y.renderBufferDirect(X,B,q,F,A,me),F.side=an,F.needsUpdate=!0,y.renderBufferDirect(X,B,q,F,A,me),F.side=Gr):y.renderBufferDirect(X,B,q,F,A,me),A.onAfterRender(y,B,X,q,F,me)}function wc(A,B,X){B.isScene!==!0&&(B=ot);const q=Be.get(A),F=f.state.lights,me=f.state.shadowsArray,Ie=F.state.version,Fe=ke.getParameters(A,F.state,me,B,X),Ge=ke.getProgramCacheKey(Fe);let Qe=q.programs;q.environment=A.isMeshStandardMaterial?B.environment:null,q.fog=B.fog,q.envMap=(A.isMeshStandardMaterial?W:S).get(A.envMap||q.environment),q.envMapRotation=q.environment!==null&&A.envMap===null?B.environmentRotation:A.envMapRotation,Qe===void 0&&(A.addEventListener("dispose",Ut),Qe=new Map,q.programs=Qe);let Ze=Qe.get(Ge);if(Ze!==void 0){if(q.currentProgram===Ze&&q.lightsStateVersion===Ie)return d0(A,Fe),Ze}else Fe.uniforms=ke.getUniforms(A),A.onBuild(X,Fe,y),A.onBeforeCompile(Fe,y),Ze=ke.acquireProgram(Fe,Ge),Qe.set(Ge,Ze),q.uniforms=Fe.uniforms;const Je=q.uniforms;return(!A.isShaderMaterial&&!A.isRawShaderMaterial||A.clipping===!0)&&(Je.clippingPlanes=ve.uniform),d0(A,Fe),q.needsLights=$S(A),q.lightsStateVersion=Ie,q.needsLights&&(Je.ambientLightColor.value=F.state.ambient,Je.lightProbe.value=F.state.probe,Je.directionalLights.value=F.state.directional,Je.directionalLightShadows.value=F.state.directionalShadow,Je.spotLights.value=F.state.spot,Je.spotLightShadows.value=F.state.spotShadow,Je.rectAreaLights.value=F.state.rectArea,Je.ltc_1.value=F.state.rectAreaLTC1,Je.ltc_2.value=F.state.rectAreaLTC2,Je.pointLights.value=F.state.point,Je.pointLightShadows.value=F.state.pointShadow,Je.hemisphereLights.value=F.state.hemi,Je.directionalShadowMap.value=F.state.directionalShadowMap,Je.directionalShadowMatrix.value=F.state.directionalShadowMatrix,Je.spotShadowMap.value=F.state.spotShadowMap,Je.spotLightMatrix.value=F.state.spotLightMatrix,Je.spotLightMap.value=F.state.spotLightMap,Je.pointShadowMap.value=F.state.pointShadowMap,Je.pointShadowMatrix.value=F.state.pointShadowMatrix),q.currentProgram=Ze,q.uniformsList=null,Ze}function h0(A){if(A.uniformsList===null){const B=A.currentProgram.getUniforms();A.uniformsList=Uu.seqWithValue(B.seq,A.uniforms)}return A.uniformsList}function d0(A,B){const X=Be.get(A);X.outputColorSpace=B.outputColorSpace,X.batching=B.batching,X.batchingColor=B.batchingColor,X.instancing=B.instancing,X.instancingColor=B.instancingColor,X.instancingMorph=B.instancingMorph,X.skinning=B.skinning,X.morphTargets=B.morphTargets,X.morphNormals=B.morphNormals,X.morphColors=B.morphColors,X.morphTargetsCount=B.morphTargetsCount,X.numClippingPlanes=B.numClippingPlanes,X.numIntersection=B.numClipIntersection,X.vertexAlphas=B.vertexAlphas,X.vertexTangents=B.vertexTangents,X.toneMapping=B.toneMapping}function qS(A,B,X,q,F){B.isScene!==!0&&(B=ot),R.resetTextureUnits();const me=B.fog,Ie=q.isMeshStandardMaterial?B.environment:null,Fe=w===null?y.outputColorSpace:w.isXRRenderTarget===!0?w.texture.colorSpace:nr,Ge=(q.isMeshStandardMaterial?W:S).get(q.envMap||Ie),Qe=q.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Ze=!!X.attributes.tangent&&(!!q.normalMap||q.anisotropy>0),Je=!!X.morphAttributes.position,Rt=!!X.morphAttributes.normal,jt=!!X.morphAttributes.color;let Qt=pr;q.toneMapped&&(w===null||w.isXRRenderTarget===!0)&&(Qt=y.toneMapping);const ci=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Ht=ci!==void 0?ci.length:0,Xe=Be.get(q),Wi=f.state.lights;if(ie===!0&&(le===!0||A!==H)){const wr=A===H&&q.id===C;ve.setState(q,A,wr)}let ys=!1;q.version===Xe.__version?(Xe.needsLights&&Xe.lightsStateVersion!==Wi.state.version||Xe.outputColorSpace!==Fe||F.isBatchedMesh&&Xe.batching===!1||!F.isBatchedMesh&&Xe.batching===!0||F.isBatchedMesh&&Xe.batchingColor===!0&&F.colorTexture===null||F.isBatchedMesh&&Xe.batchingColor===!1&&F.colorTexture!==null||F.isInstancedMesh&&Xe.instancing===!1||!F.isInstancedMesh&&Xe.instancing===!0||F.isSkinnedMesh&&Xe.skinning===!1||!F.isSkinnedMesh&&Xe.skinning===!0||F.isInstancedMesh&&Xe.instancingColor===!0&&F.instanceColor===null||F.isInstancedMesh&&Xe.instancingColor===!1&&F.instanceColor!==null||F.isInstancedMesh&&Xe.instancingMorph===!0&&F.morphTexture===null||F.isInstancedMesh&&Xe.instancingMorph===!1&&F.morphTexture!==null||Xe.envMap!==Ge||q.fog===!0&&Xe.fog!==me||Xe.numClippingPlanes!==void 0&&(Xe.numClippingPlanes!==ve.numPlanes||Xe.numIntersection!==ve.numIntersection)||Xe.vertexAlphas!==Qe||Xe.vertexTangents!==Ze||Xe.morphTargets!==Je||Xe.morphNormals!==Rt||Xe.morphColors!==jt||Xe.toneMapping!==Qt||Xe.morphTargetsCount!==Ht)&&(ys=!0):(ys=!0,Xe.__version=q.version);let Hr=Xe.currentProgram;ys===!0&&(Hr=wc(q,B,F));let fa=!1,dr=!1,kd=!1;const ei=Hr.getUniforms(),Fn=Xe.uniforms;if(we.useProgram(Hr.program)&&(fa=!0,dr=!0,kd=!0),q.id!==C&&(C=q.id,dr=!0),fa||H!==A){Ue.reverseDepthBuffer?(Te.copy(A.projectionMatrix),Iw(Te),Lw(Te),ei.setValue(L,"projectionMatrix",Te)):ei.setValue(L,"projectionMatrix",A.projectionMatrix),ei.setValue(L,"viewMatrix",A.matrixWorldInverse);const wr=ei.map.cameraPosition;wr!==void 0&&wr.setValue(L,Ye.setFromMatrixPosition(A.matrixWorld)),Ue.logarithmicDepthBuffer&&ei.setValue(L,"logDepthBufFC",2/(Math.log(A.far+1)/Math.LN2)),(q.isMeshPhongMaterial||q.isMeshToonMaterial||q.isMeshLambertMaterial||q.isMeshBasicMaterial||q.isMeshStandardMaterial||q.isShaderMaterial)&&ei.setValue(L,"isOrthographic",A.isOrthographicCamera===!0),H!==A&&(H=A,dr=!0,kd=!0)}if(F.isSkinnedMesh){ei.setOptional(L,F,"bindMatrix"),ei.setOptional(L,F,"bindMatrixInverse");const wr=F.skeleton;wr&&(wr.boneTexture===null&&wr.computeBoneTexture(),ei.setValue(L,"boneTexture",wr.boneTexture,R))}F.isBatchedMesh&&(ei.setOptional(L,F,"batchingTexture"),ei.setValue(L,"batchingTexture",F._matricesTexture,R),ei.setOptional(L,F,"batchingIdTexture"),ei.setValue(L,"batchingIdTexture",F._indirectTexture,R),ei.setOptional(L,F,"batchingColorTexture"),F._colorsTexture!==null&&ei.setValue(L,"batchingColorTexture",F._colorsTexture,R));const Hd=X.morphAttributes;if((Hd.position!==void 0||Hd.normal!==void 0||Hd.color!==void 0)&&it.update(F,X,Hr),(dr||Xe.receiveShadow!==F.receiveShadow)&&(Xe.receiveShadow=F.receiveShadow,ei.setValue(L,"receiveShadow",F.receiveShadow)),q.isMeshGouraudMaterial&&q.envMap!==null&&(Fn.envMap.value=Ge,Fn.flipEnvMap.value=Ge.isCubeTexture&&Ge.isRenderTargetTexture===!1?-1:1),q.isMeshStandardMaterial&&q.envMap===null&&B.environment!==null&&(Fn.envMapIntensity.value=B.environmentIntensity),dr&&(ei.setValue(L,"toneMappingExposure",y.toneMappingExposure),Xe.needsLights&&YS(Fn,kd),me&&q.fog===!0&&Ee.refreshFogUniforms(Fn,me),Ee.refreshMaterialUniforms(Fn,q,he,$,f.state.transmissionRenderTarget[A.id]),Uu.upload(L,h0(Xe),Fn,R)),q.isShaderMaterial&&q.uniformsNeedUpdate===!0&&(Uu.upload(L,h0(Xe),Fn,R),q.uniformsNeedUpdate=!1),q.isSpriteMaterial&&ei.setValue(L,"center",F.center),ei.setValue(L,"modelViewMatrix",F.modelViewMatrix),ei.setValue(L,"normalMatrix",F.normalMatrix),ei.setValue(L,"modelMatrix",F.matrixWorld),q.isShaderMaterial||q.isRawShaderMaterial){const wr=q.uniformsGroups;for(let Gd=0,JS=wr.length;Gd<JS;Gd++){const p0=wr[Gd];O.update(p0,Hr),O.bind(p0,Hr)}}return Hr}function YS(A,B){A.ambientLightColor.needsUpdate=B,A.lightProbe.needsUpdate=B,A.directionalLights.needsUpdate=B,A.directionalLightShadows.needsUpdate=B,A.pointLights.needsUpdate=B,A.pointLightShadows.needsUpdate=B,A.spotLights.needsUpdate=B,A.spotLightShadows.needsUpdate=B,A.rectAreaLights.needsUpdate=B,A.hemisphereLights.needsUpdate=B}function $S(A){return A.isMeshLambertMaterial||A.isMeshToonMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isShadowMaterial||A.isShaderMaterial&&A.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(A,B,X){Be.get(A.texture).__webglTexture=B,Be.get(A.depthTexture).__webglTexture=X;const q=Be.get(A);q.__hasExternalTextures=!0,q.__autoAllocateDepthBuffer=X===void 0,q.__autoAllocateDepthBuffer||pe.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),q.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(A,B){const X=Be.get(A);X.__webglFramebuffer=B,X.__useDefaultFramebuffer=B===void 0},this.setRenderTarget=function(A,B=0,X=0){w=A,I=B,b=X;let q=!0,F=null,me=!1,Ie=!1;if(A){const Fe=Be.get(A);if(Fe.__useDefaultFramebuffer!==void 0)we.bindFramebuffer(L.FRAMEBUFFER,null),q=!1;else if(Fe.__webglFramebuffer===void 0)R.setupRenderTarget(A);else if(Fe.__hasExternalTextures)R.rebindTextures(A,Be.get(A.texture).__webglTexture,Be.get(A.depthTexture).__webglTexture);else if(A.depthBuffer){const Ze=A.depthTexture;if(Fe.__boundDepthTexture!==Ze){if(Ze!==null&&Be.has(Ze)&&(A.width!==Ze.image.width||A.height!==Ze.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");R.setupDepthRenderbuffer(A)}}const Ge=A.texture;(Ge.isData3DTexture||Ge.isDataArrayTexture||Ge.isCompressedArrayTexture)&&(Ie=!0);const Qe=Be.get(A).__webglFramebuffer;A.isWebGLCubeRenderTarget?(Array.isArray(Qe[B])?F=Qe[B][X]:F=Qe[B],me=!0):A.samples>0&&R.useMultisampledRTT(A)===!1?F=Be.get(A).__webglMultisampledFramebuffer:Array.isArray(Qe)?F=Qe[X]:F=Qe,M.copy(A.viewport),T.copy(A.scissor),k=A.scissorTest}else M.copy(be).multiplyScalar(he).floor(),T.copy(Ve).multiplyScalar(he).floor(),k=at;if(we.bindFramebuffer(L.FRAMEBUFFER,F)&&q&&we.drawBuffers(A,F),we.viewport(M),we.scissor(T),we.setScissorTest(k),me){const Fe=Be.get(A.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+B,Fe.__webglTexture,X)}else if(Ie){const Fe=Be.get(A.texture),Ge=B||0;L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,Fe.__webglTexture,X||0,Ge)}C=-1},this.readRenderTargetPixels=function(A,B,X,q,F,me,Ie){if(!(A&&A.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Fe=Be.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Ie!==void 0&&(Fe=Fe[Ie]),Fe){we.bindFramebuffer(L.FRAMEBUFFER,Fe);try{const Ge=A.texture,Qe=Ge.format,Ze=Ge.type;if(!Ue.textureFormatReadable(Qe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ue.textureTypeReadable(Ze)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}B>=0&&B<=A.width-q&&X>=0&&X<=A.height-F&&L.readPixels(B,X,q,F,ut.convert(Qe),ut.convert(Ze),me)}finally{const Ge=w!==null?Be.get(w).__webglFramebuffer:null;we.bindFramebuffer(L.FRAMEBUFFER,Ge)}}},this.readRenderTargetPixelsAsync=async function(A,B,X,q,F,me,Ie){if(!(A&&A.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Fe=Be.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Ie!==void 0&&(Fe=Fe[Ie]),Fe){const Ge=A.texture,Qe=Ge.format,Ze=Ge.type;if(!Ue.textureFormatReadable(Qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ue.textureTypeReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(B>=0&&B<=A.width-q&&X>=0&&X<=A.height-F){we.bindFramebuffer(L.FRAMEBUFFER,Fe);const Je=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Je),L.bufferData(L.PIXEL_PACK_BUFFER,me.byteLength,L.STREAM_READ),L.readPixels(B,X,q,F,ut.convert(Qe),ut.convert(Ze),0);const Rt=w!==null?Be.get(w).__webglFramebuffer:null;we.bindFramebuffer(L.FRAMEBUFFER,Rt);const jt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Rw(L,jt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Je),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,me),L.deleteBuffer(Je),L.deleteSync(jt),me}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(A,B=null,X=0){A.isTexture!==!0&&(uu("WebGLRenderer: copyFramebufferToTexture function signature has changed."),B=arguments[0]||null,A=arguments[1]);const q=Math.pow(2,-X),F=Math.floor(A.image.width*q),me=Math.floor(A.image.height*q),Ie=B!==null?B.x:0,Fe=B!==null?B.y:0;R.setTexture2D(A,0),L.copyTexSubImage2D(L.TEXTURE_2D,X,0,0,Ie,Fe,F,me),we.unbindTexture()},this.copyTextureToTexture=function(A,B,X=null,q=null,F=0){A.isTexture!==!0&&(uu("WebGLRenderer: copyTextureToTexture function signature has changed."),q=arguments[0]||null,A=arguments[1],B=arguments[2],F=arguments[3]||0,X=null);let me,Ie,Fe,Ge,Qe,Ze;X!==null?(me=X.max.x-X.min.x,Ie=X.max.y-X.min.y,Fe=X.min.x,Ge=X.min.y):(me=A.image.width,Ie=A.image.height,Fe=0,Ge=0),q!==null?(Qe=q.x,Ze=q.y):(Qe=0,Ze=0);const Je=ut.convert(B.format),Rt=ut.convert(B.type);R.setTexture2D(B,0),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,B.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,B.unpackAlignment);const jt=L.getParameter(L.UNPACK_ROW_LENGTH),Qt=L.getParameter(L.UNPACK_IMAGE_HEIGHT),ci=L.getParameter(L.UNPACK_SKIP_PIXELS),Ht=L.getParameter(L.UNPACK_SKIP_ROWS),Xe=L.getParameter(L.UNPACK_SKIP_IMAGES),Wi=A.isCompressedTexture?A.mipmaps[F]:A.image;L.pixelStorei(L.UNPACK_ROW_LENGTH,Wi.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Wi.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Fe),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ge),A.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,F,Qe,Ze,me,Ie,Je,Rt,Wi.data):A.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,F,Qe,Ze,Wi.width,Wi.height,Je,Wi.data):L.texSubImage2D(L.TEXTURE_2D,F,Qe,Ze,me,Ie,Je,Rt,Wi),L.pixelStorei(L.UNPACK_ROW_LENGTH,jt),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Qt),L.pixelStorei(L.UNPACK_SKIP_PIXELS,ci),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ht),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Xe),F===0&&B.generateMipmaps&&L.generateMipmap(L.TEXTURE_2D),we.unbindTexture()},this.copyTextureToTexture3D=function(A,B,X=null,q=null,F=0){A.isTexture!==!0&&(uu("WebGLRenderer: copyTextureToTexture3D function signature has changed."),X=arguments[0]||null,q=arguments[1]||null,A=arguments[2],B=arguments[3],F=arguments[4]||0);let me,Ie,Fe,Ge,Qe,Ze,Je,Rt,jt;const Qt=A.isCompressedTexture?A.mipmaps[F]:A.image;X!==null?(me=X.max.x-X.min.x,Ie=X.max.y-X.min.y,Fe=X.max.z-X.min.z,Ge=X.min.x,Qe=X.min.y,Ze=X.min.z):(me=Qt.width,Ie=Qt.height,Fe=Qt.depth,Ge=0,Qe=0,Ze=0),q!==null?(Je=q.x,Rt=q.y,jt=q.z):(Je=0,Rt=0,jt=0);const ci=ut.convert(B.format),Ht=ut.convert(B.type);let Xe;if(B.isData3DTexture)R.setTexture3D(B,0),Xe=L.TEXTURE_3D;else if(B.isDataArrayTexture||B.isCompressedArrayTexture)R.setTexture2DArray(B,0),Xe=L.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,B.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,B.unpackAlignment);const Wi=L.getParameter(L.UNPACK_ROW_LENGTH),ys=L.getParameter(L.UNPACK_IMAGE_HEIGHT),Hr=L.getParameter(L.UNPACK_SKIP_PIXELS),fa=L.getParameter(L.UNPACK_SKIP_ROWS),dr=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,Qt.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Qt.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Ge),L.pixelStorei(L.UNPACK_SKIP_ROWS,Qe),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Ze),A.isDataTexture||A.isData3DTexture?L.texSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Ht,Qt.data):B.isCompressedArrayTexture?L.compressedTexSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Qt.data):L.texSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Ht,Qt),L.pixelStorei(L.UNPACK_ROW_LENGTH,Wi),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ys),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Hr),L.pixelStorei(L.UNPACK_SKIP_ROWS,fa),L.pixelStorei(L.UNPACK_SKIP_IMAGES,dr),F===0&&B.generateMipmaps&&L.generateMipmap(Xe),we.unbindTexture()},this.initRenderTarget=function(A){Be.get(A).__webglFramebuffer===void 0&&R.setupRenderTarget(A)},this.initTexture=function(A){A.isCubeTexture?R.setTextureCube(A,0):A.isData3DTexture?R.setTexture3D(A,0):A.isDataArrayTexture||A.isCompressedArrayTexture?R.setTexture2DArray(A,0):R.setTexture2D(A,0),we.unbindTexture()},this.resetState=function(){I=0,b=0,w=null,we.reset(),Dt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rr}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Jo?"display-p3":"srgb",t.unpackColorSpace=vt.workingColorSpace===Sa?"display-p3":"srgb"}}class Rd{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new xe(e),this.density=t}clone(){return new Rd(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let Kp=class jS{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new xe(e),this.near=t,this.far=i}clone(){return new jS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class Vu extends _t{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new hr,this.environmentIntensity=1,this.environmentRotation=new hr,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Xa{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=wa,this.updateRanges=[],this.version=0,this.uuid=vr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=vr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}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=vr()),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 $i=new N;class On{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.applyMatrix4(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.applyNormalMatrix(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.transformDirection(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Xi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=ht(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Xi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Xi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Xi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Xi(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array),s=ht(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new wt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new On(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else 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 dl extends hi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new xe(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 qa;const pl=new N,Ya=new N,$a=new N,Ja=new J,ml=new J,ly=new Re,Bu=new N,fl=new N,zu=new N,cy=new J,Zp=new J,uy=new J;class Qp extends _t{constructor(e=new dl){if(super(),this.isSprite=!0,this.type="Sprite",qa===void 0){qa=new ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Xa(t,5);qa.setIndex([0,1,2,0,2,3]),qa.setAttribute("position",new On(i,3,0,!1)),qa.setAttribute("uv",new On(i,2,3,!1))}this.geometry=qa,this.material=e,this.center=new J(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ya.setFromMatrixScale(this.matrixWorld),ly.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),$a.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ya.multiplyScalar(-$a.z);const i=this.material.rotation;let r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));const a=this.center;ku(Bu.set(-.5,-.5,0),$a,a,Ya,r,s),ku(fl.set(.5,-.5,0),$a,a,Ya,r,s),ku(zu.set(.5,.5,0),$a,a,Ya,r,s),cy.set(0,0),Zp.set(1,0),uy.set(1,1);let o=e.ray.intersectTriangle(Bu,fl,zu,!1,pl);if(o===null&&(ku(fl.set(-.5,.5,0),$a,a,Ya,r,s),Zp.set(0,1),o=e.ray.intersectTriangle(Bu,zu,fl,!1,pl),o===null))return;const l=e.ray.origin.distanceTo(pl);l<e.near||l>e.far||t.push({distance:l,point:pl.clone(),uv:er.getInterpolation(pl,Bu,fl,zu,cy,Zp,uy,new J),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ku(n,e,t,i,r,s){Ja.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(ml.x=s*Ja.x-r*Ja.y,ml.y=r*Ja.x+s*Ja.y):ml.copy(Ja),n.copy(e),n.x+=ml.x,n.y+=ml.y,n.applyMatrix4(ly)}const Hu=new N,hy=new N;class em extends _t{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i<r;i++){const s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const r=this.levels;let s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let i=0;i<t.length;i++)if(t[i].distance===e){const r=t.splice(i,1);return this.remove(r[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Hu.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Hu);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Hu.setFromMatrixPosition(e.matrixWorld),hy.setFromMatrixPosition(this.matrixWorld);const i=Hu.distanceTo(hy)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let a=t[r].distance;if(t[r].object.visible&&(a-=a*t[r].hysteresis),i>=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let r=0,s=i.length;r<s;r++){const a=i[r];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const dy=new N,py=new st,my=new st,GR=new N,fy=new Re,Gu=new N,tm=new Ai,gy=new Re,im=new Cs;class rm extends Ft{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ep,this.bindMatrix=new Re,this.bindMatrixInverse=new Re,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Bi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Gu),this.boundingBox.expandByPoint(Gu)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ai),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Gu),this.boundingSphere.expandByPoint(Gu)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),tm.copy(this.boundingSphere),tm.applyMatrix4(r),e.ray.intersectsSphere(tm)!==!1&&(gy.copy(r).invert(),im.copy(e.ray).applyMatrix4(gy),!(this.boundingBox!==null&&im.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,im)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new st,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===ep?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===U0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;py.fromBufferAttribute(r.attributes.skinIndex,e),my.fromBufferAttribute(r.attributes.skinWeight,e),dy.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=my.getComponent(s);if(a!==0){const o=py.getComponent(s);fy.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(GR.copy(dy).applyMatrix4(fy),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Wu extends _t{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ur extends Wt{constructor(e=null,t=1,i=1,r,s,a,o,l,c=$t,u=$t,h,d){super(null,a,o,l,c,u,r,s,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const vy=new Re,WR=new Re;class yc{constructor(e=[],t=[]){this.uuid=vr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new Re)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Re;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:WR;vy.multiplyMatrices(o,t[s]),vy.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new yc(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new Ur(t,e,e,Ei,Oi);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){const s=e.bones[i];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new Wu),this.bones.push(a),this.boneInverses.push(new Re().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const a=t[r];e.bones.push(a.uuid);const o=i[r];e.boneInverses.push(o.toArray())}return e}}class Nn extends wt{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}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 Ka=new Re,yy=new Re,ju=[],xy=new Bi,jR=new Re,gl=new Ft,vl=new Ai;class nm extends Ft{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Nn(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,jR)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Bi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ka),xy.copy(e.boundingBox).applyMatrix4(Ka),this.boundingBox.union(xy)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ai),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ka),vl.copy(e.boundingSphere).applyMatrix4(Ka),this.boundingSphere.union(vl)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=i.length+1,a=e*s+1;for(let o=0;o<i.length;o++)i[o]=r[a+o]}raycast(e,t){const i=this.matrixWorld,r=this.count;if(gl.geometry=this.geometry,gl.material=this.material,gl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),vl.copy(this.boundingSphere),vl.applyMatrix4(i),e.ray.intersectsSphere(vl)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Ka),yy.multiplyMatrices(i,Ka),gl.matrixWorld=yy,gl.raycast(e,ju);for(let a=0,o=ju.length;a<o;a++){const l=ju[a];l.instanceId=s,l.object=this,t.push(l)}ju.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Nn(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new Ur(new Float32Array(r*this.count),r,this.count,Oo,Oi));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<i.length;c++)a+=i[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;s[l]=o,s.set(i,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}function XR(n,e){return n.z-e.z}function qR(n,e){return e.z-n.z}class YR{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];s.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=t,a.index=i}reset(){this.list.length=0,this.index=0}}const is=new Re,sm=new Re,$R=new Re,JR=new xe(1,1,1),_y=new Re,am=new Ha,Xu=new Bi,zs=new Ai,yl=new N,My=new N,KR=new N,om=new YR,ki=new Ft,qu=[];function ZR(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const r=n.count;for(let s=0;s<r;s++)for(let a=0;a<i;a++)e.setComponent(s+t,a,n.getComponent(s,a))}else e.array.set(n.array,t*i);e.needsUpdate=!0}class lm extends Ft{get maxInstanceCount(){return this._maxInstanceCount}constructor(e,t,i=t*2,r){super(new ct,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawInfo=[],this._availableInstanceIds=[],this._drawRanges=[],this._reservedRanges=[],this._bounds=[],this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),i=new Ur(t,e,e,Ei,Oi);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new Ur(t,e,e,ya,Nr);this._indirectTexture=i}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),i=new Ur(t,e,e,Ei,Oi);i.colorSpace=vt.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const a=e.getAttribute(s),{array:o,itemSize:l,normalized:c}=a,u=new o.constructor(i*l),h=new wt(u,l,c);t.setAttribute(s,h)}if(e.getIndex()!==null){const s=i>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new wt(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bi);const e=this.boundingBox,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,is),this.getBoundingBoxAt(s,Xu).applyMatrix4(is),e.union(Xu)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ai);const e=this.boundingSphere,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,is),this.getBoundingSphereAt(s,zs).applyMatrix4(is),e.union(zs)}}addInstance(e){if(this._drawInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("BatchedMesh: Maximum item count reached.");const t={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(i=this._availableInstanceIds.pop(),this._drawInfo[i]=t):(i=this._drawInfo.length,this._drawInfo.push(t));const r=this._matricesTexture,s=r.image.data;$R.toArray(s,i*16),r.needsUpdate=!0;const a=this._colorsTexture;return a&&(JR.toArray(a.image.data,i*4),a.needsUpdate=!0),i}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=a[a.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;const c=e.getIndex(),u=c!==null;if(u&&(i===-1?r.indexCount=c.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._geometryCount;return this._geometryCount++,a.push(r),o.push({start:u?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Bi,sphereInitialized:!1,sphere:new Ai}),this.setGeometryAt(h,e),h}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),a=t.getIndex(),o=this._reservedRanges[e];if(r&&a.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const p in i.attributes){const m=t.getAttribute(p),v=i.getAttribute(p);ZR(m,v,l);const f=m.itemSize;for(let g=m.count,x=c;g<x;g++){const y=l+g;for(let _=0;_<f;_++)v.setComponent(y,_,0)}v.needsUpdate=!0,v.addUpdateRange(l*f,c*f)}if(r){const p=o.indexStart;for(let m=0;m<a.count;m++)s.setX(p+m,l+a.getX(m));for(let m=a.count,v=o.indexCount;m<v;m++)s.setX(p+m,l);s.needsUpdate=!0,s.addUpdateRange(p,o.indexCount)}const u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const h=this._drawRanges[e],d=t.getAttribute("position");return h.count=r?a.count:d.count,this._visibilityChanged=!0,e}deleteInstance(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?this:(t[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.box,s=this.geometry;if(i.boxInitialized===!1){r.makeEmpty();const a=s.index,o=s.attributes.position,l=this._drawRanges[e];for(let c=l.start,u=l.start+l.count;c<u;c++){let h=c;a&&(h=a.getX(h)),r.expandByPoint(yl.fromBufferAttribute(o,h))}i.boxInitialized=!0}return t.copy(r),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.sphere,s=this.geometry;if(i.sphereInitialized===!1){r.makeEmpty(),this.getBoundingBoxAt(e,Xu),Xu.getCenter(r.center);const a=s.index,o=s.attributes.position,l=this._drawRanges[e];let c=0;for(let u=l.start,h=l.start+l.count;u<h;u++){let d=u;a&&(d=a.getX(d)),yl.fromBufferAttribute(o,d),c=Math.max(c,r.center.distanceToSquared(yl))}r.radius=Math.sqrt(c),i.sphereInitialized=!0}return t.copy(r),t}setMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture,s=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?null:t.fromArray(r,e*16)}setColorAt(e,t){this._colorsTexture===null&&this._initColorsTexture();const i=this._colorsTexture,r=this._colorsTexture.image.data,s=this._drawInfo;return e>=s.length||s[e].active===!1?this:(t.toArray(r,e*4),i.needsUpdate=!0,this)}getColorAt(e,t){const i=this._colorsTexture.image.data,r=this._drawInfo;return e>=r.length||r[e].active===!1?null:t.fromArray(i,e*4)}setVisibleAt(e,t){const i=this._drawInfo;return e>=i.length||i[e].active===!1||i[e].visible===t?this:(i[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?!1:t[e].visible}setGeometryIdAt(e,t){const i=this._drawInfo;return e>=i.length||i[e].active===!1||t<0||t>=this._geometryCount?null:(i[e].geometryIndex=t,this)}getGeometryIdAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?-1:t[e].geometryIndex}getGeometryRangeAt(e,t={}){if(e<0||e>=this._geometryCount)return null;const i=this._drawRanges[e];return t.start=i.start,t.count=i.count,t}raycast(e,t){const i=this._drawInfo,r=this._drawRanges,s=this.matrixWorld,a=this.geometry;ki.material=this.material,ki.geometry.index=a.index,ki.geometry.attributes=a.attributes,ki.geometry.boundingBox===null&&(ki.geometry.boundingBox=new Bi),ki.geometry.boundingSphere===null&&(ki.geometry.boundingSphere=new Ai);for(let o=0,l=i.length;o<l;o++){if(!i[o].visible||!i[o].active)continue;const c=i[o].geometryIndex,u=r[c];ki.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(o,ki.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,ki.geometry.boundingBox),this.getBoundingSphereAt(c,ki.geometry.boundingSphere),ki.raycast(e,qu);for(let h=0,d=qu.length;h<d;h++){const p=qu[h];p.object=this,p.batchId=o,t.push(p)}qu.length=0}ki.material=null,ki.geometry.index=null,ki.geometry.attributes={},ki.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._drawInfo=e._drawInfo.map(t=>({...t})),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._drawInfo,c=this._multiDrawStarts,u=this._multiDrawCounts,h=this._drawRanges,d=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data;d&&(_y.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),am.setFromProjectionMatrix(_y,e.coordinateSystem));let v=0;if(this.sortObjects){sm.copy(this.matrixWorld).invert(),yl.setFromMatrixPosition(i.matrixWorld).applyMatrix4(sm),My.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(sm);for(let x=0,y=l.length;x<y;x++)if(l[x].visible&&l[x].active){const _=l[x].geometryIndex;this.getMatrixAt(x,is),this.getBoundingSphereAt(_,zs).applyMatrix4(is);let I=!1;if(d&&(I=!am.intersectsSphere(zs)),!I){const b=KR.subVectors(zs.center,yl).dot(My);om.push(h[_],b,x)}}const f=om.list,g=this.customSort;g===null?f.sort(s.transparent?qR:XR):g.call(this,f,i);for(let x=0,y=f.length;x<y;x++){const _=f[x];c[v]=_.start*o,u[v]=_.count,m[v]=_.index,v++}om.reset()}else for(let f=0,g=l.length;f<g;f++)if(l[f].visible&&l[f].active){const x=l[f].geometryIndex;let y=!1;if(d&&(this.getMatrixAt(f,is),this.getBoundingSphereAt(x,zs).applyMatrix4(is),y=!am.intersectsSphere(zs)),!y){const _=h[x];c[v]=_.start*o,u[v]=_.count,m[v]=f,v++}}p.needsUpdate=!0,this._multiDrawCount=v,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,a){this.onBeforeRender(e,null,r,s,a)}}class Ni extends hi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xe(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 Yu=new N,$u=new N,by=new Re,xl=new Cs,Ju=new Ai,cm=new N,Ty=new N;class Cn extends _t{constructor(e=new ct,t=new Ni){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)Yu.fromBufferAttribute(t,r-1),$u.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Yu.distanceTo($u);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Ju.copy(i.boundingSphere),Ju.applyMatrix4(r),Ju.radius+=s,e.ray.intersectsSphere(Ju)===!1)return;by.copy(r).invert(),xl.copy(e.ray).applyMatrix4(by);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=i.index,h=i.attributes.position;if(u!==null){const d=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let m=d,v=p-1;m<v;m+=c){const f=u.getX(m),g=u.getX(m+1),x=Ku(this,e,xl,l,f,g);x&&t.push(x)}if(this.isLineLoop){const m=u.getX(p-1),v=u.getX(d),f=Ku(this,e,xl,l,m,v);f&&t.push(f)}}else{const d=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let m=d,v=p-1;m<v;m+=c){const f=Ku(this,e,xl,l,m,m+1);f&&t.push(f)}if(this.isLineLoop){const m=Ku(this,e,xl,l,p-1,d);m&&t.push(m)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Ku(n,e,t,i,r,s){const a=n.geometry.attributes.position;if(Yu.fromBufferAttribute(a,r),$u.fromBufferAttribute(a,s),t.distanceSqToSegment(Yu,$u,cm,Ty)>i)return;cm.applyMatrix4(n.matrixWorld);const o=e.ray.origin.distanceTo(cm);if(!(o<e.near||o>e.far))return{distance:o,point:Ty.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:n}}const Sy=new N,wy=new N;class $r extends Cn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)Sy.fromBufferAttribute(t,r),wy.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Sy.distanceTo(wy);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class um extends Cn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Za extends hi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new xe(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 Ey=new Re,hm=new Cs,Zu=new Ai,Qu=new N;class dm extends _t{constructor(e=new ct,t=new Za){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Zu.copy(i.boundingSphere),Zu.applyMatrix4(r),Zu.radius+=s,e.ray.intersectsSphere(Zu)===!1)return;Ey.copy(r).invert(),hm.copy(e.ray).applyMatrix4(Ey);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,u=i.attributes.position;if(c!==null){const h=Math.max(0,a.start),d=Math.min(c.count,a.start+a.count);for(let p=h,m=d;p<m;p++){const v=c.getX(p);Qu.fromBufferAttribute(u,v),Ay(Qu,v,l,r,e,t,this)}}else{const h=Math.max(0,a.start),d=Math.min(u.count,a.start+a.count);for(let p=h,m=d;p<m;p++)Qu.fromBufferAttribute(u,p),Ay(Qu,p,l,r,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Ay(n,e,t,i,r,s,a){const o=hm.distanceSqToPoint(n);if(o<t){const l=new N;hm.closestPointToPoint(n,l),l.applyMatrix4(i);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Ny extends Wt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:Lt,this.magFilter=s!==void 0?s:Lt,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class pm extends Wt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=$t,this.minFilter=$t,this.generateMipmaps=!1,this.needsUpdate=!0}}class _l extends Wt{constructor(e,t,i,r,s,a,o,l,c,u,h,d){super(null,a,o,l,c,u,r,s,h,d),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Cy extends _l{constructor(e,t,i,r,s,a){super(e,t,i,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=fr,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Ry extends _l{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,mr),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Iy extends Wt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Or{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let a;t?a=t:a=e*i[s-1];let o=0,l=s-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=i[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,i[r]===a)return r/(s-1);const u=i[r],h=i[r+1]-u,d=(a-u)/h;return(r+d)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=t||(s.isVector2?new J:new N);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new N,r=[],s=[],a=[],o=new N,l=new Re;for(let p=0;p<=e;p++){const m=p/e;r[p]=this.getTangentAt(m,new N)}s[0]=new N,a[0]=new N;let c=Number.MAX_VALUE;const u=Math.abs(r[0].x),h=Math.abs(r[0].y),d=Math.abs(r[0].z);u<=c&&(c=u,i.set(1,0,0)),h<=c&&(c=h,i.set(0,1,0)),d<=c&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(r[p-1],r[p]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(Jt(r[p-1].dot(r[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(o,m))}a[p].crossVectors(r[p],s[p])}if(t===!0){let p=Math.acos(Jt(s[0].dot(s[e]),-1,1));p/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(p=-p);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],p*m)),a[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class eh extends Or{constructor(e=0,t=0,i=1,r=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new J){const i=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);const o=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,p=c-this.aY;l=d*u-p*h+this.aX,c=d*h+p*u+this.aY}return i.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class Ly extends eh{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function mm(){let n=0,e=0,t=0,i=0;function r(s,a,o,l){n=s,e=o,t=-3*s+3*a-2*o-l,i=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){r(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,u,h){let d=(a-s)/c-(o-s)/(c+u)+(o-a)/u,p=(o-a)/u-(l-a)/(u+h)+(l-o)/h;d*=u,p*=u,r(a,o,d,p)},calc:function(s){const a=s*s,o=a*s;return n+e*s+t*a+i*o}}}const th=new N,fm=new mm,gm=new mm,vm=new mm;class Py extends Or{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new N){const i=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,u;this.closed||o>0?c=r[(o-1)%s]:(th.subVectors(r[0],r[1]).add(r[0]),c=th);const h=r[o%s],d=r[(o+1)%s];if(this.closed||o+2<s?u=r[(o+2)%s]:(th.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=th),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(h),p),v=Math.pow(h.distanceToSquared(d),p),f=Math.pow(d.distanceToSquared(u),p);v<1e-4&&(v=1),m<1e-4&&(m=v),f<1e-4&&(f=v),fm.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,m,v,f),gm.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,m,v,f),vm.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,m,v,f)}else this.curveType==="catmullrom"&&(fm.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),gm.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),vm.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return i.set(fm.calc(l),gm.calc(l),vm.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new N().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Dy(n,e,t,i,r){const s=(i-e)*.5,a=(r-t)*.5,o=n*n,l=n*o;return(2*t-2*i+s+a)*l+(-3*t+3*i-2*s-a)*o+s*n+t}function QR(n,e){const t=1-n;return t*t*e}function eI(n,e){return 2*(1-n)*n*e}function tI(n,e){return n*n*e}function Ml(n,e,t,i){return QR(n,e)+eI(n,t)+tI(n,i)}function iI(n,e){const t=1-n;return t*t*t*e}function rI(n,e){const t=1-n;return 3*t*t*n*e}function nI(n,e){return 3*(1-n)*n*n*e}function sI(n,e){return n*n*n*e}function bl(n,e,t,i,r){return iI(n,e)+rI(n,t)+nI(n,i)+sI(n,r)}class ym extends Or{constructor(e=new J,t=new J,i=new J,r=new J){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new J){const i=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(bl(e,r.x,s.x,a.x,o.x),bl(e,r.y,s.y,a.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Uy extends Or{constructor(e=new N,t=new N,i=new N,r=new N){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new N){const i=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(bl(e,r.x,s.x,a.x,o.x),bl(e,r.y,s.y,a.y,o.y),bl(e,r.z,s.z,a.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class xm extends Or{constructor(e=new J,t=new J){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new J){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new J){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Oy extends Or{constructor(e=new N,t=new N){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new N){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new N){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class _m extends Or{constructor(e=new J,t=new J,i=new J){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new J){const i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(Ml(e,r.x,s.x,a.x),Ml(e,r.y,s.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Mm extends Or{constructor(e=new N,t=new N,i=new N){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new N){const i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(Ml(e,r.x,s.x,a.x),Ml(e,r.y,s.y,a.y),Ml(e,r.z,s.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class bm extends Or{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new J){const i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),o=s-a,l=r[a===0?a:a-1],c=r[a],u=r[a>r.length-2?r.length-1:a+1],h=r[a>r.length-3?r.length-1:a+2];return i.set(Dy(o,l.x,c.x,u.x,h.x),Dy(o,l.y,c.y,u.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new J().fromArray(r))}return this}}var ih=Object.freeze({__proto__:null,ArcCurve:Ly,CatmullRomCurve3:Py,CubicBezierCurve:ym,CubicBezierCurve3:Uy,EllipseCurve:eh,LineCurve:xm,LineCurve3:Oy,QuadraticBezierCurve:_m,QuadraticBezierCurve3:Mm,SplineCurve:bm});class Fy extends Or{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new ih[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=i){const a=r[s]-i,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let r=0,s=this.curves;r<s.length;r++){const a=s[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const u=l[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(new ih[r.type]().fromJSON(r))}return this}}class Tl extends Fy{constructor(e){super(),this.type="Path",this.currentPoint=new J,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new xm(this.currentPoint.clone(),new J(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const s=new _m(this.currentPoint.clone(),new J(e,t),new J(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){const o=new ym(this.currentPoint.clone(),new J(e,t),new J(i,r),new J(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new bm(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,o,l){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,i,r,s,a,o,l),this}absellipse(e,t,i,r,s,a,o,l){const c=new eh(e,t,i,r,s,a,o,l);if(this.curves.length>0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class xc extends ct{constructor(e=[new J(0,-.5),new J(.5,0),new J(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Jt(r,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],u=1/t,h=new N,d=new J,p=new N,m=new N,v=new N;let f=0,g=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:f=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,p.x=g*1,p.y=-f,p.z=g*0,v.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(v.x,v.y,v.z);break;default:f=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,p.x=g*1,p.y=-f,p.z=g*0,m.copy(p),p.x+=v.x,p.y+=v.y,p.z+=v.z,p.normalize(),l.push(p.x,p.y,p.z),v.copy(m)}for(let x=0;x<=t;x++){const y=i+x*u*r,_=Math.sin(y),I=Math.cos(y);for(let b=0;b<=e.length-1;b++){h.x=e[b].x*_,h.y=e[b].y,h.z=e[b].x*I,a.push(h.x,h.y,h.z),d.x=x/t,d.y=b/(e.length-1),o.push(d.x,d.y);const w=l[3*b+0]*_,C=l[3*b+1],H=l[3*b+0]*I;c.push(w,C,H)}}for(let x=0;x<t;x++)for(let y=0;y<e.length-1;y++){const _=y+x*e.length,I=_,b=_+e.length,w=_+e.length+1,C=_+1;s.push(I,b,C),s.push(w,C,b)}this.setIndex(s),this.setAttribute("position",new De(a,3)),this.setAttribute("uv",new De(o,2)),this.setAttribute("normal",new De(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xc(e.points,e.segments,e.phiStart,e.phiLength)}}class Id extends xc{constructor(e=1,t=1,i=4,r=8){const s=new Tl;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new Id(e.radius,e.length,e.capSegments,e.radialSegments)}}class Ld extends ct{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new N,u=new J;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){const p=i+h/t*r;c.x=e*Math.cos(p),c.y=e*Math.sin(p),a.push(c.x,c.y,c.z),o.push(0,0,1),u.x=(a[d]/e+1)/2,u.y=(a[d+1]/e+1)/2,l.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new De(a,3)),this.setAttribute("normal",new De(o,3)),this.setAttribute("uv",new De(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ld(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class ma extends ct{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;r=Math.floor(r),s=Math.floor(s);const u=[],h=[],d=[],p=[];let m=0;const v=[],f=i/2;let g=0;x(),a===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(u),this.setAttribute("position",new De(h,3)),this.setAttribute("normal",new De(d,3)),this.setAttribute("uv",new De(p,2));function x(){const _=new N,I=new N;let b=0;const w=(t-e)/i;for(let C=0;C<=s;C++){const H=[],M=C/s,T=M*(t-e)+e;for(let k=0;k<=r;k++){const j=k/r,Y=j*l+o,re=Math.sin(Y),$=Math.cos(Y);I.x=T*re,I.y=-M*i+f,I.z=T*$,h.push(I.x,I.y,I.z),_.set(re,w,$).normalize(),d.push(_.x,_.y,_.z),p.push(j,1-M),H.push(m++)}v.push(H)}for(let C=0;C<r;C++)for(let H=0;H<s;H++){const M=v[H][C],T=v[H+1][C],k=v[H+1][C+1],j=v[H][C+1];e>0&&(u.push(M,T,j),b+=3),t>0&&(u.push(T,k,j),b+=3)}c.addGroup(g,b,0),g+=b}function y(_){const I=m,b=new J,w=new N;let C=0;const H=_===!0?e:t,M=_===!0?1:-1;for(let k=1;k<=r;k++)h.push(0,f*M,0),d.push(0,M,0),p.push(.5,.5),m++;const T=m;for(let k=0;k<=r;k++){const j=k/r*l+o,Y=Math.cos(j),re=Math.sin(j);w.x=H*re,w.y=f*M,w.z=H*Y,h.push(w.x,w.y,w.z),d.push(0,M,0),b.x=Y*.5+.5,b.y=re*.5*M+.5,p.push(b.x,b.y),m++}for(let k=0;k<r;k++){const j=I+k,Y=T+k;_===!0?u.push(Y,Y+1,j):u.push(Y+1,Y,j),C+=3}c.addGroup(g,C,_===!0?1:2),g+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ma(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Pd extends ma{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,i,r,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Pd(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class fs extends ct{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const s=[],a=[];o(r),c(i),u(),this.setAttribute("position",new De(s,3)),this.setAttribute("normal",new De(s.slice(),3)),this.setAttribute("uv",new De(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(x){const y=new N,_=new N,I=new N;for(let b=0;b<t.length;b+=3)p(t[b+0],y),p(t[b+1],_),p(t[b+2],I),l(y,_,I,x)}function l(x,y,_,I){const b=I+1,w=[];for(let C=0;C<=b;C++){w[C]=[];const H=x.clone().lerp(_,C/b),M=y.clone().lerp(_,C/b),T=b-C;for(let k=0;k<=T;k++)k===0&&C===b?w[C][k]=H:w[C][k]=H.clone().lerp(M,k/T)}for(let C=0;C<b;C++)for(let H=0;H<2*(b-C)-1;H++){const M=Math.floor(H/2);H%2===0?(d(w[C][M+1]),d(w[C+1][M]),d(w[C][M])):(d(w[C][M+1]),d(w[C+1][M+1]),d(w[C+1][M]))}}function c(x){const y=new N;for(let _=0;_<s.length;_+=3)y.x=s[_+0],y.y=s[_+1],y.z=s[_+2],y.normalize().multiplyScalar(x),s[_+0]=y.x,s[_+1]=y.y,s[_+2]=y.z}function u(){const x=new N;for(let y=0;y<s.length;y+=3){x.x=s[y+0],x.y=s[y+1],x.z=s[y+2];const _=f(x)/2/Math.PI+.5,I=g(x)/Math.PI+.5;a.push(_,1-I)}m(),h()}function h(){for(let x=0;x<a.length;x+=6){const y=a[x+0],_=a[x+2],I=a[x+4],b=Math.max(y,_,I),w=Math.min(y,_,I);b>.9&&w<.1&&(y<.2&&(a[x+0]+=1),_<.2&&(a[x+2]+=1),I<.2&&(a[x+4]+=1))}}function d(x){s.push(x.x,x.y,x.z)}function p(x,y){const _=x*3;y.x=e[_+0],y.y=e[_+1],y.z=e[_+2]}function m(){const x=new N,y=new N,_=new N,I=new N,b=new J,w=new J,C=new J;for(let H=0,M=0;H<s.length;H+=9,M+=6){x.set(s[H+0],s[H+1],s[H+2]),y.set(s[H+3],s[H+4],s[H+5]),_.set(s[H+6],s[H+7],s[H+8]),b.set(a[M+0],a[M+1]),w.set(a[M+2],a[M+3]),C.set(a[M+4],a[M+5]),I.copy(x).add(y).add(_).divideScalar(3);const T=f(I);v(b,M+0,x,T),v(w,M+2,y,T),v(C,M+4,_,T)}}function v(x,y,_,I){I<0&&x.x===1&&(a[y]=x.x-1),_.x===0&&_.z===0&&(a[y]=I/2/Math.PI+.5)}function f(x){return Math.atan2(x.z,-x.x)}function g(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fs(e.vertices,e.indices,e.radius,e.details)}}class Dd extends fs{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Dd(e.radius,e.detail)}}const rh=new N,nh=new N,Tm=new N,sh=new er;class Sm extends ct{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),r=Math.cos(Es*t),s=e.getIndex(),a=e.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),h={},d=[];for(let p=0;p<o;p+=3){s?(l[0]=s.getX(p),l[1]=s.getX(p+1),l[2]=s.getX(p+2)):(l[0]=p,l[1]=p+1,l[2]=p+2);const{a:m,b:v,c:f}=sh;if(m.fromBufferAttribute(a,l[0]),v.fromBufferAttribute(a,l[1]),f.fromBufferAttribute(a,l[2]),sh.getNormal(Tm),u[0]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,u[1]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,u[2]=`${Math.round(f.x*i)},${Math.round(f.y*i)},${Math.round(f.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let g=0;g<3;g++){const x=(g+1)%3,y=u[g],_=u[x],I=sh[c[g]],b=sh[c[x]],w=`${y}_${_}`,C=`${_}_${y}`;C in h&&h[C]?(Tm.dot(h[C].normal)<=r&&(d.push(I.x,I.y,I.z),d.push(b.x,b.y,b.z)),h[C]=null):w in h||(h[w]={index0:l[g],index1:l[x],normal:Tm.clone()})}}for(const p in h)if(h[p]){const{index0:m,index1:v}=h[p];rh.fromBufferAttribute(a,m),nh.fromBufferAttribute(a,v),d.push(rh.x,rh.y,rh.z),d.push(nh.x,nh.y,nh.z)}this.setAttribute("position",new De(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class rs extends Tl{constructor(e){super(e),this.uuid=vr(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(new Tl().fromJSON(r))}return this}}const aI={triangulate:function(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let s=Vy(n,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c,u,h,d,p;if(i&&(s=hI(n,e,s,t)),n.length>80*t){o=c=n[0],l=u=n[1];for(let m=t;m<r;m+=t)h=n[m],d=n[m+1],h<o&&(o=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);p=Math.max(c-o,u-l),p=p!==0?32767/p:0}return Sl(s,a,t,o,l,p,0),a}};function Vy(n,e,t,i,r){let s,a;if(r===bI(n,e,t,i)>0)for(s=e;s<t;s+=i)a=ky(s,n[s],n[s+1],a);else for(s=t-i;s>=e;s-=i)a=ky(s,n[s],n[s+1],a);return a&&ah(a,a.next)&&(El(a),a=a.next),a}function ks(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(ah(t,t.next)||Xt(t.prev,t,t.next)===0)){if(El(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Sl(n,e,t,i,r,s,a){if(!n)return;!a&&s&&gI(n,i,r,s);let o=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?lI(n,i,r,s):oI(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),El(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=cI(ks(n),e,t),Sl(n,e,t,i,r,s,2)):a===2&&uI(n,e,t,i,r,s):Sl(ks(n),e,t,i,r,s,1);break}}}function oI(n){const e=n.prev,t=n,i=n.next;if(Xt(e,t,i)>=0)return!1;const r=e.x,s=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=r<s?r<a?r:a:s<a?s:a,h=o<l?o<c?o:c:l<c?l:c,d=r>s?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let m=i.next;for(;m!==e;){if(m.x>=u&&m.x<=d&&m.y>=h&&m.y<=p&&Qa(r,o,s,l,a,c,m.x,m.y)&&Xt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function lI(n,e,t,i){const r=n.prev,s=n,a=n.next;if(Xt(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,u=r.y,h=s.y,d=a.y,p=o<l?o<c?o:c:l<c?l:c,m=u<h?u<d?u:d:h<d?h:d,v=o>l?o>c?o:c:l>c?l:c,f=u>h?u>d?u:d:h>d?h:d,g=wm(p,m,e,t,i),x=wm(v,f,e,t,i);let y=n.prevZ,_=n.nextZ;for(;y&&y.z>=g&&_&&_.z<=x;){if(y.x>=p&&y.x<=v&&y.y>=m&&y.y<=f&&y!==r&&y!==a&&Qa(o,u,l,h,c,d,y.x,y.y)&&Xt(y.prev,y,y.next)>=0||(y=y.prevZ,_.x>=p&&_.x<=v&&_.y>=m&&_.y<=f&&_!==r&&_!==a&&Qa(o,u,l,h,c,d,_.x,_.y)&&Xt(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;y&&y.z>=g;){if(y.x>=p&&y.x<=v&&y.y>=m&&y.y<=f&&y!==r&&y!==a&&Qa(o,u,l,h,c,d,y.x,y.y)&&Xt(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=v&&_.y>=m&&_.y<=f&&_!==r&&_!==a&&Qa(o,u,l,h,c,d,_.x,_.y)&&Xt(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function cI(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!ah(r,s)&&By(r,i,i.next,s)&&wl(r,s)&&wl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),El(i),El(i.next),i=n=s),i=i.next}while(i!==n);return ks(i)}function uI(n,e,t,i,r,s){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&xI(a,o)){let l=zy(a,o);a=ks(a,a.next),l=ks(l,l.next),Sl(a,e,t,i,r,s,0),Sl(l,e,t,i,r,s,0);return}o=o.next}a=a.next}while(a!==n)}function hI(n,e,t,i){const r=[];let s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*i,l=s<a-1?e[s+1]*i:n.length,c=Vy(n,o,l,i,!1),c===c.next&&(c.steiner=!0),r.push(yI(c));for(r.sort(dI),s=0;s<r.length;s++)t=pI(r[s],t);return t}function dI(n,e){return n.x-e.x}function pI(n,e){const t=mI(n,e);if(!t)return e;const i=zy(t,n);return ks(i,i.next),ks(t,t.next)}function mI(n,e){let t=e,i=-1/0,r;const s=n.x,a=n.y;do{if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const d=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=s&&d>i&&(i=d,r=t.x<t.next.x?t:t.next,d===s))return r}t=t.next}while(t!==e);if(!r)return null;const o=r,l=r.x,c=r.y;let u=1/0,h;t=r;do s>=t.x&&t.x>=l&&s!==t.x&&Qa(a<c?s:i,a,l,c,a<c?i:s,a,t.x,t.y)&&(h=Math.abs(a-t.y)/(s-t.x),wl(t,n)&&(h<u||h===u&&(t.x>r.x||t.x===r.x&&fI(r,t)))&&(r=t,u=h)),t=t.next;while(t!==o);return r}function fI(n,e){return Xt(n.prev,n,e.prev)<0&&Xt(e.next,n,n.next)<0}function gI(n,e,t,i){let r=n;do r.z===0&&(r.z=wm(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,vI(r)}function vI(n){let e,t,i,r,s,a,o,l,c=1;do{for(t=n,n=null,s=null,a=0;t;){for(a++,i=t,o=0,e=0;e<c&&(o++,i=i.nextZ,!!i);e++);for(l=c;o>0||l>0&&i;)o!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,c*=2}while(a>1);return n}function wm(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function yI(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function Qa(n,e,t,i,r,s,a,o){return(r-a)*(e-o)>=(n-a)*(s-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(r-a)*(i-o)}function xI(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!_I(n,e)&&(wl(n,e)&&wl(e,n)&&MI(n,e)&&(Xt(n.prev,n,e.prev)||Xt(n,e.prev,e))||ah(n,e)&&Xt(n.prev,n,n.next)>0&&Xt(e.prev,e,e.next)>0)}function Xt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function ah(n,e){return n.x===e.x&&n.y===e.y}function By(n,e,t,i){const r=lh(Xt(n,e,t)),s=lh(Xt(n,e,i)),a=lh(Xt(t,i,n)),o=lh(Xt(t,i,e));return!!(r!==s&&a!==o||r===0&&oh(n,t,e)||s===0&&oh(n,i,e)||a===0&&oh(t,n,i)||o===0&&oh(t,e,i))}function oh(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function lh(n){return n>0?1:n<0?-1:0}function _I(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&By(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function wl(n,e){return Xt(n.prev,n,n.next)<0?Xt(n,e,n.next)>=0&&Xt(n,n.prev,e)>=0:Xt(n,e,n.prev)<0||Xt(n,n.next,e)<0}function MI(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function zy(n,e){const t=new Em(n.i,n.x,n.y),i=new Em(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function ky(n,e,t,i){const r=new Em(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function El(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Em(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function bI(n,e,t,i){let r=0;for(let s=e,a=t-i;s<t;s+=i)r+=(n[a]-n[s])*(n[s+1]+n[a+1]),a=s;return r}class nn{static area(e){const t=e.length;let i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return nn.area(e)<0}static triangulateShape(e,t){const i=[],r=[],s=[];Hy(e),Gy(i,e);let a=e.length;t.forEach(Hy);for(let l=0;l<t.length;l++)r.push(a),a+=t[l].length,Gy(i,t[l]);const o=aI.triangulate(i,r);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function Hy(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Gy(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class _c extends ct{constructor(e=new rs([new J(.5,.5),new J(-.5,.5),new J(-.5,-.5),new J(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],s=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new De(r,3)),this.setAttribute("uv",new De(s,2)),this.computeVertexNormals();function a(o){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,v=t.bevelOffset!==void 0?t.bevelOffset:0,f=t.bevelSegments!==void 0?t.bevelSegments:3;const g=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:TI;let y,_=!1,I,b,w,C;g&&(y=g.getSpacedPoints(u),_=!0,d=!1,I=g.computeFrenetFrames(u,!1),b=new N,w=new N,C=new N),d||(f=0,p=0,m=0,v=0);const H=o.extractPoints(c);let M=H.shape;const T=H.holes;if(!nn.isClockWise(M)){M=M.reverse();for(let ce=0,ue=T.length;ce<ue;ce++){const L=T[ce];nn.isClockWise(L)&&(T[ce]=L.reverse())}}const k=nn.triangulateShape(M,T),j=M;for(let ce=0,ue=T.length;ce<ue;ce++){const L=T[ce];M=M.concat(L)}function Y(ce,ue,L){return ue||console.error("THREE.ExtrudeGeometry: vec does not exist"),ce.clone().addScaledVector(ue,L)}const re=M.length,$=k.length;function he(ce,ue,L){let He,pe,Ue;const we=ce.x-ue.x,$e=ce.y-ue.y,Be=L.x-ce.x,R=L.y-ce.y,S=we*we+$e*$e,W=we*R-$e*Be;if(Math.abs(W)>Number.EPSILON){const ne=Math.sqrt(S),de=Math.sqrt(Be*Be+R*R),se=ue.x-$e/ne,ke=ue.y+we/ne,Ee=L.x-R/de,Pe=L.y+Be/de,mt=((Ee-se)*R-(Pe-ke)*Be)/(we*R-$e*Be);He=se+we*mt-ce.x,pe=ke+$e*mt-ce.y;const ve=He*He+pe*pe;if(ve<=2)return new J(He,pe);Ue=Math.sqrt(ve/2)}else{let ne=!1;we>Number.EPSILON?Be>Number.EPSILON&&(ne=!0):we<-Number.EPSILON?Be<-Number.EPSILON&&(ne=!0):Math.sign($e)===Math.sign(R)&&(ne=!0),ne?(He=-$e,pe=we,Ue=Math.sqrt(S)):(He=we,pe=$e,Ue=Math.sqrt(S/2))}return new J(He/Ue,pe/Ue)}const Q=[];for(let ce=0,ue=j.length,L=ue-1,He=ce+1;ce<ue;ce++,L++,He++)L===ue&&(L=0),He===ue&&(He=0),Q[ce]=he(j[ce],j[L],j[He]);const ye=[];let be,Ve=Q.concat();for(let ce=0,ue=T.length;ce<ue;ce++){const L=T[ce];be=[];for(let He=0,pe=L.length,Ue=pe-1,we=He+1;He<pe;He++,Ue++,we++)Ue===pe&&(Ue=0),we===pe&&(we=0),be[He]=he(L[He],L[Ue],L[we]);ye.push(be),Ve=Ve.concat(be)}for(let ce=0;ce<f;ce++){const ue=ce/f,L=p*Math.cos(ue*Math.PI/2),He=m*Math.sin(ue*Math.PI/2)+v;for(let pe=0,Ue=j.length;pe<Ue;pe++){const we=Y(j[pe],Q[pe],He);Te(we.x,we.y,-L)}for(let pe=0,Ue=T.length;pe<Ue;pe++){const we=T[pe];be=ye[pe];for(let $e=0,Be=we.length;$e<Be;$e++){const R=Y(we[$e],be[$e],He);Te(R.x,R.y,-L)}}}const at=m+v;for(let ce=0;ce<re;ce++){const ue=d?Y(M[ce],Ve[ce],at):M[ce];_?(w.copy(I.normals[0]).multiplyScalar(ue.x),b.copy(I.binormals[0]).multiplyScalar(ue.y),C.copy(y[0]).add(w).add(b),Te(C.x,C.y,C.z)):Te(ue.x,ue.y,0)}for(let ce=1;ce<=u;ce++)for(let ue=0;ue<re;ue++){const L=d?Y(M[ue],Ve[ue],at):M[ue];_?(w.copy(I.normals[ce]).multiplyScalar(L.x),b.copy(I.binormals[ce]).multiplyScalar(L.y),C.copy(y[ce]).add(w).add(b),Te(C.x,C.y,C.z)):Te(L.x,L.y,h/u*ce)}for(let ce=f-1;ce>=0;ce--){const ue=ce/f,L=p*Math.cos(ue*Math.PI/2),He=m*Math.sin(ue*Math.PI/2)+v;for(let pe=0,Ue=j.length;pe<Ue;pe++){const we=Y(j[pe],Q[pe],He);Te(we.x,we.y,h+L)}for(let pe=0,Ue=T.length;pe<Ue;pe++){const we=T[pe];be=ye[pe];for(let $e=0,Be=we.length;$e<Be;$e++){const R=Y(we[$e],be[$e],He);_?Te(R.x,R.y+y[u-1].y,y[u-1].x+L):Te(R.x,R.y,h+L)}}}et(),ie();function et(){const ce=r.length/3;if(d){let ue=0,L=re*ue;for(let He=0;He<$;He++){const pe=k[He];Se(pe[2]+L,pe[1]+L,pe[0]+L)}ue=u+f*2,L=re*ue;for(let He=0;He<$;He++){const pe=k[He];Se(pe[0]+L,pe[1]+L,pe[2]+L)}}else{for(let ue=0;ue<$;ue++){const L=k[ue];Se(L[2],L[1],L[0])}for(let ue=0;ue<$;ue++){const L=k[ue];Se(L[0]+re*u,L[1]+re*u,L[2]+re*u)}}i.addGroup(ce,r.length/3-ce,0)}function ie(){const ce=r.length/3;let ue=0;le(j,ue),ue+=j.length;for(let L=0,He=T.length;L<He;L++){const pe=T[L];le(pe,ue),ue+=pe.length}i.addGroup(ce,r.length/3-ce,1)}function le(ce,ue){let L=ce.length;for(;--L>=0;){const He=L;let pe=L-1;pe<0&&(pe=ce.length-1);for(let Ue=0,we=u+f*2;Ue<we;Ue++){const $e=re*Ue,Be=re*(Ue+1),R=ue+He+$e,S=ue+pe+$e,W=ue+pe+Be,ne=ue+He+Be;Ye(R,S,W,ne)}}}function Te(ce,ue,L){l.push(ce),l.push(ue),l.push(L)}function Se(ce,ue,L){We(ce),We(ue),We(L);const He=r.length/3,pe=x.generateTopUV(i,r,He-3,He-2,He-1);ot(pe[0]),ot(pe[1]),ot(pe[2])}function Ye(ce,ue,L,He){We(ce),We(ue),We(He),We(ue),We(L),We(He);const pe=r.length/3,Ue=x.generateSideWallUV(i,r,pe-6,pe-3,pe-2,pe-1);ot(Ue[0]),ot(Ue[1]),ot(Ue[3]),ot(Ue[1]),ot(Ue[2]),ot(Ue[3])}function We(ce){r.push(l[ce*3+0]),r.push(l[ce*3+1]),r.push(l[ce*3+2])}function ot(ce){s.push(ce.x),s.push(ce.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return SI(t,i,e)}static fromJSON(e,t){const i=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];i.push(o)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new ih[r.type]().fromJSON(r)),new _c(i,e.options)}}const TI={generateTopUV:function(n,e,t,i,r){const s=e[t*3],a=e[t*3+1],o=e[i*3],l=e[i*3+1],c=e[r*3],u=e[r*3+1];return[new J(s,a),new J(o,l),new J(c,u)]},generateSideWallUV:function(n,e,t,i,r,s){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[i*3],u=e[i*3+1],h=e[i*3+2],d=e[r*3],p=e[r*3+1],m=e[r*3+2],v=e[s*3],f=e[s*3+1],g=e[s*3+2];return Math.abs(o-u)<Math.abs(a-c)?[new J(a,1-l),new J(c,1-h),new J(d,1-m),new J(v,1-g)]:[new J(o,1-l),new J(u,1-h),new J(p,1-m),new J(f,1-g)]}};function SI(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){const s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Ud extends fs{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ud(e.radius,e.detail)}}class Eo extends fs{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Eo(e.radius,e.detail)}}class Mc extends ct{constructor(e=.5,t=1,i=32,r=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:a},i=Math.max(3,i),r=Math.max(1,r);const o=[],l=[],c=[],u=[];let h=e;const d=(t-e)/r,p=new N,m=new J;for(let v=0;v<=r;v++){for(let f=0;f<=i;f++){const g=s+f/i*a;p.x=h*Math.cos(g),p.y=h*Math.sin(g),l.push(p.x,p.y,p.z),c.push(0,0,1),m.x=(p.x/t+1)/2,m.y=(p.y/t+1)/2,u.push(m.x,m.y)}h+=d}for(let v=0;v<r;v++){const f=v*(i+1);for(let g=0;g<i;g++){const x=g+f,y=x,_=x+i+1,I=x+i+2,b=x+1;o.push(y,_,b),o.push(_,I,b)}}this.setIndex(o),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Mc(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Od extends ct{constructor(e=new rs([new J(0,.5),new J(-.5,-.5),new J(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],s=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(o,l,u),o+=l,l=0;this.setIndex(i),this.setAttribute("position",new De(r,3)),this.setAttribute("normal",new De(s,3)),this.setAttribute("uv",new De(a,2));function c(u){const h=r.length/3,d=u.extractPoints(t);let p=d.shape;const m=d.holes;nn.isClockWise(p)===!1&&(p=p.reverse());for(let f=0,g=m.length;f<g;f++){const x=m[f];nn.isClockWise(x)===!0&&(m[f]=x.reverse())}const v=nn.triangulateShape(p,m);for(let f=0,g=m.length;f<g;f++){const x=m[f];p=p.concat(x)}for(let f=0,g=p.length;f<g;f++){const x=p[f];r.push(x.x,x.y,0),s.push(0,0,1),a.push(x.x,x.y)}for(let f=0,g=v.length;f<g;f++){const x=v[f],y=x[0]+h,_=x[1]+h,I=x[2]+h;i.push(y,_,I),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return wI(t,e)}static fromJSON(e,t){const i=[];for(let r=0,s=e.shapes.length;r<s;r++){const a=t[e.shapes[r]];i.push(a)}return new Od(i,e.curveSegments)}}function wI(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}class Ao extends ct{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(a+o,Math.PI);let c=0;const u=[],h=new N,d=new N,p=[],m=[],v=[],f=[];for(let g=0;g<=i;g++){const x=[],y=g/i;let _=0;g===0&&a===0?_=.5/t:g===i&&l===Math.PI&&(_=-.5/t);for(let I=0;I<=t;I++){const b=I/t;h.x=-e*Math.cos(r+b*s)*Math.sin(a+y*o),h.y=e*Math.cos(a+y*o),h.z=e*Math.sin(r+b*s)*Math.sin(a+y*o),m.push(h.x,h.y,h.z),d.copy(h).normalize(),v.push(d.x,d.y,d.z),f.push(b+_,1-y),x.push(c++)}u.push(x)}for(let g=0;g<i;g++)for(let x=0;x<t;x++){const y=u[g][x+1],_=u[g][x],I=u[g+1][x],b=u[g+1][x+1];(g!==0||a>0)&&p.push(y,_,b),(g!==i-1||l<Math.PI)&&p.push(_,I,b)}this.setIndex(p),this.setAttribute("position",new De(m,3)),this.setAttribute("normal",new De(v,3)),this.setAttribute("uv",new De(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ao(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Fd extends fs{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Fd(e.radius,e.detail)}}class bc extends ct{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);const a=[],o=[],l=[],c=[],u=new N,h=new N,d=new N;for(let p=0;p<=i;p++)for(let m=0;m<=r;m++){const v=m/r*s,f=p/i*Math.PI*2;h.x=(e+t*Math.cos(f))*Math.cos(v),h.y=(e+t*Math.cos(f))*Math.sin(v),h.z=t*Math.sin(f),o.push(h.x,h.y,h.z),u.x=e*Math.cos(v),u.y=e*Math.sin(v),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(m/r),c.push(p/i)}for(let p=1;p<=i;p++)for(let m=1;m<=r;m++){const v=(r+1)*p+m-1,f=(r+1)*(p-1)+m-1,g=(r+1)*(p-1)+m,x=(r+1)*p+m;a.push(v,f,x),a.push(f,g,x)}this.setIndex(a),this.setAttribute("position",new De(o,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bc(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Vd extends ct{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);const o=[],l=[],c=[],u=[],h=new N,d=new N,p=new N,m=new N,v=new N,f=new N,g=new N;for(let y=0;y<=i;++y){const _=y/i*s*Math.PI*2;x(_,s,a,e,p),x(_+.01,s,a,e,m),f.subVectors(m,p),g.addVectors(m,p),v.crossVectors(f,g),g.crossVectors(v,f),v.normalize(),g.normalize();for(let I=0;I<=r;++I){const b=I/r*Math.PI*2,w=-t*Math.cos(b),C=t*Math.sin(b);h.x=p.x+(w*g.x+C*v.x),h.y=p.y+(w*g.y+C*v.y),h.z=p.z+(w*g.z+C*v.z),l.push(h.x,h.y,h.z),d.subVectors(h,p).normalize(),c.push(d.x,d.y,d.z),u.push(y/i),u.push(I/r)}}for(let y=1;y<=i;y++)for(let _=1;_<=r;_++){const I=(r+1)*(y-1)+(_-1),b=(r+1)*y+(_-1),w=(r+1)*y+_,C=(r+1)*(y-1)+_;o.push(I,b,C),o.push(b,w,C)}this.setIndex(o),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2));function x(y,_,I,b,w){const C=Math.cos(y),H=Math.sin(y),M=I/_*y,T=Math.cos(M);w.x=b*(2+T)*.5*C,w.y=b*(2+T)*H*.5,w.z=b*Math.sin(M)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vd(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Bd extends ct{constructor(e=new Mm(new N(-1,-1,0),new N(-1,1,0),new N(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new N,l=new N,c=new J;let u=new N;const h=[],d=[],p=[],m=[];v(),this.setIndex(m),this.setAttribute("position",new De(h,3)),this.setAttribute("normal",new De(d,3)),this.setAttribute("uv",new De(p,2));function v(){for(let y=0;y<t;y++)f(y);f(s===!1?t:0),x(),g()}function f(y){u=e.getPointAt(y/t,u);const _=a.normals[y],I=a.binormals[y];for(let b=0;b<=r;b++){const w=b/r*Math.PI*2,C=Math.sin(w),H=-Math.cos(w);l.x=H*_.x+C*I.x,l.y=H*_.y+C*I.y,l.z=H*_.z+C*I.z,l.normalize(),d.push(l.x,l.y,l.z),o.x=u.x+i*l.x,o.y=u.y+i*l.y,o.z=u.z+i*l.z,h.push(o.x,o.y,o.z)}}function g(){for(let y=1;y<=t;y++)for(let _=1;_<=r;_++){const I=(r+1)*(y-1)+(_-1),b=(r+1)*y+(_-1),w=(r+1)*y+_,C=(r+1)*(y-1)+_;m.push(I,b,C),m.push(b,w,C)}}function x(){for(let y=0;y<=t;y++)for(let _=0;_<=r;_++)c.x=y/t,c.y=_/r,p.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new Bd(new ih[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Am extends ct{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,r=new N,s=new N;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const h=l[c],d=h.start,p=h.count;for(let m=d,v=d+p;m<v;m+=3)for(let f=0;f<3;f++){const g=o.getX(m+f),x=o.getX(m+(f+1)%3);r.fromBufferAttribute(a,g),s.fromBufferAttribute(a,x),Wy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const u=3*o+c,h=3*o+(c+1)%3;r.fromBufferAttribute(a,u),s.fromBufferAttribute(a,h),Wy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new De(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Wy(n,e,t){const i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}var jy=Object.freeze({__proto__:null,BoxGeometry:yn,CapsuleGeometry:Id,CircleGeometry:Ld,ConeGeometry:Pd,CylinderGeometry:ma,DodecahedronGeometry:Dd,EdgesGeometry:Sm,ExtrudeGeometry:_c,IcosahedronGeometry:Ud,LatheGeometry:xc,OctahedronGeometry:Eo,PlaneGeometry:pa,PolyhedronGeometry:fs,RingGeometry:Mc,ShapeGeometry:Od,SphereGeometry:Ao,TetrahedronGeometry:Fd,TorusGeometry:bc,TorusKnotGeometry:Vd,TubeGeometry:Bd,WireframeGeometry:Am});class ch extends hi{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new xe(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class Nm extends Pr{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Al extends hi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new xe(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 xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hr,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.envMapRotation.copy(e.envMapRotation),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 uh extends Al{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new J(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Jt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new xe(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 xe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new xe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=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 dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=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.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,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.dispersion=e.dispersion,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}}class hh extends hi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new xe(16777215),this.specular=new xe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hr,this.combine=ga,this.reflectivity=1,this.refractionRatio=.98,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.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,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.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,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 Cm extends hi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new xe(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,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.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class dh extends hi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class ph extends hi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hr,this.combine=ga,this.reflectivity=1,this.refractionRatio=.98,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.color.copy(e.color),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.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,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 Rm extends hi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new xe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,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.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class mh extends Ni{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Hs(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Xy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function qy(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Im(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,a=0;a!==i;++s){const o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=n[o+l]}return r}function Lm(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let a=s[i];if(a!==void 0)if(Array.isArray(a))do a=s[i],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=n[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[i],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do a=s[i],a!==void 0&&(e.push(s.time),t.push(a)),s=n[r++];while(s!==void 0)}function EI(n,e,t,i,r=30){const s=n.clone();s.name=e;const a=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],u=c.getValueSize(),h=[],d=[];for(let p=0;p<c.times.length;++p){const m=c.times[p]*r;if(!(m<t||m>=i)){h.push(c.times[p]);for(let v=0;v<u;++v)d.push(c.values[p*u+v])}}h.length!==0&&(c.times=Hs(h,c.times.constructor),c.values=Hs(d,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function AI(n,e=0,t=n,i=30){i<=0&&(i=30);const r=t.tracks.length,s=e/i;for(let a=0;a<r;++a){const o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const c=n.tracks.find(function(g){return g.name===o.name&&g.ValueTypeName===l});if(c===void 0)continue;let u=0;const h=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let d=0;const p=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=p/3);const m=o.times.length-1;let v;if(s<=o.times[0]){const g=u,x=h-u;v=o.values.slice(g,x)}else if(s>=o.times[m]){const g=m*h+u,x=g+h-u;v=o.values.slice(g,x)}else{const g=o.createInterpolant(),x=u,y=h-u;g.evaluate(s),v=g.resultBuffer.slice(x,y)}l==="quaternion"&&new qi().fromArray(v).normalize().conjugate().toArray(v);const f=c.times.length;for(let g=0;g<f;++g){const x=g*p+d;if(l==="quaternion")qi.multiplyQuaternionsFlat(c.values,x,v,0,c.values,x);else{const y=p-d*2;for(let _=0;_<y;++_)c.values[x+_]-=v[_]}}}return n.blendMode=lp,n}const NI={convertArray:Hs,isTypedArray:Xy,getKeyframeOrder:qy,sortedArray:Im,flattenJSON:Lm,subclip:EI,makeClipAdditive:AI};class eo{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let a;i:{r:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=s)){const o=t[1];e<o&&(i=2,s=o);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=s,s=t[--i-1],e>=s)break t}a=i,i=0;break i}break e}for(;i<a;){const o=i+a>>>1;e<t[o]?a=o:i=o+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Yy extends eo{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:bs,endingEnd:bs}}intervalChanged_(e,t,i){const r=this.parameterPositions;let s=e-2,a=e+1,o=r[s],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case Ts:s=e,o=2*t-i;break;case $o:s=r.length-2,o=t+r[s]-r[s+1];break;default:s=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case Ts:a=e,l=2*i-t;break;case $o:a=1,l=i+r[1]-r[0];break;default:a=e-1,l=t}const c=(i-t)*.5,u=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-i),this._offsetPrev=s*u,this._offsetNext=a*u}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,p=this._weightNext,m=(i-t)/(r-t),v=m*m,f=v*m,g=-d*f+2*d*v-d*m,x=(1+d)*f+(-1.5-2*d)*v+(-.5+d)*m+1,y=(-1-p)*f+(1.5+p)*v+.5*m,_=p*f-p*v;for(let I=0;I!==o;++I)s[I]=g*a[u+I]+x*a[c+I]+y*a[l+I]+_*a[h+I];return s}}class Pm extends eo{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=(i-t)/(r-t),h=1-u;for(let d=0;d!==o;++d)s[d]=a[c+d]*h+a[l+d]*u;return s}}class $y extends eo{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Jr{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Hs(t,this.TimeBufferType),this.values=Hs(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Hs(e.times,Array),values:Hs(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new $y(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Pm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Yy(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ta:t=this.InterpolantFactoryMethodDiscrete;break;case Yo:t=this.InterpolantFactoryMethodLinear;break;case su:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ta;case this.InterpolantFactoryMethodLinear:return Yo;case this.InterpolantFactoryMethodSmooth:return su}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){const i=this.times,r=i.length;let s=0,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=i.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&Xy(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===su,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],u=e[o+1];if(c!==u&&(o!==1||c!==e[0]))if(r)l=!0;else{const h=o*i,d=h-i,p=h+i;for(let m=0;m!==i;++m){const v=t[h+m];if(v!==t[d+m]||v!==t[p+m]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const h=o*i,d=a*i;for(let p=0;p!==i;++p)t[d+p]=t[h+p]}++a}}if(s>0){e[a]=e[s];for(let o=s*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Jr.prototype.TimeBufferType=Float32Array,Jr.prototype.ValueBufferType=Float32Array,Jr.prototype.DefaultInterpolation=Yo;class Gs extends Jr{constructor(e,t,i){super(e,t,i)}}Gs.prototype.ValueTypeName="bool",Gs.prototype.ValueBufferType=Array,Gs.prototype.DefaultInterpolation=Ta,Gs.prototype.InterpolantFactoryMethodLinear=void 0,Gs.prototype.InterpolantFactoryMethodSmooth=void 0;class fh extends Jr{}fh.prototype.ValueTypeName="color";class to extends Jr{}to.prototype.ValueTypeName="number";class Jy extends eo{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(r-t);let c=e*o;for(let u=c+o;c!==u;c+=4)qi.slerpFlat(s,0,a,c-o,a,c,l);return s}}class io extends Jr{InterpolantFactoryMethodLinear(e){return new Jy(this.times,this.values,this.getValueSize(),e)}}io.prototype.ValueTypeName="quaternion",io.prototype.InterpolantFactoryMethodSmooth=void 0;class Ws extends Jr{constructor(e,t,i){super(e,t,i)}}Ws.prototype.ValueTypeName="string",Ws.prototype.ValueBufferType=Array,Ws.prototype.DefaultInterpolation=Ta,Ws.prototype.InterpolantFactoryMethodLinear=void 0,Ws.prototype.InterpolantFactoryMethodSmooth=void 0;class ro extends Jr{}ro.prototype.ValueTypeName="vector";class no{constructor(e="",t=-1,i=[],r=au){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=vr(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(RI(i[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(Jr.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const u=qy(l);l=Im(l,1,u),c=Im(c,1,u),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new to(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const r={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],u=c.name.match(s);if(u&&u.length>1){const h=u[1];let d=r[h];d||(r[h]=d=[]),d.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(u,h,d,p,m){if(d.length!==0){const v=[],f=[];Lm(d,v,f,p),v.length!==0&&m.push(new u(h,v,f))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u<c.length;u++){const h=c[u].keys;if(!(!h||h.length===0))if(h[0].morphTargets){const d={};let p;for(p=0;p<h.length;p++)if(h[p].morphTargets)for(let m=0;m<h[p].morphTargets.length;m++)d[h[p].morphTargets[m]]=-1;for(const m in d){const v=[],f=[];for(let g=0;g!==h[p].morphTargets.length;++g){const x=h[p];v.push(x.time),f.push(x.morphTarget===m?1:0)}r.push(new to(".morphTargetInfluence["+m+"]",v,f))}l=d.length*a}else{const d=".bones["+t[u].name+"]";i(ro,d+".position",h,"pos",r),i(io,d+".quaternion",h,"rot",r),i(ro,d+".scale",h,"scl",r)}}return r.length===0?null:new this(s,l,r,o)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function CI(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return to;case"vector":case"vector2":case"vector3":case"vector4":return ro;case"color":return fh;case"quaternion":return io;case"bool":case"boolean":return Gs;case"string":return Ws}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function RI(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=CI(n.type);if(n.times===void 0){const t=[],i=[];Lm(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const Rn={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class gh{constructor(e,t,i){const r=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){o++,s===!1&&r.onStart!==void 0&&r.onStart(u,a,o),s=!0},this.itemEnd=function(u){a++,r.onProgress!==void 0&&r.onProgress(u,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){const h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){const p=c[h],m=c[h+1];if(p.global&&(p.lastIndex=0),p.test(u))return m}return null}}}const Dm=new gh;class Hi{constructor(e){this.manager=e!==void 0?e:Dm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}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}}Hi.DEFAULT_MATERIAL_NAME="__DEFAULT";const In={};class II extends Error{constructor(e,t){super(e),this.response=t}}class Kr extends Hi{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=Rn.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(In[e]!==void 0){In[e].push({onLoad:t,onProgress:i,onError:r});return}In[e]=[],In[e].push({onLoad:t,onProgress:i,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=In[e],h=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,m=p!==0;let v=0;const f=new ReadableStream({start(g){x();function x(){h.read().then(({done:y,value:_})=>{if(y)g.close();else{v+=_.byteLength;const I=new ProgressEvent("progress",{lengthComputable:m,loaded:v,total:p});for(let b=0,w=u.length;b<w;b++){const C=u[b];C.onProgress&&C.onProgress(I)}g.enqueue(_),x()}},y=>{g.error(y)})}}});return new Response(f)}else throw new II(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),h=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(h);return c.arrayBuffer().then(p=>d.decode(p))}}}).then(c=>{Rn.add(e,c);const u=In[e];delete In[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onLoad&&p.onLoad(c)}}).catch(c=>{const u=In[e];if(u===void 0)throw this.manager.itemError(e),c;delete In[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onError&&p.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 LI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i<e.length;i++){const r=no.parse(e[i]);t.push(r)}return t}}class PI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=[],o=new _l,l=new Kr(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function u(h){l.load(e[h],function(d){const p=s.parse(d,!0);a[h]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},c+=1,c===6&&(p.mipmapCount===1&&(o.minFilter=Lt),o.image=a,o.format=p.format,o.needsUpdate=!0,t&&t(o))},i,r)}if(Array.isArray(e))for(let h=0,d=e.length;h<d;++h)u(h);else l.load(e,function(h){const d=s.parse(h,!0);if(d.isCubemap){const p=d.mipmaps.length/d.mipmapCount;for(let m=0;m<p;m++){a[m]={mipmaps:[]};for(let v=0;v<d.mipmapCount;v++)a[m].mipmaps.push(d.mipmaps[m*d.mipmapCount+v]),a[m].format=d.format,a[m].width=d.width,a[m].height=d.height}o.image=a}else o.image.width=d.width,o.image.height=d.height,o.mipmaps=d.mipmaps;d.mipmapCount===1&&(o.minFilter=Lt),o.format=d.format,o.needsUpdate=!0,t&&t(o)},i,r);return o}}class Nl extends Hi{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Rn.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=tl("img");function l(){u(),Rn.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(h){u(),r&&r(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class DI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=new Is;s.colorSpace=Fi;const a=new Nl(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(u){s.images[c]=u,o++,o===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let c=0;c<e.length;++c)l(c);return s}}class Ky extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Ur,o=new Kr(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let c;try{c=s.parse(l)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:fr,a.wrapT=c.wrapT!==void 0?c.wrapT:fr,a.magFilter=c.magFilter!==void 0?c.magFilter:Lt,a.minFilter=c.minFilter!==void 0?c.minFilter:Lt,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=ji),c.mipmapCount===1&&(a.minFilter=Lt),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},i,r),a}}class Zy extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=new Wt,a=new Nl(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}}class ns extends _t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new xe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class vh extends ns{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new xe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Um=new Re,Qy=new N,ex=new N;class Om{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new J(512,512),this.map=null,this.mapPass=null,this.matrix=new Re,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ha,this._frameExtents=new J(1,1),this._viewportCount=1,this._viewports=[new st(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;Qy.setFromMatrixPosition(e.matrixWorld),t.position.copy(Qy),ex.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ex),t.updateMatrixWorld(),Um.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Um),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Um)}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.intensity=e.intensity,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.intensity!==1&&(e.intensity=this.intensity),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 UI extends Om{constructor(){super(new di(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=Ea*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Cl extends ns{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new UI}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const tx=new Re,Rl=new N,Fm=new N;class OI extends Om{constructor(){super(new di(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new J(4,2),this._viewportCount=6,this._viewports=[new st(2,1,1,1),new st(0,1,1,1),new st(3,1,1,1),new st(1,1,1,1),new st(3,0,1,1),new st(1,0,1,1)],this._cubeDirections=[new N(1,0,0),new N(-1,0,0),new N(0,0,1),new N(0,0,-1),new N(0,1,0),new N(0,-1,0)],this._cubeUps=[new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,0,1),new N(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Rl.setFromMatrixPosition(e.matrixWorld),i.position.copy(Rl),Fm.copy(i.position),Fm.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Fm),i.updateMatrixWorld(),r.makeTranslation(-Rl.x,-Rl.y,-Rl.z),tx.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(tx)}}class yh extends ns{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new OI}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class FI extends Om{constructor(){super(new Ds(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class xh extends ns{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new FI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class _h extends ns{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Vm extends ns{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class ix{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new N)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*i),t.addScaledVector(a[4],1.092548*(i*r)),t.addScaledVector(a[5],1.092548*(r*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(i*s)),t.addScaledVector(a[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){const i=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*s),t.addScaledVector(a[3],2*.511664*i),t.addScaledVector(a[4],2*.429043*i*r),t.addScaledVector(a[5],2*.429043*r*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*i*s),t.addScaledVector(a[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}}class Bm extends ns{constructor(e=new ix,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Tc extends Hi{constructor(e){super(e),this.textures={}}load(e,t,i,r){const s=this,a=new Kr(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new xe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(r.uniforms[s]={},a.type){case"t":r.uniforms[s].value=i(a.value);break;case"c":r.uniforms[s].value=new xe().setHex(a.value);break;case"v2":r.uniforms[s].value=new J().fromArray(a.value);break;case"v3":r.uniforms[s].value=new N().fromArray(a.value);break;case"v4":r.uniforms[s].value=new st().fromArray(a.value);break;case"m3":r.uniforms[s].value=new Ke().fromArray(a.value);break;case"m4":r.uniforms[s].value=new Re().fromArray(a.value);break;default:r.uniforms[s].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new J().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new J().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return Tc.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:ch,SpriteMaterial:dl,RawShaderMaterial:Nm,ShaderMaterial:Pr,PointsMaterial:Za,MeshPhysicalMaterial:uh,MeshStandardMaterial:Al,MeshPhongMaterial:hh,MeshToonMaterial:Cm,MeshNormalMaterial:dh,MeshLambertMaterial:ph,MeshDepthMaterial:Fu,MeshDistanceMaterial:qp,MeshBasicMaterial:Yr,MeshMatcapMaterial:Rm,LineDashedMaterial:mh,LineBasicMaterial:Ni,Material:hi};return new t[e]}}class Mh{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class zm extends ct{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class rx extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(d,p){if(t[p]!==void 0)return t[p];const m=d.interleavedBuffers[p],v=s(d,m.buffer),f=Aa(m.type,v),g=new Xa(f,m.stride);return g.uuid=m.uuid,t[p]=g,g}function s(d,p){if(i[p]!==void 0)return i[p];const m=d.arrayBuffers[p],v=new Uint32Array(m).buffer;return i[p]=v,v}const a=e.isInstancedBufferGeometry?new zm:new ct,o=e.data.index;if(o!==void 0){const d=Aa(o.type,o.array);a.setIndex(new wt(d,1))}const l=e.data.attributes;for(const d in l){const p=l[d];let m;if(p.isInterleavedBufferAttribute){const v=r(e.data,p.data);m=new On(v,p.itemSize,p.offset,p.normalized)}else{const v=Aa(p.type,p.array),f=p.isInstancedBufferAttribute?Nn:wt;m=new f(v,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),a.setAttribute(d,m)}const c=e.data.morphAttributes;if(c)for(const d in c){const p=c[d],m=[];for(let v=0,f=p.length;v<f;v++){const g=p[v];let x;if(g.isInterleavedBufferAttribute){const y=r(e.data,g.data);x=new On(y,g.itemSize,g.offset,g.normalized)}else{const y=Aa(g.type,g.array);x=new wt(y,g.itemSize,g.normalized)}g.name!==void 0&&(x.name=g.name),m.push(x)}a.morphAttributes[d]=m}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let d=0,p=u.length;d!==p;++d){const m=u[d];a.addGroup(m.start,m.count,m.materialIndex)}const h=e.data.boundingSphere;if(h!==void 0){const d=new N;h.center!==void 0&&d.fromArray(h.center),a.boundingSphere=new Ai(d,h.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class nx extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=this.path===""?Mh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new Kr(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(h){r!==void 0&&r(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}const u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},i,r)}async loadAsync(e,t){const i=this,r=this.path===""?Mh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const s=new Kr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=await s.loadAsync(e,t),o=JSON.parse(a),l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(o)}parse(e,t){const i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,s,l,o,i),u=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,u),this.bindLightTargets(c),t!==void 0){let h=!1;for(const d in a)if(a[d].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,o,a,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){const s=new rs().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){const i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=new yc().fromJSON(e[s],r);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new rx;for(let s=0,a=e.length;s<a;s++){let o;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(l);break;default:l.type in jy?o=jy[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),i[l.uuid]=o}}return i}parseMaterials(e,t){const i={},r={};if(e!==void 0){const s=new Tc;s.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];i[l.uuid]===void 0&&(i[l.uuid]=s.parse(l)),r[l.uuid]=i[l.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const r=e[i],s=no.parse(r);t[s.uuid]=s}return t}parseImages(e,t){const i=this,r={};let s;function a(l){return i.manager.itemStart(l),s.load(l,function(){i.manager.itemEnd(l)},void 0,function(){i.manager.itemError(l),i.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){const c=l,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return a(u)}else return l.data?{data:Aa(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new gh(t);s=new Nl(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c<u;c++){const h=e[c],d=h.url;if(Array.isArray(d)){const p=[];for(let m=0,v=d.length;m<v;m++){const f=d[m],g=o(f);g!==null&&(g instanceof HTMLImageElement?p.push(g):p.push(new Ur(g.data,g.width,g.height)))}r[h.uuid]=new $n(p)}else{const p=o(h.url);r[h.uuid]=new $n(p)}}}return r}async parseImagesAsync(e){const t=this,i={};let r;async function s(a){if(typeof a=="string"){const o=a,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await r.loadAsync(l)}else return a.data?{data:Aa(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new Nl(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){const l=e[a],c=l.url;if(Array.isArray(c)){const u=[];for(let h=0,d=c.length;h<d;h++){const p=c[h],m=await s(p);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new Ur(m.data,m.width,m.height)))}i[l.uuid]=new $n(u)}else{const u=await s(l.url);i[l.uuid]=new $n(u)}}}return i}parseTextures(e,t){function i(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const r={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=e[s];o.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const l=t[o.image],c=l.data;let u;Array.isArray(c)?(u=new Is,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new Ur:u=new Wt,c&&(u.needsUpdate=!0)),u.source=l,u.uuid=o.uuid,o.name!==void 0&&(u.name=o.name),o.mapping!==void 0&&(u.mapping=i(o.mapping,VI)),o.channel!==void 0&&(u.channel=o.channel),o.offset!==void 0&&u.offset.fromArray(o.offset),o.repeat!==void 0&&u.repeat.fromArray(o.repeat),o.center!==void 0&&u.center.fromArray(o.center),o.rotation!==void 0&&(u.rotation=o.rotation),o.wrap!==void 0&&(u.wrapS=i(o.wrap[0],sx),u.wrapT=i(o.wrap[1],sx)),o.format!==void 0&&(u.format=o.format),o.internalFormat!==void 0&&(u.internalFormat=o.internalFormat),o.type!==void 0&&(u.type=o.type),o.colorSpace!==void 0&&(u.colorSpace=o.colorSpace),o.minFilter!==void 0&&(u.minFilter=i(o.minFilter,ax)),o.magFilter!==void 0&&(u.magFilter=i(o.magFilter,ax)),o.anisotropy!==void 0&&(u.anisotropy=o.anisotropy),o.flipY!==void 0&&(u.flipY=o.flipY),o.generateMipmaps!==void 0&&(u.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(u.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(u.compareFunction=o.compareFunction),o.userData!==void 0&&(u.userData=o.userData),r[o.uuid]=u}return r}parseObject(e,t,i,r,s){let a;function o(d){return t[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",d),t[d]}function l(d){if(d!==void 0){if(Array.isArray(d)){const p=[];for(let m=0,v=d.length;m<v;m++){const f=d[m];i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),p.push(i[f])}return p}return i[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),i[d]}}function c(d){return r[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",d),r[d]}let u,h;switch(e.type){case"Scene":a=new Vu,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new xe(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new Kp(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Rd(e.fog.color,e.fog.density)),e.fog.name!==""&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new di(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new Ds(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new _h(e.color,e.intensity);break;case"DirectionalLight":a=new xh(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new yh(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Vm(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Cl(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new vh(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new Bm().fromJSON(e);break;case"SkinnedMesh":u=o(e.geometry),h=l(e.material),a=new rm(u,h),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":u=o(e.geometry),h=l(e.material),a=new Ft(u,h);break;case"InstancedMesh":u=o(e.geometry),h=l(e.material);const d=e.count,p=e.instanceMatrix,m=e.instanceColor;a=new nm(u,h,d),a.instanceMatrix=new Nn(new Float32Array(p.array),16),m!==void 0&&(a.instanceColor=new Nn(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=o(e.geometry),h=l(e.material),a=new lm(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,h),a.geometry=u,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._visibility=e.visibility,a._active=e.active,a._bounds=e.bounds.map(v=>{const f=new Bi;f.min.fromArray(v.boxMin),f.max.fromArray(v.boxMax);const g=new Ai;return g.radius=v.sphereRadius,g.center.fromArray(v.sphereCenter),{boxInitialized:v.boxInitialized,box:f,sphereInitialized:v.sphereInitialized,sphere:g}}),a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":a=new em;break;case"Line":a=new Cn(o(e.geometry),l(e.material));break;case"LineLoop":a=new um(o(e.geometry),l(e.material));break;case"LineSegments":a=new $r(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new dm(o(e.geometry),l(e.material));break;case"Sprite":a=new Qp(l(e.material));break;case"Group":a=new Vs;break;case"Bone":a=new Wu;break;default:a=new _t}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const d=e.children;for(let p=0;p<d.length;p++)a.add(this.parseObject(d[p],t,i,r,s))}if(e.animations!==void 0){const d=e.animations;for(let p=0;p<d.length;p++){const m=d[p];a.animations.push(s[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const d=e.levels;for(let p=0;p<d.length;p++){const m=d[p],v=a.getObjectByProperty("uuid",m.object);v!==void 0&&a.addLevel(v,m.distance,m.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const i=t.target,r=e.getObjectByProperty("uuid",i);r!==void 0?t.target=r:t.target=new _t}})}}const VI={UVMapping:Pc,CubeReflectionMapping:mr,CubeRefractionMapping:Ar,EquirectangularReflectionMapping:kn,EquirectangularRefractionMapping:Hn,CubeUVReflectionMapping:xs},sx={RepeatWrapping:Gn,ClampToEdgeWrapping:fr,MirroredRepeatWrapping:va},ax={NearestFilter:$t,NearestMipmapNearestFilter:Dc,NearestMipmapLinearFilter:Mn,LinearFilter:Lt,LinearMipmapNearestFilter:Wn,LinearMipmapLinearFilter:ji};class ox extends Hi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Rn.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return Rn.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),Rn.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});Rn.add(e,l),s.manager.itemStart(e)}}let bh;class Th{static getContext(){return bh===void 0&&(bh=new(window.AudioContext||window.webkitAudioContext)),bh}static setContext(e){bh=e}}class lx extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0);Th.getContext().decodeAudioData(c,function(u){t(u)}).catch(o)}catch(c){o(c)}},i,r);function o(l){r?r(l):console.error(l),s.manager.itemError(e)}}}const cx=new Re,ux=new Re,js=new Re;class km{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new di,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new di,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,js.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,s=t.near*Math.tan(Es*t.fov*.5)/t.zoom;let a,o;ux.elements[12]=-i,cx.elements[12]=i,a=-s*t.aspect+r,o=s*t.aspect+r,js.elements[0]=2*t.near/(o-a),js.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(js),a=-s*t.aspect-r,o=s*t.aspect-r,js.elements[0]=2*t.near/(o-a),js.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(js)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(ux),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(cx)}}class Hm{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=hx(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=hx();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function hx(){return performance.now()}const cn=new N,dx=new qi,BI=new N,Xs=new N;let px=class extends _t{constructor(){super(),this.type="AudioListener",this.context=Th.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Hm}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(n){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=n,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(n){return this.gain.gain.setTargetAtTime(n,this.context.currentTime,.01),this}updateMatrixWorld(n){super.updateMatrixWorld(n);const e=this.context.listener,t=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(cn,dx,BI),!(!Number.isFinite(cn.x)||!Number.isFinite(cn.y)||!Number.isFinite(cn.z)))if(Xs.set(0,0,-1).applyQuaternion(dx),e.positionX){const i=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(cn.x,i),e.positionY.linearRampToValueAtTime(cn.y,i),e.positionZ.linearRampToValueAtTime(cn.z,i),e.forwardX.linearRampToValueAtTime(Xs.x,i),e.forwardY.linearRampToValueAtTime(Xs.y,i),e.forwardZ.linearRampToValueAtTime(Xs.z,i),e.upX.linearRampToValueAtTime(t.x,i),e.upY.linearRampToValueAtTime(t.y,i),e.upZ.linearRampToValueAtTime(t.z,i)}else e.setPosition(cn.x,cn.y,cn.z),e.setOrientation(Xs.x,Xs.y,Xs.z,t.x,t.y,t.z)}};class Gm extends _t{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||(this.buffer?this.buffer.duration:Number.MAX_VALUE))),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const qs=new N,mx=new qi,zI=new N,Ys=new N;class fx extends Gm{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(qs,mx,zI),Ys.set(0,0,1).applyQuaternion(mx);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(qs.x,i),t.positionY.linearRampToValueAtTime(qs.y,i),t.positionZ.linearRampToValueAtTime(qs.z,i),t.orientationX.linearRampToValueAtTime(Ys.x,i),t.orientationY.linearRampToValueAtTime(Ys.y,i),t.orientationZ.linearRampToValueAtTime(Ys.z,i)}else t.setPosition(qs.x,qs.y,qs.z),t.setOrientation(Ys.x,Ys.y,Ys.z)}}class kI{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}}class gx{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,r=this.valueSize,s=e*r+r;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==r;++o)i[s+o]=i[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(i,s,0,o,r)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(i,r,l,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){o.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,a=r;s!==a;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){qi.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const a=this._workIndex*s;qi.multiplyQuaternionsFlat(e,a,e,t,e,i),qi.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){const a=1-r;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[i+o]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[i+a]*r}}}const Wm="\\[\\]\\.:\\/",HI=new RegExp("["+Wm+"]","g"),jm="[^"+Wm+"]",GI="[^"+Wm.replace("\\.","")+"]",WI=/((?:WC+[\/:])*)/.source.replace("WC",jm),jI=/(WCOD+)?/.source.replace("WCOD",GI),XI=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",jm),qI=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",jm),YI=new RegExp("^"+WI+jI+XI+qI+"$"),$I=["material","materials","bones","map"];class JI{constructor(e,t,i){const r=i||Tt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class Tt{constructor(e,t,i){this.path=t,this.parsedPath=i||Tt.parseTrackName(t),this.node=Tt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Tt.Composite(e,t,i):new Tt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(HI,"")}static parseTrackName(e){const t=YI.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=i.nodeName.substring(r+1);$I.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s,a){for(let o=0;o<s.length;o++){const l=s[o];if(!a&&(l.name===t||l.uuid===t)||a&&l.userData&&l.userData.name===t)return l;const c=i(l.children,a);if(c)return c}return null},r=i(e.children);if(r)return r;{const s=i(e.children,!0);if(s)return s}}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,r=t.propertyName;let s=t.propertyIndex;if(e||(e=Tt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[r];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Tt.Composite=JI,Tt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Tt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Tt.prototype.GetterByBindingType=[Tt.prototype._getValue_direct,Tt.prototype._getValue_array,Tt.prototype._getValue_arrayElement,Tt.prototype._getValue_toArray],Tt.prototype.SetterByBindingTypeAndVersioning=[[Tt.prototype._setValue_direct,Tt.prototype._setValue_direct_setNeedsUpdate,Tt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_array,Tt.prototype._setValue_array_setNeedsUpdate,Tt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_arrayElement,Tt.prototype._setValue_arrayElement_setNeedsUpdate,Tt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_fromArray,Tt.prototype._setValue_fromArray_setNeedsUpdate,Tt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class KI{constructor(){this.isAnimationObjectGroup=!0,this.uuid=vr(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length;let o,l=e.length,c=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){const d=arguments[u],p=d.uuid;let m=t[p];if(m===void 0){m=l++,t[p]=m,e.push(d);for(let v=0,f=a;v!==f;++v)s[v].push(new Tt(d,i[v],r[v]))}else if(m<c){o=e[m];const v=--c,f=e[v];t[f.uuid]=m,e[m]=f,t[p]=v,e[v]=d;for(let g=0,x=a;g!==x;++g){const y=s[g],_=y[v];let I=y[m];y[m]=_,I===void 0&&(I=new Tt(d,i[g],r[g])),y[v]=I}}else e[m]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],c=l.uuid,u=t[c];if(u!==void 0&&u>=s){const h=s++,d=e[h];t[d.uuid]=u,e[u]=d,t[c]=h,e[h]=l;for(let p=0,m=r;p!==m;++p){const v=i[p],f=v[h],g=v[u];v[u]=f,v[h]=g}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],u=c.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<s){const d=--s,p=e[d],m=--a,v=e[m];t[p.uuid]=h,e[h]=p,t[v.uuid]=d,e[d]=v,e.pop();for(let f=0,g=r;f!==g;++f){const x=i[f],y=x[d],_=x[m];x[h]=y,x[d]=_,x.pop()}}else{const d=--a,p=e[d];d>0&&(t[p.uuid]=h),e[h]=p,e.pop();for(let m=0,v=r;m!==v;++m){const f=i[m];f[h]=f[d],f.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const s=this._bindings;if(r!==void 0)return s[r];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,h=new Array(c);r=s.length,i[e]=r,a.push(e),o.push(t),s.push(h);for(let d=u,p=l.length;d!==p;++d){const m=l[d];h[d]=new Tt(m,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=i,a[i]=l,a.pop(),s[i]=s[o],s.pop(),r[i]=r[o],r.pop()}}}class vx{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:bs,endingEnd:bs};for(let c=0;c!==a;++c){const u=s[c].createInterpolant(null);o[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=op,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const r=this._clip.duration,s=e._clip.duration,a=s/r,o=r/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const r=this._mixer,s=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/a,c[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case lp:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulateAdditive(o);break;case au:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,s=this._loopCount;const a=i===F0;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===ap){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const o=Math.floor(r/t);r-=t*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=Ts,r.endingEnd=Ts):(e?r.endingStart=this.zeroSlopeAtStart?Ts:bs:r.endingStart=$o,t?r.endingEnd=this.zeroSlopeAtEnd?Ts:bs:r.endingEnd=$o)}_scheduleFading(e,t,i){const r=this._mixer,s=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=i,this}}const ZI=new Float32Array(1);class yx extends gr{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,o=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){const d=r[h],p=d.name;let m=u[p];if(m!==void 0)++m.referenceCount,a[h]=m;else{if(m=a[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const v=t&&t._propertyBindings[h].binding.parsedPath;m=new gx(Tt.create(i,p,v),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),a[h]=m}o[h].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){const r=this._actions,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;const h=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete h[d],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){const r=this._bindingsByRootAndName,s=this._bindings;let a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,o=a[r],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new Pm(new Float32Array(2),new Float32Array(2),1,ZI),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){const r=t||this._root,s=r.uuid;let a=typeof e=="string"?no.findByName(r,e):e;const o=a!==null?a.uuid:e,l=this._actionsByClip[o];let c=null;if(i===void 0&&(a!==null?i=a.blendMode:i=au),l!==void 0){const h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===i)return h;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;const u=new vx(this,a,t,i);return this._bindAction(u,c),this._addInactiveAction(u,o,s),u}existingAction(e,t){const i=t||this._root,r=i.uuid,s=typeof e=="string"?no.findByName(i,e):e,a=s?s.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(r,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){const a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){const c=a[o];this._deactivateAction(c);const u=c._cacheIndex,h=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(c)}delete r[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const a in i){const o=i[a].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}let xx=class XS{constructor(e){this.value=e}clone(){return new XS(this.value.clone===void 0?this.value:this.value.clone())}},QI=0;class e2 extends gr{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:QI++}),this.name="",this.usage=wa,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){const s=Array.isArray(t[i])?t[i]:[t[i]];for(let a=0;a<s.length;a++)this.uniforms.push(s[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class Xm extends Xa{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class t2{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const _x=new Re;class Mx{constructor(e,t,i=0,r=1/0){this.ray=new Cs(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new al,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return _x.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(_x),this}intersectObject(e,t=!0,i=[]){return qm(e,this,i,t),i.sort(bx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)qm(e[r],this,i,t);return i.sort(bx),i}}function bx(n,e){return n.distance-e.distance}function qm(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const s=n.children;for(let a=0,o=s.length;a<o;a++)qm(s[a],e,t,!0)}}class Tx{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Jt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class i2{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}}class s0{constructor(e,t,i,r){s0.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=i,s[3]=r,this}}const Sx=new J;class r2{constructor(e=new J(1/0,1/0),t=new J(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Sx.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Sx).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const wx=new N,Sh=new N;class Ex{constructor(e=new N,t=new N){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){wx.subVectors(e,this.start),Sh.subVectors(this.end,this.start);const i=Sh.dot(Sh);let r=Sh.dot(wx)/i;return t&&(r=Jt(r,0,1)),r}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Ax=new N;class n2 extends _t{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new ct,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a<l;a++,o++){const c=a/l*Math.PI*2,u=o/l*Math.PI*2;r.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new De(r,3));const s=new Ni({fog:!1,toneMapped:!1});this.cone=new $r(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Ax.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Ax),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const ss=new N,wh=new Re,Ym=new Re;class s2 extends $r{constructor(e){const t=Nx(e),i=new ct,r=[],s=[],a=new xe(0,0,1),o=new xe(0,1,0);for(let c=0;c<t.length;c++){const u=t[c];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(a.r,a.g,a.b),s.push(o.r,o.g,o.b))}i.setAttribute("position",new De(r,3)),i.setAttribute("color",new De(s,3));const l=new Ni({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,i=this.geometry,r=i.getAttribute("position");Ym.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const o=t[s];o.parent&&o.parent.isBone&&(wh.multiplyMatrices(Ym,o.matrixWorld),ss.setFromMatrixPosition(wh),r.setXYZ(a,ss.x,ss.y,ss.z),wh.multiplyMatrices(Ym,o.parent.matrixWorld),ss.setFromMatrixPosition(wh),r.setXYZ(a+1,ss.x,ss.y,ss.z),a+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function Nx(n){const e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,Nx(n.children[t]));return e}class a2 extends Ft{constructor(e,t,i){const r=new Ao(t,4,2),s=new Yr({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const o2=new N,Cx=new xe,Rx=new xe;class l2 extends _t{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const r=new Eo(t);r.rotateY(Math.PI*.5),this.material=new Yr({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=r.getAttribute("position"),a=new Float32Array(s.count*3);r.setAttribute("color",new wt(a,3)),this.add(new Ft(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Cx.copy(this.light.color),Rx.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){const s=i<r/2?Cx:Rx;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(o2.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Ix=class extends $r{constructor(n=10,e=10,t=4473924,i=8947848){t=new xe(t),i=new xe(i);const r=e/2,s=n/e,a=n/2,o=[],l=[];for(let h=0,d=0,p=-a;h<=e;h++,p+=s){o.push(-a,0,p,a,0,p),o.push(p,0,-a,p,0,a);const m=h===r?t:i;m.toArray(l,d),d+=3,m.toArray(l,d),d+=3,m.toArray(l,d),d+=3,m.toArray(l,d),d+=3}const c=new ct;c.setAttribute("position",new De(o,3)),c.setAttribute("color",new De(l,3));const u=new Ni({vertexColors:!0,toneMapped:!1});super(c,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};class c2 extends $r{constructor(e=10,t=16,i=8,r=64,s=4473924,a=8947848){s=new xe(s),a=new xe(a);const o=[],l=[];if(t>1)for(let h=0;h<t;h++){const d=h/t*(Math.PI*2),p=Math.sin(d)*e,m=Math.cos(d)*e;o.push(0,0,0),o.push(p,0,m);const v=h&1?s:a;l.push(v.r,v.g,v.b),l.push(v.r,v.g,v.b)}for(let h=0;h<i;h++){const d=h&1?s:a,p=e-e/i*h;for(let m=0;m<r;m++){let v=m/r*(Math.PI*2),f=Math.sin(v)*p,g=Math.cos(v)*p;o.push(f,0,g),l.push(d.r,d.g,d.b),v=(m+1)/r*(Math.PI*2),f=Math.sin(v)*p,g=Math.cos(v)*p,o.push(f,0,g),l.push(d.r,d.g,d.b)}}const c=new ct;c.setAttribute("position",new De(o,3)),c.setAttribute("color",new De(l,3));const u=new Ni({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Lx=new N,Eh=new N,Px=new N;class Dx extends _t{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new ct;r.setAttribute("position",new De([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new Ni({fog:!1,toneMapped:!1});this.lightPlane=new Cn(r,s),this.add(this.lightPlane),r=new ct,r.setAttribute("position",new De([0,0,0,0,0,1],3)),this.targetLine=new Cn(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Lx.setFromMatrixPosition(this.light.matrixWorld),Eh.setFromMatrixPosition(this.light.target.matrixWorld),Px.subVectors(Eh,Lx),this.lightPlane.lookAt(Eh),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Eh),this.targetLine.scale.z=Px.length()}}const Ah=new N,Kt=new ul;class Ux extends $r{constructor(e){const t=new ct,i=new Ni({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(m,v){l(m),l(v)}function l(m){r.push(0,0,0),s.push(0,0,0),a[m]===void 0&&(a[m]=[]),a[m].push(r.length/3-1)}t.setAttribute("position",new De(r,3)),t.setAttribute("color",new De(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const c=new xe(16755200),u=new xe(16711680),h=new xe(43775),d=new xe(16777215),p=new xe(3355443);this.setColors(c,u,h,d,p)}setColors(e,t,i,r,s){const a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,i=1,r=1;Kt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),ti("c",t,e,Kt,0,0,-1),ti("t",t,e,Kt,0,0,1),ti("n1",t,e,Kt,-i,-r,-1),ti("n2",t,e,Kt,i,-r,-1),ti("n3",t,e,Kt,-i,r,-1),ti("n4",t,e,Kt,i,r,-1),ti("f1",t,e,Kt,-i,-r,1),ti("f2",t,e,Kt,i,-r,1),ti("f3",t,e,Kt,-i,r,1),ti("f4",t,e,Kt,i,r,1),ti("u1",t,e,Kt,i*.7,r*1.1,-1),ti("u2",t,e,Kt,-i*.7,r*1.1,-1),ti("u3",t,e,Kt,0,r*2,-1),ti("cf1",t,e,Kt,-i,0,1),ti("cf2",t,e,Kt,i,0,1),ti("cf3",t,e,Kt,0,-r,1),ti("cf4",t,e,Kt,0,r,1),ti("cn1",t,e,Kt,-i,0,-1),ti("cn2",t,e,Kt,i,0,-1),ti("cn3",t,e,Kt,0,-r,-1),ti("cn4",t,e,Kt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function ti(n,e,t,i,r,s,a){Ah.set(r,s,a).unproject(i);const o=e[n];if(o!==void 0){const l=t.getAttribute("position");for(let c=0,u=o.length;c<u;c++)l.setXYZ(o[c],Ah.x,Ah.y,Ah.z)}}const Nh=new Bi;class Ox extends $r{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(8*3),s=new ct;s.setIndex(new wt(i,1)),s.setAttribute("position",new wt(r,3)),super(s,new Ni({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Nh.setFromObject(this.object),Nh.isEmpty())return;const t=Nh.min,i=Nh.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Fx extends $r{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new ct;s.setIndex(new wt(i,1)),s.setAttribute("position",new De(r,3)),super(s,new Ni({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class u2 extends Cn{constructor(e,t=1,i=16776960){const r=i,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new ct;a.setAttribute("position",new De(s,3)),a.computeBoundingSphere(),super(a,new Ni({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new ct;l.setAttribute("position",new De(o,3)),l.computeBoundingSphere(),this.add(new Ft(l,new Yr({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Vx=new N;let Ch,$m;class h2 extends _t{constructor(e=new N(0,0,1),t=new N(0,0,0),i=1,r=16776960,s=i*.2,a=s*.2){super(),this.type="ArrowHelper",Ch===void 0&&(Ch=new ct,Ch.setAttribute("position",new De([0,0,0,0,1,0],3)),$m=new ma(0,.5,1,5,1),$m.translate(0,-.5,0)),this.position.copy(t),this.line=new Cn(Ch,new Ni({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ft($m,new Yr({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Vx.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Vx,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}let Bx=class extends $r{constructor(n=1){const e=[0,0,0,n,0,0,0,0,0,0,n,0,0,0,0,0,0,n],t=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new ct;i.setAttribute("position",new De(e,3)),i.setAttribute("color",new De(t,3));const r=new Ni({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(n,e,t){const i=new xe,r=this.geometry.attributes.color.array;return i.set(n),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(t),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};class zx{constructor(){this.type="ShapePath",this.color=new xe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Tl,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,a){return this.currentPath.bezierCurveTo(e,t,i,r,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const x=[];for(let y=0,_=g.length;y<_;y++){const I=g[y],b=new rs;b.curves=I.curves,x.push(b)}return x}function i(g,x){const y=x.length;let _=!1;for(let I=y-1,b=0;b<y;I=b++){let w=x[I],C=x[b],H=C.x-w.x,M=C.y-w.y;if(Math.abs(M)>Number.EPSILON){if(M<0&&(w=x[b],H=-H,C=x[I],M=-M),g.y<w.y||g.y>C.y)continue;if(g.y===w.y){if(g.x===w.x)return!0}else{const T=M*(g.x-w.x)-H*(g.y-w.y);if(T===0)return!0;if(T<0)continue;_=!_}}else{if(g.y!==w.y)continue;if(C.x<=g.x&&g.x<=w.x||w.x<=g.x&&g.x<=C.x)return!0}}return _}const r=nn.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new rs,l.curves=o.curves,c.push(l),c;let u=!r(s[0].getPoints());u=e?!u:u;const h=[],d=[];let p=[],m=0,v;d[m]=void 0,p[m]=[];for(let g=0,x=s.length;g<x;g++)o=s[g],v=o.getPoints(),a=r(v),a=e?!a:a,a?(!u&&d[m]&&m++,d[m]={s:new rs,p:v},d[m].s.curves=o.curves,u&&m++,p[m]=[]):p[m].push({h:o,p:v[0]});if(!d[0])return t(s);if(d.length>1){let g=!1,x=0;for(let y=0,_=d.length;y<_;y++)h[y]=[];for(let y=0,_=d.length;y<_;y++){const I=p[y];for(let b=0;b<I.length;b++){const w=I[b];let C=!0;for(let H=0;H<d.length;H++)i(w.p,d[H].p)&&(y!==H&&x++,C?(C=!1,h[H].push(w)):g=!0);C&&h[y].push(w)}}x>0&&g===!1&&(p=h)}let f;for(let g=0,x=d.length;g<x;g++){l=d[g].s,c.push(l),f=p[g];for(let y=0,_=f.length;y<_;y++)l.holes.push(f[y].h)}return c}}class kx extends gr{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}class d2 extends Ir{constructor(e=1,t=1,i=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}const p2=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveMap","envMap","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class Hx{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=p2,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}getRenderObjectData(e){let t=this.renderObjects.get(e);return t===void 0&&(t={material:this.getMaterialData(e.material),worldMatrix:e.object.matrixWorld.clone()},e.object.center&&(t.center=e.object.center.clone()),e.object.morphTargetInfluences&&(t.morphTargetInfluences=e.object.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),this.renderObjects.set(e,t)),t}containsNode(e){const t=e.material;for(const i in t)if(t[i]&&t[i].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const i of this.refreshUniforms){const r=e[i];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[i]={id:r.id,version:r.version}:t[i]=r.clone():t[i]=r)}return t}equals(e){const{object:t,material:i}=e,r=this.getRenderObjectData(e);if(r.worldMatrix.equals(t.matrixWorld)!==!0)return r.worldMatrix.copy(t.matrixWorld),!1;const s=r.material;for(const a in s){const o=s[a],l=i[a];if(o.equals!==void 0){if(o.equals(l)===!1)return o.copy(l),!1}else if(l.isTexture===!0){if(o.id!==l.id||o.version!==l.version)return o.id=l.id,o.version=l.version,!1}else if(o!==l)return s[a]=l,!1}if(r.morphTargetInfluences){let a=!1;for(let o=0;o<r.morphTargetInfluences.length;o++)r.morphTargetInfluences[o]!==t.morphTargetInfluences[o]&&(a=!0);if(a)return!0}return r.center&&r.center.equals(t.center)===!1?(r.center.copy(t.center),!0):(e.bundle!==null&&(r.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e))return!0;const{renderId:i}=t;if(this.renderId!==i)return this.renderId=i,!0;const r=e.object.static===!0,s=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;return r||s?!1:this.equals(e)!==!0}}function Il(n,e=0){let t=3735928559^e,i=1103547991^e;if(n instanceof Array)for(let r=0,s;r<n.length;r++)s=n[r],t=Math.imul(t^s,2654435761),i=Math.imul(i^s,1597334677);else for(let r=0,s;r<n.length;r++)s=n.charCodeAt(r),t=Math.imul(t^s,2654435761),i=Math.imul(i^s,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&i)+(t>>>0)}const Gx=n=>Il(n),Wx=n=>Il(n),Jm=(...n)=>Il(n);function Km(n,e=!1){const t=[];n.isNode===!0&&(t.push(n.id),n=n.getSelf());for(const{property:i,childNode:r}of Ll(n))t.push(t,Il(i.slice(0,-4)),r.getCacheKey(e));return Il(t)}function*Ll(n,e=!1){for(const t in n){if(t.startsWith("_")===!0)continue;const i=n[t];if(Array.isArray(i)===!0)for(let r=0;r<i.length;r++){const s=i[r];s&&(s.isNode===!0||e&&typeof s.toJSON=="function")&&(yield{property:t,index:r,childNode:s})}else if(i&&i.isNode===!0)yield{property:t,childNode:i};else if(typeof i=="object")for(const r in i){const s=i[r];s&&(s.isNode===!0||e&&typeof s.toJSON=="function")&&(yield{property:t,index:r,childNode:s})}}}function Ln(n){if(n==null)return null;const e=typeof n;return n.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":n.isVector2===!0?"vec2":n.isVector3===!0?"vec3":n.isVector4===!0?"vec4":n.isMatrix3===!0?"mat3":n.isMatrix4===!0?"mat4":n.isColor===!0?"color":n instanceof ArrayBuffer?"ArrayBuffer":null}function Zm(n,...e){const t=n?n.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),n==="color"?new xe(...e):t==="vec2"?new J(...e):t==="vec3"?new N(...e):t==="vec4"?new st(...e):t==="mat3"?new Ke(...e):t==="mat4"?new Re(...e):n==="bool"?e[0]||!1:n==="float"||n==="int"||n==="uint"?e[0]||0:n==="string"?e[0]||"":n==="ArrayBuffer"?ef(e[0]):null}function Qm(n){let e="";const t=new Uint8Array(n);for(let i=0;i<t.length;i++)e+=String.fromCharCode(t[i]);return btoa(e)}function ef(n){return Uint8Array.from(atob(n),e=>e.charCodeAt(0)).buffer}var m2=Object.freeze({__proto__:null,arrayBufferToBase64:Qm,base64ToArrayBuffer:ef,getCacheKey:Km,getNodeChildren:Ll,getValueFromType:Zm,getValueType:Ln,hash:Jm,hashArray:Wx,hashString:Gx});const tf={VERTEX:"vertex",FRAGMENT:"fragment"},je={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},f2={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},jx=["fragment","vertex"],rf=["setup","analyze","generate"],nf=[...jx,"compute"],so=["x","y","z","w"];let g2=0;class qe extends gr{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=je.NONE,this.updateBeforeType=je.NONE,this.updateAfterType=je.NONE,this.uuid=cu.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:g2++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,je.FRAME)}onRenderUpdate(e){return this.onUpdate(e,je.RENDER)}onObjectUpdate(e){return this.onUpdate(e,je.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Ll(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=Km(this,e),this._cacheKeyVersion=this.version),this._cacheKey}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let i=0;for(const r of this.getChildren())t["node"+i++]=r;return null}analyze(e){if(e.increaseUsage(this)===1){const t=e.getNodeProperties(this);for(const i of Object.values(t))i&&i.isNode===!0&&i.build(e)}}generate(e,t){const{outputNode:i}=e.getNodeProperties(this);if(i&&i.isNode===!0)return i.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const i=this.getShared(e);if(this!==i)return i.build(e,t);e.addNode(this),e.addChain(this);let r=null;const s=e.getBuildStage();if(s==="setup"){this.updateReference(e);const a=e.getNodeProperties(this);if(a.initialized!==!0){const o=e.stack.nodes.length;a.initialized=!0,a.outputNode=this.setup(e),a.outputNode!==null&&e.stack.nodes.length;for(const l of Object.values(a))l&&l.isNode===!0&&l.build(e)}}else if(s==="analyze")this.analyze(e);else if(s==="generate")if(this.generate.length===1){const a=this.getNodeType(e),o=e.getDataFromNode(this);r=o.snippet,r===void 0?(r=this.generate(e)||"",o.snippet=r):o.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,a,t)}else r=this.generate(e,t)||"";return e.removeChain(this),r}getSerializeChildren(){return Ll(this)}serialize(e){const t=this.getSerializeChildren(),i={};for(const{property:r,index:s,childNode:a}of t)s!==void 0?(i[r]===void 0&&(i[r]=Number.isInteger(s)?[]:{}),i[r][s]=a.toJSON(e.meta).uuid):i[r]=a.toJSON(e.meta).uuid;Object.keys(i).length>0&&(e.inputNodes=i)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const i in e.inputNodes)if(Array.isArray(e.inputNodes[i])){const r=[];for(const s of e.inputNodes[i])r.push(t[s]);this[i]=r}else if(typeof e.inputNodes[i]=="object"){const r={};for(const s in e.inputNodes[i]){const a=e.inputNodes[i][s];r[s]=t[a]}this[i]=r}else{const r=e.inputNodes[i];this[i]=t[r]}}}toJSON(e){const{uuid:t,type:i}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];s===void 0&&(s={uuid:t,type:i,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}if(r){const o=a(e.textures),l=a(e.images),c=a(e.nodes);o.length>0&&(s.textures=o),l.length>0&&(s.images=l),c.length>0&&(s.nodes=c)}return s}}class as extends qe{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.node.build(e),i=this.indexNode.build(e,"uint");return`${t}[ ${i} ]`}}class sf extends qe{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let i=null;for(const r of this.convertTo.split("|"))(i===null||e.getTypeLength(t)===e.getTypeLength(r))&&(i=r);return i}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const i=this.node,r=this.getNodeType(e),s=i.build(e,r);return e.format(s,r,t)}}class pt extends qe{static get type(){return"TempNode"}constructor(e){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const i=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,i,t);if(i!=="void"&&t!=="void"&&this.hasDependencies(e)){const s=super.build(e,i),a=e.getVarFromNode(this,null,i),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${s}`,this),r.snippet=s,r.propertyName=o,e.format(r.propertyName,i,t)}}return super.build(e,t)}}class Xx extends pt{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,i)=>t+e.getTypeLength(i.getNodeType(e)),0))}generate(e,t){const i=this.getNodeType(e),r=this.nodes,s=e.getComponentType(i),a=[];for(const l of r){let c=l.build(e);const u=e.getComponentType(l.getNodeType(e));u!==s&&(c=e.format(c,u,s)),a.push(c)}const o=`${e.getType(i)}( ${a.join(", ")} )`;return e.format(o,i,t)}}const v2=so.join("");class Rh extends qe{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(so.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const i=this.node,r=e.getTypeLength(i.getNodeType(e));let s=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const o=i.build(e,a);this.components.length===r&&this.components===v2.slice(0,this.components.length)?s=e.format(o,a,t):s=e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else s=i.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class qx extends pt{static get type(){return"SetNode"}constructor(e,t,i){super(),this.sourceNode=e,this.components=t,this.targetNode=i}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:i,targetNode:r}=this,s=this.getNodeType(e),a=e.getTypeFromLength(i.length,r.getNodeType(e)),o=r.build(e,a),l=t.build(e,s),c=e.getTypeLength(s),u=[];for(let h=0;h<c;h++){const d=so[h];d===i[0]?(u.push(o),h+=i.length-1):u.push(l+"."+d)}return`${e.getType(s)}( ${u.join(", ")} )`}}class y2 extends pt{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:i}=this,r=this.getNodeType(e),s=i.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+" = "+s,this);const l=e.getTypeLength(r),c=[];let u=0;for(let h=0;h<l;h++){const d=so[h];d===t[u]?(c.push("1.0 - "+(o+"."+d)),u++):c.push(o+"."+d)}return`${e.getType(r)}( ${c.join(", ")} )`}}class af extends qe{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Ln(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Ln(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=Qm(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Zm(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}class Fr extends af{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const i=this.getNodeType(e);return e.format(this.generateConst(e),i,t)}}let ao=null;const oo=new Map;function te(n,e){if(oo.has(n)){console.warn(`Redefinition of method chaining ${n}`);return}if(typeof e!="function")throw new Error(`Node element ${n} is not a function`);oo.set(n,e)}const Yx=n=>n.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),$x=n=>Yx(n).split("").sort().join(""),Jx={setup(n,e){const t=e.shift();return n(Ul(t),...e)},get(n,e,t){if(typeof e=="string"&&n[e]===void 0){if(n.isStackNode!==!0&&e==="assign")return(...i)=>(ao.assign(t,...i),t);if(oo.has(e)){const i=oo.get(e);return n.isStackNode?(...r)=>t.add(i(...r)):(...r)=>i(t,...r)}else{if(e==="self")return n;if(e.endsWith("Assign")&&oo.has(e.slice(0,e.length-6))){const i=oo.get(e.slice(0,e.length-6));return n.isStackNode?(...r)=>t.assign(r[0],i(...r)):(...r)=>t.assign(i(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=Yx(e),G(new Rh(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=$x(e.slice(3).toLowerCase()),i=>G(new qx(n,e,i));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=$x(e.slice(4).toLowerCase()),()=>G(new y2(G(n),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),G(new Rh(n,e));if(/^\d+$/.test(e)===!0)return G(new as(t,new Fr(Number(e),"uint")))}}}return Reflect.get(n,e,t)},set(n,e,t,i){return typeof e=="string"&&n[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(i[e].assign(t),!0):Reflect.set(n,e,t,i)}},of=new WeakMap,Kx=new WeakMap,x2=function(n,e=null){const t=Ln(n);if(t==="node"){let i=of.get(n);return i===void 0&&(i=new Proxy(n,Jx),of.set(n,i),of.set(i,i)),i}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return G(hf(n,e));if(t==="shader")return U(n)}return n},_2=function(n,e=null){for(const t in n)n[t]=G(n[t],e);return n},M2=function(n,e=null){const t=n.length;for(let i=0;i<t;i++)n[i]=G(n[i],e);return n},b2=function(n,e=null,t=null,i=null){const r=s=>G(i!==null?Object.assign(s,i):s);return e===null?(...s)=>r(new n(...$s(s))):t!==null?(t=G(t),(...s)=>r(new n(e,...$s(s),t))):(...s)=>r(new n(e,...$s(s)))},T2=function(n,...e){return G(new n(...$s(e)))};class S2 extends qe{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:i}=this,r=e.getNodeProperties(t);if(r.onceOutput)return r.onceOutput;let s=null;if(t.layout){let a=Kx.get(e.constructor);a===void 0&&(a=new WeakMap,Kx.set(e.constructor,a));let o=a.get(t);o===void 0&&(o=G(e.buildFunctionNode(t)),a.set(t,o)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(o),s=G(o.call(i))}else{const a=t.jsFunc,o=i!==null?a(i,e):a(e);s=G(o)}return t.once&&(r.onceOutput=s),s}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class w2 extends qe{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Ul(e),G(new S2(this,e))}setup(){return this.call()}}const E2=[!1,!0],A2=[0,1,2,3],N2=[-1,-2],Zx=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],lf=new Map;for(const n of E2)lf.set(n,new Fr(n));const cf=new Map;for(const n of A2)cf.set(n,new Fr(n,"uint"));const uf=new Map([...cf].map(n=>new Fr(n.value,"int")));for(const n of N2)uf.set(n,new Fr(n,"int"));const Ih=new Map([...uf].map(n=>new Fr(n.value)));for(const n of Zx)Ih.set(n,new Fr(n));for(const n of Zx)Ih.set(-n,new Fr(-n));const Lh={bool:lf,uint:cf,ints:uf,float:Ih},Qx=new Map([...lf,...Ih]),hf=(n,e)=>Qx.has(n)?Qx.get(n):n.isNode===!0?n:new Fr(n,e),C2=n=>{try{return n.getNodeType()}catch{return}},oi=function(n,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(n)&&t.every(r=>typeof r!="object"))&&(t=[Zm(n,...t)]),t.length===1&&e!==null&&e.has(t[0]))return G(e.get(t[0]));if(t.length===1){const r=hf(t[0],n);return C2(r)===n?G(r):G(new sf(r,n))}const i=t.map(r=>hf(r));return G(new Xx(i,n))}},Pl=n=>typeof n=="object"&&n!==null?n.value:n,e_=n=>n!=null?n.nodeType||n.convertTo||(typeof n=="string"?n:null):null;function Dl(n,e){return new Proxy(new w2(n,e),Jx)}const G=(n,e=null)=>x2(n,e),Ul=(n,e=null)=>new _2(n,e),$s=(n,e=null)=>new M2(n,e),K=(...n)=>new b2(...n),ge=(...n)=>new T2(...n),U=(n,e)=>{const t=new Dl(n,e),i=(...r)=>{let s;return Ul(r),r[0]&&r[0].isNode?s=[...r]:s=r[0],t.call(s)};return i.shaderNode=t,i.setLayout=r=>(t.setLayout(r),i),i.once=()=>(t.once=!0,i),i},R2=(...n)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),U(...n));te("toGlobal",n=>(n.global=!0,n));const Ol=n=>{ao=n},df=()=>ao,Le=(...n)=>ao.If(...n);function t_(n){return ao&&ao.add(n),n}te("append",t_);const i_=new oi("color"),E=new oi("float",Lh.float),P=new oi("int",Lh.ints),_e=new oi("uint",Lh.uint),os=new oi("bool",Lh.bool),z=new oi("vec2"),un=new oi("ivec2"),r_=new oi("uvec2"),n_=new oi("bvec2"),D=new oi("vec3"),s_=new oi("ivec3"),lo=new oi("uvec3"),pf=new oi("bvec3"),ae=new oi("vec4"),a_=new oi("ivec4"),o_=new oi("uvec4"),l_=new oi("bvec4"),Fl=new oi("mat2"),yi=new oi("mat3"),Js=new oi("mat4"),I2=(n="")=>G(new Fr(n,"string")),L2=n=>G(new Fr(n,"ArrayBuffer"));te("toColor",i_),te("toFloat",E),te("toInt",P),te("toUint",_e),te("toBool",os),te("toVec2",z),te("toIVec2",un),te("toUVec2",r_),te("toBVec2",n_),te("toVec3",D),te("toIVec3",s_),te("toUVec3",lo),te("toBVec3",pf),te("toVec4",ae),te("toIVec4",a_),te("toUVec4",o_),te("toBVec4",l_),te("toMat2",Fl),te("toMat3",yi),te("toMat4",Js);const c_=K(as),u_=(n,e)=>G(new sf(G(n),e)),P2=(n,e)=>G(new Rh(G(n),e));te("element",c_),te("convert",u_);class mf extends qe{static get type(){return"UniformGroupNode"}constructor(e,t=!1,i=1){super("string"),this.name=e,this.version=0,this.shared=t,this.order=i,this.isUniformGroup=!0}set needsUpdate(e){e===!0&&this.version++}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const h_=n=>new mf(n),ff=(n,e=0)=>new mf(n,!0,e),D2=ff("frame"),xt=ff("render"),d_=h_("object");class Ks extends af{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=d_}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const i=this.getSelf();return e=e.bind(i),super.onUpdate(r=>{const s=e(r,i);s!==void 0&&(this.value=s)},t)}generate(e,t){const i=this.getNodeType(e),r=this.getUniformHash(e);let s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);const a=s.getInputType(e),o=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.label),l=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(l,i,t)}}const fe=(n,e)=>{const t=e_(e||n),i=n&&n.isNode===!0?n.node&&n.node.value||n.value:n;return G(new Ks(i,t))};class Et extends qe{static get type(){return"PropertyNode"}constructor(e,t=null,i=!1){super(e),this.name=t,this.varying=i,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const ar=(n,e)=>G(new Et(n,e)),Zr=(n,e)=>G(new Et(n,e,!0)),Nt=ge(Et,"vec4","DiffuseColor"),gf=ge(Et,"vec3","EmissiveColor"),hn=ge(Et,"float","Roughness"),Vl=ge(Et,"float","Metalness"),Ph=ge(Et,"float","Clearcoat"),Bl=ge(Et,"float","ClearcoatRoughness"),Zs=ge(Et,"vec3","Sheen"),Dh=ge(Et,"float","SheenRoughness"),Uh=ge(Et,"float","Iridescence"),vf=ge(Et,"float","IridescenceIOR"),yf=ge(Et,"float","IridescenceThickness"),Oh=ge(Et,"float","AlphaT"),ls=ge(Et,"float","Anisotropy"),zl=ge(Et,"vec3","AnisotropyT"),Qs=ge(Et,"vec3","AnisotropyB"),or=ge(Et,"color","SpecularColor"),kl=ge(Et,"float","SpecularF90"),Fh=ge(Et,"float","Shininess"),xf=ge(Et,"vec4","Output"),ea=ge(Et,"float","dashSize"),Hl=ge(Et,"float","gapSize"),U2=ge(Et,"float","pointWidth"),Gl=ge(Et,"float","IOR"),Vh=ge(Et,"float","Transmission"),_f=ge(Et,"float","Thickness"),Mf=ge(Et,"float","AttenuationDistance"),bf=ge(Et,"color","AttenuationColor"),Tf=ge(Et,"float","Dispersion");class p_ extends pt{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const i=e.getTypeLength(t.node.getNodeType(e));return so.join("").slice(0,i)!==t.components}return!1}generate(e,t){const{targetNode:i,sourceNode:r}=this,s=this.needsSplitAssign(e),a=i.getNodeType(e),o=i.context({assign:!0}).build(e),l=r.build(e,a),c=r.getNodeType(e),u=e.getDataFromNode(this);let h;if(u.initialized===!0)t!=="void"&&(h=o);else if(s){const d=e.getVarFromNode(this,null,a),p=e.getPropertyName(d);e.addLineFlowCode(`${p} = ${l}`,this);const m=i.node.context({assign:!0}).build(e);for(let v=0;v<i.components.length;v++){const f=i.components[v];e.addLineFlowCode(`${m}.${f} = ${p}[ ${v} ]`,this)}t!=="void"&&(h=o)}else h=`${o} = ${l}`,(t==="void"||c==="void")&&(e.addLineFlowCode(h,this),t!=="void"&&(h=o));return u.initialized=!0,e.format(h,a,t)}}const m_=K(p_);te("assign",m_);class f_ extends pt{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){const t=[],i=this.functionNode,r=i.getInputs(e),s=this.parameters;if(Array.isArray(s))for(let a=0;a<s.length;a++){const o=r[a],l=s[a];t.push(l.build(e,o.type))}else for(const a of r){const o=s[a.name];if(o!==void 0)t.push(o.build(e,a.type));else throw new Error(`FunctionCallNode: Input '${a.name}' not found in FunctionNode.`)}return`${i.build(e,"property")}( ${t.join(", ")} )`}}const g_=(n,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?$s(e):Ul(e[0]),G(new f_(G(n),e)));te("call",g_);class Gt extends pt{static get type(){return"OperatorNode"}constructor(e,t,i,...r){if(super(),r.length>0){let s=new Gt(e,t,i);for(let a=0;a<r.length-1;a++)s=new Gt(e,s,r[a]);t=s,i=r[r.length-1]}this.op=e,this.aNode=t,this.bNode=i}getNodeType(e,t){const i=this.op,r=this.aNode,s=this.bNode,a=r.getNodeType(e),o=typeof s<"u"?s.getNodeType(e):null;if(a==="void"||o==="void")return"void";if(i==="%")return a;if(i==="~"||i==="&"||i==="|"||i==="^"||i===">>"||i==="<<")return e.getIntegerType(a);if(i==="!"||i==="=="||i==="&&"||i==="||"||i==="^^")return"bool";if(i==="<"||i===">"||i==="<="||i===">="){const l=t?e.getTypeLength(t):Math.max(e.getTypeLength(a),e.getTypeLength(o));return l>1?`bvec${l}`:"bool"}else return a==="float"&&e.isMatrix(o)?o:e.isMatrix(a)&&e.isVector(o)?e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(o)?e.getVectorFromMatrix(o):e.getTypeLength(o)>e.getTypeLength(a)?o:a}generate(e,t){const i=this.op,r=this.aNode,s=this.bNode,a=this.getNodeType(e,t);let o=null,l=null;a!=="void"?(o=r.getNodeType(e),l=typeof s<"u"?s.getNodeType(e):null,i==="<"||i===">"||i==="<="||i===">="||i==="=="?e.isVector(o)?l=o:o!==l&&(o=l="float"):i===">>"||i==="<<"?(o=a,l=e.changeComponentType(l,"uint")):e.isMatrix(o)&&e.isVector(l)?l=e.getVectorFromMatrix(o):e.isVector(o)&&e.isMatrix(l)?o=e.getVectorFromMatrix(l):o=l=a):o=l=a;const c=r.build(e,o),u=typeof s<"u"?s.build(e,l):null,h=e.getTypeLength(t),d=e.getFunctionOperator(i);if(t!=="void")return i==="<"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} < ${u} )`,a,t):i==="<="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} <= ${u} )`,a,t):i===">"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} > ${u} )`,a,t):i===">="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} >= ${u} )`,a,t):i==="!"||i==="~"?e.format(`(${i}${c})`,o,t):d?e.format(`${d}( ${c}, ${u} )`,a,t):e.format(`( ${c} ${i} ${u} )`,a,t);if(o!=="void")return d?e.format(`${d}( ${c}, ${u} )`,a,t):e.format(`${c} ${i} ${u}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const zt=K(Gt,"+"),Pt=K(Gt,"-"),lt=K(Gt,"*"),Qr=K(Gt,"/"),Sf=K(Gt,"%"),v_=K(Gt,"=="),y_=K(Gt,"!="),x_=K(Gt,"<"),wf=K(Gt,">"),__=K(Gt,"<="),M_=K(Gt,">="),b_=K(Gt,"&&"),T_=K(Gt,"||"),S_=K(Gt,"!"),w_=K(Gt,"^^"),E_=K(Gt,"&"),A_=K(Gt,"~"),N_=K(Gt,"|"),C_=K(Gt,"^"),R_=K(Gt,"<<"),I_=K(Gt,">>");te("add",zt),te("sub",Pt),te("mul",lt),te("div",Qr),te("modInt",Sf),te("equal",v_),te("notEqual",y_),te("lessThan",x_),te("greaterThan",wf),te("lessThanEqual",__),te("greaterThanEqual",M_),te("and",b_),te("or",T_),te("not",S_),te("xor",w_),te("bitAnd",E_),te("bitNot",A_),te("bitOr",N_),te("bitXor",C_),te("shiftLeft",R_),te("shiftRight",I_);const L_=(...n)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),Sf(...n));te("remainder",L_);class V extends pt{static get type(){return"MathNode"}constructor(e,t,i=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=i,this.cNode=r}getInputType(e){const t=this.aNode.getNodeType(e),i=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(i)?0:e.getTypeLength(i),o=e.isMatrix(r)?0:e.getTypeLength(r);return s>a&&s>o?t:a>o?i:o>s?r:t}getNodeType(e){const t=this.method;return t===V.LENGTH||t===V.DISTANCE||t===V.DOT?"float":t===V.CROSS?"vec3":t===V.ALL?"bool":t===V.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===V.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){const i=this.method,r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,o=this.bNode,l=this.cNode,c=e.renderer.isWebGLRenderer===!0;if(i===V.TRANSFORM_DIRECTION){let u=a,h=o;e.isMatrix(u.getNodeType(e))?h=ae(D(h),0):u=ae(D(u),0);const d=lt(u,h).xyz;return _r(d).build(e,t)}else{if(i===V.NEGATE)return e.format("( - "+a.build(e,s)+" )",r,t);if(i===V.ONE_MINUS)return Pt(1,a).build(e,t);if(i===V.RECIPROCAL)return Qr(1,a).build(e,t);if(i===V.DIFFERENCE)return It(Pt(a,o)).build(e,t);{const u=[];return i===V.CROSS||i===V.MOD?u.push(a.build(e,r),o.build(e,r)):c&&i===V.STEP?u.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":s),o.build(e,s)):c&&(i===V.MIN||i===V.MAX)||i===V.MOD?u.push(a.build(e,s),o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":s)):i===V.REFRACT?u.push(a.build(e,s),o.build(e,s),l.build(e,"float")):i===V.MIX?u.push(a.build(e,s),o.build(e,s),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":s)):(u.push(a.build(e,s)),o!==null&&u.push(o.build(e,s)),l!==null&&u.push(l.build(e,s))),e.format(`${e.getMethod(i,r)}( ${u.join(", ")} )`,r,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}V.ALL="all",V.ANY="any",V.EQUALS="equals",V.RADIANS="radians",V.DEGREES="degrees",V.EXP="exp",V.EXP2="exp2",V.LOG="log",V.LOG2="log2",V.SQRT="sqrt",V.INVERSE_SQRT="inversesqrt",V.FLOOR="floor",V.CEIL="ceil",V.NORMALIZE="normalize",V.FRACT="fract",V.SIN="sin",V.COS="cos",V.TAN="tan",V.ASIN="asin",V.ACOS="acos",V.ATAN="atan",V.ABS="abs",V.SIGN="sign",V.LENGTH="length",V.NEGATE="negate",V.ONE_MINUS="oneMinus",V.DFDX="dFdx",V.DFDY="dFdy",V.ROUND="round",V.RECIPROCAL="reciprocal",V.TRUNC="trunc",V.FWIDTH="fwidth",V.BITCAST="bitcast",V.TRANSPOSE="transpose",V.ATAN2="atan2",V.MIN="min",V.MAX="max",V.MOD="mod",V.STEP="step",V.REFLECT="reflect",V.DISTANCE="distance",V.DIFFERENCE="difference",V.DOT="dot",V.CROSS="cross",V.POW="pow",V.TRANSFORM_DIRECTION="transformDirection",V.MIX="mix",V.CLAMP="clamp",V.REFRACT="refract",V.SMOOTHSTEP="smoothstep",V.FACEFORWARD="faceforward";const P_=E(1e-6),O2=E(1e6),ta=E(Math.PI),F2=E(Math.PI*2),Ef=K(V,V.ALL),D_=K(V,V.ANY),U_=K(V,V.EQUALS),O_=K(V,V.RADIANS),F_=K(V,V.DEGREES),Af=K(V,V.EXP),Bh=K(V,V.EXP2),Nf=K(V,V.LOG),Wl=K(V,V.LOG2),en=K(V,V.SQRT),V_=K(V,V.INVERSE_SQRT),cs=K(V,V.FLOOR),Cf=K(V,V.CEIL),_r=K(V,V.NORMALIZE),us=K(V,V.FRACT),Ci=K(V,V.SIN),Mr=K(V,V.COS),B_=K(V,V.TAN),z_=K(V,V.ASIN),zh=K(V,V.ACOS),k_=K(V,V.ATAN),It=K(V,V.ABS),jl=K(V,V.SIGN),ia=K(V,V.LENGTH),H_=K(V,V.NEGATE),G_=K(V,V.ONE_MINUS),W_=K(V,V.DFDX),j_=K(V,V.DFDY),X_=K(V,V.ROUND),q_=K(V,V.RECIPROCAL),Rf=K(V,V.TRUNC),Y_=K(V,V.FWIDTH),V2=K(V,V.BITCAST),$_=K(V,V.TRANSPOSE),J_=K(V,V.ATAN2),xi=K(V,V.MIN),ft=K(V,V.MAX),kh=K(V,V.MOD),Xl=K(V,V.STEP),K_=K(V,V.REFLECT),Z_=K(V,V.DISTANCE),Q_=K(V,V.DIFFERENCE),qt=K(V,V.DOT),co=K(V,V.CROSS),Ji=K(V,V.POW),If=K(V,V.POW,2),eM=K(V,V.POW,3),tM=K(V,V.POW,4),iM=K(V,V.TRANSFORM_DIRECTION),rM=n=>lt(jl(n),Ji(It(n),1/3)),Lf=n=>qt(n,n),rt=K(V,V.MIX),li=(n,e=0,t=1)=>G(new V(V.CLAMP,G(n),G(e),G(t))),nM=n=>li(n),Pf=K(V,V.REFRACT),Ki=K(V,V.SMOOTHSTEP),sM=K(V,V.FACEFORWARD),Df=U(([n])=>{const e=43758.5453,t=qt(n.xy,z(12.9898,78.233)),i=kh(t,ta);return us(Ci(i).mul(e))}),aM=(n,e,t)=>rt(e,t,n),oM=(n,e,t)=>Ki(e,t,n);te("all",Ef),te("any",D_),te("equals",U_),te("radians",O_),te("degrees",F_),te("exp",Af),te("exp2",Bh),te("log",Nf),te("log2",Wl),te("sqrt",en),te("inverseSqrt",V_),te("floor",cs),te("ceil",Cf),te("normalize",_r),te("fract",us),te("sin",Ci),te("cos",Mr),te("tan",B_),te("asin",z_),te("acos",zh),te("atan",k_),te("abs",It),te("sign",jl),te("length",ia),te("lengthSq",Lf),te("negate",H_),te("oneMinus",G_),te("dFdx",W_),te("dFdy",j_),te("round",X_),te("reciprocal",q_),te("trunc",Rf),te("fwidth",Y_),te("atan2",J_),te("min",xi),te("max",ft),te("mod",kh),te("step",Xl),te("reflect",K_),te("distance",Z_),te("dot",qt),te("cross",co),te("pow",Ji),te("pow2",If),te("pow3",eM),te("pow4",tM),te("transformDirection",iM),te("mix",aM),te("clamp",li),te("refract",Pf),te("smoothstep",oM),te("faceForward",sM),te("difference",Q_),te("saturate",nM),te("cbrt",rM),te("transpose",$_),te("rand",Df);class B2 extends qe{static get type(){return"ConditionalNode"}constructor(e,t,i=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=i}getNodeType(e){const t=this.ifNode.getNodeType(e);if(this.elseNode!==null){const i=this.elseNode.getNodeType(e);if(e.getTypeLength(i)>e.getTypeLength(t))return i}return t}setup(e){const t=this.condNode.cache(),i=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,s=e.context.nodeBlock;e.getDataFromNode(i).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);const a=e.getNodeProperties(this);a.condNode=t,a.ifNode=i.context({nodeBlock:i}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){const i=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:s,ifNode:a,elseNode:o}=e.getNodeProperties(this),l=t!=="void",c=l?ar(i).build(e):"";r.nodeProperty=c;const u=s.build(e,"bool");e.addFlowCode(`
|
|
3847
|
+
}`;class VR{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,i){if(this.texture===null){const r=new Wt,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=i.depthNear||t.depthFar!=i.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Pr({vertexShader:OR,fragmentShader:FR,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ft(new pa(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class BR extends gr{constructor(e,t){super();const i=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,u=null,h=null,d=null,p=null,m=null;const v=new VR,f=t.getContextAttributes();let g=null,x=null;const y=[],_=[],I=new J;let b=null;const w=new di;w.layers.enable(1),w.viewport=new st;const C=new di;C.layers.enable(2),C.viewport=new st;const H=[w,C],M=new $p;M.layers.enable(1),M.layers.enable(2);let T=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(ie){let le=y[ie];return le===void 0&&(le=new Jp,y[ie]=le),le.getTargetRaySpace()},this.getControllerGrip=function(ie){let le=y[ie];return le===void 0&&(le=new Jp,y[ie]=le),le.getGripSpace()},this.getHand=function(ie){let le=y[ie];return le===void 0&&(le=new Jp,y[ie]=le),le.getHandSpace()};function j(ie){const le=_.indexOf(ie.inputSource);if(le===-1)return;const Te=y[le];Te!==void 0&&(Te.update(ie.inputSource,ie.frame,c||a),Te.dispatchEvent({type:ie.type,data:ie.inputSource}))}function Y(){r.removeEventListener("select",j),r.removeEventListener("selectstart",j),r.removeEventListener("selectend",j),r.removeEventListener("squeeze",j),r.removeEventListener("squeezestart",j),r.removeEventListener("squeezeend",j),r.removeEventListener("end",Y),r.removeEventListener("inputsourceschange",re);for(let ie=0;ie<y.length;ie++){const le=_[ie];le!==null&&(_[ie]=null,y[ie]&&y[ie].disconnect(le))}T=null,k=null,v.reset(),e.setRenderTarget(g),p=null,d=null,h=null,r=null,x=null,et.stop(),i.isPresenting=!1,e.setPixelRatio(b),e.setSize(I.width,I.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ie){s=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ie){o=ie,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(ie){c=ie},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return h},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(ie){if(r=ie,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",j),r.addEventListener("selectstart",j),r.addEventListener("selectend",j),r.addEventListener("squeeze",j),r.addEventListener("squeezestart",j),r.addEventListener("squeezeend",j),r.addEventListener("end",Y),r.addEventListener("inputsourceschange",re),f.xrCompatible!==!0&&await t.makeXRCompatible(),b=e.getPixelRatio(),e.getSize(I),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let le=null,Te=null,Se=null;f.depth&&(Se=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,le=f.stencil?qn:Xn,Te=f.stencil?jn:Nr);const Ye={colorFormat:t.RGBA8,depthFormat:Se,scaleFactor:s};h=new XRWebGLBinding(r,t),d=h.createProjectionLayer(Ye),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),x=new Ir(d.textureWidth,d.textureHeight,{format:Ei,type:Wr,depthTexture:new Fs(d.textureWidth,d.textureHeight,Te,void 0,void 0,void 0,void 0,void 0,void 0,le),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}else{const le={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,t,le),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),x=new Ir(p.framebufferWidth,p.framebufferHeight,{format:Ei,type:Wr,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),et.setContext(r),et.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function re(ie){for(let le=0;le<ie.removed.length;le++){const Te=ie.removed[le],Se=_.indexOf(Te);Se>=0&&(_[Se]=null,y[Se]&&y[Se].disconnect(Te))}for(let le=0;le<ie.added.length;le++){const Te=ie.added[le];let Se=_.indexOf(Te);if(Se===-1){for(let We=0;We<y.length;We++)if(We>=_.length){_.push(Te),Se=We;break}else if(_[We]===null){_[We]=Te,Se=We;break}if(Se===-1)break}const Ye=y[Se];Ye&&Ye.connect(Te)}}const $=new N,he=new N;function Q(ie,le,Te){$.setFromMatrixPosition(le.matrixWorld),he.setFromMatrixPosition(Te.matrixWorld);const Se=$.distanceTo(he),Ye=le.projectionMatrix.elements,We=Te.projectionMatrix.elements,ot=Ye[14]/(Ye[10]-1),ce=Ye[14]/(Ye[10]+1),ue=(Ye[9]+1)/Ye[5],L=(Ye[9]-1)/Ye[5],He=(Ye[8]-1)/Ye[0],pe=(We[8]+1)/We[0],Ue=ot*He,we=ot*pe,$e=Se/(-He+pe),Be=$e*-He;if(le.matrixWorld.decompose(ie.position,ie.quaternion,ie.scale),ie.translateX(Be),ie.translateZ($e),ie.matrixWorld.compose(ie.position,ie.quaternion,ie.scale),ie.matrixWorldInverse.copy(ie.matrixWorld).invert(),Ye[10]===-1)ie.projectionMatrix.copy(le.projectionMatrix),ie.projectionMatrixInverse.copy(le.projectionMatrixInverse);else{const R=ot+$e,S=ce+$e,W=Ue-Be,ne=we+(Se-Be),de=ue*ce/S*R,se=L*ce/S*R;ie.projectionMatrix.makePerspective(W,ne,de,se,R,S),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert()}}function ye(ie,le){le===null?ie.matrixWorld.copy(ie.matrix):ie.matrixWorld.multiplyMatrices(le.matrixWorld,ie.matrix),ie.matrixWorldInverse.copy(ie.matrixWorld).invert()}this.updateCamera=function(ie){if(r===null)return;let le=ie.near,Te=ie.far;v.texture!==null&&(v.depthNear>0&&(le=v.depthNear),v.depthFar>0&&(Te=v.depthFar)),M.near=C.near=w.near=le,M.far=C.far=w.far=Te,(T!==M.near||k!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),T=M.near,k=M.far);const Se=ie.parent,Ye=M.cameras;ye(M,Se);for(let We=0;We<Ye.length;We++)ye(Ye[We],Se);Ye.length===2?Q(M,w,C):M.projectionMatrix.copy(w.projectionMatrix),be(ie,M,Se)};function be(ie,le,Te){Te===null?ie.matrix.copy(le.matrixWorld):(ie.matrix.copy(Te.matrixWorld),ie.matrix.invert(),ie.matrix.multiply(le.matrixWorld)),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.updateMatrixWorld(!0),ie.projectionMatrix.copy(le.projectionMatrix),ie.projectionMatrixInverse.copy(le.projectionMatrixInverse),ie.isPerspectiveCamera&&(ie.fov=Ea*2*Math.atan(1/ie.projectionMatrix.elements[5]),ie.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(ie){l=ie,d!==null&&(d.fixedFoveation=ie),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ie)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(M)};let Ve=null;function at(ie,le){if(u=le.getViewerPose(c||a),m=le,u!==null){const Te=u.views;p!==null&&(e.setRenderTargetFramebuffer(x,p.framebuffer),e.setRenderTarget(x));let Se=!1;Te.length!==M.cameras.length&&(M.cameras.length=0,Se=!0);for(let We=0;We<Te.length;We++){const ot=Te[We];let ce=null;if(p!==null)ce=p.getViewport(ot);else{const L=h.getViewSubImage(d,ot);ce=L.viewport,We===0&&(e.setRenderTargetTextures(x,L.colorTexture,d.ignoreDepthValues?void 0:L.depthStencilTexture),e.setRenderTarget(x))}let ue=H[We];ue===void 0&&(ue=new di,ue.layers.enable(We),ue.viewport=new st,H[We]=ue),ue.matrix.fromArray(ot.transform.matrix),ue.matrix.decompose(ue.position,ue.quaternion,ue.scale),ue.projectionMatrix.fromArray(ot.projectionMatrix),ue.projectionMatrixInverse.copy(ue.projectionMatrix).invert(),ue.viewport.set(ce.x,ce.y,ce.width,ce.height),We===0&&(M.matrix.copy(ue.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),Se===!0&&M.cameras.push(ue)}const Ye=r.enabledFeatures;if(Ye&&Ye.includes("depth-sensing")){const We=h.getDepthInformation(Te[0]);We&&We.isValid&&We.texture&&v.init(e,We,r.renderState)}}if(i.controllerAutoUpdate)for(let Te=0;Te<y.length;Te++){const Se=_[Te],Ye=y[Te];Se!==null&&Ye!==void 0&&Ye.update(Se,le,c||a)}Ve&&Ve(ie,le),le.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:le}),m=null}const et=new Lv;et.setAnimationLoop(at),this.setAnimationLoop=function(ie){Ve=ie},this.dispose=function(){}}}const Bs=new hr,zR=new Re;function kR(n,e){function t(f,g){f.matrixAutoUpdate===!0&&f.updateMatrix(),g.value.copy(f.matrix)}function i(f,g){g.color.getRGB(f.fogColor.value,Cv(n)),g.isFog?(f.fogNear.value=g.near,f.fogFar.value=g.far):g.isFogExp2&&(f.fogDensity.value=g.density)}function r(f,g,x,y,_){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(f,g):g.isMeshToonMaterial?(s(f,g),h(f,g)):g.isMeshPhongMaterial?(s(f,g),u(f,g)):g.isMeshStandardMaterial?(s(f,g),d(f,g),g.isMeshPhysicalMaterial&&p(f,g,_)):g.isMeshMatcapMaterial?(s(f,g),m(f,g)):g.isMeshDepthMaterial?s(f,g):g.isMeshDistanceMaterial?(s(f,g),v(f,g)):g.isMeshNormalMaterial?s(f,g):g.isLineBasicMaterial?(a(f,g),g.isLineDashedMaterial&&o(f,g)):g.isPointsMaterial?l(f,g,x,y):g.isSpriteMaterial?c(f,g):g.isShadowMaterial?(f.color.value.copy(g.color),f.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(f,g){f.opacity.value=g.opacity,g.color&&f.diffuse.value.copy(g.color),g.emissive&&f.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(f.map.value=g.map,t(g.map,f.mapTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.bumpMap&&(f.bumpMap.value=g.bumpMap,t(g.bumpMap,f.bumpMapTransform),f.bumpScale.value=g.bumpScale,g.side===si&&(f.bumpScale.value*=-1)),g.normalMap&&(f.normalMap.value=g.normalMap,t(g.normalMap,f.normalMapTransform),f.normalScale.value.copy(g.normalScale),g.side===si&&f.normalScale.value.negate()),g.displacementMap&&(f.displacementMap.value=g.displacementMap,t(g.displacementMap,f.displacementMapTransform),f.displacementScale.value=g.displacementScale,f.displacementBias.value=g.displacementBias),g.emissiveMap&&(f.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,f.emissiveMapTransform)),g.specularMap&&(f.specularMap.value=g.specularMap,t(g.specularMap,f.specularMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest);const x=e.get(g),y=x.envMap,_=x.envMapRotation;y&&(f.envMap.value=y,Bs.copy(_),Bs.x*=-1,Bs.y*=-1,Bs.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(Bs.y*=-1,Bs.z*=-1),f.envMapRotation.value.setFromMatrix4(zR.makeRotationFromEuler(Bs)),f.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=g.reflectivity,f.ior.value=g.ior,f.refractionRatio.value=g.refractionRatio),g.lightMap&&(f.lightMap.value=g.lightMap,f.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,f.lightMapTransform)),g.aoMap&&(f.aoMap.value=g.aoMap,f.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,f.aoMapTransform))}function a(f,g){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,g.map&&(f.map.value=g.map,t(g.map,f.mapTransform))}function o(f,g){f.dashSize.value=g.dashSize,f.totalSize.value=g.dashSize+g.gapSize,f.scale.value=g.scale}function l(f,g,x,y){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,f.size.value=g.size*x,f.scale.value=y*.5,g.map&&(f.map.value=g.map,t(g.map,f.uvTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest)}function c(f,g){f.diffuse.value.copy(g.color),f.opacity.value=g.opacity,f.rotation.value=g.rotation,g.map&&(f.map.value=g.map,t(g.map,f.mapTransform)),g.alphaMap&&(f.alphaMap.value=g.alphaMap,t(g.alphaMap,f.alphaMapTransform)),g.alphaTest>0&&(f.alphaTest.value=g.alphaTest)}function u(f,g){f.specular.value.copy(g.specular),f.shininess.value=Math.max(g.shininess,1e-4)}function h(f,g){g.gradientMap&&(f.gradientMap.value=g.gradientMap)}function d(f,g){f.metalness.value=g.metalness,g.metalnessMap&&(f.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,f.metalnessMapTransform)),f.roughness.value=g.roughness,g.roughnessMap&&(f.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,f.roughnessMapTransform)),g.envMap&&(f.envMapIntensity.value=g.envMapIntensity)}function p(f,g,x){f.ior.value=g.ior,g.sheen>0&&(f.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),f.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(f.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,f.sheenColorMapTransform)),g.sheenRoughnessMap&&(f.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,f.sheenRoughnessMapTransform))),g.clearcoat>0&&(f.clearcoat.value=g.clearcoat,f.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(f.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,f.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(f.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===si&&f.clearcoatNormalScale.value.negate())),g.dispersion>0&&(f.dispersion.value=g.dispersion),g.iridescence>0&&(f.iridescence.value=g.iridescence,f.iridescenceIOR.value=g.iridescenceIOR,f.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(f.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,f.iridescenceMapTransform)),g.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),g.transmission>0&&(f.transmission.value=g.transmission,f.transmissionSamplerMap.value=x.texture,f.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(f.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,f.transmissionMapTransform)),f.thickness.value=g.thickness,g.thicknessMap&&(f.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=g.attenuationDistance,f.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(f.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(f.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=g.specularIntensity,f.specularColor.value.copy(g.specularColor),g.specularColorMap&&(f.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,f.specularColorMapTransform)),g.specularIntensityMap&&(f.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,f.specularIntensityMapTransform))}function m(f,g){g.matcap&&(f.matcap.value=g.matcap)}function v(f,g){const x=e.get(g).light;f.referencePosition.value.setFromMatrixPosition(x.matrixWorld),f.nearDistance.value=x.shadow.camera.near,f.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function HR(n,e,t,i){let r={},s={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,y){const _=y.program;i.uniformBlockBinding(x,_)}function c(x,y){let _=r[x.id];_===void 0&&(m(x),_=u(x),r[x.id]=_,x.addEventListener("dispose",f));const I=y.program;i.updateUBOMapping(x,I);const b=e.render.frame;s[x.id]!==b&&(d(x),s[x.id]=b)}function u(x){const y=h();x.__bindingPointIndex=y;const _=n.createBuffer(),I=x.__size,b=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,_),n.bufferData(n.UNIFORM_BUFFER,I,b),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,y,_),_}function h(){for(let x=0;x<o;x++)if(a.indexOf(x)===-1)return a.push(x),x;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(x){const y=r[x.id],_=x.uniforms,I=x.__cache;n.bindBuffer(n.UNIFORM_BUFFER,y);for(let b=0,w=_.length;b<w;b++){const C=Array.isArray(_[b])?_[b]:[_[b]];for(let H=0,M=C.length;H<M;H++){const T=C[H];if(p(T,b,H,I)===!0){const k=T.__offset,j=Array.isArray(T.value)?T.value:[T.value];let Y=0;for(let re=0;re<j.length;re++){const $=j[re],he=v($);typeof $=="number"||typeof $=="boolean"?(T.__data[0]=$,n.bufferSubData(n.UNIFORM_BUFFER,k+Y,T.__data)):$.isMatrix3?(T.__data[0]=$.elements[0],T.__data[1]=$.elements[1],T.__data[2]=$.elements[2],T.__data[3]=0,T.__data[4]=$.elements[3],T.__data[5]=$.elements[4],T.__data[6]=$.elements[5],T.__data[7]=0,T.__data[8]=$.elements[6],T.__data[9]=$.elements[7],T.__data[10]=$.elements[8],T.__data[11]=0):($.toArray(T.__data,Y),Y+=he.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,k,T.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function p(x,y,_,I){const b=x.value,w=y+"_"+_;if(I[w]===void 0)return typeof b=="number"||typeof b=="boolean"?I[w]=b:I[w]=b.clone(),!0;{const C=I[w];if(typeof b=="number"||typeof b=="boolean"){if(C!==b)return I[w]=b,!0}else if(C.equals(b)===!1)return C.copy(b),!0}return!1}function m(x){const y=x.uniforms;let _=0;const I=16;for(let w=0,C=y.length;w<C;w++){const H=Array.isArray(y[w])?y[w]:[y[w]];for(let M=0,T=H.length;M<T;M++){const k=H[M],j=Array.isArray(k.value)?k.value:[k.value];for(let Y=0,re=j.length;Y<re;Y++){const $=j[Y],he=v($),Q=_%I,ye=Q%he.boundary,be=Q+ye;_+=ye,be!==0&&I-be<he.storage&&(_+=I-be),k.__data=new Float32Array(he.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=_,_+=he.storage}}}const b=_%I;return b>0&&(_+=I-b),x.__size=_,x.__cache={},this}function v(x){const y={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(y.boundary=4,y.storage=4):x.isVector2?(y.boundary=8,y.storage=8):x.isVector3||x.isColor?(y.boundary=16,y.storage=12):x.isVector4?(y.boundary=16,y.storage=16):x.isMatrix3?(y.boundary=48,y.storage=48):x.isMatrix4?(y.boundary=64,y.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),y}function f(x){const y=x.target;y.removeEventListener("dispose",f);const _=a.indexOf(y.__bindingPointIndex);a.splice(_,1),n.deleteBuffer(r[y.id]),delete r[y.id],delete s[y.id]}function g(){for(const x in r)n.deleteBuffer(r[x]);a=[],r={},s={}}return{bind:l,update:c,dispose:g}}class oy{constructor(e={}){const{canvas:t=cv(),context:i=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let d;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=i.getContextAttributes().alpha}else d=a;const p=new Uint32Array(4),m=new Int32Array(4);let v=null,f=null;const g=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Fi,this.toneMapping=pr,this.toneMappingExposure=1;const y=this;let _=!1,I=0,b=0,w=null,C=-1,H=null;const M=new st,T=new st;let k=null;const j=new xe(0);let Y=0,re=t.width,$=t.height,he=1,Q=null,ye=null;const be=new st(0,0,re,$),Ve=new st(0,0,re,$);let at=!1;const et=new Ha;let ie=!1,le=!1;const Te=new Re,Se=new Re,Ye=new N,We=new st,ot={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ce=!1;function ue(){return w===null?he:1}let L=i;function He(A,B){return t.getContext(A,B)}try{const A={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Vn}`),t.addEventListener("webglcontextlost",oe,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",Ae,!1),L===null){const B="webgl2";if(L=He(B,A),L===null)throw He(B)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(A){throw console.error("THREE.WebGLRenderer: "+A.message),A}let pe,Ue,we,$e,Be,R,S,W,ne,de,se,ke,Ee,Pe,mt,ve,ze,tt,it,Oe,Mt,ut,Dt,O;function Ce(){pe=new YN(L),pe.init(),ut=new ay(L,pe),Ue=new GN(L,pe,e,ut),we=new NR(L),Ue.reverseDepthBuffer&&we.buffers.depth.setReversed(!0),$e=new KN(L),Be=new fR,R=new DR(L,pe,we,Be,Ue,ut,$e),S=new jN(y),W=new qN(y),ne=new sE(L),Dt=new kN(L,ne),de=new $N(L,ne,$e,Dt),se=new QN(L,de,ne,$e),it=new ZN(L,Ue,R),ve=new WN(Be),ke=new mR(y,S,W,pe,Ue,Dt,ve),Ee=new kR(y,Be),Pe=new vR,mt=new TR(pe),tt=new zN(y,S,W,we,se,d,l),ze=new ER(y,se,Ue),O=new HR(L,$e,Ue,we),Oe=new HN(L,pe,$e),Mt=new JN(L,pe,$e),$e.programs=ke.programs,y.capabilities=Ue,y.extensions=pe,y.properties=Be,y.renderLists=Pe,y.shadowMap=ze,y.state=we,y.info=$e}Ce();const ee=new BR(y,L);this.xr=ee,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const A=pe.get("WEBGL_lose_context");A&&A.loseContext()},this.forceContextRestore=function(){const A=pe.get("WEBGL_lose_context");A&&A.restoreContext()},this.getPixelRatio=function(){return he},this.setPixelRatio=function(A){A!==void 0&&(he=A,this.setSize(re,$,!1))},this.getSize=function(A){return A.set(re,$)},this.setSize=function(A,B,X=!0){if(ee.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}re=A,$=B,t.width=Math.floor(A*he),t.height=Math.floor(B*he),X===!0&&(t.style.width=A+"px",t.style.height=B+"px"),this.setViewport(0,0,A,B)},this.getDrawingBufferSize=function(A){return A.set(re*he,$*he).floor()},this.setDrawingBufferSize=function(A,B,X){re=A,$=B,he=X,t.width=Math.floor(A*X),t.height=Math.floor(B*X),this.setViewport(0,0,A,B)},this.getCurrentViewport=function(A){return A.copy(M)},this.getViewport=function(A){return A.copy(be)},this.setViewport=function(A,B,X,q){A.isVector4?be.set(A.x,A.y,A.z,A.w):be.set(A,B,X,q),we.viewport(M.copy(be).multiplyScalar(he).round())},this.getScissor=function(A){return A.copy(Ve)},this.setScissor=function(A,B,X,q){A.isVector4?Ve.set(A.x,A.y,A.z,A.w):Ve.set(A,B,X,q),we.scissor(T.copy(Ve).multiplyScalar(he).round())},this.getScissorTest=function(){return at},this.setScissorTest=function(A){we.setScissorTest(at=A)},this.setOpaqueSort=function(A){Q=A},this.setTransparentSort=function(A){ye=A},this.getClearColor=function(A){return A.copy(tt.getClearColor())},this.setClearColor=function(){tt.setClearColor.apply(tt,arguments)},this.getClearAlpha=function(){return tt.getClearAlpha()},this.setClearAlpha=function(){tt.setClearAlpha.apply(tt,arguments)},this.clear=function(A=!0,B=!0,X=!0){let q=0;if(A){let F=!1;if(w!==null){const me=w.texture.format;F=me===Vo||me===Fo||me===ya}if(F){const me=w.texture.type,Ie=me===Wr||me===Nr||me===_s||me===jn||me===Fc||me===Vc,Fe=tt.getClearColor(),Ge=tt.getClearAlpha(),Qe=Fe.r,Ze=Fe.g,Je=Fe.b;Ie?(p[0]=Qe,p[1]=Ze,p[2]=Je,p[3]=Ge,L.clearBufferuiv(L.COLOR,0,p)):(m[0]=Qe,m[1]=Ze,m[2]=Je,m[3]=Ge,L.clearBufferiv(L.COLOR,0,m))}else q|=L.COLOR_BUFFER_BIT}B&&(q|=L.DEPTH_BUFFER_BIT,L.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),X&&(q|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),L.clear(q)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",oe,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",Ae,!1),Pe.dispose(),mt.dispose(),Be.dispose(),S.dispose(),W.dispose(),se.dispose(),Dt.dispose(),O.dispose(),ke.dispose(),ee.dispose(),ee.removeEventListener("sessionstart",a0),ee.removeEventListener("sessionend",o0),vs.stop()};function oe(A){A.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),_=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),_=!1;const A=$e.autoReset,B=ze.enabled,X=ze.autoUpdate,q=ze.needsUpdate,F=ze.type;Ce(),$e.autoReset=A,ze.enabled=B,ze.autoUpdate=X,ze.needsUpdate=q,ze.type=F}function Ae(A){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",A.statusMessage)}function Ut(A){const B=A.target;B.removeEventListener("dispose",Ut),ni(B)}function ni(A){tr(A),Be.remove(A)}function tr(A){const B=Be.get(A).programs;B!==void 0&&(B.forEach(function(X){ke.releaseProgram(X)}),A.isShaderMaterial&&ke.releaseShaderCache(A))}this.renderBufferDirect=function(A,B,X,q,F,me){B===null&&(B=ot);const Ie=F.isMesh&&F.matrixWorld.determinant()<0,Fe=qS(A,B,X,q,F);we.setMaterial(q,Ie);let Ge=X.index,Qe=1;if(q.wireframe===!0){if(Ge=de.getWireframeAttribute(X),Ge===void 0)return;Qe=2}const Ze=X.drawRange,Je=X.attributes.position;let Rt=Ze.start*Qe,jt=(Ze.start+Ze.count)*Qe;me!==null&&(Rt=Math.max(Rt,me.start*Qe),jt=Math.min(jt,(me.start+me.count)*Qe)),Ge!==null?(Rt=Math.max(Rt,0),jt=Math.min(jt,Ge.count)):Je!=null&&(Rt=Math.max(Rt,0),jt=Math.min(jt,Je.count));const Qt=jt-Rt;if(Qt<0||Qt===1/0)return;Dt.setup(F,q,Fe,X,Ge);let ci,Ht=Oe;if(Ge!==null&&(ci=ne.get(Ge),Ht=Mt,Ht.setIndex(ci)),F.isMesh)q.wireframe===!0?(we.setLineWidth(q.wireframeLinewidth*ue()),Ht.setMode(L.LINES)):Ht.setMode(L.TRIANGLES);else if(F.isLine){let Xe=q.linewidth;Xe===void 0&&(Xe=1),we.setLineWidth(Xe*ue()),F.isLineSegments?Ht.setMode(L.LINES):F.isLineLoop?Ht.setMode(L.LINE_LOOP):Ht.setMode(L.LINE_STRIP)}else F.isPoints?Ht.setMode(L.POINTS):F.isSprite&&Ht.setMode(L.TRIANGLES);if(F.isBatchedMesh)if(F._multiDrawInstances!==null)Ht.renderMultiDrawInstances(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount,F._multiDrawInstances);else if(pe.get("WEBGL_multi_draw"))Ht.renderMultiDraw(F._multiDrawStarts,F._multiDrawCounts,F._multiDrawCount);else{const Xe=F._multiDrawStarts,Wi=F._multiDrawCounts,ys=F._multiDrawCount,Hr=Ge?ne.get(Ge).bytesPerElement:1,fa=Be.get(q).currentProgram.getUniforms();for(let dr=0;dr<ys;dr++)fa.setValue(L,"_gl_DrawID",dr),Ht.render(Xe[dr]/Hr,Wi[dr])}else if(F.isInstancedMesh)Ht.renderInstances(Rt,Qt,F.count);else if(X.isInstancedBufferGeometry){const Xe=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,Wi=Math.min(X.instanceCount,Xe);Ht.renderInstances(Rt,Qt,Wi)}else Ht.render(Rt,Qt)};function At(A,B,X){A.transparent===!0&&A.side===Gr&&A.forceSinglePass===!1?(A.side=si,A.needsUpdate=!0,wc(A,B,X),A.side=an,A.needsUpdate=!0,wc(A,B,X),A.side=Gr):wc(A,B,X)}this.compile=function(A,B,X=null){X===null&&(X=A),f=mt.get(X),f.init(B),x.push(f),X.traverseVisible(function(F){F.isLight&&F.layers.test(B.layers)&&(f.pushLight(F),F.castShadow&&f.pushShadow(F))}),A!==X&&A.traverseVisible(function(F){F.isLight&&F.layers.test(B.layers)&&(f.pushLight(F),F.castShadow&&f.pushShadow(F))}),f.setupLights();const q=new Set;return A.traverse(function(F){if(!(F.isMesh||F.isPoints||F.isLine||F.isSprite))return;const me=F.material;if(me)if(Array.isArray(me))for(let Ie=0;Ie<me.length;Ie++){const Fe=me[Ie];At(Fe,X,F),q.add(Fe)}else At(me,X,F),q.add(me)}),x.pop(),f=null,q},this.compileAsync=function(A,B,X=null){const q=this.compile(A,B,X);return new Promise(F=>{function me(){if(q.forEach(function(Ie){Be.get(Ie).currentProgram.isReady()&&q.delete(Ie)}),q.size===0){F(A);return}setTimeout(me,10)}pe.get("KHR_parallel_shader_compile")!==null?me():setTimeout(me,10)})};let ir=null;function xn(A){ir&&ir(A)}function a0(){vs.stop()}function o0(){vs.start()}const vs=new Lv;vs.setAnimationLoop(xn),typeof self<"u"&&vs.setContext(self),this.setAnimationLoop=function(A){ir=A,ee.setAnimationLoop(A),A===null?vs.stop():vs.start()},ee.addEventListener("sessionstart",a0),ee.addEventListener("sessionend",o0),this.render=function(A,B){if(B!==void 0&&B.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(_===!0)return;if(A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld(),B.parent===null&&B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ee.enabled===!0&&ee.isPresenting===!0&&(ee.cameraAutoUpdate===!0&&ee.updateCamera(B),B=ee.getCamera()),A.isScene===!0&&A.onBeforeRender(y,A,B,w),f=mt.get(A,x.length),f.init(B),x.push(f),Se.multiplyMatrices(B.projectionMatrix,B.matrixWorldInverse),et.setFromProjectionMatrix(Se),le=this.localClippingEnabled,ie=ve.init(this.clippingPlanes,le),v=Pe.get(A,g.length),v.init(),g.push(v),ee.enabled===!0&&ee.isPresenting===!0){const me=y.xr.getDepthSensingMesh();me!==null&&zd(me,B,-1/0,y.sortObjects)}zd(A,B,0,y.sortObjects),v.finish(),y.sortObjects===!0&&v.sort(Q,ye),ce=ee.enabled===!1||ee.isPresenting===!1||ee.hasDepthSensing()===!1,ce&&tt.addToRenderList(v,A),this.info.render.frame++,ie===!0&&ve.beginShadows();const X=f.state.shadowsArray;ze.render(X,A,B),ie===!0&&ve.endShadows(),this.info.autoReset===!0&&this.info.reset();const q=v.opaque,F=v.transmissive;if(f.setupLights(),B.isArrayCamera){const me=B.cameras;if(F.length>0)for(let Ie=0,Fe=me.length;Ie<Fe;Ie++){const Ge=me[Ie];c0(q,F,A,Ge)}ce&&tt.render(A);for(let Ie=0,Fe=me.length;Ie<Fe;Ie++){const Ge=me[Ie];l0(v,A,Ge,Ge.viewport)}}else F.length>0&&c0(q,F,A,B),ce&&tt.render(A),l0(v,A,B);w!==null&&(R.updateMultisampleRenderTarget(w),R.updateRenderTargetMipmap(w)),A.isScene===!0&&A.onAfterRender(y,A,B),Dt.resetDefaultState(),C=-1,H=null,x.pop(),x.length>0?(f=x[x.length-1],ie===!0&&ve.setGlobalState(y.clippingPlanes,f.state.camera)):f=null,g.pop(),g.length>0?v=g[g.length-1]:v=null};function zd(A,B,X,q){if(A.visible===!1)return;if(A.layers.test(B.layers)){if(A.isGroup)X=A.renderOrder;else if(A.isLOD)A.autoUpdate===!0&&A.update(B);else if(A.isLight)f.pushLight(A),A.castShadow&&f.pushShadow(A);else if(A.isSprite){if(!A.frustumCulled||et.intersectsSprite(A)){q&&We.setFromMatrixPosition(A.matrixWorld).applyMatrix4(Se);const me=se.update(A),Ie=A.material;Ie.visible&&v.push(A,me,Ie,X,We.z,null)}}else if((A.isMesh||A.isLine||A.isPoints)&&(!A.frustumCulled||et.intersectsObject(A))){const me=se.update(A),Ie=A.material;if(q&&(A.boundingSphere!==void 0?(A.boundingSphere===null&&A.computeBoundingSphere(),We.copy(A.boundingSphere.center)):(me.boundingSphere===null&&me.computeBoundingSphere(),We.copy(me.boundingSphere.center)),We.applyMatrix4(A.matrixWorld).applyMatrix4(Se)),Array.isArray(Ie)){const Fe=me.groups;for(let Ge=0,Qe=Fe.length;Ge<Qe;Ge++){const Ze=Fe[Ge],Je=Ie[Ze.materialIndex];Je&&Je.visible&&v.push(A,me,Je,X,We.z,Ze)}}else Ie.visible&&v.push(A,me,Ie,X,We.z,null)}}const F=A.children;for(let me=0,Ie=F.length;me<Ie;me++)zd(F[me],B,X,q)}function l0(A,B,X,q){const F=A.opaque,me=A.transmissive,Ie=A.transparent;f.setupLightsView(X),ie===!0&&ve.setGlobalState(y.clippingPlanes,X),q&&we.viewport(M.copy(q)),F.length>0&&Sc(F,B,X),me.length>0&&Sc(me,B,X),Ie.length>0&&Sc(Ie,B,X),we.buffers.depth.setTest(!0),we.buffers.depth.setMask(!0),we.buffers.color.setMask(!0),we.setPolygonOffset(!1)}function c0(A,B,X,q){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[q.id]===void 0&&(f.state.transmissionRenderTarget[q.id]=new Ir(1,1,{generateMipmaps:!0,type:pe.has("EXT_color_buffer_half_float")||pe.has("EXT_color_buffer_float")?wi:Wr,minFilter:ji,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:vt.workingColorSpace}));const F=f.state.transmissionRenderTarget[q.id],me=q.viewport||M;F.setSize(me.z,me.w);const Ie=y.getRenderTarget();y.setRenderTarget(F),y.getClearColor(j),Y=y.getClearAlpha(),Y<1&&y.setClearColor(16777215,.5),y.clear(),ce&&tt.render(X);const Fe=y.toneMapping;y.toneMapping=pr;const Ge=q.viewport;if(q.viewport!==void 0&&(q.viewport=void 0),f.setupLightsView(q),ie===!0&&ve.setGlobalState(y.clippingPlanes,q),Sc(A,X,q),R.updateMultisampleRenderTarget(F),R.updateRenderTargetMipmap(F),pe.has("WEBGL_multisampled_render_to_texture")===!1){let Qe=!1;for(let Ze=0,Je=B.length;Ze<Je;Ze++){const Rt=B[Ze],jt=Rt.object,Qt=Rt.geometry,ci=Rt.material,Ht=Rt.group;if(ci.side===Gr&&jt.layers.test(q.layers)){const Xe=ci.side;ci.side=si,ci.needsUpdate=!0,u0(jt,X,q,Qt,ci,Ht),ci.side=Xe,ci.needsUpdate=!0,Qe=!0}}Qe===!0&&(R.updateMultisampleRenderTarget(F),R.updateRenderTargetMipmap(F))}y.setRenderTarget(Ie),y.setClearColor(j,Y),Ge!==void 0&&(q.viewport=Ge),y.toneMapping=Fe}function Sc(A,B,X){const q=B.isScene===!0?B.overrideMaterial:null;for(let F=0,me=A.length;F<me;F++){const Ie=A[F],Fe=Ie.object,Ge=Ie.geometry,Qe=q===null?Ie.material:q,Ze=Ie.group;Fe.layers.test(X.layers)&&u0(Fe,B,X,Ge,Qe,Ze)}}function u0(A,B,X,q,F,me){A.onBeforeRender(y,B,X,q,F,me),A.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,A.matrixWorld),A.normalMatrix.getNormalMatrix(A.modelViewMatrix),F.onBeforeRender(y,B,X,q,A,me),F.transparent===!0&&F.side===Gr&&F.forceSinglePass===!1?(F.side=si,F.needsUpdate=!0,y.renderBufferDirect(X,B,q,F,A,me),F.side=an,F.needsUpdate=!0,y.renderBufferDirect(X,B,q,F,A,me),F.side=Gr):y.renderBufferDirect(X,B,q,F,A,me),A.onAfterRender(y,B,X,q,F,me)}function wc(A,B,X){B.isScene!==!0&&(B=ot);const q=Be.get(A),F=f.state.lights,me=f.state.shadowsArray,Ie=F.state.version,Fe=ke.getParameters(A,F.state,me,B,X),Ge=ke.getProgramCacheKey(Fe);let Qe=q.programs;q.environment=A.isMeshStandardMaterial?B.environment:null,q.fog=B.fog,q.envMap=(A.isMeshStandardMaterial?W:S).get(A.envMap||q.environment),q.envMapRotation=q.environment!==null&&A.envMap===null?B.environmentRotation:A.envMapRotation,Qe===void 0&&(A.addEventListener("dispose",Ut),Qe=new Map,q.programs=Qe);let Ze=Qe.get(Ge);if(Ze!==void 0){if(q.currentProgram===Ze&&q.lightsStateVersion===Ie)return d0(A,Fe),Ze}else Fe.uniforms=ke.getUniforms(A),A.onBuild(X,Fe,y),A.onBeforeCompile(Fe,y),Ze=ke.acquireProgram(Fe,Ge),Qe.set(Ge,Ze),q.uniforms=Fe.uniforms;const Je=q.uniforms;return(!A.isShaderMaterial&&!A.isRawShaderMaterial||A.clipping===!0)&&(Je.clippingPlanes=ve.uniform),d0(A,Fe),q.needsLights=$S(A),q.lightsStateVersion=Ie,q.needsLights&&(Je.ambientLightColor.value=F.state.ambient,Je.lightProbe.value=F.state.probe,Je.directionalLights.value=F.state.directional,Je.directionalLightShadows.value=F.state.directionalShadow,Je.spotLights.value=F.state.spot,Je.spotLightShadows.value=F.state.spotShadow,Je.rectAreaLights.value=F.state.rectArea,Je.ltc_1.value=F.state.rectAreaLTC1,Je.ltc_2.value=F.state.rectAreaLTC2,Je.pointLights.value=F.state.point,Je.pointLightShadows.value=F.state.pointShadow,Je.hemisphereLights.value=F.state.hemi,Je.directionalShadowMap.value=F.state.directionalShadowMap,Je.directionalShadowMatrix.value=F.state.directionalShadowMatrix,Je.spotShadowMap.value=F.state.spotShadowMap,Je.spotLightMatrix.value=F.state.spotLightMatrix,Je.spotLightMap.value=F.state.spotLightMap,Je.pointShadowMap.value=F.state.pointShadowMap,Je.pointShadowMatrix.value=F.state.pointShadowMatrix),q.currentProgram=Ze,q.uniformsList=null,Ze}function h0(A){if(A.uniformsList===null){const B=A.currentProgram.getUniforms();A.uniformsList=Uu.seqWithValue(B.seq,A.uniforms)}return A.uniformsList}function d0(A,B){const X=Be.get(A);X.outputColorSpace=B.outputColorSpace,X.batching=B.batching,X.batchingColor=B.batchingColor,X.instancing=B.instancing,X.instancingColor=B.instancingColor,X.instancingMorph=B.instancingMorph,X.skinning=B.skinning,X.morphTargets=B.morphTargets,X.morphNormals=B.morphNormals,X.morphColors=B.morphColors,X.morphTargetsCount=B.morphTargetsCount,X.numClippingPlanes=B.numClippingPlanes,X.numIntersection=B.numClipIntersection,X.vertexAlphas=B.vertexAlphas,X.vertexTangents=B.vertexTangents,X.toneMapping=B.toneMapping}function qS(A,B,X,q,F){B.isScene!==!0&&(B=ot),R.resetTextureUnits();const me=B.fog,Ie=q.isMeshStandardMaterial?B.environment:null,Fe=w===null?y.outputColorSpace:w.isXRRenderTarget===!0?w.texture.colorSpace:nr,Ge=(q.isMeshStandardMaterial?W:S).get(q.envMap||Ie),Qe=q.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,Ze=!!X.attributes.tangent&&(!!q.normalMap||q.anisotropy>0),Je=!!X.morphAttributes.position,Rt=!!X.morphAttributes.normal,jt=!!X.morphAttributes.color;let Qt=pr;q.toneMapped&&(w===null||w.isXRRenderTarget===!0)&&(Qt=y.toneMapping);const ci=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Ht=ci!==void 0?ci.length:0,Xe=Be.get(q),Wi=f.state.lights;if(ie===!0&&(le===!0||A!==H)){const wr=A===H&&q.id===C;ve.setState(q,A,wr)}let ys=!1;q.version===Xe.__version?(Xe.needsLights&&Xe.lightsStateVersion!==Wi.state.version||Xe.outputColorSpace!==Fe||F.isBatchedMesh&&Xe.batching===!1||!F.isBatchedMesh&&Xe.batching===!0||F.isBatchedMesh&&Xe.batchingColor===!0&&F.colorTexture===null||F.isBatchedMesh&&Xe.batchingColor===!1&&F.colorTexture!==null||F.isInstancedMesh&&Xe.instancing===!1||!F.isInstancedMesh&&Xe.instancing===!0||F.isSkinnedMesh&&Xe.skinning===!1||!F.isSkinnedMesh&&Xe.skinning===!0||F.isInstancedMesh&&Xe.instancingColor===!0&&F.instanceColor===null||F.isInstancedMesh&&Xe.instancingColor===!1&&F.instanceColor!==null||F.isInstancedMesh&&Xe.instancingMorph===!0&&F.morphTexture===null||F.isInstancedMesh&&Xe.instancingMorph===!1&&F.morphTexture!==null||Xe.envMap!==Ge||q.fog===!0&&Xe.fog!==me||Xe.numClippingPlanes!==void 0&&(Xe.numClippingPlanes!==ve.numPlanes||Xe.numIntersection!==ve.numIntersection)||Xe.vertexAlphas!==Qe||Xe.vertexTangents!==Ze||Xe.morphTargets!==Je||Xe.morphNormals!==Rt||Xe.morphColors!==jt||Xe.toneMapping!==Qt||Xe.morphTargetsCount!==Ht)&&(ys=!0):(ys=!0,Xe.__version=q.version);let Hr=Xe.currentProgram;ys===!0&&(Hr=wc(q,B,F));let fa=!1,dr=!1,kd=!1;const ei=Hr.getUniforms(),Fn=Xe.uniforms;if(we.useProgram(Hr.program)&&(fa=!0,dr=!0,kd=!0),q.id!==C&&(C=q.id,dr=!0),fa||H!==A){Ue.reverseDepthBuffer?(Te.copy(A.projectionMatrix),Iw(Te),Lw(Te),ei.setValue(L,"projectionMatrix",Te)):ei.setValue(L,"projectionMatrix",A.projectionMatrix),ei.setValue(L,"viewMatrix",A.matrixWorldInverse);const wr=ei.map.cameraPosition;wr!==void 0&&wr.setValue(L,Ye.setFromMatrixPosition(A.matrixWorld)),Ue.logarithmicDepthBuffer&&ei.setValue(L,"logDepthBufFC",2/(Math.log(A.far+1)/Math.LN2)),(q.isMeshPhongMaterial||q.isMeshToonMaterial||q.isMeshLambertMaterial||q.isMeshBasicMaterial||q.isMeshStandardMaterial||q.isShaderMaterial)&&ei.setValue(L,"isOrthographic",A.isOrthographicCamera===!0),H!==A&&(H=A,dr=!0,kd=!0)}if(F.isSkinnedMesh){ei.setOptional(L,F,"bindMatrix"),ei.setOptional(L,F,"bindMatrixInverse");const wr=F.skeleton;wr&&(wr.boneTexture===null&&wr.computeBoneTexture(),ei.setValue(L,"boneTexture",wr.boneTexture,R))}F.isBatchedMesh&&(ei.setOptional(L,F,"batchingTexture"),ei.setValue(L,"batchingTexture",F._matricesTexture,R),ei.setOptional(L,F,"batchingIdTexture"),ei.setValue(L,"batchingIdTexture",F._indirectTexture,R),ei.setOptional(L,F,"batchingColorTexture"),F._colorsTexture!==null&&ei.setValue(L,"batchingColorTexture",F._colorsTexture,R));const Hd=X.morphAttributes;if((Hd.position!==void 0||Hd.normal!==void 0||Hd.color!==void 0)&&it.update(F,X,Hr),(dr||Xe.receiveShadow!==F.receiveShadow)&&(Xe.receiveShadow=F.receiveShadow,ei.setValue(L,"receiveShadow",F.receiveShadow)),q.isMeshGouraudMaterial&&q.envMap!==null&&(Fn.envMap.value=Ge,Fn.flipEnvMap.value=Ge.isCubeTexture&&Ge.isRenderTargetTexture===!1?-1:1),q.isMeshStandardMaterial&&q.envMap===null&&B.environment!==null&&(Fn.envMapIntensity.value=B.environmentIntensity),dr&&(ei.setValue(L,"toneMappingExposure",y.toneMappingExposure),Xe.needsLights&&YS(Fn,kd),me&&q.fog===!0&&Ee.refreshFogUniforms(Fn,me),Ee.refreshMaterialUniforms(Fn,q,he,$,f.state.transmissionRenderTarget[A.id]),Uu.upload(L,h0(Xe),Fn,R)),q.isShaderMaterial&&q.uniformsNeedUpdate===!0&&(Uu.upload(L,h0(Xe),Fn,R),q.uniformsNeedUpdate=!1),q.isSpriteMaterial&&ei.setValue(L,"center",F.center),ei.setValue(L,"modelViewMatrix",F.modelViewMatrix),ei.setValue(L,"normalMatrix",F.normalMatrix),ei.setValue(L,"modelMatrix",F.matrixWorld),q.isShaderMaterial||q.isRawShaderMaterial){const wr=q.uniformsGroups;for(let Gd=0,JS=wr.length;Gd<JS;Gd++){const p0=wr[Gd];O.update(p0,Hr),O.bind(p0,Hr)}}return Hr}function YS(A,B){A.ambientLightColor.needsUpdate=B,A.lightProbe.needsUpdate=B,A.directionalLights.needsUpdate=B,A.directionalLightShadows.needsUpdate=B,A.pointLights.needsUpdate=B,A.pointLightShadows.needsUpdate=B,A.spotLights.needsUpdate=B,A.spotLightShadows.needsUpdate=B,A.rectAreaLights.needsUpdate=B,A.hemisphereLights.needsUpdate=B}function $S(A){return A.isMeshLambertMaterial||A.isMeshToonMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isShadowMaterial||A.isShaderMaterial&&A.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(A,B,X){Be.get(A.texture).__webglTexture=B,Be.get(A.depthTexture).__webglTexture=X;const q=Be.get(A);q.__hasExternalTextures=!0,q.__autoAllocateDepthBuffer=X===void 0,q.__autoAllocateDepthBuffer||pe.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),q.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(A,B){const X=Be.get(A);X.__webglFramebuffer=B,X.__useDefaultFramebuffer=B===void 0},this.setRenderTarget=function(A,B=0,X=0){w=A,I=B,b=X;let q=!0,F=null,me=!1,Ie=!1;if(A){const Fe=Be.get(A);if(Fe.__useDefaultFramebuffer!==void 0)we.bindFramebuffer(L.FRAMEBUFFER,null),q=!1;else if(Fe.__webglFramebuffer===void 0)R.setupRenderTarget(A);else if(Fe.__hasExternalTextures)R.rebindTextures(A,Be.get(A.texture).__webglTexture,Be.get(A.depthTexture).__webglTexture);else if(A.depthBuffer){const Ze=A.depthTexture;if(Fe.__boundDepthTexture!==Ze){if(Ze!==null&&Be.has(Ze)&&(A.width!==Ze.image.width||A.height!==Ze.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");R.setupDepthRenderbuffer(A)}}const Ge=A.texture;(Ge.isData3DTexture||Ge.isDataArrayTexture||Ge.isCompressedArrayTexture)&&(Ie=!0);const Qe=Be.get(A).__webglFramebuffer;A.isWebGLCubeRenderTarget?(Array.isArray(Qe[B])?F=Qe[B][X]:F=Qe[B],me=!0):A.samples>0&&R.useMultisampledRTT(A)===!1?F=Be.get(A).__webglMultisampledFramebuffer:Array.isArray(Qe)?F=Qe[X]:F=Qe,M.copy(A.viewport),T.copy(A.scissor),k=A.scissorTest}else M.copy(be).multiplyScalar(he).floor(),T.copy(Ve).multiplyScalar(he).floor(),k=at;if(we.bindFramebuffer(L.FRAMEBUFFER,F)&&q&&we.drawBuffers(A,F),we.viewport(M),we.scissor(T),we.setScissorTest(k),me){const Fe=Be.get(A.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+B,Fe.__webglTexture,X)}else if(Ie){const Fe=Be.get(A.texture),Ge=B||0;L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,Fe.__webglTexture,X||0,Ge)}C=-1},this.readRenderTargetPixels=function(A,B,X,q,F,me,Ie){if(!(A&&A.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Fe=Be.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Ie!==void 0&&(Fe=Fe[Ie]),Fe){we.bindFramebuffer(L.FRAMEBUFFER,Fe);try{const Ge=A.texture,Qe=Ge.format,Ze=Ge.type;if(!Ue.textureFormatReadable(Qe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ue.textureTypeReadable(Ze)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}B>=0&&B<=A.width-q&&X>=0&&X<=A.height-F&&L.readPixels(B,X,q,F,ut.convert(Qe),ut.convert(Ze),me)}finally{const Ge=w!==null?Be.get(w).__webglFramebuffer:null;we.bindFramebuffer(L.FRAMEBUFFER,Ge)}}},this.readRenderTargetPixelsAsync=async function(A,B,X,q,F,me,Ie){if(!(A&&A.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Fe=Be.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Ie!==void 0&&(Fe=Fe[Ie]),Fe){const Ge=A.texture,Qe=Ge.format,Ze=Ge.type;if(!Ue.textureFormatReadable(Qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ue.textureTypeReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(B>=0&&B<=A.width-q&&X>=0&&X<=A.height-F){we.bindFramebuffer(L.FRAMEBUFFER,Fe);const Je=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Je),L.bufferData(L.PIXEL_PACK_BUFFER,me.byteLength,L.STREAM_READ),L.readPixels(B,X,q,F,ut.convert(Qe),ut.convert(Ze),0);const Rt=w!==null?Be.get(w).__webglFramebuffer:null;we.bindFramebuffer(L.FRAMEBUFFER,Rt);const jt=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Rw(L,jt,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Je),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,me),L.deleteBuffer(Je),L.deleteSync(jt),me}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(A,B=null,X=0){A.isTexture!==!0&&(uu("WebGLRenderer: copyFramebufferToTexture function signature has changed."),B=arguments[0]||null,A=arguments[1]);const q=Math.pow(2,-X),F=Math.floor(A.image.width*q),me=Math.floor(A.image.height*q),Ie=B!==null?B.x:0,Fe=B!==null?B.y:0;R.setTexture2D(A,0),L.copyTexSubImage2D(L.TEXTURE_2D,X,0,0,Ie,Fe,F,me),we.unbindTexture()},this.copyTextureToTexture=function(A,B,X=null,q=null,F=0){A.isTexture!==!0&&(uu("WebGLRenderer: copyTextureToTexture function signature has changed."),q=arguments[0]||null,A=arguments[1],B=arguments[2],F=arguments[3]||0,X=null);let me,Ie,Fe,Ge,Qe,Ze;X!==null?(me=X.max.x-X.min.x,Ie=X.max.y-X.min.y,Fe=X.min.x,Ge=X.min.y):(me=A.image.width,Ie=A.image.height,Fe=0,Ge=0),q!==null?(Qe=q.x,Ze=q.y):(Qe=0,Ze=0);const Je=ut.convert(B.format),Rt=ut.convert(B.type);R.setTexture2D(B,0),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,B.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,B.unpackAlignment);const jt=L.getParameter(L.UNPACK_ROW_LENGTH),Qt=L.getParameter(L.UNPACK_IMAGE_HEIGHT),ci=L.getParameter(L.UNPACK_SKIP_PIXELS),Ht=L.getParameter(L.UNPACK_SKIP_ROWS),Xe=L.getParameter(L.UNPACK_SKIP_IMAGES),Wi=A.isCompressedTexture?A.mipmaps[F]:A.image;L.pixelStorei(L.UNPACK_ROW_LENGTH,Wi.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Wi.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Fe),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ge),A.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,F,Qe,Ze,me,Ie,Je,Rt,Wi.data):A.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,F,Qe,Ze,Wi.width,Wi.height,Je,Wi.data):L.texSubImage2D(L.TEXTURE_2D,F,Qe,Ze,me,Ie,Je,Rt,Wi),L.pixelStorei(L.UNPACK_ROW_LENGTH,jt),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Qt),L.pixelStorei(L.UNPACK_SKIP_PIXELS,ci),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ht),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Xe),F===0&&B.generateMipmaps&&L.generateMipmap(L.TEXTURE_2D),we.unbindTexture()},this.copyTextureToTexture3D=function(A,B,X=null,q=null,F=0){A.isTexture!==!0&&(uu("WebGLRenderer: copyTextureToTexture3D function signature has changed."),X=arguments[0]||null,q=arguments[1]||null,A=arguments[2],B=arguments[3],F=arguments[4]||0);let me,Ie,Fe,Ge,Qe,Ze,Je,Rt,jt;const Qt=A.isCompressedTexture?A.mipmaps[F]:A.image;X!==null?(me=X.max.x-X.min.x,Ie=X.max.y-X.min.y,Fe=X.max.z-X.min.z,Ge=X.min.x,Qe=X.min.y,Ze=X.min.z):(me=Qt.width,Ie=Qt.height,Fe=Qt.depth,Ge=0,Qe=0,Ze=0),q!==null?(Je=q.x,Rt=q.y,jt=q.z):(Je=0,Rt=0,jt=0);const ci=ut.convert(B.format),Ht=ut.convert(B.type);let Xe;if(B.isData3DTexture)R.setTexture3D(B,0),Xe=L.TEXTURE_3D;else if(B.isDataArrayTexture||B.isCompressedArrayTexture)R.setTexture2DArray(B,0),Xe=L.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,B.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,B.unpackAlignment);const Wi=L.getParameter(L.UNPACK_ROW_LENGTH),ys=L.getParameter(L.UNPACK_IMAGE_HEIGHT),Hr=L.getParameter(L.UNPACK_SKIP_PIXELS),fa=L.getParameter(L.UNPACK_SKIP_ROWS),dr=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,Qt.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Qt.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Ge),L.pixelStorei(L.UNPACK_SKIP_ROWS,Qe),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Ze),A.isDataTexture||A.isData3DTexture?L.texSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Ht,Qt.data):B.isCompressedArrayTexture?L.compressedTexSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Qt.data):L.texSubImage3D(Xe,F,Je,Rt,jt,me,Ie,Fe,ci,Ht,Qt),L.pixelStorei(L.UNPACK_ROW_LENGTH,Wi),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ys),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Hr),L.pixelStorei(L.UNPACK_SKIP_ROWS,fa),L.pixelStorei(L.UNPACK_SKIP_IMAGES,dr),F===0&&B.generateMipmaps&&L.generateMipmap(Xe),we.unbindTexture()},this.initRenderTarget=function(A){Be.get(A).__webglFramebuffer===void 0&&R.setupRenderTarget(A)},this.initTexture=function(A){A.isCubeTexture?R.setTextureCube(A,0):A.isData3DTexture?R.setTexture3D(A,0):A.isDataArrayTexture||A.isCompressedArrayTexture?R.setTexture2DArray(A,0):R.setTexture2D(A,0),we.unbindTexture()},this.resetState=function(){I=0,b=0,w=null,we.reset(),Dt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rr}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Jo?"display-p3":"srgb",t.unpackColorSpace=vt.workingColorSpace===Sa?"display-p3":"srgb"}}class Rd{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new xe(e),this.density=t}clone(){return new Rd(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let Kp=class jS{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new xe(e),this.near=t,this.far=i}clone(){return new jS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class Vu extends _t{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new hr,this.environmentIntensity=1,this.environmentRotation=new hr,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Xa{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=wa,this.updateRanges=[],this.version=0,this.uuid=vr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=vr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}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=vr()),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 $i=new N;class On{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.applyMatrix4(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.applyNormalMatrix(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)$i.fromBufferAttribute(this,t),$i.transformDirection(e),this.setXYZ(t,$i.x,$i.y,$i.z);return this}getComponent(e,t){let i=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(i=Xi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=ht(i,this.array)),this.data.array[e*this.data.stride+this.offset+t]=i,this}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Xi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Xi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Xi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Xi(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),i=ht(i,this.array),r=ht(r,this.array),s=ht(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new wt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new On(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else 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 dl extends hi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new xe(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 qa;const pl=new N,Ya=new N,$a=new N,Ja=new J,ml=new J,ly=new Re,Bu=new N,fl=new N,zu=new N,cy=new J,Zp=new J,uy=new J;class Qp extends _t{constructor(e=new dl){if(super(),this.isSprite=!0,this.type="Sprite",qa===void 0){qa=new ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Xa(t,5);qa.setIndex([0,1,2,0,2,3]),qa.setAttribute("position",new On(i,3,0,!1)),qa.setAttribute("uv",new On(i,2,3,!1))}this.geometry=qa,this.material=e,this.center=new J(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ya.setFromMatrixScale(this.matrixWorld),ly.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),$a.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ya.multiplyScalar(-$a.z);const i=this.material.rotation;let r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));const a=this.center;ku(Bu.set(-.5,-.5,0),$a,a,Ya,r,s),ku(fl.set(.5,-.5,0),$a,a,Ya,r,s),ku(zu.set(.5,.5,0),$a,a,Ya,r,s),cy.set(0,0),Zp.set(1,0),uy.set(1,1);let o=e.ray.intersectTriangle(Bu,fl,zu,!1,pl);if(o===null&&(ku(fl.set(-.5,.5,0),$a,a,Ya,r,s),Zp.set(0,1),o=e.ray.intersectTriangle(Bu,zu,fl,!1,pl),o===null))return;const l=e.ray.origin.distanceTo(pl);l<e.near||l>e.far||t.push({distance:l,point:pl.clone(),uv:er.getInterpolation(pl,Bu,fl,zu,cy,Zp,uy,new J),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ku(n,e,t,i,r,s){Ja.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(ml.x=s*Ja.x-r*Ja.y,ml.y=r*Ja.x+s*Ja.y):ml.copy(Ja),n.copy(e),n.x+=ml.x,n.y+=ml.y,n.applyMatrix4(ly)}const Hu=new N,hy=new N;class em extends _t{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i<r;i++){const s=t[i];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);const r=this.levels;let s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let i=0;i<t.length;i++)if(t[i].distance===e){const r=t.splice(i,1);return this.remove(r[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r;i++){let s=t[i].distance;if(t[i].object.visible&&(s-=s*t[i].hysteresis),e<s)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){Hu.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Hu);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Hu.setFromMatrixPosition(e.matrixWorld),hy.setFromMatrixPosition(this.matrixWorld);const i=Hu.distanceTo(hy)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let a=t[r].distance;if(t[r].object.visible&&(a-=a*t[r].hysteresis),i>=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let r=0,s=i.length;r<s;r++){const a=i[r];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const dy=new N,py=new st,my=new st,GR=new N,fy=new Re,Gu=new N,tm=new Ai,gy=new Re,im=new Cs;class rm extends Ft{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ep,this.bindMatrix=new Re,this.bindMatrixInverse=new Re,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Bi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Gu),this.boundingBox.expandByPoint(Gu)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ai),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Gu),this.boundingSphere.expandByPoint(Gu)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),tm.copy(this.boundingSphere),tm.applyMatrix4(r),e.ray.intersectsSphere(tm)!==!1&&(gy.copy(r).invert(),im.copy(e.ray).applyMatrix4(gy),!(this.boundingBox!==null&&im.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,im)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new st,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===ep?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===U0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;py.fromBufferAttribute(r.attributes.skinIndex,e),my.fromBufferAttribute(r.attributes.skinWeight,e),dy.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const a=my.getComponent(s);if(a!==0){const o=py.getComponent(s);fy.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(GR.copy(dy).applyMatrix4(fy),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Wu extends _t{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ur extends Wt{constructor(e=null,t=1,i=1,r,s,a,o,l,c=$t,u=$t,h,d){super(null,a,o,l,c,u,r,s,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const vy=new Re,WR=new Re;class yc{constructor(e=[],t=[]){this.uuid=vr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new Re)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Re;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){const o=e[s]?e[s].matrixWorld:WR;vy.multiplyMatrices(o,t[s]),vy.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new yc(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new Ur(t,e,e,Ei,Oi);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){const s=e.bones[i];let a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new Wu),this.bones.push(a),this.boneInverses.push(new Re().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const a=t[r];e.bones.push(a.uuid);const o=i[r];e.boneInverses.push(o.toArray())}return e}}class Nn extends wt{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}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 Ka=new Re,yy=new Re,ju=[],xy=new Bi,jR=new Re,gl=new Ft,vl=new Ai;class nm extends Ft{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Nn(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,jR)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Bi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ka),xy.copy(e.boundingBox).applyMatrix4(Ka),this.boundingBox.union(xy)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ai),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Ka),vl.copy(e.boundingSphere).applyMatrix4(Ka),this.boundingSphere.union(vl)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=i.length+1,a=e*s+1;for(let o=0;o<i.length;o++)i[o]=r[a+o]}raycast(e,t){const i=this.matrixWorld,r=this.count;if(gl.geometry=this.geometry,gl.material=this.material,gl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),vl.copy(this.boundingSphere),vl.applyMatrix4(i),e.ray.intersectsSphere(vl)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Ka),yy.multiplyMatrices(i,Ka),gl.matrixWorld=yy,gl.raycast(e,ju);for(let a=0,o=ju.length;a<o;a++){const l=ju[a];l.instanceId=s,l.object=this,t.push(l)}ju.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Nn(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new Ur(new Float32Array(r*this.count),r,this.count,Oo,Oi));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<i.length;c++)a+=i[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=r*e;s[l]=o,s.set(i,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}function XR(n,e){return n.z-e.z}function qR(n,e){return e.z-n.z}class YR{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,i){const r=this.pool,s=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];s.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=t,a.index=i}reset(){this.list.length=0,this.index=0}}const is=new Re,sm=new Re,$R=new Re,JR=new xe(1,1,1),_y=new Re,am=new Ha,Xu=new Bi,zs=new Ai,yl=new N,My=new N,KR=new N,om=new YR,ki=new Ft,qu=[];function ZR(n,e,t=0){const i=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const r=n.count;for(let s=0;s<r;s++)for(let a=0;a<i;a++)e.setComponent(s+t,a,n.getComponent(s,a))}else e.array.set(n.array,t*i);e.needsUpdate=!0}class lm extends Ft{get maxInstanceCount(){return this._maxInstanceCount}constructor(e,t,i=t*2,r){super(new ct,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawInfo=[],this._availableInstanceIds=[],this._drawRanges=[],this._reservedRanges=[],this._bounds=[],this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),i=new Ur(t,e,e,Ei,Oi);this._matricesTexture=i}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),i=new Ur(t,e,e,ya,Nr);this._indirectTexture=i}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),i=new Ur(t,e,e,Ei,Oi);i.colorSpace=vt.workingColorSpace,this._colorsTexture=i}_initializeGeometry(e){const t=this.geometry,i=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const a=e.getAttribute(s),{array:o,itemSize:l,normalized:c}=a,u=new o.constructor(i*l),h=new wt(u,l,c);t.setAttribute(s,h)}if(e.getIndex()!==null){const s=i>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new wt(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),s=t.getAttribute(i);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bi);const e=this.boundingBox,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,is),this.getBoundingBoxAt(s,Xu).applyMatrix4(is),e.union(Xu)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ai);const e=this.boundingSphere,t=this._drawInfo;e.makeEmpty();for(let i=0,r=t.length;i<r;i++){if(t[i].active===!1)continue;const s=t[i].geometryIndex;this.getMatrixAt(i,is),this.getBoundingSphereAt(s,zs).applyMatrix4(is),e.union(zs)}}addInstance(e){if(this._drawInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("BatchedMesh: Maximum item count reached.");const t={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(i=this._availableInstanceIds.pop(),this._drawInfo[i]=t):(i=this._drawInfo.length,this._drawInfo.push(t));const r=this._matricesTexture,s=r.image.data;$R.toArray(s,i*16),r.needsUpdate=!0;const a=this._colorsTexture;return a&&(JR.toArray(a.image.data,i*4),a.needsUpdate=!0),i}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=a[a.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;const c=e.getIndex(),u=c!==null;if(u&&(i===-1?r.indexCount=c.count:r.indexCount=i,s===null?r.indexStart=0:r.indexStart=s.indexStart+s.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._geometryCount;return this._geometryCount++,a.push(r),o.push({start:u?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Bi,sphereInitialized:!1,sphere:new Ai}),this.setGeometryAt(h,e),h}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),a=t.getIndex(),o=this._reservedRanges[e];if(r&&a.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const p in i.attributes){const m=t.getAttribute(p),v=i.getAttribute(p);ZR(m,v,l);const f=m.itemSize;for(let g=m.count,x=c;g<x;g++){const y=l+g;for(let _=0;_<f;_++)v.setComponent(y,_,0)}v.needsUpdate=!0,v.addUpdateRange(l*f,c*f)}if(r){const p=o.indexStart;for(let m=0;m<a.count;m++)s.setX(p+m,l+a.getX(m));for(let m=a.count,v=o.indexCount;m<v;m++)s.setX(p+m,l);s.needsUpdate=!0,s.addUpdateRange(p,o.indexCount)}const u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const h=this._drawRanges[e],d=t.getAttribute("position");return h.count=r?a.count:d.count,this._visibilityChanged=!0,e}deleteInstance(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?this:(t[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.box,s=this.geometry;if(i.boxInitialized===!1){r.makeEmpty();const a=s.index,o=s.attributes.position,l=this._drawRanges[e];for(let c=l.start,u=l.start+l.count;c<u;c++){let h=c;a&&(h=a.getX(h)),r.expandByPoint(yl.fromBufferAttribute(o,h))}i.boxInitialized=!0}return t.copy(r),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const i=this._bounds[e],r=i.sphere,s=this.geometry;if(i.sphereInitialized===!1){r.makeEmpty(),this.getBoundingBoxAt(e,Xu),Xu.getCenter(r.center);const a=s.index,o=s.attributes.position,l=this._drawRanges[e];let c=0;for(let u=l.start,h=l.start+l.count;u<h;u++){let d=u;a&&(d=a.getX(d)),yl.fromBufferAttribute(o,d),c=Math.max(c,r.center.distanceToSquared(yl))}r.radius=Math.sqrt(c),i.sphereInitialized=!0}return t.copy(r),t}setMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture,s=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){const i=this._drawInfo,r=this._matricesTexture.image.data;return e>=i.length||i[e].active===!1?null:t.fromArray(r,e*16)}setColorAt(e,t){this._colorsTexture===null&&this._initColorsTexture();const i=this._colorsTexture,r=this._colorsTexture.image.data,s=this._drawInfo;return e>=s.length||s[e].active===!1?this:(t.toArray(r,e*4),i.needsUpdate=!0,this)}getColorAt(e,t){const i=this._colorsTexture.image.data,r=this._drawInfo;return e>=r.length||r[e].active===!1?null:t.fromArray(i,e*4)}setVisibleAt(e,t){const i=this._drawInfo;return e>=i.length||i[e].active===!1||i[e].visible===t?this:(i[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?!1:t[e].visible}setGeometryIdAt(e,t){const i=this._drawInfo;return e>=i.length||i[e].active===!1||t<0||t>=this._geometryCount?null:(i[e].geometryIndex=t,this)}getGeometryIdAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?-1:t[e].geometryIndex}getGeometryRangeAt(e,t={}){if(e<0||e>=this._geometryCount)return null;const i=this._drawRanges[e];return t.start=i.start,t.count=i.count,t}raycast(e,t){const i=this._drawInfo,r=this._drawRanges,s=this.matrixWorld,a=this.geometry;ki.material=this.material,ki.geometry.index=a.index,ki.geometry.attributes=a.attributes,ki.geometry.boundingBox===null&&(ki.geometry.boundingBox=new Bi),ki.geometry.boundingSphere===null&&(ki.geometry.boundingSphere=new Ai);for(let o=0,l=i.length;o<l;o++){if(!i[o].visible||!i[o].active)continue;const c=i[o].geometryIndex,u=r[c];ki.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(o,ki.matrixWorld).premultiply(s),this.getBoundingBoxAt(c,ki.geometry.boundingBox),this.getBoundingSphereAt(c,ki.geometry.boundingSphere),ki.raycast(e,qu);for(let h=0,d=qu.length;h<d;h++){const p=qu[h];p.object=this,p.batchId=o,t.push(p)}qu.length=0}ki.material=null,ki.geometry.index=null,ki.geometry.attributes={},ki.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._drawInfo=e._drawInfo.map(t=>({...t})),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._drawInfo,c=this._multiDrawStarts,u=this._multiDrawCounts,h=this._drawRanges,d=this.perObjectFrustumCulled,p=this._indirectTexture,m=p.image.data;d&&(_y.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),am.setFromProjectionMatrix(_y,e.coordinateSystem));let v=0;if(this.sortObjects){sm.copy(this.matrixWorld).invert(),yl.setFromMatrixPosition(i.matrixWorld).applyMatrix4(sm),My.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(sm);for(let x=0,y=l.length;x<y;x++)if(l[x].visible&&l[x].active){const _=l[x].geometryIndex;this.getMatrixAt(x,is),this.getBoundingSphereAt(_,zs).applyMatrix4(is);let I=!1;if(d&&(I=!am.intersectsSphere(zs)),!I){const b=KR.subVectors(zs.center,yl).dot(My);om.push(h[_],b,x)}}const f=om.list,g=this.customSort;g===null?f.sort(s.transparent?qR:XR):g.call(this,f,i);for(let x=0,y=f.length;x<y;x++){const _=f[x];c[v]=_.start*o,u[v]=_.count,m[v]=_.index,v++}om.reset()}else for(let f=0,g=l.length;f<g;f++)if(l[f].visible&&l[f].active){const x=l[f].geometryIndex;let y=!1;if(d&&(this.getMatrixAt(f,is),this.getBoundingSphereAt(x,zs).applyMatrix4(is),y=!am.intersectsSphere(zs)),!y){const _=h[x];c[v]=_.start*o,u[v]=_.count,m[v]=f,v++}}p.needsUpdate=!0,this._multiDrawCount=v,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,a){this.onBeforeRender(e,null,r,s,a)}}class Ni extends hi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xe(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 Yu=new N,$u=new N,by=new Re,xl=new Cs,Ju=new Ai,cm=new N,Ty=new N;class Cn extends _t{constructor(e=new ct,t=new Ni){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)Yu.fromBufferAttribute(t,r-1),$u.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Yu.distanceTo($u);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Ju.copy(i.boundingSphere),Ju.applyMatrix4(r),Ju.radius+=s,e.ray.intersectsSphere(Ju)===!1)return;by.copy(r).invert(),xl.copy(e.ray).applyMatrix4(by);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=i.index,h=i.attributes.position;if(u!==null){const d=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let m=d,v=p-1;m<v;m+=c){const f=u.getX(m),g=u.getX(m+1),x=Ku(this,e,xl,l,f,g);x&&t.push(x)}if(this.isLineLoop){const m=u.getX(p-1),v=u.getX(d),f=Ku(this,e,xl,l,m,v);f&&t.push(f)}}else{const d=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let m=d,v=p-1;m<v;m+=c){const f=Ku(this,e,xl,l,m,m+1);f&&t.push(f)}if(this.isLineLoop){const m=Ku(this,e,xl,l,p-1,d);m&&t.push(m)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Ku(n,e,t,i,r,s){const a=n.geometry.attributes.position;if(Yu.fromBufferAttribute(a,r),$u.fromBufferAttribute(a,s),t.distanceSqToSegment(Yu,$u,cm,Ty)>i)return;cm.applyMatrix4(n.matrixWorld);const o=e.ray.origin.distanceTo(cm);if(!(o<e.near||o>e.far))return{distance:o,point:Ty.clone().applyMatrix4(n.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:n}}const Sy=new N,wy=new N;class $r extends Cn{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)Sy.fromBufferAttribute(t,r),wy.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Sy.distanceTo(wy);e.setAttribute("lineDistance",new De(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class um extends Cn{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Za extends hi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new xe(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 Ey=new Re,hm=new Cs,Zu=new Ai,Qu=new N;class dm extends _t{constructor(e=new ct,t=new Za){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Zu.copy(i.boundingSphere),Zu.applyMatrix4(r),Zu.radius+=s,e.ray.intersectsSphere(Zu)===!1)return;Ey.copy(r).invert(),hm.copy(e.ray).applyMatrix4(Ey);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,u=i.attributes.position;if(c!==null){const h=Math.max(0,a.start),d=Math.min(c.count,a.start+a.count);for(let p=h,m=d;p<m;p++){const v=c.getX(p);Qu.fromBufferAttribute(u,v),Ay(Qu,v,l,r,e,t,this)}}else{const h=Math.max(0,a.start),d=Math.min(u.count,a.start+a.count);for(let p=h,m=d;p<m;p++)Qu.fromBufferAttribute(u,p),Ay(Qu,p,l,r,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Ay(n,e,t,i,r,s,a){const o=hm.distanceSqToPoint(n);if(o<t){const l=new N;hm.closestPointToPoint(n,l),l.applyMatrix4(i);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Ny extends Wt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:Lt,this.magFilter=s!==void 0?s:Lt,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class pm extends Wt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=$t,this.minFilter=$t,this.generateMipmaps=!1,this.needsUpdate=!0}}class _l extends Wt{constructor(e,t,i,r,s,a,o,l,c,u,h,d){super(null,a,o,l,c,u,r,s,h,d),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Cy extends _l{constructor(e,t,i,r,s,a){super(e,t,i,s,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=fr,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Ry extends _l{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,mr),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Iy extends Wt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Or{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let a;t?a=t:a=e*i[s-1];let o=0,l=s-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=i[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,i[r]===a)return r/(s-1);const u=i[r],h=i[r+1]-u,d=(a-u)/h;return(r+d)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=t||(s.isVector2?new J:new N);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new N,r=[],s=[],a=[],o=new N,l=new Re;for(let p=0;p<=e;p++){const m=p/e;r[p]=this.getTangentAt(m,new N)}s[0]=new N,a[0]=new N;let c=Number.MAX_VALUE;const u=Math.abs(r[0].x),h=Math.abs(r[0].y),d=Math.abs(r[0].z);u<=c&&(c=u,i.set(1,0,0)),h<=c&&(c=h,i.set(0,1,0)),d<=c&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(r[p-1],r[p]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(Jt(r[p-1].dot(r[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(o,m))}a[p].crossVectors(r[p],s[p])}if(t===!0){let p=Math.acos(Jt(s[0].dot(s[e]),-1,1));p/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(p=-p);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(r[m],p*m)),a[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class eh extends Or{constructor(e=0,t=0,i=1,r=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new J){const i=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);const o=this.aStartAngle+e*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,p=c-this.aY;l=d*u-p*h+this.aX,c=d*h+p*u+this.aY}return i.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class Ly extends eh{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}}function mm(){let n=0,e=0,t=0,i=0;function r(s,a,o,l){n=s,e=o,t=-3*s+3*a-2*o-l,i=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){r(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,u,h){let d=(a-s)/c-(o-s)/(c+u)+(o-a)/u,p=(o-a)/u-(l-a)/(u+h)+(l-o)/h;d*=u,p*=u,r(a,o,d,p)},calc:function(s){const a=s*s,o=a*s;return n+e*s+t*a+i*o}}}const th=new N,fm=new mm,gm=new mm,vm=new mm;class Py extends Or{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new N){const i=t,r=this.points,s=r.length,a=(s-(this.closed?0:1))*e;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,u;this.closed||o>0?c=r[(o-1)%s]:(th.subVectors(r[0],r[1]).add(r[0]),c=th);const h=r[o%s],d=r[(o+1)%s];if(this.closed||o+2<s?u=r[(o+2)%s]:(th.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=th),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(h),p),v=Math.pow(h.distanceToSquared(d),p),f=Math.pow(d.distanceToSquared(u),p);v<1e-4&&(v=1),m<1e-4&&(m=v),f<1e-4&&(f=v),fm.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,m,v,f),gm.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,m,v,f),vm.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,m,v,f)}else this.curveType==="catmullrom"&&(fm.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),gm.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),vm.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return i.set(fm.calc(l),gm.calc(l),vm.calc(l)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new N().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Dy(n,e,t,i,r){const s=(i-e)*.5,a=(r-t)*.5,o=n*n,l=n*o;return(2*t-2*i+s+a)*l+(-3*t+3*i-2*s-a)*o+s*n+t}function QR(n,e){const t=1-n;return t*t*e}function eI(n,e){return 2*(1-n)*n*e}function tI(n,e){return n*n*e}function Ml(n,e,t,i){return QR(n,e)+eI(n,t)+tI(n,i)}function iI(n,e){const t=1-n;return t*t*t*e}function rI(n,e){const t=1-n;return 3*t*t*n*e}function nI(n,e){return 3*(1-n)*n*n*e}function sI(n,e){return n*n*n*e}function bl(n,e,t,i,r){return iI(n,e)+rI(n,t)+nI(n,i)+sI(n,r)}class ym extends Or{constructor(e=new J,t=new J,i=new J,r=new J){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new J){const i=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(bl(e,r.x,s.x,a.x,o.x),bl(e,r.y,s.y,a.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Uy extends Or{constructor(e=new N,t=new N,i=new N,r=new N){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new N){const i=t,r=this.v0,s=this.v1,a=this.v2,o=this.v3;return i.set(bl(e,r.x,s.x,a.x,o.x),bl(e,r.y,s.y,a.y,o.y),bl(e,r.z,s.z,a.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class xm extends Or{constructor(e=new J,t=new J){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new J){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new J){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Oy extends Or{constructor(e=new N,t=new N){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new N){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new N){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class _m extends Or{constructor(e=new J,t=new J,i=new J){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new J){const i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(Ml(e,r.x,s.x,a.x),Ml(e,r.y,s.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Mm extends Or{constructor(e=new N,t=new N,i=new N){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new N){const i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(Ml(e,r.x,s.x,a.x),Ml(e,r.y,s.y,a.y),Ml(e,r.z,s.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class bm extends Or{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new J){const i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),o=s-a,l=r[a===0?a:a-1],c=r[a],u=r[a>r.length-2?r.length-1:a+1],h=r[a>r.length-3?r.length-1:a+2];return i.set(Dy(o,l.x,c.x,u.x,h.x),Dy(o,l.y,c.y,u.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new J().fromArray(r))}return this}}var ih=Object.freeze({__proto__:null,ArcCurve:Ly,CatmullRomCurve3:Py,CubicBezierCurve:ym,CubicBezierCurve3:Uy,EllipseCurve:eh,LineCurve:xm,LineCurve3:Oy,QuadraticBezierCurve:_m,QuadraticBezierCurve3:Mm,SplineCurve:bm});class Fy extends Or{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new ih[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),r=this.getCurveLengths();let s=0;for(;s<r.length;){if(r[s]>=i){const a=r[s]-i,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let r=0,s=this.curves;r<s.length;r++){const a=s[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,l=a.getPoints(o);for(let c=0;c<l.length;c++){const u=l[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(new ih[r.type]().fromJSON(r))}return this}}class Tl extends Fy{constructor(e){super(),this.type="Path",this.currentPoint=new J,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new xm(this.currentPoint.clone(),new J(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const s=new _m(this.currentPoint.clone(),new J(e,t),new J(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){const o=new ym(this.currentPoint.clone(),new J(e,t),new J(i,r),new J(s,a));return this.curves.push(o),this.currentPoint.set(s,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new bm(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+o,t+l,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,o,l){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,i,r,s,a,o,l),this}absellipse(e,t,i,r,s,a,o,l){const c=new eh(e,t,i,r,s,a,o,l);if(this.curves.length>0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class xc extends ct{constructor(e=[new J(0,-.5),new J(.5,0),new J(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Jt(r,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],u=1/t,h=new N,d=new J,p=new N,m=new N,v=new N;let f=0,g=0;for(let x=0;x<=e.length-1;x++)switch(x){case 0:f=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,p.x=g*1,p.y=-f,p.z=g*0,v.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(v.x,v.y,v.z);break;default:f=e[x+1].x-e[x].x,g=e[x+1].y-e[x].y,p.x=g*1,p.y=-f,p.z=g*0,m.copy(p),p.x+=v.x,p.y+=v.y,p.z+=v.z,p.normalize(),l.push(p.x,p.y,p.z),v.copy(m)}for(let x=0;x<=t;x++){const y=i+x*u*r,_=Math.sin(y),I=Math.cos(y);for(let b=0;b<=e.length-1;b++){h.x=e[b].x*_,h.y=e[b].y,h.z=e[b].x*I,a.push(h.x,h.y,h.z),d.x=x/t,d.y=b/(e.length-1),o.push(d.x,d.y);const w=l[3*b+0]*_,C=l[3*b+1],H=l[3*b+0]*I;c.push(w,C,H)}}for(let x=0;x<t;x++)for(let y=0;y<e.length-1;y++){const _=y+x*e.length,I=_,b=_+e.length,w=_+e.length+1,C=_+1;s.push(I,b,C),s.push(w,C,b)}this.setIndex(s),this.setAttribute("position",new De(a,3)),this.setAttribute("uv",new De(o,2)),this.setAttribute("normal",new De(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xc(e.points,e.segments,e.phiStart,e.phiLength)}}class Id extends xc{constructor(e=1,t=1,i=4,r=8){const s=new Tl;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new Id(e.radius,e.length,e.capSegments,e.radialSegments)}}class Ld extends ct{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new N,u=new J;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){const p=i+h/t*r;c.x=e*Math.cos(p),c.y=e*Math.sin(p),a.push(c.x,c.y,c.z),o.push(0,0,1),u.x=(a[d]/e+1)/2,u.y=(a[d+1]/e+1)/2,l.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new De(a,3)),this.setAttribute("normal",new De(o,3)),this.setAttribute("uv",new De(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ld(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class ma extends ct{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:o,thetaLength:l};const c=this;r=Math.floor(r),s=Math.floor(s);const u=[],h=[],d=[],p=[];let m=0;const v=[],f=i/2;let g=0;x(),a===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(u),this.setAttribute("position",new De(h,3)),this.setAttribute("normal",new De(d,3)),this.setAttribute("uv",new De(p,2));function x(){const _=new N,I=new N;let b=0;const w=(t-e)/i;for(let C=0;C<=s;C++){const H=[],M=C/s,T=M*(t-e)+e;for(let k=0;k<=r;k++){const j=k/r,Y=j*l+o,re=Math.sin(Y),$=Math.cos(Y);I.x=T*re,I.y=-M*i+f,I.z=T*$,h.push(I.x,I.y,I.z),_.set(re,w,$).normalize(),d.push(_.x,_.y,_.z),p.push(j,1-M),H.push(m++)}v.push(H)}for(let C=0;C<r;C++)for(let H=0;H<s;H++){const M=v[H][C],T=v[H+1][C],k=v[H+1][C+1],j=v[H][C+1];e>0&&(u.push(M,T,j),b+=3),t>0&&(u.push(T,k,j),b+=3)}c.addGroup(g,b,0),g+=b}function y(_){const I=m,b=new J,w=new N;let C=0;const H=_===!0?e:t,M=_===!0?1:-1;for(let k=1;k<=r;k++)h.push(0,f*M,0),d.push(0,M,0),p.push(.5,.5),m++;const T=m;for(let k=0;k<=r;k++){const j=k/r*l+o,Y=Math.cos(j),re=Math.sin(j);w.x=H*re,w.y=f*M,w.z=H*Y,h.push(w.x,w.y,w.z),d.push(0,M,0),b.x=Y*.5+.5,b.y=re*.5*M+.5,p.push(b.x,b.y),m++}for(let k=0;k<r;k++){const j=I+k,Y=T+k;_===!0?u.push(Y,Y+1,j):u.push(Y+1,Y,j),C+=3}c.addGroup(g,C,_===!0?1:2),g+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ma(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Pd extends ma{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,o=Math.PI*2){super(0,e,t,i,r,s,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Pd(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class fs extends ct{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const s=[],a=[];o(r),c(i),u(),this.setAttribute("position",new De(s,3)),this.setAttribute("normal",new De(s.slice(),3)),this.setAttribute("uv",new De(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(x){const y=new N,_=new N,I=new N;for(let b=0;b<t.length;b+=3)p(t[b+0],y),p(t[b+1],_),p(t[b+2],I),l(y,_,I,x)}function l(x,y,_,I){const b=I+1,w=[];for(let C=0;C<=b;C++){w[C]=[];const H=x.clone().lerp(_,C/b),M=y.clone().lerp(_,C/b),T=b-C;for(let k=0;k<=T;k++)k===0&&C===b?w[C][k]=H:w[C][k]=H.clone().lerp(M,k/T)}for(let C=0;C<b;C++)for(let H=0;H<2*(b-C)-1;H++){const M=Math.floor(H/2);H%2===0?(d(w[C][M+1]),d(w[C+1][M]),d(w[C][M])):(d(w[C][M+1]),d(w[C+1][M+1]),d(w[C+1][M]))}}function c(x){const y=new N;for(let _=0;_<s.length;_+=3)y.x=s[_+0],y.y=s[_+1],y.z=s[_+2],y.normalize().multiplyScalar(x),s[_+0]=y.x,s[_+1]=y.y,s[_+2]=y.z}function u(){const x=new N;for(let y=0;y<s.length;y+=3){x.x=s[y+0],x.y=s[y+1],x.z=s[y+2];const _=f(x)/2/Math.PI+.5,I=g(x)/Math.PI+.5;a.push(_,1-I)}m(),h()}function h(){for(let x=0;x<a.length;x+=6){const y=a[x+0],_=a[x+2],I=a[x+4],b=Math.max(y,_,I),w=Math.min(y,_,I);b>.9&&w<.1&&(y<.2&&(a[x+0]+=1),_<.2&&(a[x+2]+=1),I<.2&&(a[x+4]+=1))}}function d(x){s.push(x.x,x.y,x.z)}function p(x,y){const _=x*3;y.x=e[_+0],y.y=e[_+1],y.z=e[_+2]}function m(){const x=new N,y=new N,_=new N,I=new N,b=new J,w=new J,C=new J;for(let H=0,M=0;H<s.length;H+=9,M+=6){x.set(s[H+0],s[H+1],s[H+2]),y.set(s[H+3],s[H+4],s[H+5]),_.set(s[H+6],s[H+7],s[H+8]),b.set(a[M+0],a[M+1]),w.set(a[M+2],a[M+3]),C.set(a[M+4],a[M+5]),I.copy(x).add(y).add(_).divideScalar(3);const T=f(I);v(b,M+0,x,T),v(w,M+2,y,T),v(C,M+4,_,T)}}function v(x,y,_,I){I<0&&x.x===1&&(a[y]=x.x-1),_.x===0&&_.z===0&&(a[y]=I/2/Math.PI+.5)}function f(x){return Math.atan2(x.z,-x.x)}function g(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fs(e.vertices,e.indices,e.radius,e.details)}}class Dd extends fs{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Dd(e.radius,e.detail)}}const rh=new N,nh=new N,Tm=new N,sh=new er;class Sm extends ct{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),r=Math.cos(Es*t),s=e.getIndex(),a=e.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),h={},d=[];for(let p=0;p<o;p+=3){s?(l[0]=s.getX(p),l[1]=s.getX(p+1),l[2]=s.getX(p+2)):(l[0]=p,l[1]=p+1,l[2]=p+2);const{a:m,b:v,c:f}=sh;if(m.fromBufferAttribute(a,l[0]),v.fromBufferAttribute(a,l[1]),f.fromBufferAttribute(a,l[2]),sh.getNormal(Tm),u[0]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,u[1]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,u[2]=`${Math.round(f.x*i)},${Math.round(f.y*i)},${Math.round(f.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let g=0;g<3;g++){const x=(g+1)%3,y=u[g],_=u[x],I=sh[c[g]],b=sh[c[x]],w=`${y}_${_}`,C=`${_}_${y}`;C in h&&h[C]?(Tm.dot(h[C].normal)<=r&&(d.push(I.x,I.y,I.z),d.push(b.x,b.y,b.z)),h[C]=null):w in h||(h[w]={index0:l[g],index1:l[x],normal:Tm.clone()})}}for(const p in h)if(h[p]){const{index0:m,index1:v}=h[p];rh.fromBufferAttribute(a,m),nh.fromBufferAttribute(a,v),d.push(rh.x,rh.y,rh.z),d.push(nh.x,nh.y,nh.z)}this.setAttribute("position",new De(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class rs extends Tl{constructor(e){super(e),this.uuid=vr(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(new Tl().fromJSON(r))}return this}}const aI={triangulate:function(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let s=Vy(n,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,c,u,h,d,p;if(i&&(s=hI(n,e,s,t)),n.length>80*t){o=c=n[0],l=u=n[1];for(let m=t;m<r;m+=t)h=n[m],d=n[m+1],h<o&&(o=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);p=Math.max(c-o,u-l),p=p!==0?32767/p:0}return Sl(s,a,t,o,l,p,0),a}};function Vy(n,e,t,i,r){let s,a;if(r===bI(n,e,t,i)>0)for(s=e;s<t;s+=i)a=ky(s,n[s],n[s+1],a);else for(s=t-i;s>=e;s-=i)a=ky(s,n[s],n[s+1],a);return a&&ah(a,a.next)&&(El(a),a=a.next),a}function ks(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(ah(t,t.next)||Xt(t.prev,t,t.next)===0)){if(El(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Sl(n,e,t,i,r,s,a){if(!n)return;!a&&s&&gI(n,i,r,s);let o=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?lI(n,i,r,s):oI(n)){e.push(l.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),El(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=cI(ks(n),e,t),Sl(n,e,t,i,r,s,2)):a===2&&uI(n,e,t,i,r,s):Sl(ks(n),e,t,i,r,s,1);break}}}function oI(n){const e=n.prev,t=n,i=n.next;if(Xt(e,t,i)>=0)return!1;const r=e.x,s=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=r<s?r<a?r:a:s<a?s:a,h=o<l?o<c?o:c:l<c?l:c,d=r>s?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let m=i.next;for(;m!==e;){if(m.x>=u&&m.x<=d&&m.y>=h&&m.y<=p&&Qa(r,o,s,l,a,c,m.x,m.y)&&Xt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function lI(n,e,t,i){const r=n.prev,s=n,a=n.next;if(Xt(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,u=r.y,h=s.y,d=a.y,p=o<l?o<c?o:c:l<c?l:c,m=u<h?u<d?u:d:h<d?h:d,v=o>l?o>c?o:c:l>c?l:c,f=u>h?u>d?u:d:h>d?h:d,g=wm(p,m,e,t,i),x=wm(v,f,e,t,i);let y=n.prevZ,_=n.nextZ;for(;y&&y.z>=g&&_&&_.z<=x;){if(y.x>=p&&y.x<=v&&y.y>=m&&y.y<=f&&y!==r&&y!==a&&Qa(o,u,l,h,c,d,y.x,y.y)&&Xt(y.prev,y,y.next)>=0||(y=y.prevZ,_.x>=p&&_.x<=v&&_.y>=m&&_.y<=f&&_!==r&&_!==a&&Qa(o,u,l,h,c,d,_.x,_.y)&&Xt(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;y&&y.z>=g;){if(y.x>=p&&y.x<=v&&y.y>=m&&y.y<=f&&y!==r&&y!==a&&Qa(o,u,l,h,c,d,y.x,y.y)&&Xt(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;_&&_.z<=x;){if(_.x>=p&&_.x<=v&&_.y>=m&&_.y<=f&&_!==r&&_!==a&&Qa(o,u,l,h,c,d,_.x,_.y)&&Xt(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function cI(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!ah(r,s)&&By(r,i,i.next,s)&&wl(r,s)&&wl(s,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(s.i/t|0),El(i),El(i.next),i=n=s),i=i.next}while(i!==n);return ks(i)}function uI(n,e,t,i,r,s){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&xI(a,o)){let l=zy(a,o);a=ks(a,a.next),l=ks(l,l.next),Sl(a,e,t,i,r,s,0),Sl(l,e,t,i,r,s,0);return}o=o.next}a=a.next}while(a!==n)}function hI(n,e,t,i){const r=[];let s,a,o,l,c;for(s=0,a=e.length;s<a;s++)o=e[s]*i,l=s<a-1?e[s+1]*i:n.length,c=Vy(n,o,l,i,!1),c===c.next&&(c.steiner=!0),r.push(yI(c));for(r.sort(dI),s=0;s<r.length;s++)t=pI(r[s],t);return t}function dI(n,e){return n.x-e.x}function pI(n,e){const t=mI(n,e);if(!t)return e;const i=zy(t,n);return ks(i,i.next),ks(t,t.next)}function mI(n,e){let t=e,i=-1/0,r;const s=n.x,a=n.y;do{if(a<=t.y&&a>=t.next.y&&t.next.y!==t.y){const d=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=s&&d>i&&(i=d,r=t.x<t.next.x?t:t.next,d===s))return r}t=t.next}while(t!==e);if(!r)return null;const o=r,l=r.x,c=r.y;let u=1/0,h;t=r;do s>=t.x&&t.x>=l&&s!==t.x&&Qa(a<c?s:i,a,l,c,a<c?i:s,a,t.x,t.y)&&(h=Math.abs(a-t.y)/(s-t.x),wl(t,n)&&(h<u||h===u&&(t.x>r.x||t.x===r.x&&fI(r,t)))&&(r=t,u=h)),t=t.next;while(t!==o);return r}function fI(n,e){return Xt(n.prev,n,e.prev)<0&&Xt(e.next,n,n.next)<0}function gI(n,e,t,i){let r=n;do r.z===0&&(r.z=wm(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,vI(r)}function vI(n){let e,t,i,r,s,a,o,l,c=1;do{for(t=n,n=null,s=null,a=0;t;){for(a++,i=t,o=0,e=0;e<c&&(o++,i=i.nextZ,!!i);e++);for(l=c;o>0||l>0&&i;)o!==0&&(l===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,c*=2}while(a>1);return n}function wm(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function yI(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function Qa(n,e,t,i,r,s,a,o){return(r-a)*(e-o)>=(n-a)*(s-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(r-a)*(i-o)}function xI(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!_I(n,e)&&(wl(n,e)&&wl(e,n)&&MI(n,e)&&(Xt(n.prev,n,e.prev)||Xt(n,e.prev,e))||ah(n,e)&&Xt(n.prev,n,n.next)>0&&Xt(e.prev,e,e.next)>0)}function Xt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function ah(n,e){return n.x===e.x&&n.y===e.y}function By(n,e,t,i){const r=lh(Xt(n,e,t)),s=lh(Xt(n,e,i)),a=lh(Xt(t,i,n)),o=lh(Xt(t,i,e));return!!(r!==s&&a!==o||r===0&&oh(n,t,e)||s===0&&oh(n,i,e)||a===0&&oh(t,n,i)||o===0&&oh(t,e,i))}function oh(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function lh(n){return n>0?1:n<0?-1:0}function _I(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&By(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function wl(n,e){return Xt(n.prev,n,n.next)<0?Xt(n,e,n.next)>=0&&Xt(n,n.prev,e)>=0:Xt(n,e,n.prev)<0||Xt(n,n.next,e)<0}function MI(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function zy(n,e){const t=new Em(n.i,n.x,n.y),i=new Em(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function ky(n,e,t,i){const r=new Em(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function El(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Em(n,e,t){this.i=n,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function bI(n,e,t,i){let r=0;for(let s=e,a=t-i;s<t;s+=i)r+=(n[a]-n[s])*(n[s+1]+n[a+1]),a=s;return r}class nn{static area(e){const t=e.length;let i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return nn.area(e)<0}static triangulateShape(e,t){const i=[],r=[],s=[];Hy(e),Gy(i,e);let a=e.length;t.forEach(Hy);for(let l=0;l<t.length;l++)r.push(a),a+=t[l].length,Gy(i,t[l]);const o=aI.triangulate(i,r);for(let l=0;l<o.length;l+=3)s.push(o.slice(l,l+3));return s}}function Hy(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Gy(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class _c extends ct{constructor(e=new rs([new J(.5,.5),new J(-.5,.5),new J(-.5,-.5),new J(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],s=[];for(let o=0,l=e.length;o<l;o++){const c=e[o];a(c)}this.setAttribute("position",new De(r,3)),this.setAttribute("uv",new De(s,2)),this.computeVertexNormals();function a(o){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:p-.1,v=t.bevelOffset!==void 0?t.bevelOffset:0,f=t.bevelSegments!==void 0?t.bevelSegments:3;const g=t.extrudePath,x=t.UVGenerator!==void 0?t.UVGenerator:TI;let y,_=!1,I,b,w,C;g&&(y=g.getSpacedPoints(u),_=!0,d=!1,I=g.computeFrenetFrames(u,!1),b=new N,w=new N,C=new N),d||(f=0,p=0,m=0,v=0);const H=o.extractPoints(c);let M=H.shape;const T=H.holes;if(!nn.isClockWise(M)){M=M.reverse();for(let ce=0,ue=T.length;ce<ue;ce++){const L=T[ce];nn.isClockWise(L)&&(T[ce]=L.reverse())}}const k=nn.triangulateShape(M,T),j=M;for(let ce=0,ue=T.length;ce<ue;ce++){const L=T[ce];M=M.concat(L)}function Y(ce,ue,L){return ue||console.error("THREE.ExtrudeGeometry: vec does not exist"),ce.clone().addScaledVector(ue,L)}const re=M.length,$=k.length;function he(ce,ue,L){let He,pe,Ue;const we=ce.x-ue.x,$e=ce.y-ue.y,Be=L.x-ce.x,R=L.y-ce.y,S=we*we+$e*$e,W=we*R-$e*Be;if(Math.abs(W)>Number.EPSILON){const ne=Math.sqrt(S),de=Math.sqrt(Be*Be+R*R),se=ue.x-$e/ne,ke=ue.y+we/ne,Ee=L.x-R/de,Pe=L.y+Be/de,mt=((Ee-se)*R-(Pe-ke)*Be)/(we*R-$e*Be);He=se+we*mt-ce.x,pe=ke+$e*mt-ce.y;const ve=He*He+pe*pe;if(ve<=2)return new J(He,pe);Ue=Math.sqrt(ve/2)}else{let ne=!1;we>Number.EPSILON?Be>Number.EPSILON&&(ne=!0):we<-Number.EPSILON?Be<-Number.EPSILON&&(ne=!0):Math.sign($e)===Math.sign(R)&&(ne=!0),ne?(He=-$e,pe=we,Ue=Math.sqrt(S)):(He=we,pe=$e,Ue=Math.sqrt(S/2))}return new J(He/Ue,pe/Ue)}const Q=[];for(let ce=0,ue=j.length,L=ue-1,He=ce+1;ce<ue;ce++,L++,He++)L===ue&&(L=0),He===ue&&(He=0),Q[ce]=he(j[ce],j[L],j[He]);const ye=[];let be,Ve=Q.concat();for(let ce=0,ue=T.length;ce<ue;ce++){const L=T[ce];be=[];for(let He=0,pe=L.length,Ue=pe-1,we=He+1;He<pe;He++,Ue++,we++)Ue===pe&&(Ue=0),we===pe&&(we=0),be[He]=he(L[He],L[Ue],L[we]);ye.push(be),Ve=Ve.concat(be)}for(let ce=0;ce<f;ce++){const ue=ce/f,L=p*Math.cos(ue*Math.PI/2),He=m*Math.sin(ue*Math.PI/2)+v;for(let pe=0,Ue=j.length;pe<Ue;pe++){const we=Y(j[pe],Q[pe],He);Te(we.x,we.y,-L)}for(let pe=0,Ue=T.length;pe<Ue;pe++){const we=T[pe];be=ye[pe];for(let $e=0,Be=we.length;$e<Be;$e++){const R=Y(we[$e],be[$e],He);Te(R.x,R.y,-L)}}}const at=m+v;for(let ce=0;ce<re;ce++){const ue=d?Y(M[ce],Ve[ce],at):M[ce];_?(w.copy(I.normals[0]).multiplyScalar(ue.x),b.copy(I.binormals[0]).multiplyScalar(ue.y),C.copy(y[0]).add(w).add(b),Te(C.x,C.y,C.z)):Te(ue.x,ue.y,0)}for(let ce=1;ce<=u;ce++)for(let ue=0;ue<re;ue++){const L=d?Y(M[ue],Ve[ue],at):M[ue];_?(w.copy(I.normals[ce]).multiplyScalar(L.x),b.copy(I.binormals[ce]).multiplyScalar(L.y),C.copy(y[ce]).add(w).add(b),Te(C.x,C.y,C.z)):Te(L.x,L.y,h/u*ce)}for(let ce=f-1;ce>=0;ce--){const ue=ce/f,L=p*Math.cos(ue*Math.PI/2),He=m*Math.sin(ue*Math.PI/2)+v;for(let pe=0,Ue=j.length;pe<Ue;pe++){const we=Y(j[pe],Q[pe],He);Te(we.x,we.y,h+L)}for(let pe=0,Ue=T.length;pe<Ue;pe++){const we=T[pe];be=ye[pe];for(let $e=0,Be=we.length;$e<Be;$e++){const R=Y(we[$e],be[$e],He);_?Te(R.x,R.y+y[u-1].y,y[u-1].x+L):Te(R.x,R.y,h+L)}}}et(),ie();function et(){const ce=r.length/3;if(d){let ue=0,L=re*ue;for(let He=0;He<$;He++){const pe=k[He];Se(pe[2]+L,pe[1]+L,pe[0]+L)}ue=u+f*2,L=re*ue;for(let He=0;He<$;He++){const pe=k[He];Se(pe[0]+L,pe[1]+L,pe[2]+L)}}else{for(let ue=0;ue<$;ue++){const L=k[ue];Se(L[2],L[1],L[0])}for(let ue=0;ue<$;ue++){const L=k[ue];Se(L[0]+re*u,L[1]+re*u,L[2]+re*u)}}i.addGroup(ce,r.length/3-ce,0)}function ie(){const ce=r.length/3;let ue=0;le(j,ue),ue+=j.length;for(let L=0,He=T.length;L<He;L++){const pe=T[L];le(pe,ue),ue+=pe.length}i.addGroup(ce,r.length/3-ce,1)}function le(ce,ue){let L=ce.length;for(;--L>=0;){const He=L;let pe=L-1;pe<0&&(pe=ce.length-1);for(let Ue=0,we=u+f*2;Ue<we;Ue++){const $e=re*Ue,Be=re*(Ue+1),R=ue+He+$e,S=ue+pe+$e,W=ue+pe+Be,ne=ue+He+Be;Ye(R,S,W,ne)}}}function Te(ce,ue,L){l.push(ce),l.push(ue),l.push(L)}function Se(ce,ue,L){We(ce),We(ue),We(L);const He=r.length/3,pe=x.generateTopUV(i,r,He-3,He-2,He-1);ot(pe[0]),ot(pe[1]),ot(pe[2])}function Ye(ce,ue,L,He){We(ce),We(ue),We(He),We(ue),We(L),We(He);const pe=r.length/3,Ue=x.generateSideWallUV(i,r,pe-6,pe-3,pe-2,pe-1);ot(Ue[0]),ot(Ue[1]),ot(Ue[3]),ot(Ue[1]),ot(Ue[2]),ot(Ue[3])}function We(ce){r.push(l[ce*3+0]),r.push(l[ce*3+1]),r.push(l[ce*3+2])}function ot(ce){s.push(ce.x),s.push(ce.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return SI(t,i,e)}static fromJSON(e,t){const i=[];for(let s=0,a=e.shapes.length;s<a;s++){const o=t[e.shapes[s]];i.push(o)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new ih[r.type]().fromJSON(r)),new _c(i,e.options)}}const TI={generateTopUV:function(n,e,t,i,r){const s=e[t*3],a=e[t*3+1],o=e[i*3],l=e[i*3+1],c=e[r*3],u=e[r*3+1];return[new J(s,a),new J(o,l),new J(c,u)]},generateSideWallUV:function(n,e,t,i,r,s){const a=e[t*3],o=e[t*3+1],l=e[t*3+2],c=e[i*3],u=e[i*3+1],h=e[i*3+2],d=e[r*3],p=e[r*3+1],m=e[r*3+2],v=e[s*3],f=e[s*3+1],g=e[s*3+2];return Math.abs(o-u)<Math.abs(a-c)?[new J(a,1-l),new J(c,1-h),new J(d,1-m),new J(v,1-g)]:[new J(o,1-l),new J(u,1-h),new J(p,1-m),new J(f,1-g)]}};function SI(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){const s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class Ud extends fs{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ud(e.radius,e.detail)}}class Eo extends fs{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Eo(e.radius,e.detail)}}class Mc extends ct{constructor(e=.5,t=1,i=32,r=1,s=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:a},i=Math.max(3,i),r=Math.max(1,r);const o=[],l=[],c=[],u=[];let h=e;const d=(t-e)/r,p=new N,m=new J;for(let v=0;v<=r;v++){for(let f=0;f<=i;f++){const g=s+f/i*a;p.x=h*Math.cos(g),p.y=h*Math.sin(g),l.push(p.x,p.y,p.z),c.push(0,0,1),m.x=(p.x/t+1)/2,m.y=(p.y/t+1)/2,u.push(m.x,m.y)}h+=d}for(let v=0;v<r;v++){const f=v*(i+1);for(let g=0;g<i;g++){const x=g+f,y=x,_=x+i+1,I=x+i+2,b=x+1;o.push(y,_,b),o.push(_,I,b)}}this.setIndex(o),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Mc(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Od extends ct{constructor(e=new rs([new J(0,.5),new J(-.5,-.5),new J(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],s=[],a=[];let o=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(o,l,u),o+=l,l=0;this.setIndex(i),this.setAttribute("position",new De(r,3)),this.setAttribute("normal",new De(s,3)),this.setAttribute("uv",new De(a,2));function c(u){const h=r.length/3,d=u.extractPoints(t);let p=d.shape;const m=d.holes;nn.isClockWise(p)===!1&&(p=p.reverse());for(let f=0,g=m.length;f<g;f++){const x=m[f];nn.isClockWise(x)===!0&&(m[f]=x.reverse())}const v=nn.triangulateShape(p,m);for(let f=0,g=m.length;f<g;f++){const x=m[f];p=p.concat(x)}for(let f=0,g=p.length;f<g;f++){const x=p[f];r.push(x.x,x.y,0),s.push(0,0,1),a.push(x.x,x.y)}for(let f=0,g=v.length;f<g;f++){const x=v[f],y=x[0]+h,_=x[1]+h,I=x[2]+h;i.push(y,_,I),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return wI(t,e)}static fromJSON(e,t){const i=[];for(let r=0,s=e.shapes.length;r<s;r++){const a=t[e.shapes[r]];i.push(a)}return new Od(i,e.curveSegments)}}function wI(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}class Ao extends ct{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(a+o,Math.PI);let c=0;const u=[],h=new N,d=new N,p=[],m=[],v=[],f=[];for(let g=0;g<=i;g++){const x=[],y=g/i;let _=0;g===0&&a===0?_=.5/t:g===i&&l===Math.PI&&(_=-.5/t);for(let I=0;I<=t;I++){const b=I/t;h.x=-e*Math.cos(r+b*s)*Math.sin(a+y*o),h.y=e*Math.cos(a+y*o),h.z=e*Math.sin(r+b*s)*Math.sin(a+y*o),m.push(h.x,h.y,h.z),d.copy(h).normalize(),v.push(d.x,d.y,d.z),f.push(b+_,1-y),x.push(c++)}u.push(x)}for(let g=0;g<i;g++)for(let x=0;x<t;x++){const y=u[g][x+1],_=u[g][x],I=u[g+1][x],b=u[g+1][x+1];(g!==0||a>0)&&p.push(y,_,b),(g!==i-1||l<Math.PI)&&p.push(_,I,b)}this.setIndex(p),this.setAttribute("position",new De(m,3)),this.setAttribute("normal",new De(v,3)),this.setAttribute("uv",new De(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ao(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Fd extends fs{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Fd(e.radius,e.detail)}}class bc extends ct{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);const a=[],o=[],l=[],c=[],u=new N,h=new N,d=new N;for(let p=0;p<=i;p++)for(let m=0;m<=r;m++){const v=m/r*s,f=p/i*Math.PI*2;h.x=(e+t*Math.cos(f))*Math.cos(v),h.y=(e+t*Math.cos(f))*Math.sin(v),h.z=t*Math.sin(f),o.push(h.x,h.y,h.z),u.x=e*Math.cos(v),u.y=e*Math.sin(v),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(m/r),c.push(p/i)}for(let p=1;p<=i;p++)for(let m=1;m<=r;m++){const v=(r+1)*p+m-1,f=(r+1)*(p-1)+m-1,g=(r+1)*(p-1)+m,x=(r+1)*p+m;a.push(v,f,x),a.push(f,g,x)}this.setIndex(a),this.setAttribute("position",new De(o,3)),this.setAttribute("normal",new De(l,3)),this.setAttribute("uv",new De(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bc(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Vd extends ct{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);const o=[],l=[],c=[],u=[],h=new N,d=new N,p=new N,m=new N,v=new N,f=new N,g=new N;for(let y=0;y<=i;++y){const _=y/i*s*Math.PI*2;x(_,s,a,e,p),x(_+.01,s,a,e,m),f.subVectors(m,p),g.addVectors(m,p),v.crossVectors(f,g),g.crossVectors(v,f),v.normalize(),g.normalize();for(let I=0;I<=r;++I){const b=I/r*Math.PI*2,w=-t*Math.cos(b),C=t*Math.sin(b);h.x=p.x+(w*g.x+C*v.x),h.y=p.y+(w*g.y+C*v.y),h.z=p.z+(w*g.z+C*v.z),l.push(h.x,h.y,h.z),d.subVectors(h,p).normalize(),c.push(d.x,d.y,d.z),u.push(y/i),u.push(I/r)}}for(let y=1;y<=i;y++)for(let _=1;_<=r;_++){const I=(r+1)*(y-1)+(_-1),b=(r+1)*y+(_-1),w=(r+1)*y+_,C=(r+1)*(y-1)+_;o.push(I,b,C),o.push(b,w,C)}this.setIndex(o),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(c,3)),this.setAttribute("uv",new De(u,2));function x(y,_,I,b,w){const C=Math.cos(y),H=Math.sin(y),M=I/_*y,T=Math.cos(M);w.x=b*(2+T)*.5*C,w.y=b*(2+T)*H*.5,w.z=b*Math.sin(M)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vd(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Bd extends ct{constructor(e=new Mm(new N(-1,-1,0),new N(-1,1,0),new N(1,1,0)),t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};const a=e.computeFrenetFrames(t,s);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new N,l=new N,c=new J;let u=new N;const h=[],d=[],p=[],m=[];v(),this.setIndex(m),this.setAttribute("position",new De(h,3)),this.setAttribute("normal",new De(d,3)),this.setAttribute("uv",new De(p,2));function v(){for(let y=0;y<t;y++)f(y);f(s===!1?t:0),x(),g()}function f(y){u=e.getPointAt(y/t,u);const _=a.normals[y],I=a.binormals[y];for(let b=0;b<=r;b++){const w=b/r*Math.PI*2,C=Math.sin(w),H=-Math.cos(w);l.x=H*_.x+C*I.x,l.y=H*_.y+C*I.y,l.z=H*_.z+C*I.z,l.normalize(),d.push(l.x,l.y,l.z),o.x=u.x+i*l.x,o.y=u.y+i*l.y,o.z=u.z+i*l.z,h.push(o.x,o.y,o.z)}}function g(){for(let y=1;y<=t;y++)for(let _=1;_<=r;_++){const I=(r+1)*(y-1)+(_-1),b=(r+1)*y+(_-1),w=(r+1)*y+_,C=(r+1)*(y-1)+_;m.push(I,b,C),m.push(b,w,C)}}function x(){for(let y=0;y<=t;y++)for(let _=0;_<=r;_++)c.x=y/t,c.y=_/r,p.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new Bd(new ih[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Am extends ct{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],i=new Set,r=new N,s=new N;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const h=l[c],d=h.start,p=h.count;for(let m=d,v=d+p;m<v;m+=3)for(let f=0;f<3;f++){const g=o.getX(m+f),x=o.getX(m+(f+1)%3);r.fromBufferAttribute(a,g),s.fromBufferAttribute(a,x),Wy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const u=3*o+c,h=3*o+(c+1)%3;r.fromBufferAttribute(a,u),s.fromBufferAttribute(a,h),Wy(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new De(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Wy(n,e,t){const i=`${n.x},${n.y},${n.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${n.x},${n.y},${n.z}`;return t.has(i)===!0||t.has(r)===!0?!1:(t.add(i),t.add(r),!0)}var jy=Object.freeze({__proto__:null,BoxGeometry:yn,CapsuleGeometry:Id,CircleGeometry:Ld,ConeGeometry:Pd,CylinderGeometry:ma,DodecahedronGeometry:Dd,EdgesGeometry:Sm,ExtrudeGeometry:_c,IcosahedronGeometry:Ud,LatheGeometry:xc,OctahedronGeometry:Eo,PlaneGeometry:pa,PolyhedronGeometry:fs,RingGeometry:Mc,ShapeGeometry:Od,SphereGeometry:Ao,TetrahedronGeometry:Fd,TorusGeometry:bc,TorusKnotGeometry:Vd,TubeGeometry:Bd,WireframeGeometry:Am});class ch extends hi{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new xe(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class Nm extends Pr{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Al extends hi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new xe(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 xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hr,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.envMapRotation.copy(e.envMapRotation),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 uh extends Al{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new J(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Jt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new xe(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 xe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new xe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=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 dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=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.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,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.dispersion=e.dispersion,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}}class hh extends hi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new xe(16777215),this.specular=new xe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hr,this.combine=ga,this.reflectivity=1,this.refractionRatio=.98,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.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,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.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,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 Cm extends hi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new xe(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,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.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class dh extends hi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class ph extends hi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hr,this.combine=ga,this.reflectivity=1,this.refractionRatio=.98,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.color.copy(e.color),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.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,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 Rm extends hi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new xe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=on,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,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.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class mh extends Ni{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Hs(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Xy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function qy(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function Im(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,a=0;a!==i;++s){const o=t[s]*e;for(let l=0;l!==e;++l)r[a++]=n[o+l]}return r}function Lm(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let a=s[i];if(a!==void 0)if(Array.isArray(a))do a=s[i],a!==void 0&&(e.push(s.time),t.push.apply(t,a)),s=n[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[i],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do a=s[i],a!==void 0&&(e.push(s.time),t.push(a)),s=n[r++];while(s!==void 0)}function EI(n,e,t,i,r=30){const s=n.clone();s.name=e;const a=[];for(let l=0;l<s.tracks.length;++l){const c=s.tracks[l],u=c.getValueSize(),h=[],d=[];for(let p=0;p<c.times.length;++p){const m=c.times[p]*r;if(!(m<t||m>=i)){h.push(c.times[p]);for(let v=0;v<u;++v)d.push(c.values[p*u+v])}}h.length!==0&&(c.times=Hs(h,c.times.constructor),c.values=Hs(d,c.values.constructor),a.push(c))}s.tracks=a;let o=1/0;for(let l=0;l<s.tracks.length;++l)o>s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*o);return s.resetDuration(),s}function AI(n,e=0,t=n,i=30){i<=0&&(i=30);const r=t.tracks.length,s=e/i;for(let a=0;a<r;++a){const o=t.tracks[a],l=o.ValueTypeName;if(l==="bool"||l==="string")continue;const c=n.tracks.find(function(g){return g.name===o.name&&g.ValueTypeName===l});if(c===void 0)continue;let u=0;const h=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let d=0;const p=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=p/3);const m=o.times.length-1;let v;if(s<=o.times[0]){const g=u,x=h-u;v=o.values.slice(g,x)}else if(s>=o.times[m]){const g=m*h+u,x=g+h-u;v=o.values.slice(g,x)}else{const g=o.createInterpolant(),x=u,y=h-u;g.evaluate(s),v=g.resultBuffer.slice(x,y)}l==="quaternion"&&new qi().fromArray(v).normalize().conjugate().toArray(v);const f=c.times.length;for(let g=0;g<f;++g){const x=g*p+d;if(l==="quaternion")qi.multiplyQuaternionsFlat(c.values,x,v,0,c.values,x);else{const y=p-d*2;for(let _=0;_<y;++_)c.values[x+_]-=v[_]}}}return n.blendMode=lp,n}const NI={convertArray:Hs,isTypedArray:Xy,getKeyframeOrder:qy,sortedArray:Im,flattenJSON:Lm,subclip:EI,makeClipAdditive:AI};class eo{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let a;i:{r:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=s)){const o=t[1];e<o&&(i=2,s=o);for(let l=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===l)break;if(r=s,s=t[--i-1],e>=s)break t}a=i,i=0;break i}break e}for(;i<a;){const o=i+a>>>1;e<t[o]?a=o:i=o+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Yy extends eo{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:bs,endingEnd:bs}}intervalChanged_(e,t,i){const r=this.parameterPositions;let s=e-2,a=e+1,o=r[s],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case Ts:s=e,o=2*t-i;break;case $o:s=r.length-2,o=t+r[s]-r[s+1];break;default:s=e,o=i}if(l===void 0)switch(this.getSettings_().endingEnd){case Ts:a=e,l=2*i-t;break;case $o:a=1,l=i+r[1]-r[0];break;default:a=e-1,l=t}const c=(i-t)*.5,u=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-i),this._offsetPrev=s*u,this._offsetNext=a*u}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,p=this._weightNext,m=(i-t)/(r-t),v=m*m,f=v*m,g=-d*f+2*d*v-d*m,x=(1+d)*f+(-1.5-2*d)*v+(-.5+d)*m+1,y=(-1-p)*f+(1.5+p)*v+.5*m,_=p*f-p*v;for(let I=0;I!==o;++I)s[I]=g*a[u+I]+x*a[c+I]+y*a[l+I]+_*a[h+I];return s}}class Pm extends eo{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=(i-t)/(r-t),h=1-u;for(let d=0;d!==o;++d)s[d]=a[c+d]*h+a[l+d]*u;return s}}class $y extends eo{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Jr{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Hs(t,this.TimeBufferType),this.values=Hs(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Hs(e.times,Array),values:Hs(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new $y(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Pm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Yy(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Ta:t=this.InterpolantFactoryMethodDiscrete;break;case Yo:t=this.InterpolantFactoryMethodLinear;break;case su:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ta;case this.InterpolantFactoryMethodLinear:return Yo;case this.InterpolantFactoryMethodSmooth:return su}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){const i=this.times,r=i.length;let s=0,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=i.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=i[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(r!==void 0&&Xy(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===su,s=e.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=e[o],u=e[o+1];if(c!==u&&(o!==1||c!==e[0]))if(r)l=!0;else{const h=o*i,d=h-i,p=h+i;for(let m=0;m!==i;++m){const v=t[h+m];if(v!==t[d+m]||v!==t[p+m]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const h=o*i,d=a*i;for(let p=0;p!==i;++p)t[d+p]=t[h+p]}++a}}if(s>0){e[a]=e[s];for(let o=s*i,l=a*i,c=0;c!==i;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Jr.prototype.TimeBufferType=Float32Array,Jr.prototype.ValueBufferType=Float32Array,Jr.prototype.DefaultInterpolation=Yo;class Gs extends Jr{constructor(e,t,i){super(e,t,i)}}Gs.prototype.ValueTypeName="bool",Gs.prototype.ValueBufferType=Array,Gs.prototype.DefaultInterpolation=Ta,Gs.prototype.InterpolantFactoryMethodLinear=void 0,Gs.prototype.InterpolantFactoryMethodSmooth=void 0;class fh extends Jr{}fh.prototype.ValueTypeName="color";class to extends Jr{}to.prototype.ValueTypeName="number";class Jy extends eo{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(r-t);let c=e*o;for(let u=c+o;c!==u;c+=4)qi.slerpFlat(s,0,a,c-o,a,c,l);return s}}class io extends Jr{InterpolantFactoryMethodLinear(e){return new Jy(this.times,this.values,this.getValueSize(),e)}}io.prototype.ValueTypeName="quaternion",io.prototype.InterpolantFactoryMethodSmooth=void 0;class Ws extends Jr{constructor(e,t,i){super(e,t,i)}}Ws.prototype.ValueTypeName="string",Ws.prototype.ValueBufferType=Array,Ws.prototype.DefaultInterpolation=Ta,Ws.prototype.InterpolantFactoryMethodLinear=void 0,Ws.prototype.InterpolantFactoryMethodSmooth=void 0;class ro extends Jr{}ro.prototype.ValueTypeName="vector";class no{constructor(e="",t=-1,i=[],r=au){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=vr(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,o=i.length;a!==o;++a)t.push(RI(i[a]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(Jr.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const u=qy(l);l=Im(l,1,u),c=Im(c,1,u),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new to(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const r={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],u=c.name.match(s);if(u&&u.length>1){const h=u[1];let d=r[h];d||(r[h]=d=[]),d.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(u,h,d,p,m){if(d.length!==0){const v=[],f=[];Lm(d,v,f,p),v.length!==0&&m.push(new u(h,v,f))}},r=[],s=e.name||"default",a=e.fps||30,o=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u<c.length;u++){const h=c[u].keys;if(!(!h||h.length===0))if(h[0].morphTargets){const d={};let p;for(p=0;p<h.length;p++)if(h[p].morphTargets)for(let m=0;m<h[p].morphTargets.length;m++)d[h[p].morphTargets[m]]=-1;for(const m in d){const v=[],f=[];for(let g=0;g!==h[p].morphTargets.length;++g){const x=h[p];v.push(x.time),f.push(x.morphTarget===m?1:0)}r.push(new to(".morphTargetInfluence["+m+"]",v,f))}l=d.length*a}else{const d=".bones["+t[u].name+"]";i(ro,d+".position",h,"pos",r),i(io,d+".quaternion",h,"rot",r),i(ro,d+".scale",h,"scl",r)}}return r.length===0?null:new this(s,l,r,o)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function CI(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return to;case"vector":case"vector2":case"vector3":case"vector4":return ro;case"color":return fh;case"quaternion":return io;case"bool":case"boolean":return Gs;case"string":return Ws}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function RI(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=CI(n.type);if(n.times===void 0){const t=[],i=[];Lm(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const Rn={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class gh{constructor(e,t,i){const r=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){o++,s===!1&&r.onStart!==void 0&&r.onStart(u,a,o),s=!0},this.itemEnd=function(u){a++,r.onProgress!==void 0&&r.onProgress(u,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){const h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){const p=c[h],m=c[h+1];if(p.global&&(p.lastIndex=0),p.test(u))return m}return null}}}const Dm=new gh;class Hi{constructor(e){this.manager=e!==void 0?e:Dm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}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}}Hi.DEFAULT_MATERIAL_NAME="__DEFAULT";const In={};class II extends Error{constructor(e,t){super(e),this.response=t}}class Kr extends Hi{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=Rn.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(In[e]!==void 0){In[e].push({onLoad:t,onProgress:i,onError:r});return}In[e]=[],In[e].push({onLoad:t,onProgress:i,onError:r});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=In[e],h=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,m=p!==0;let v=0;const f=new ReadableStream({start(g){x();function x(){h.read().then(({done:y,value:_})=>{if(y)g.close();else{v+=_.byteLength;const I=new ProgressEvent("progress",{lengthComputable:m,loaded:v,total:p});for(let b=0,w=u.length;b<w;b++){const C=u[b];C.onProgress&&C.onProgress(I)}g.enqueue(_),x()}},y=>{g.error(y)})}}});return new Response(f)}else throw new II(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),h=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(h);return c.arrayBuffer().then(p=>d.decode(p))}}}).then(c=>{Rn.add(e,c);const u=In[e];delete In[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onLoad&&p.onLoad(c)}}).catch(c=>{const u=In[e];if(u===void 0)throw this.manager.itemError(e),c;delete In[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onError&&p.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 LI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i<e.length;i++){const r=no.parse(e[i]);t.push(r)}return t}}class PI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=[],o=new _l,l=new Kr(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(s.withCredentials);let c=0;function u(h){l.load(e[h],function(d){const p=s.parse(d,!0);a[h]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},c+=1,c===6&&(p.mipmapCount===1&&(o.minFilter=Lt),o.image=a,o.format=p.format,o.needsUpdate=!0,t&&t(o))},i,r)}if(Array.isArray(e))for(let h=0,d=e.length;h<d;++h)u(h);else l.load(e,function(h){const d=s.parse(h,!0);if(d.isCubemap){const p=d.mipmaps.length/d.mipmapCount;for(let m=0;m<p;m++){a[m]={mipmaps:[]};for(let v=0;v<d.mipmapCount;v++)a[m].mipmaps.push(d.mipmaps[m*d.mipmapCount+v]),a[m].format=d.format,a[m].width=d.width,a[m].height=d.height}o.image=a}else o.image.width=d.width,o.image.height=d.height,o.mipmaps=d.mipmaps;d.mipmapCount===1&&(o.minFilter=Lt),o.format=d.format,o.needsUpdate=!0,t&&t(o)},i,r);return o}}class Nl extends Hi{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Rn.get(e);if(a!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a;const o=tl("img");function l(){u(),Rn.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(h){u(),r&&r(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(e),o.src=e,o}}class DI extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=new Is;s.colorSpace=Fi;const a=new Nl(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;function l(c){a.load(e[c],function(u){s.images[c]=u,o++,o===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let c=0;c<e.length;++c)l(c);return s}}class Ky extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Ur,o=new Kr(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let c;try{c=s.parse(l)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}c.image!==void 0?a.image=c.image:c.data!==void 0&&(a.image.width=c.width,a.image.height=c.height,a.image.data=c.data),a.wrapS=c.wrapS!==void 0?c.wrapS:fr,a.wrapT=c.wrapT!==void 0?c.wrapT:fr,a.magFilter=c.magFilter!==void 0?c.magFilter:Lt,a.minFilter=c.minFilter!==void 0?c.minFilter:Lt,a.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(a.colorSpace=c.colorSpace),c.flipY!==void 0&&(a.flipY=c.flipY),c.format!==void 0&&(a.format=c.format),c.type!==void 0&&(a.type=c.type),c.mipmaps!==void 0&&(a.mipmaps=c.mipmaps,a.minFilter=ji),c.mipmapCount===1&&(a.minFilter=Lt),c.generateMipmaps!==void 0&&(a.generateMipmaps=c.generateMipmaps),a.needsUpdate=!0,t&&t(a,c)},i,r),a}}class Zy extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=new Wt,a=new Nl(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){s.image=o,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}}class ns extends _t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new xe(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class vh extends ns{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.groundColor=new xe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Um=new Re,Qy=new N,ex=new N;class Om{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new J(512,512),this.map=null,this.mapPass=null,this.matrix=new Re,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ha,this._frameExtents=new J(1,1),this._viewportCount=1,this._viewports=[new st(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;Qy.setFromMatrixPosition(e.matrixWorld),t.position.copy(Qy),ex.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ex),t.updateMatrixWorld(),Um.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Um),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Um)}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.intensity=e.intensity,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.intensity!==1&&(e.intensity=this.intensity),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 UI extends Om{constructor(){super(new di(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=Ea*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Cl extends ns{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new UI}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const tx=new Re,Rl=new N,Fm=new N;class OI extends Om{constructor(){super(new di(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new J(4,2),this._viewportCount=6,this._viewports=[new st(2,1,1,1),new st(0,1,1,1),new st(3,1,1,1),new st(1,1,1,1),new st(3,0,1,1),new st(1,0,1,1)],this._cubeDirections=[new N(1,0,0),new N(-1,0,0),new N(0,0,1),new N(0,0,-1),new N(0,1,0),new N(0,-1,0)],this._cubeUps=[new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,0,1),new N(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Rl.setFromMatrixPosition(e.matrixWorld),i.position.copy(Rl),Fm.copy(i.position),Fm.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Fm),i.updateMatrixWorld(),r.makeTranslation(-Rl.x,-Rl.y,-Rl.z),tx.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(tx)}}class yh extends ns{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new OI}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class FI extends Om{constructor(){super(new Ds(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class xh extends ns{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_t.DEFAULT_UP),this.updateMatrix(),this.target=new _t,this.shadow=new FI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class _h extends ns{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Vm extends ns{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class ix{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new N)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*i),t.addScaledVector(a[4],1.092548*(i*r)),t.addScaledVector(a[5],1.092548*(r*s)),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],1.092548*(i*s)),t.addScaledVector(a[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){const i=e.x,r=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*s),t.addScaledVector(a[3],2*.511664*i),t.addScaledVector(a[4],2*.429043*i*r),t.addScaledVector(a[5],2*.429043*r*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],2*.429043*i*s),t.addScaledVector(a[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}}class Bm extends ns{constructor(e=new ix,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Tc extends Hi{constructor(e){super(e),this.textures={}}load(e,t,i,r){const s=this,a=new Kr(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new xe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const a=e.uniforms[s];switch(r.uniforms[s]={},a.type){case"t":r.uniforms[s].value=i(a.value);break;case"c":r.uniforms[s].value=new xe().setHex(a.value);break;case"v2":r.uniforms[s].value=new J().fromArray(a.value);break;case"v3":r.uniforms[s].value=new N().fromArray(a.value);break;case"v4":r.uniforms[s].value=new st().fromArray(a.value);break;case"m3":r.uniforms[s].value=new Ke().fromArray(a.value);break;case"m4":r.uniforms[s].value=new Re().fromArray(a.value);break;default:r.uniforms[s].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new J().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new J().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return Tc.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:ch,SpriteMaterial:dl,RawShaderMaterial:Nm,ShaderMaterial:Pr,PointsMaterial:Za,MeshPhysicalMaterial:uh,MeshStandardMaterial:Al,MeshPhongMaterial:hh,MeshToonMaterial:Cm,MeshNormalMaterial:dh,MeshLambertMaterial:ph,MeshDepthMaterial:Fu,MeshDistanceMaterial:qp,MeshBasicMaterial:Yr,MeshMatcapMaterial:Rm,LineDashedMaterial:mh,LineBasicMaterial:Ni,Material:hi};return new t[e]}}class Mh{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class zm extends ct{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class rx extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(d,p){if(t[p]!==void 0)return t[p];const m=d.interleavedBuffers[p],v=s(d,m.buffer),f=Aa(m.type,v),g=new Xa(f,m.stride);return g.uuid=m.uuid,t[p]=g,g}function s(d,p){if(i[p]!==void 0)return i[p];const m=d.arrayBuffers[p],v=new Uint32Array(m).buffer;return i[p]=v,v}const a=e.isInstancedBufferGeometry?new zm:new ct,o=e.data.index;if(o!==void 0){const d=Aa(o.type,o.array);a.setIndex(new wt(d,1))}const l=e.data.attributes;for(const d in l){const p=l[d];let m;if(p.isInterleavedBufferAttribute){const v=r(e.data,p.data);m=new On(v,p.itemSize,p.offset,p.normalized)}else{const v=Aa(p.type,p.array),f=p.isInstancedBufferAttribute?Nn:wt;m=new f(v,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),a.setAttribute(d,m)}const c=e.data.morphAttributes;if(c)for(const d in c){const p=c[d],m=[];for(let v=0,f=p.length;v<f;v++){const g=p[v];let x;if(g.isInterleavedBufferAttribute){const y=r(e.data,g.data);x=new On(y,g.itemSize,g.offset,g.normalized)}else{const y=Aa(g.type,g.array);x=new wt(y,g.itemSize,g.normalized)}g.name!==void 0&&(x.name=g.name),m.push(x)}a.morphAttributes[d]=m}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let d=0,p=u.length;d!==p;++d){const m=u[d];a.addGroup(m.start,m.count,m.materialIndex)}const h=e.data.boundingSphere;if(h!==void 0){const d=new N;h.center!==void 0&&d.fromArray(h.center),a.boundingSphere=new Ai(d,h.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class nx extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=this.path===""?Mh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const o=new Kr(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(h){r!==void 0&&r(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}const u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},i,r)}async loadAsync(e,t){const i=this,r=this.path===""?Mh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const s=new Kr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const a=await s.loadAsync(e,t),o=JSON.parse(a),l=o.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(o)}parse(e,t){const i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(c)}),o=this.parseTextures(e.textures,a),l=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,s,l,o,i),u=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,u),this.bindLightTargets(c),t!==void 0){let h=!1;for(const d in a)if(a[d].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,o,a,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),this.bindLightTargets(l),l}parseShapes(e){const t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){const s=new rs().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){const i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=new yc().fromJSON(e[s],r);i[o.uuid]=o}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new rx;for(let s=0,a=e.length;s<a;s++){let o;const l=e[s];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":o=r.parse(l);break;default:l.type in jy?o=jy[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}o.uuid=l.uuid,l.name!==void 0&&(o.name=l.name),l.userData!==void 0&&(o.userData=l.userData),i[l.uuid]=o}}return i}parseMaterials(e,t){const i={},r={};if(e!==void 0){const s=new Tc;s.setTextures(t);for(let a=0,o=e.length;a<o;a++){const l=e[a];i[l.uuid]===void 0&&(i[l.uuid]=s.parse(l)),r[l.uuid]=i[l.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const r=e[i],s=no.parse(r);t[s.uuid]=s}return t}parseImages(e,t){const i=this,r={};let s;function a(l){return i.manager.itemStart(l),s.load(l,function(){i.manager.itemEnd(l)},void 0,function(){i.manager.itemError(l),i.manager.itemEnd(l)})}function o(l){if(typeof l=="string"){const c=l,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return a(u)}else return l.data?{data:Aa(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new gh(t);s=new Nl(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c<u;c++){const h=e[c],d=h.url;if(Array.isArray(d)){const p=[];for(let m=0,v=d.length;m<v;m++){const f=d[m],g=o(f);g!==null&&(g instanceof HTMLImageElement?p.push(g):p.push(new Ur(g.data,g.width,g.height)))}r[h.uuid]=new $n(p)}else{const p=o(h.url);r[h.uuid]=new $n(p)}}}return r}async parseImagesAsync(e){const t=this,i={};let r;async function s(a){if(typeof a=="string"){const o=a,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(o)?o:t.resourcePath+o;return await r.loadAsync(l)}else return a.data?{data:Aa(a.type,a.data),width:a.width,height:a.height}:null}if(e!==void 0&&e.length>0){r=new Nl(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a<o;a++){const l=e[a],c=l.url;if(Array.isArray(c)){const u=[];for(let h=0,d=c.length;h<d;h++){const p=c[h],m=await s(p);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new Ur(m.data,m.width,m.height)))}i[l.uuid]=new $n(u)}else{const u=await s(l.url);i[l.uuid]=new $n(u)}}}return i}parseTextures(e,t){function i(s,a){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),a[s])}const r={};if(e!==void 0)for(let s=0,a=e.length;s<a;s++){const o=e[s];o.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',o.uuid),t[o.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",o.image);const l=t[o.image],c=l.data;let u;Array.isArray(c)?(u=new Is,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new Ur:u=new Wt,c&&(u.needsUpdate=!0)),u.source=l,u.uuid=o.uuid,o.name!==void 0&&(u.name=o.name),o.mapping!==void 0&&(u.mapping=i(o.mapping,VI)),o.channel!==void 0&&(u.channel=o.channel),o.offset!==void 0&&u.offset.fromArray(o.offset),o.repeat!==void 0&&u.repeat.fromArray(o.repeat),o.center!==void 0&&u.center.fromArray(o.center),o.rotation!==void 0&&(u.rotation=o.rotation),o.wrap!==void 0&&(u.wrapS=i(o.wrap[0],sx),u.wrapT=i(o.wrap[1],sx)),o.format!==void 0&&(u.format=o.format),o.internalFormat!==void 0&&(u.internalFormat=o.internalFormat),o.type!==void 0&&(u.type=o.type),o.colorSpace!==void 0&&(u.colorSpace=o.colorSpace),o.minFilter!==void 0&&(u.minFilter=i(o.minFilter,ax)),o.magFilter!==void 0&&(u.magFilter=i(o.magFilter,ax)),o.anisotropy!==void 0&&(u.anisotropy=o.anisotropy),o.flipY!==void 0&&(u.flipY=o.flipY),o.generateMipmaps!==void 0&&(u.generateMipmaps=o.generateMipmaps),o.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=o.premultiplyAlpha),o.unpackAlignment!==void 0&&(u.unpackAlignment=o.unpackAlignment),o.compareFunction!==void 0&&(u.compareFunction=o.compareFunction),o.userData!==void 0&&(u.userData=o.userData),r[o.uuid]=u}return r}parseObject(e,t,i,r,s){let a;function o(d){return t[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",d),t[d]}function l(d){if(d!==void 0){if(Array.isArray(d)){const p=[];for(let m=0,v=d.length;m<v;m++){const f=d[m];i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),p.push(i[f])}return p}return i[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),i[d]}}function c(d){return r[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",d),r[d]}let u,h;switch(e.type){case"Scene":a=new Vu,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new xe(e.background):a.background=c(e.background)),e.environment!==void 0&&(a.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new Kp(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Rd(e.fog.color,e.fog.density)),e.fog.name!==""&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new di(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new Ds(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new _h(e.color,e.intensity);break;case"DirectionalLight":a=new xh(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new yh(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Vm(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Cl(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new vh(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new Bm().fromJSON(e);break;case"SkinnedMesh":u=o(e.geometry),h=l(e.material),a=new rm(u,h),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":u=o(e.geometry),h=l(e.material),a=new Ft(u,h);break;case"InstancedMesh":u=o(e.geometry),h=l(e.material);const d=e.count,p=e.instanceMatrix,m=e.instanceColor;a=new nm(u,h,d),a.instanceMatrix=new Nn(new Float32Array(p.array),16),m!==void 0&&(a.instanceColor=new Nn(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=o(e.geometry),h=l(e.material),a=new lm(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,h),a.geometry=u,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._visibility=e.visibility,a._active=e.active,a._bounds=e.bounds.map(v=>{const f=new Bi;f.min.fromArray(v.boxMin),f.max.fromArray(v.boxMax);const g=new Ai;return g.radius=v.sphereRadius,g.center.fromArray(v.sphereCenter),{boxInitialized:v.boxInitialized,box:f,sphereInitialized:v.sphereInitialized,sphere:g}}),a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._geometryCount=e.geometryCount,a._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":a=new em;break;case"Line":a=new Cn(o(e.geometry),l(e.material));break;case"LineLoop":a=new um(o(e.geometry),l(e.material));break;case"LineSegments":a=new $r(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new dm(o(e.geometry),l(e.material));break;case"Sprite":a=new Qp(l(e.material));break;case"Group":a=new Vs;break;case"Bone":a=new Wu;break;default:a=new _t}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const d=e.children;for(let p=0;p<d.length;p++)a.add(this.parseObject(d[p],t,i,r,s))}if(e.animations!==void 0){const d=e.animations;for(let p=0;p<d.length;p++){const m=d[p];a.animations.push(s[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const d=e.levels;for(let p=0;p<d.length;p++){const m=d[p],v=a.getObjectByProperty("uuid",m.object);v!==void 0&&a.addLevel(v,m.distance,m.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const i=t.target,r=e.getObjectByProperty("uuid",i);r!==void 0?t.target=r:t.target=new _t}})}}const VI={UVMapping:Pc,CubeReflectionMapping:mr,CubeRefractionMapping:Ar,EquirectangularReflectionMapping:kn,EquirectangularRefractionMapping:Hn,CubeUVReflectionMapping:xs},sx={RepeatWrapping:Gn,ClampToEdgeWrapping:fr,MirroredRepeatWrapping:va},ax={NearestFilter:$t,NearestMipmapNearestFilter:Dc,NearestMipmapLinearFilter:Mn,LinearFilter:Lt,LinearMipmapNearestFilter:Wn,LinearMipmapLinearFilter:ji};class ox extends Hi{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Rn.get(e);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{t&&t(c),s.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return Rn.add(e,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),Rn.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});Rn.add(e,l),s.manager.itemStart(e)}}let bh;class Th{static getContext(){return bh===void 0&&(bh=new(window.AudioContext||window.webkitAudioContext)),bh}static setContext(e){bh=e}}class lx extends Hi{constructor(e){super(e)}load(e,t,i,r){const s=this,a=new Kr(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0);Th.getContext().decodeAudioData(c,function(u){t(u)}).catch(o)}catch(c){o(c)}},i,r);function o(l){r?r(l):console.error(l),s.manager.itemError(e)}}}const cx=new Re,ux=new Re,js=new Re;class km{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new di,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new di,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,js.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,s=t.near*Math.tan(Es*t.fov*.5)/t.zoom;let a,o;ux.elements[12]=-i,cx.elements[12]=i,a=-s*t.aspect+r,o=s*t.aspect+r,js.elements[0]=2*t.near/(o-a),js.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(js),a=-s*t.aspect-r,o=s*t.aspect-r,js.elements[0]=2*t.near/(o-a),js.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(js)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(ux),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(cx)}}class Hm{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=hx(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=hx();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function hx(){return performance.now()}const cn=new N,dx=new qi,BI=new N,Xs=new N;let px=class extends _t{constructor(){super(),this.type="AudioListener",this.context=Th.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Hm}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(n){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=n,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(n){return this.gain.gain.setTargetAtTime(n,this.context.currentTime,.01),this}updateMatrixWorld(n){super.updateMatrixWorld(n);const e=this.context.listener,t=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(cn,dx,BI),!(!Number.isFinite(cn.x)||!Number.isFinite(cn.y)||!Number.isFinite(cn.z)))if(Xs.set(0,0,-1).applyQuaternion(dx),e.positionX){const i=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(cn.x,i),e.positionY.linearRampToValueAtTime(cn.y,i),e.positionZ.linearRampToValueAtTime(cn.z,i),e.forwardX.linearRampToValueAtTime(Xs.x,i),e.forwardY.linearRampToValueAtTime(Xs.y,i),e.forwardZ.linearRampToValueAtTime(Xs.z,i),e.upX.linearRampToValueAtTime(t.x,i),e.upY.linearRampToValueAtTime(t.y,i),e.upZ.linearRampToValueAtTime(t.z,i)}else e.setPosition(cn.x,cn.y,cn.z),e.setOrientation(Xs.x,Xs.y,Xs.z,t.x,t.y,t.z)}};class Gm extends _t{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||(this.buffer?this.buffer.duration:Number.MAX_VALUE))),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const qs=new N,mx=new qi,zI=new N,Ys=new N;class fx extends Gm{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(qs,mx,zI),Ys.set(0,0,1).applyQuaternion(mx);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(qs.x,i),t.positionY.linearRampToValueAtTime(qs.y,i),t.positionZ.linearRampToValueAtTime(qs.z,i),t.orientationX.linearRampToValueAtTime(Ys.x,i),t.orientationY.linearRampToValueAtTime(Ys.y,i),t.orientationZ.linearRampToValueAtTime(Ys.z,i)}else t.setPosition(qs.x,qs.y,qs.z),t.setOrientation(Ys.x,Ys.y,Ys.z)}}class kI{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}}class gx{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,r=this.valueSize,s=e*r+r;let a=this.cumulativeWeight;if(a===0){for(let o=0;o!==r;++o)i[s+o]=i[o];a=t}else{a+=t;const o=t/a;this._mixBufferRegion(i,s,0,o,r)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const l=t*this._origIndex;this._mixBufferRegion(i,r,l,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){o.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,a=r;s!==a;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){qi.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const a=this._workIndex*s;qi.multiplyQuaternionsFlat(e,a,e,t,e,i),qi.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){const a=1-r;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[i+o]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[i+a]*r}}}const Wm="\\[\\]\\.:\\/",HI=new RegExp("["+Wm+"]","g"),jm="[^"+Wm+"]",GI="[^"+Wm.replace("\\.","")+"]",WI=/((?:WC+[\/:])*)/.source.replace("WC",jm),jI=/(WCOD+)?/.source.replace("WCOD",GI),XI=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",jm),qI=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",jm),YI=new RegExp("^"+WI+jI+XI+qI+"$"),$I=["material","materials","bones","map"];class JI{constructor(e,t,i){const r=i||Tt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class Tt{constructor(e,t,i){this.path=t,this.parsedPath=i||Tt.parseTrackName(t),this.node=Tt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Tt.Composite(e,t,i):new Tt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(HI,"")}static parseTrackName(e){const t=YI.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=i.nodeName.substring(r+1);$I.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s,a){for(let o=0;o<s.length;o++){const l=s[o];if(!a&&(l.name===t||l.uuid===t)||a&&l.userData&&l.userData.name===t)return l;const c=i(l.children,a);if(c)return c}return null},r=i(e.children);if(r)return r;{const s=i(e.children,!0);if(s)return s}}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,r=t.propertyName;let s=t.propertyIndex;if(e||(e=Tt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let c=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[r];if(a===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Tt.Composite=JI,Tt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Tt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Tt.prototype.GetterByBindingType=[Tt.prototype._getValue_direct,Tt.prototype._getValue_array,Tt.prototype._getValue_arrayElement,Tt.prototype._getValue_toArray],Tt.prototype.SetterByBindingTypeAndVersioning=[[Tt.prototype._setValue_direct,Tt.prototype._setValue_direct_setNeedsUpdate,Tt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_array,Tt.prototype._setValue_array_setNeedsUpdate,Tt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_arrayElement,Tt.prototype._setValue_arrayElement_setNeedsUpdate,Tt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_fromArray,Tt.prototype._setValue_fromArray_setNeedsUpdate,Tt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class KI{constructor(){this.isAnimationObjectGroup=!0,this.uuid=vr(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length;let o,l=e.length,c=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){const d=arguments[u],p=d.uuid;let m=t[p];if(m===void 0){m=l++,t[p]=m,e.push(d);for(let v=0,f=a;v!==f;++v)s[v].push(new Tt(d,i[v],r[v]))}else if(m<c){o=e[m];const v=--c,f=e[v];t[f.uuid]=m,e[m]=f,t[p]=v,e[v]=d;for(let g=0,x=a;g!==x;++g){const y=s[g],_=y[v];let I=y[m];y[m]=_,I===void 0&&(I=new Tt(d,i[g],r[g])),y[v]=I}}else e[m]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_;for(let a=0,o=arguments.length;a!==o;++a){const l=arguments[a],c=l.uuid,u=t[c];if(u!==void 0&&u>=s){const h=s++,d=e[h];t[d.uuid]=u,e[u]=d,t[c]=h,e[h]=l;for(let p=0,m=r;p!==m;++p){const v=i[p],f=v[h],g=v[u];v[u]=f,v[h]=g}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],u=c.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<s){const d=--s,p=e[d],m=--a,v=e[m];t[p.uuid]=h,e[h]=p,t[v.uuid]=d,e[d]=v,e.pop();for(let f=0,g=r;f!==g;++f){const x=i[f],y=x[d],_=x[m];x[h]=y,x[d]=_,x.pop()}}else{const d=--a,p=e[d];d>0&&(t[p.uuid]=h),e[h]=p,e.pop();for(let m=0,v=r;m!==v;++m){const f=i[m];f[h]=f[d],f.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const s=this._bindings;if(r!==void 0)return s[r];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,h=new Array(c);r=s.length,i[e]=r,a.push(e),o.push(t),s.push(h);for(let d=u,p=l.length;d!==p;++d){const m=l[d];h[d]=new Tt(m,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=i,a[i]=l,a.pop(),s[i]=s[o],s.pop(),r[i]=r[o],r.pop()}}}class vx{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:bs,endingEnd:bs};for(let c=0;c!==a;++c){const u=s[c].createInterpolant(null);o[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=op,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const r=this._clip.duration,s=e._clip.duration,a=s/r,o=r/s;e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const r=this._mixer,s=r.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/a,c[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*i;l<0||i===0?t=0:(this._startTime=null,t=i*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case lp:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulateAdditive(o);break;case au:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulate(r,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,s=this._loopCount;const a=i===F0;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===ap){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const o=Math.floor(r/t);r-=t*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=Ts,r.endingEnd=Ts):(e?r.endingStart=this.zeroSlopeAtStart?Ts:bs:r.endingStart=$o,t?r.endingEnd=this.zeroSlopeAtEnd?Ts:bs:r.endingEnd=$o)}_scheduleFading(e,t,i){const r=this._mixer,s=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=i,this}}const ZI=new Float32Array(1);class yx extends gr{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,o=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){const d=r[h],p=d.name;let m=u[p];if(m!==void 0)++m.referenceCount,a[h]=m;else{if(m=a[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}const v=t&&t._propertyBindings[h].binding.parsedPath;m=new gx(Tt.create(i,p,v),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),a[h]=m}o[h].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){const r=this._actions,s=this._actionsByClip;let a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{const o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,a=this._actionsByClip,o=a[s],l=o.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;const h=o.actionByRoot,d=(e._localRoot||this._root).uuid;delete h[d],l.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){const r=this._bindingsByRootAndName,s=this._bindings;let a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,o=a[r],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[s],Object.keys(o).length===0&&delete a[r]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new Pm(new Float32Array(2),new Float32Array(2),1,ZI),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){const r=t||this._root,s=r.uuid;let a=typeof e=="string"?no.findByName(r,e):e;const o=a!==null?a.uuid:e,l=this._actionsByClip[o];let c=null;if(i===void 0&&(a!==null?i=a.blendMode:i=au),l!==void 0){const h=l.actionByRoot[s];if(h!==void 0&&h.blendMode===i)return h;c=l.knownActions[0],a===null&&(a=c._clip)}if(a===null)return null;const u=new vx(this,a,t,i);return this._bindAction(u,c),this._addInactiveAction(u,o,s),u}existingAction(e,t){const i=t||this._root,r=i.uuid,s=typeof e=="string"?no.findByName(i,e):e,a=s?s.uuid:e,o=this._actionsByClip[a];return o!==void 0&&o.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(r,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){const a=s.knownActions;for(let o=0,l=a.length;o!==l;++o){const c=a[o];this._deactivateAction(c);const u=c._cacheIndex,h=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(c)}delete r[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const a in i){const o=i[a].actionByRoot,l=o[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(const a in s){const o=s[a];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}let xx=class XS{constructor(e){this.value=e}clone(){return new XS(this.value.clone===void 0?this.value:this.value.clone())}},QI=0;class e2 extends gr{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:QI++}),this.name="",this.usage=wa,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){const s=Array.isArray(t[i])?t[i]:[t[i]];for(let a=0;a<s.length;a++)this.uniforms.push(s[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class Xm extends Xa{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class t2{constructor(e,t,i,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const _x=new Re;class Mx{constructor(e,t,i=0,r=1/0){this.ray=new Cs(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new al,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return _x.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(_x),this}intersectObject(e,t=!0,i=[]){return qm(e,this,i,t),i.sort(bx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)qm(e[r],this,i,t);return i.sort(bx),i}}function bx(n,e){return n.distance-e.distance}function qm(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const s=n.children;for(let a=0,o=s.length;a<o;a++)qm(s[a],e,t,!0)}}class Tx{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Jt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class i2{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}}class s0{constructor(e,t,i,r){s0.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=i,s[3]=r,this}}const Sx=new J;class r2{constructor(e=new J(1/0,1/0),t=new J(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Sx.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Sx).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const wx=new N,Sh=new N;class Ex{constructor(e=new N,t=new N){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){wx.subVectors(e,this.start),Sh.subVectors(this.end,this.start);const i=Sh.dot(Sh);let r=Sh.dot(wx)/i;return t&&(r=Jt(r,0,1)),r}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Ax=new N;class n2 extends _t{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new ct,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a<l;a++,o++){const c=a/l*Math.PI*2,u=o/l*Math.PI*2;r.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new De(r,3));const s=new Ni({fog:!1,toneMapped:!1});this.cone=new $r(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Ax.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Ax),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const ss=new N,wh=new Re,Ym=new Re;class s2 extends $r{constructor(e){const t=Nx(e),i=new ct,r=[],s=[],a=new xe(0,0,1),o=new xe(0,1,0);for(let c=0;c<t.length;c++){const u=t[c];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(a.r,a.g,a.b),s.push(o.r,o.g,o.b))}i.setAttribute("position",new De(r,3)),i.setAttribute("color",new De(s,3));const l=new Ni({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,i=this.geometry,r=i.getAttribute("position");Ym.copy(this.root.matrixWorld).invert();for(let s=0,a=0;s<t.length;s++){const o=t[s];o.parent&&o.parent.isBone&&(wh.multiplyMatrices(Ym,o.matrixWorld),ss.setFromMatrixPosition(wh),r.setXYZ(a,ss.x,ss.y,ss.z),wh.multiplyMatrices(Ym,o.parent.matrixWorld),ss.setFromMatrixPosition(wh),r.setXYZ(a+1,ss.x,ss.y,ss.z),a+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function Nx(n){const e=[];n.isBone===!0&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,Nx(n.children[t]));return e}class a2 extends Ft{constructor(e,t,i){const r=new Ao(t,4,2),s=new Yr({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const o2=new N,Cx=new xe,Rx=new xe;class l2 extends _t{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const r=new Eo(t);r.rotateY(Math.PI*.5),this.material=new Yr({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=r.getAttribute("position"),a=new Float32Array(s.count*3);r.setAttribute("color",new wt(a,3)),this.add(new Ft(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Cx.copy(this.light.color),Rx.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){const s=i<r/2?Cx:Rx;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(o2.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Ix=class extends $r{constructor(n=10,e=10,t=4473924,i=8947848){t=new xe(t),i=new xe(i);const r=e/2,s=n/e,a=n/2,o=[],l=[];for(let h=0,d=0,p=-a;h<=e;h++,p+=s){o.push(-a,0,p,a,0,p),o.push(p,0,-a,p,0,a);const m=h===r?t:i;m.toArray(l,d),d+=3,m.toArray(l,d),d+=3,m.toArray(l,d),d+=3,m.toArray(l,d),d+=3}const c=new ct;c.setAttribute("position",new De(o,3)),c.setAttribute("color",new De(l,3));const u=new Ni({vertexColors:!0,toneMapped:!1});super(c,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};class c2 extends $r{constructor(e=10,t=16,i=8,r=64,s=4473924,a=8947848){s=new xe(s),a=new xe(a);const o=[],l=[];if(t>1)for(let h=0;h<t;h++){const d=h/t*(Math.PI*2),p=Math.sin(d)*e,m=Math.cos(d)*e;o.push(0,0,0),o.push(p,0,m);const v=h&1?s:a;l.push(v.r,v.g,v.b),l.push(v.r,v.g,v.b)}for(let h=0;h<i;h++){const d=h&1?s:a,p=e-e/i*h;for(let m=0;m<r;m++){let v=m/r*(Math.PI*2),f=Math.sin(v)*p,g=Math.cos(v)*p;o.push(f,0,g),l.push(d.r,d.g,d.b),v=(m+1)/r*(Math.PI*2),f=Math.sin(v)*p,g=Math.cos(v)*p,o.push(f,0,g),l.push(d.r,d.g,d.b)}}const c=new ct;c.setAttribute("position",new De(o,3)),c.setAttribute("color",new De(l,3));const u=new Ni({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Lx=new N,Eh=new N,Px=new N;class Dx extends _t{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new ct;r.setAttribute("position",new De([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new Ni({fog:!1,toneMapped:!1});this.lightPlane=new Cn(r,s),this.add(this.lightPlane),r=new ct,r.setAttribute("position",new De([0,0,0,0,0,1],3)),this.targetLine=new Cn(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Lx.setFromMatrixPosition(this.light.matrixWorld),Eh.setFromMatrixPosition(this.light.target.matrixWorld),Px.subVectors(Eh,Lx),this.lightPlane.lookAt(Eh),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Eh),this.targetLine.scale.z=Px.length()}}const Ah=new N,Kt=new ul;class Ux extends $r{constructor(e){const t=new ct,i=new Ni({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4");function o(m,v){l(m),l(v)}function l(m){r.push(0,0,0),s.push(0,0,0),a[m]===void 0&&(a[m]=[]),a[m].push(r.length/3-1)}t.setAttribute("position",new De(r,3)),t.setAttribute("color",new De(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const c=new xe(16755200),u=new xe(16711680),h=new xe(43775),d=new xe(16777215),p=new xe(3355443);this.setColors(c,u,h,d,p)}setColors(e,t,i,r,s){const a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,i=1,r=1;Kt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),ti("c",t,e,Kt,0,0,-1),ti("t",t,e,Kt,0,0,1),ti("n1",t,e,Kt,-1,-1,-1),ti("n2",t,e,Kt,i,-1,-1),ti("n3",t,e,Kt,-1,r,-1),ti("n4",t,e,Kt,i,r,-1),ti("f1",t,e,Kt,-1,-1,1),ti("f2",t,e,Kt,i,-1,1),ti("f3",t,e,Kt,-1,r,1),ti("f4",t,e,Kt,i,r,1),ti("u1",t,e,Kt,i*.7,r*1.1,-1),ti("u2",t,e,Kt,-1*.7,r*1.1,-1),ti("u3",t,e,Kt,0,r*2,-1),ti("cf1",t,e,Kt,-1,0,1),ti("cf2",t,e,Kt,i,0,1),ti("cf3",t,e,Kt,0,-1,1),ti("cf4",t,e,Kt,0,r,1),ti("cn1",t,e,Kt,-1,0,-1),ti("cn2",t,e,Kt,i,0,-1),ti("cn3",t,e,Kt,0,-1,-1),ti("cn4",t,e,Kt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function ti(n,e,t,i,r,s,a){Ah.set(r,s,a).unproject(i);const o=e[n];if(o!==void 0){const l=t.getAttribute("position");for(let c=0,u=o.length;c<u;c++)l.setXYZ(o[c],Ah.x,Ah.y,Ah.z)}}const Nh=new Bi;class Ox extends $r{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(8*3),s=new ct;s.setIndex(new wt(i,1)),s.setAttribute("position",new wt(r,3)),super(s,new Ni({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Nh.setFromObject(this.object),Nh.isEmpty())return;const t=Nh.min,i=Nh.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Fx extends $r{constructor(e,t=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new ct;s.setIndex(new wt(i,1)),s.setAttribute("position",new De(r,3)),super(s,new Ni({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class u2 extends Cn{constructor(e,t=1,i=16776960){const r=i,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new ct;a.setAttribute("position",new De(s,3)),a.computeBoundingSphere(),super(a,new Ni({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const o=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new ct;l.setAttribute("position",new De(o,3)),l.computeBoundingSphere(),this.add(new Ft(l,new Yr({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Vx=new N;let Ch,$m;class h2 extends _t{constructor(e=new N(0,0,1),t=new N(0,0,0),i=1,r=16776960,s=i*.2,a=s*.2){super(),this.type="ArrowHelper",Ch===void 0&&(Ch=new ct,Ch.setAttribute("position",new De([0,0,0,0,1,0],3)),$m=new ma(0,.5,1,5,1),$m.translate(0,-.5,0)),this.position.copy(t),this.line=new Cn(Ch,new Ni({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ft($m,new Yr({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Vx.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Vx,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}let Bx=class extends $r{constructor(n=1){const e=[0,0,0,n,0,0,0,0,0,0,n,0,0,0,0,0,0,n],t=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new ct;i.setAttribute("position",new De(e,3)),i.setAttribute("color",new De(t,3));const r=new Ni({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(n,e,t){const i=new xe,r=this.geometry.attributes.color.array;return i.set(n),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(t),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};class zx{constructor(){this.type="ShapePath",this.color=new xe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Tl,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,a){return this.currentPath.bezierCurveTo(e,t,i,r,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const x=[];for(let y=0,_=g.length;y<_;y++){const I=g[y],b=new rs;b.curves=I.curves,x.push(b)}return x}function i(g,x){const y=x.length;let _=!1;for(let I=y-1,b=0;b<y;I=b++){let w=x[I],C=x[b],H=C.x-w.x,M=C.y-w.y;if(Math.abs(M)>Number.EPSILON){if(M<0&&(w=x[b],H=-H,C=x[I],M=-M),g.y<w.y||g.y>C.y)continue;if(g.y===w.y){if(g.x===w.x)return!0}else{const T=M*(g.x-w.x)-H*(g.y-w.y);if(T===0)return!0;if(T<0)continue;_=!_}}else{if(g.y!==w.y)continue;if(C.x<=g.x&&g.x<=w.x||w.x<=g.x&&g.x<=C.x)return!0}}return _}const r=nn.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new rs,l.curves=o.curves,c.push(l),c;let u=!r(s[0].getPoints());u=e?!u:u;const h=[],d=[];let p=[],m=0,v;d[m]=void 0,p[m]=[];for(let g=0,x=s.length;g<x;g++)o=s[g],v=o.getPoints(),a=r(v),a=e?!a:a,a?(!u&&d[m]&&m++,d[m]={s:new rs,p:v},d[m].s.curves=o.curves,u&&m++,p[m]=[]):p[m].push({h:o,p:v[0]});if(!d[0])return t(s);if(d.length>1){let g=!1,x=0;for(let y=0,_=d.length;y<_;y++)h[y]=[];for(let y=0,_=d.length;y<_;y++){const I=p[y];for(let b=0;b<I.length;b++){const w=I[b];let C=!0;for(let H=0;H<d.length;H++)i(w.p,d[H].p)&&(y!==H&&x++,C?(C=!1,h[H].push(w)):g=!0);C&&h[y].push(w)}}x>0&&g===!1&&(p=h)}let f;for(let g=0,x=d.length;g<x;g++){l=d[g].s,c.push(l),f=p[g];for(let y=0,_=f.length;y<_;y++)l.holes.push(f[y].h)}return c}}class kx extends gr{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}class d2 extends Ir{constructor(e=1,t=1,i=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:i}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}const p2=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveMap","envMap","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class Hx{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=p2,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}getRenderObjectData(e){let t=this.renderObjects.get(e);return t===void 0&&(t={material:this.getMaterialData(e.material),worldMatrix:e.object.matrixWorld.clone()},e.object.center&&(t.center=e.object.center.clone()),e.object.morphTargetInfluences&&(t.morphTargetInfluences=e.object.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),this.renderObjects.set(e,t)),t}containsNode(e){const t=e.material;for(const i in t)if(t[i]&&t[i].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const i of this.refreshUniforms){const r=e[i];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[i]={id:r.id,version:r.version}:t[i]=r.clone():t[i]=r)}return t}equals(e){const{object:t,material:i}=e,r=this.getRenderObjectData(e);if(r.worldMatrix.equals(t.matrixWorld)!==!0)return r.worldMatrix.copy(t.matrixWorld),!1;const s=r.material;for(const a in s){const o=s[a],l=i[a];if(o.equals!==void 0){if(o.equals(l)===!1)return o.copy(l),!1}else if(l.isTexture===!0){if(o.id!==l.id||o.version!==l.version)return o.id=l.id,o.version=l.version,!1}else if(o!==l)return s[a]=l,!1}if(r.morphTargetInfluences){let a=!1;for(let o=0;o<r.morphTargetInfluences.length;o++)r.morphTargetInfluences[o]!==t.morphTargetInfluences[o]&&(a=!0);if(a)return!0}return r.center&&r.center.equals(t.center)===!1?(r.center.copy(t.center),!0):(e.bundle!==null&&(r.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e))return!0;const{renderId:i}=t;if(this.renderId!==i)return this.renderId=i,!0;const r=e.object.static===!0,s=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;return r||s?!1:this.equals(e)!==!0}}function Il(n,e=0){let t=3735928559^e,i=1103547991^e;if(n instanceof Array)for(let r=0,s;r<n.length;r++)s=n[r],t=Math.imul(t^s,2654435761),i=Math.imul(i^s,1597334677);else for(let r=0,s;r<n.length;r++)s=n.charCodeAt(r),t=Math.imul(t^s,2654435761),i=Math.imul(i^s,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&i)+(t>>>0)}const Gx=n=>Il(n),Wx=n=>Il(n),Jm=(...n)=>Il(n);function Km(n,e=!1){const t=[];n.isNode===!0&&(t.push(n.id),n=n.getSelf());for(const{property:i,childNode:r}of Ll(n))t.push(t,Il(i.slice(0,-4)),r.getCacheKey(e));return Il(t)}function*Ll(n,e=!1){for(const t in n){if(t.startsWith("_")===!0)continue;const i=n[t];if(Array.isArray(i)===!0)for(let r=0;r<i.length;r++){const s=i[r];s&&(s.isNode===!0||e&&typeof s.toJSON=="function")&&(yield{property:t,index:r,childNode:s})}else if(i&&i.isNode===!0)yield{property:t,childNode:i};else if(typeof i=="object")for(const r in i){const s=i[r];s&&(s.isNode===!0||e&&typeof s.toJSON=="function")&&(yield{property:t,index:r,childNode:s})}}}function Ln(n){if(n==null)return null;const e=typeof n;return n.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":n.isVector2===!0?"vec2":n.isVector3===!0?"vec3":n.isVector4===!0?"vec4":n.isMatrix3===!0?"mat3":n.isMatrix4===!0?"mat4":n.isColor===!0?"color":n instanceof ArrayBuffer?"ArrayBuffer":null}function Zm(n,...e){const t=n?n.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),n==="color"?new xe(...e):t==="vec2"?new J(...e):t==="vec3"?new N(...e):t==="vec4"?new st(...e):t==="mat3"?new Ke(...e):t==="mat4"?new Re(...e):n==="bool"?e[0]||!1:n==="float"||n==="int"||n==="uint"?e[0]||0:n==="string"?e[0]||"":n==="ArrayBuffer"?ef(e[0]):null}function Qm(n){let e="";const t=new Uint8Array(n);for(let i=0;i<t.length;i++)e+=String.fromCharCode(t[i]);return btoa(e)}function ef(n){return Uint8Array.from(atob(n),e=>e.charCodeAt(0)).buffer}var m2=Object.freeze({__proto__:null,arrayBufferToBase64:Qm,base64ToArrayBuffer:ef,getCacheKey:Km,getNodeChildren:Ll,getValueFromType:Zm,getValueType:Ln,hash:Jm,hashArray:Wx,hashString:Gx});const tf={VERTEX:"vertex",FRAGMENT:"fragment"},je={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},f2={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},jx=["fragment","vertex"],rf=["setup","analyze","generate"],nf=[...jx,"compute"],so=["x","y","z","w"];let g2=0;class qe extends gr{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=je.NONE,this.updateBeforeType=je.NONE,this.updateAfterType=je.NONE,this.uuid=cu.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:g2++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,je.FRAME)}onRenderUpdate(e){return this.onUpdate(e,je.RENDER)}onObjectUpdate(e){return this.onUpdate(e,je.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Ll(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=Km(this,e),this._cacheKeyVersion=this.version),this._cacheKey}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let i=0;for(const r of this.getChildren())t["node"+i++]=r;return null}analyze(e){if(e.increaseUsage(this)===1){const t=e.getNodeProperties(this);for(const i of Object.values(t))i&&i.isNode===!0&&i.build(e)}}generate(e,t){const{outputNode:i}=e.getNodeProperties(this);if(i&&i.isNode===!0)return i.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const i=this.getShared(e);if(this!==i)return i.build(e,t);e.addNode(this),e.addChain(this);let r=null;const s=e.getBuildStage();if(s==="setup"){this.updateReference(e);const a=e.getNodeProperties(this);if(a.initialized!==!0){const o=e.stack.nodes.length;a.initialized=!0,a.outputNode=this.setup(e),a.outputNode!==null&&e.stack.nodes.length;for(const l of Object.values(a))l&&l.isNode===!0&&l.build(e)}}else if(s==="analyze")this.analyze(e);else if(s==="generate")if(this.generate.length===1){const a=this.getNodeType(e),o=e.getDataFromNode(this);r=o.snippet,r===void 0?(r=this.generate(e)||"",o.snippet=r):o.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,a,t)}else r=this.generate(e,t)||"";return e.removeChain(this),r}getSerializeChildren(){return Ll(this)}serialize(e){const t=this.getSerializeChildren(),i={};for(const{property:r,index:s,childNode:a}of t)s!==void 0?(i[r]===void 0&&(i[r]=Number.isInteger(s)?[]:{}),i[r][s]=a.toJSON(e.meta).uuid):i[r]=a.toJSON(e.meta).uuid;Object.keys(i).length>0&&(e.inputNodes=i)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const i in e.inputNodes)if(Array.isArray(e.inputNodes[i])){const r=[];for(const s of e.inputNodes[i])r.push(t[s]);this[i]=r}else if(typeof e.inputNodes[i]=="object"){const r={};for(const s in e.inputNodes[i]){const a=e.inputNodes[i][s];r[s]=t[a]}this[i]=r}else{const r=e.inputNodes[i];this[i]=t[r]}}}toJSON(e){const{uuid:t,type:i}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];s===void 0&&(s={uuid:t,type:i,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}if(r){const o=a(e.textures),l=a(e.images),c=a(e.nodes);o.length>0&&(s.textures=o),l.length>0&&(s.images=l),c.length>0&&(s.nodes=c)}return s}}class as extends qe{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.node.build(e),i=this.indexNode.build(e,"uint");return`${t}[ ${i} ]`}}class sf extends qe{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let i=null;for(const r of this.convertTo.split("|"))(i===null||e.getTypeLength(t)===e.getTypeLength(r))&&(i=r);return i}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const i=this.node,r=this.getNodeType(e),s=i.build(e,r);return e.format(s,r,t)}}class pt extends qe{static get type(){return"TempNode"}constructor(e){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const i=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,i,t);if(i!=="void"&&t!=="void"&&this.hasDependencies(e)){const s=super.build(e,i),a=e.getVarFromNode(this,null,i),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${s}`,this),r.snippet=s,r.propertyName=o,e.format(r.propertyName,i,t)}}return super.build(e,t)}}class Xx extends pt{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,i)=>t+e.getTypeLength(i.getNodeType(e)),0))}generate(e,t){const i=this.getNodeType(e),r=this.nodes,s=e.getComponentType(i),a=[];for(const l of r){let c=l.build(e);const u=e.getComponentType(l.getNodeType(e));u!==s&&(c=e.format(c,u,s)),a.push(c)}const o=`${e.getType(i)}( ${a.join(", ")} )`;return e.format(o,i,t)}}const v2=so.join("");class Rh extends qe{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(so.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const i=this.node,r=e.getTypeLength(i.getNodeType(e));let s=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const o=i.build(e,a);this.components.length===r&&this.components===v2.slice(0,this.components.length)?s=e.format(o,a,t):s=e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else s=i.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class qx extends pt{static get type(){return"SetNode"}constructor(e,t,i){super(),this.sourceNode=e,this.components=t,this.targetNode=i}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:i,targetNode:r}=this,s=this.getNodeType(e),a=e.getTypeFromLength(i.length,r.getNodeType(e)),o=r.build(e,a),l=t.build(e,s),c=e.getTypeLength(s),u=[];for(let h=0;h<c;h++){const d=so[h];d===i[0]?(u.push(o),h+=i.length-1):u.push(l+"."+d)}return`${e.getType(s)}( ${u.join(", ")} )`}}class y2 extends pt{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:i}=this,r=this.getNodeType(e),s=i.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+" = "+s,this);const l=e.getTypeLength(r),c=[];let u=0;for(let h=0;h<l;h++){const d=so[h];d===t[u]?(c.push("1.0 - "+(o+"."+d)),u++):c.push(o+"."+d)}return`${e.getType(r)}( ${c.join(", ")} )`}}class af extends qe{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Ln(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Ln(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=Qm(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Zm(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}class Fr extends af{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const i=this.getNodeType(e);return e.format(this.generateConst(e),i,t)}}let ao=null;const oo=new Map;function te(n,e){if(oo.has(n)){console.warn(`Redefinition of method chaining ${n}`);return}if(typeof e!="function")throw new Error(`Node element ${n} is not a function`);oo.set(n,e)}const Yx=n=>n.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),$x=n=>Yx(n).split("").sort().join(""),Jx={setup(n,e){const t=e.shift();return n(Ul(t),...e)},get(n,e,t){if(typeof e=="string"&&n[e]===void 0){if(n.isStackNode!==!0&&e==="assign")return(...i)=>(ao.assign(t,...i),t);if(oo.has(e)){const i=oo.get(e);return n.isStackNode?(...r)=>t.add(i(...r)):(...r)=>i(t,...r)}else{if(e==="self")return n;if(e.endsWith("Assign")&&oo.has(e.slice(0,e.length-6))){const i=oo.get(e.slice(0,e.length-6));return n.isStackNode?(...r)=>t.assign(r[0],i(...r)):(...r)=>t.assign(i(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=Yx(e),G(new Rh(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=$x(e.slice(3).toLowerCase()),i=>G(new qx(n,e,i));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=$x(e.slice(4).toLowerCase()),()=>G(new y2(G(n),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),G(new Rh(n,e));if(/^\d+$/.test(e)===!0)return G(new as(t,new Fr(Number(e),"uint")))}}}return Reflect.get(n,e,t)},set(n,e,t,i){return typeof e=="string"&&n[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(i[e].assign(t),!0):Reflect.set(n,e,t,i)}},of=new WeakMap,Kx=new WeakMap,x2=function(n,e=null){const t=Ln(n);if(t==="node"){let i=of.get(n);return i===void 0&&(i=new Proxy(n,Jx),of.set(n,i),of.set(i,i)),i}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return G(hf(n,e));if(t==="shader")return U(n)}return n},_2=function(n,e=null){for(const t in n)n[t]=G(n[t],e);return n},M2=function(n,e=null){const t=n.length;for(let i=0;i<t;i++)n[i]=G(n[i],e);return n},b2=function(n,e=null,t=null,i=null){const r=s=>G(i!==null?Object.assign(s,i):s);return e===null?(...s)=>r(new n(...$s(s))):t!==null?(t=G(t),(...s)=>r(new n(e,...$s(s),t))):(...s)=>r(new n(e,...$s(s)))},T2=function(n,...e){return G(new n(...$s(e)))};class S2 extends qe{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:i}=this,r=e.getNodeProperties(t);if(r.onceOutput)return r.onceOutput;let s=null;if(t.layout){let a=Kx.get(e.constructor);a===void 0&&(a=new WeakMap,Kx.set(e.constructor,a));let o=a.get(t);o===void 0&&(o=G(e.buildFunctionNode(t)),a.set(t,o)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(o),s=G(o.call(i))}else{const a=t.jsFunc,o=i!==null?a(i,e):a(e);s=G(o)}return t.once&&(r.onceOutput=s),s}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class w2 extends qe{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Ul(e),G(new S2(this,e))}setup(){return this.call()}}const E2=[!1,!0],A2=[0,1,2,3],N2=[-1,-2],Zx=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],lf=new Map;for(const n of E2)lf.set(n,new Fr(n));const cf=new Map;for(const n of A2)cf.set(n,new Fr(n,"uint"));const uf=new Map([...cf].map(n=>new Fr(n.value,"int")));for(const n of N2)uf.set(n,new Fr(n,"int"));const Ih=new Map([...uf].map(n=>new Fr(n.value)));for(const n of Zx)Ih.set(n,new Fr(n));for(const n of Zx)Ih.set(-n,new Fr(-n));const Lh={bool:lf,uint:cf,ints:uf,float:Ih},Qx=new Map([...lf,...Ih]),hf=(n,e)=>Qx.has(n)?Qx.get(n):n.isNode===!0?n:new Fr(n,e),C2=n=>{try{return n.getNodeType()}catch{return}},oi=function(n,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(n)&&t.every(r=>typeof r!="object"))&&(t=[Zm(n,...t)]),t.length===1&&e!==null&&e.has(t[0]))return G(e.get(t[0]));if(t.length===1){const r=hf(t[0],n);return C2(r)===n?G(r):G(new sf(r,n))}const i=t.map(r=>hf(r));return G(new Xx(i,n))}},Pl=n=>typeof n=="object"&&n!==null?n.value:n,e_=n=>n!=null?n.nodeType||n.convertTo||(typeof n=="string"?n:null):null;function Dl(n,e){return new Proxy(new w2(n,e),Jx)}const G=(n,e=null)=>x2(n,e),Ul=(n,e=null)=>new _2(n,e),$s=(n,e=null)=>new M2(n,e),K=(...n)=>new b2(...n),ge=(...n)=>new T2(...n),U=(n,e)=>{const t=new Dl(n,e),i=(...r)=>{let s;return Ul(r),r[0]&&r[0].isNode?s=[...r]:s=r[0],t.call(s)};return i.shaderNode=t,i.setLayout=r=>(t.setLayout(r),i),i.once=()=>(t.once=!0,i),i},R2=(...n)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),U(...n));te("toGlobal",n=>(n.global=!0,n));const Ol=n=>{ao=n},df=()=>ao,Le=(...n)=>ao.If(...n);function t_(n){return ao&&ao.add(n),n}te("append",t_);const i_=new oi("color"),E=new oi("float",Lh.float),P=new oi("int",Lh.ints),_e=new oi("uint",Lh.uint),os=new oi("bool",Lh.bool),z=new oi("vec2"),un=new oi("ivec2"),r_=new oi("uvec2"),n_=new oi("bvec2"),D=new oi("vec3"),s_=new oi("ivec3"),lo=new oi("uvec3"),pf=new oi("bvec3"),ae=new oi("vec4"),a_=new oi("ivec4"),o_=new oi("uvec4"),l_=new oi("bvec4"),Fl=new oi("mat2"),yi=new oi("mat3"),Js=new oi("mat4"),I2=(n="")=>G(new Fr(n,"string")),L2=n=>G(new Fr(n,"ArrayBuffer"));te("toColor",i_),te("toFloat",E),te("toInt",P),te("toUint",_e),te("toBool",os),te("toVec2",z),te("toIVec2",un),te("toUVec2",r_),te("toBVec2",n_),te("toVec3",D),te("toIVec3",s_),te("toUVec3",lo),te("toBVec3",pf),te("toVec4",ae),te("toIVec4",a_),te("toUVec4",o_),te("toBVec4",l_),te("toMat2",Fl),te("toMat3",yi),te("toMat4",Js);const c_=K(as),u_=(n,e)=>G(new sf(G(n),e)),P2=(n,e)=>G(new Rh(G(n),e));te("element",c_),te("convert",u_);class mf extends qe{static get type(){return"UniformGroupNode"}constructor(e,t=!1,i=1){super("string"),this.name=e,this.version=0,this.shared=t,this.order=i,this.isUniformGroup=!0}set needsUpdate(e){e===!0&&this.version++}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const h_=n=>new mf(n),ff=(n,e=0)=>new mf(n,!0,e),D2=ff("frame"),xt=ff("render"),d_=h_("object");class Ks extends af{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=d_}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const i=this.getSelf();return e=e.bind(i),super.onUpdate(r=>{const s=e(r,i);s!==void 0&&(this.value=s)},t)}generate(e,t){const i=this.getNodeType(e),r=this.getUniformHash(e);let s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);const a=s.getInputType(e),o=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.label),l=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(l,i,t)}}const fe=(n,e)=>{const t=e_(e||n),i=n&&n.isNode===!0?n.node&&n.node.value||n.value:n;return G(new Ks(i,t))};class Et extends qe{static get type(){return"PropertyNode"}constructor(e,t=null,i=!1){super(e),this.name=t,this.varying=i,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const ar=(n,e)=>G(new Et(n,e)),Zr=(n,e)=>G(new Et(n,e,!0)),Nt=ge(Et,"vec4","DiffuseColor"),gf=ge(Et,"vec3","EmissiveColor"),hn=ge(Et,"float","Roughness"),Vl=ge(Et,"float","Metalness"),Ph=ge(Et,"float","Clearcoat"),Bl=ge(Et,"float","ClearcoatRoughness"),Zs=ge(Et,"vec3","Sheen"),Dh=ge(Et,"float","SheenRoughness"),Uh=ge(Et,"float","Iridescence"),vf=ge(Et,"float","IridescenceIOR"),yf=ge(Et,"float","IridescenceThickness"),Oh=ge(Et,"float","AlphaT"),ls=ge(Et,"float","Anisotropy"),zl=ge(Et,"vec3","AnisotropyT"),Qs=ge(Et,"vec3","AnisotropyB"),or=ge(Et,"color","SpecularColor"),kl=ge(Et,"float","SpecularF90"),Fh=ge(Et,"float","Shininess"),xf=ge(Et,"vec4","Output"),ea=ge(Et,"float","dashSize"),Hl=ge(Et,"float","gapSize"),U2=ge(Et,"float","pointWidth"),Gl=ge(Et,"float","IOR"),Vh=ge(Et,"float","Transmission"),_f=ge(Et,"float","Thickness"),Mf=ge(Et,"float","AttenuationDistance"),bf=ge(Et,"color","AttenuationColor"),Tf=ge(Et,"float","Dispersion");class p_ extends pt{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const i=e.getTypeLength(t.node.getNodeType(e));return so.join("").slice(0,i)!==t.components}return!1}generate(e,t){const{targetNode:i,sourceNode:r}=this,s=this.needsSplitAssign(e),a=i.getNodeType(e),o=i.context({assign:!0}).build(e),l=r.build(e,a),c=r.getNodeType(e),u=e.getDataFromNode(this);let h;if(u.initialized===!0)t!=="void"&&(h=o);else if(s){const d=e.getVarFromNode(this,null,a),p=e.getPropertyName(d);e.addLineFlowCode(`${p} = ${l}`,this);const m=i.node.context({assign:!0}).build(e);for(let v=0;v<i.components.length;v++){const f=i.components[v];e.addLineFlowCode(`${m}.${f} = ${p}[ ${v} ]`,this)}t!=="void"&&(h=o)}else h=`${o} = ${l}`,(t==="void"||c==="void")&&(e.addLineFlowCode(h,this),t!=="void"&&(h=o));return u.initialized=!0,e.format(h,a,t)}}const m_=K(p_);te("assign",m_);class f_ extends pt{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){const t=[],i=this.functionNode,r=i.getInputs(e),s=this.parameters;if(Array.isArray(s))for(let a=0;a<s.length;a++){const o=r[a],l=s[a];t.push(l.build(e,o.type))}else for(const a of r){const o=s[a.name];if(o!==void 0)t.push(o.build(e,a.type));else throw new Error(`FunctionCallNode: Input '${a.name}' not found in FunctionNode.`)}return`${i.build(e,"property")}( ${t.join(", ")} )`}}const g_=(n,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?$s(e):Ul(e[0]),G(new f_(G(n),e)));te("call",g_);class Gt extends pt{static get type(){return"OperatorNode"}constructor(e,t,i,...r){if(super(),r.length>0){let s=new Gt(e,t,i);for(let a=0;a<r.length-1;a++)s=new Gt(e,s,r[a]);t=s,i=r[r.length-1]}this.op=e,this.aNode=t,this.bNode=i}getNodeType(e,t){const i=this.op,r=this.aNode,s=this.bNode,a=r.getNodeType(e),o=typeof s<"u"?s.getNodeType(e):null;if(a==="void"||o==="void")return"void";if(i==="%")return a;if(i==="~"||i==="&"||i==="|"||i==="^"||i===">>"||i==="<<")return e.getIntegerType(a);if(i==="!"||i==="=="||i==="&&"||i==="||"||i==="^^")return"bool";if(i==="<"||i===">"||i==="<="||i===">="){const l=t?e.getTypeLength(t):Math.max(e.getTypeLength(a),e.getTypeLength(o));return l>1?`bvec${l}`:"bool"}else return a==="float"&&e.isMatrix(o)?o:e.isMatrix(a)&&e.isVector(o)?e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(o)?e.getVectorFromMatrix(o):e.getTypeLength(o)>e.getTypeLength(a)?o:a}generate(e,t){const i=this.op,r=this.aNode,s=this.bNode,a=this.getNodeType(e,t);let o=null,l=null;a!=="void"?(o=r.getNodeType(e),l=typeof s<"u"?s.getNodeType(e):null,i==="<"||i===">"||i==="<="||i===">="||i==="=="?e.isVector(o)?l=o:o!==l&&(o=l="float"):i===">>"||i==="<<"?(o=a,l=e.changeComponentType(l,"uint")):e.isMatrix(o)&&e.isVector(l)?l=e.getVectorFromMatrix(o):e.isVector(o)&&e.isMatrix(l)?o=e.getVectorFromMatrix(l):o=l=a):o=l=a;const c=r.build(e,o),u=typeof s<"u"?s.build(e,l):null,h=e.getTypeLength(t),d=e.getFunctionOperator(i);if(t!=="void")return i==="<"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} < ${u} )`,a,t):i==="<="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} <= ${u} )`,a,t):i===">"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} > ${u} )`,a,t):i===">="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} >= ${u} )`,a,t):i==="!"||i==="~"?e.format(`(${i}${c})`,o,t):d?e.format(`${d}( ${c}, ${u} )`,a,t):e.format(`( ${c} ${i} ${u} )`,a,t);if(o!=="void")return d?e.format(`${d}( ${c}, ${u} )`,a,t):e.format(`${c} ${i} ${u}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const zt=K(Gt,"+"),Pt=K(Gt,"-"),lt=K(Gt,"*"),Qr=K(Gt,"/"),Sf=K(Gt,"%"),v_=K(Gt,"=="),y_=K(Gt,"!="),x_=K(Gt,"<"),wf=K(Gt,">"),__=K(Gt,"<="),M_=K(Gt,">="),b_=K(Gt,"&&"),T_=K(Gt,"||"),S_=K(Gt,"!"),w_=K(Gt,"^^"),E_=K(Gt,"&"),A_=K(Gt,"~"),N_=K(Gt,"|"),C_=K(Gt,"^"),R_=K(Gt,"<<"),I_=K(Gt,">>");te("add",zt),te("sub",Pt),te("mul",lt),te("div",Qr),te("modInt",Sf),te("equal",v_),te("notEqual",y_),te("lessThan",x_),te("greaterThan",wf),te("lessThanEqual",__),te("greaterThanEqual",M_),te("and",b_),te("or",T_),te("not",S_),te("xor",w_),te("bitAnd",E_),te("bitNot",A_),te("bitOr",N_),te("bitXor",C_),te("shiftLeft",R_),te("shiftRight",I_);const L_=(...n)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),Sf(...n));te("remainder",L_);class V extends pt{static get type(){return"MathNode"}constructor(e,t,i=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=i,this.cNode=r}getInputType(e){const t=this.aNode.getNodeType(e),i=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(i)?0:e.getTypeLength(i),o=e.isMatrix(r)?0:e.getTypeLength(r);return s>a&&s>o?t:a>o?i:o>s?r:t}getNodeType(e){const t=this.method;return t===V.LENGTH||t===V.DISTANCE||t===V.DOT?"float":t===V.CROSS?"vec3":t===V.ALL?"bool":t===V.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===V.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){const i=this.method,r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,o=this.bNode,l=this.cNode,c=e.renderer.isWebGLRenderer===!0;if(i===V.TRANSFORM_DIRECTION){let u=a,h=o;e.isMatrix(u.getNodeType(e))?h=ae(D(h),0):u=ae(D(u),0);const d=lt(u,h).xyz;return _r(d).build(e,t)}else{if(i===V.NEGATE)return e.format("( - "+a.build(e,s)+" )",r,t);if(i===V.ONE_MINUS)return Pt(1,a).build(e,t);if(i===V.RECIPROCAL)return Qr(1,a).build(e,t);if(i===V.DIFFERENCE)return It(Pt(a,o)).build(e,t);{const u=[];return i===V.CROSS||i===V.MOD?u.push(a.build(e,r),o.build(e,r)):c&&i===V.STEP?u.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":s),o.build(e,s)):c&&(i===V.MIN||i===V.MAX)||i===V.MOD?u.push(a.build(e,s),o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":s)):i===V.REFRACT?u.push(a.build(e,s),o.build(e,s),l.build(e,"float")):i===V.MIX?u.push(a.build(e,s),o.build(e,s),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":s)):(u.push(a.build(e,s)),o!==null&&u.push(o.build(e,s)),l!==null&&u.push(l.build(e,s))),e.format(`${e.getMethod(i,r)}( ${u.join(", ")} )`,r,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}V.ALL="all",V.ANY="any",V.EQUALS="equals",V.RADIANS="radians",V.DEGREES="degrees",V.EXP="exp",V.EXP2="exp2",V.LOG="log",V.LOG2="log2",V.SQRT="sqrt",V.INVERSE_SQRT="inversesqrt",V.FLOOR="floor",V.CEIL="ceil",V.NORMALIZE="normalize",V.FRACT="fract",V.SIN="sin",V.COS="cos",V.TAN="tan",V.ASIN="asin",V.ACOS="acos",V.ATAN="atan",V.ABS="abs",V.SIGN="sign",V.LENGTH="length",V.NEGATE="negate",V.ONE_MINUS="oneMinus",V.DFDX="dFdx",V.DFDY="dFdy",V.ROUND="round",V.RECIPROCAL="reciprocal",V.TRUNC="trunc",V.FWIDTH="fwidth",V.BITCAST="bitcast",V.TRANSPOSE="transpose",V.ATAN2="atan2",V.MIN="min",V.MAX="max",V.MOD="mod",V.STEP="step",V.REFLECT="reflect",V.DISTANCE="distance",V.DIFFERENCE="difference",V.DOT="dot",V.CROSS="cross",V.POW="pow",V.TRANSFORM_DIRECTION="transformDirection",V.MIX="mix",V.CLAMP="clamp",V.REFRACT="refract",V.SMOOTHSTEP="smoothstep",V.FACEFORWARD="faceforward";const P_=E(1e-6),O2=E(1e6),ta=E(Math.PI),F2=E(Math.PI*2),Ef=K(V,V.ALL),D_=K(V,V.ANY),U_=K(V,V.EQUALS),O_=K(V,V.RADIANS),F_=K(V,V.DEGREES),Af=K(V,V.EXP),Bh=K(V,V.EXP2),Nf=K(V,V.LOG),Wl=K(V,V.LOG2),en=K(V,V.SQRT),V_=K(V,V.INVERSE_SQRT),cs=K(V,V.FLOOR),Cf=K(V,V.CEIL),_r=K(V,V.NORMALIZE),us=K(V,V.FRACT),Ci=K(V,V.SIN),Mr=K(V,V.COS),B_=K(V,V.TAN),z_=K(V,V.ASIN),zh=K(V,V.ACOS),k_=K(V,V.ATAN),It=K(V,V.ABS),jl=K(V,V.SIGN),ia=K(V,V.LENGTH),H_=K(V,V.NEGATE),G_=K(V,V.ONE_MINUS),W_=K(V,V.DFDX),j_=K(V,V.DFDY),X_=K(V,V.ROUND),q_=K(V,V.RECIPROCAL),Rf=K(V,V.TRUNC),Y_=K(V,V.FWIDTH),V2=K(V,V.BITCAST),$_=K(V,V.TRANSPOSE),J_=K(V,V.ATAN2),xi=K(V,V.MIN),ft=K(V,V.MAX),kh=K(V,V.MOD),Xl=K(V,V.STEP),K_=K(V,V.REFLECT),Z_=K(V,V.DISTANCE),Q_=K(V,V.DIFFERENCE),qt=K(V,V.DOT),co=K(V,V.CROSS),Ji=K(V,V.POW),If=K(V,V.POW,2),eM=K(V,V.POW,3),tM=K(V,V.POW,4),iM=K(V,V.TRANSFORM_DIRECTION),rM=n=>lt(jl(n),Ji(It(n),1/3)),Lf=n=>qt(n,n),rt=K(V,V.MIX),li=(n,e=0,t=1)=>G(new V(V.CLAMP,G(n),G(e),G(t))),nM=n=>li(n),Pf=K(V,V.REFRACT),Ki=K(V,V.SMOOTHSTEP),sM=K(V,V.FACEFORWARD),Df=U(([n])=>{const e=43758.5453,t=qt(n.xy,z(12.9898,78.233)),i=kh(t,ta);return us(Ci(i).mul(e))}),aM=(n,e,t)=>rt(e,t,n),oM=(n,e,t)=>Ki(e,t,n);te("all",Ef),te("any",D_),te("equals",U_),te("radians",O_),te("degrees",F_),te("exp",Af),te("exp2",Bh),te("log",Nf),te("log2",Wl),te("sqrt",en),te("inverseSqrt",V_),te("floor",cs),te("ceil",Cf),te("normalize",_r),te("fract",us),te("sin",Ci),te("cos",Mr),te("tan",B_),te("asin",z_),te("acos",zh),te("atan",k_),te("abs",It),te("sign",jl),te("length",ia),te("lengthSq",Lf),te("negate",H_),te("oneMinus",G_),te("dFdx",W_),te("dFdy",j_),te("round",X_),te("reciprocal",q_),te("trunc",Rf),te("fwidth",Y_),te("atan2",J_),te("min",xi),te("max",ft),te("mod",kh),te("step",Xl),te("reflect",K_),te("distance",Z_),te("dot",qt),te("cross",co),te("pow",Ji),te("pow2",If),te("pow3",eM),te("pow4",tM),te("transformDirection",iM),te("mix",aM),te("clamp",li),te("refract",Pf),te("smoothstep",oM),te("faceForward",sM),te("difference",Q_),te("saturate",nM),te("cbrt",rM),te("transpose",$_),te("rand",Df);class B2 extends qe{static get type(){return"ConditionalNode"}constructor(e,t,i=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=i}getNodeType(e){const t=this.ifNode.getNodeType(e);if(this.elseNode!==null){const i=this.elseNode.getNodeType(e);if(e.getTypeLength(i)>e.getTypeLength(t))return i}return t}setup(e){const t=this.condNode.cache(),i=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,s=e.context.nodeBlock;e.getDataFromNode(i).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);const a=e.getNodeProperties(this);a.condNode=t,a.ifNode=i.context({nodeBlock:i}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){const i=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:s,ifNode:a,elseNode:o}=e.getNodeProperties(this),l=t!=="void",c=l?ar(i).build(e):"";r.nodeProperty=c;const u=s.build(e,"bool");e.addFlowCode(`
|
|
3848
3848
|
${e.tab}if ( ${u} ) {
|
|
3849
3849
|
|
|
3850
3850
|
`).addFlowTab();let h=a.build(e,i);if(h&&(l?h=c+" = "+h+";":h="return "+h+";"),e.removeFlowTab().addFlowCode(e.tab+" "+h+`
|