| 3682 | }`;Al=class extends vt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Dn=class extends it{constructor(){super(),this.isGroup=!0,this.type="Group"}},l1={type:"move"},Jo=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Dn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Dn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new w,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new w),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Dn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new w,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new w),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(let y of e.hand.values()){let g=t.getJointPose(y,i),p=this._getHandJoint(l,y);g!==null&&(p.matrix.fromArray(g.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=g.radius),p.visible=g!==null}let u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],f=u.position.distanceTo(h.position),d=.02,m=.005;l.inputState.pinching&&f>d+m?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&f<=d-m&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(l1)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Dn;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},ud=class extends $n{constructor(e,t){super();let i=this,r=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,h=null,f=null,d=null,m=null,y=t.getContextAttributes(),g=null,p=null,_=[],x=[],b=new Z,T=null,A=new vt;A.layers.enable(1),A.viewport=new tt;let M=new vt;M.layers.enable(2),M.viewport=new tt;let C=[A,M],S=new Al;S.layers.enable(1),S.layers.enable(2);let v=null,L=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let Q=_[X];return Q===void 0&&(Q=new Jo,_[X]=Q),Q.getTargetRaySpace()},this.getControllerGrip=function(X){let Q=_[X];return Q===void 0&&(Q=new Jo,_[X]=Q),Q.getGripSpace()},this.getHand=function(X){let Q=_[X];return Q===void 0&&(Q=new Jo,_[X]=Q),Q.getHandSpace()};function U(X){let Q=x.indexOf(X.inputSource);if(Q===-1)return;let ue=_[Q];ue!==void 0&&(ue.update(X.inputSource,X.frame,l||o),ue.dispatchEvent({type:X.type,data:X.inputSource}))}function G(){r.removeEventListener("select",U),r.removeEventListener("selectstart",U),r.removeEventListener("selectend",U),r.removeEventListener("squeeze",U),r.removeEventListener("squeezestart",U),r.removeEventListener("squeezeend",U),r.removeEventListener("end",G),r.removeEventListener("inputsourceschange",P);for(let X=0;X<_.length;X++){let Q=x[X];Q!==null&&(x[X]=null,_[X].disconnect(Q))}v=null,L=null,e.setRenderTarget(g),d=null,f=null,h=null,r=null,p=null,le.stop(),i.isPresenting=!1,e.setPixelRatio(T),e.setSize(b.width,b.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){s=X,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){a=X,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(X){l=X},this.getBaseLayer=function(){return f!==null?f:d},this.getBinding=function(){return h},this.getFrame=function(){return m},this.getSession=function(){return r},this.setSession=async function(X){if(r=X,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",U),r.addEventListener("selectstart",U),r.addEventListener("selectend",U),r.addEventListener("squeeze",U),r.addEventListener("squeezestart",U),r.addEventListener("squeezeend",U),r.addEventListener("end",G),r.addEventListener("inputsourceschange",P),y.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(b),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let Q={antialias:r.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,Q),r.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),p=new Tn(d.framebufferWidth,d.framebufferHeight,{format:mn,type:Di,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let Q=null,ue=null,xe=null;y.depth&&(xe=y.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Q=y.stencil?Zr:or,ue=y.stencil?sr:Ri);let he={colorFormat:t.RGBA8,depthFormat:xe,scaleFactor:s};h=new XRWebGLBinding(r,t),f=h.createProjectionLayer(he),r.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),p=new Tn(f.textureWidth,f.textureHeight,{format:mn,type:Di,depthTexture:new ma(f.textureWidth,f.textureHeight,ue,void 0,void 0,void 0,void 0,void 0,void 0,Q),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});let Ce=e.properties.get(p);Ce.__ignoreDepthValues=f.ignoreDepthValues}p.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await r.requestReferenceSpace(a),le.setContext(r),le.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function P(X){for(let Q=0;Q<X.removed.length;Q++){let ue=X.removed[Q],xe=x.indexOf(ue);xe>=0&&(x[xe]=null,_[xe].disconnect(ue))}for(let Q=0;Q<X.added.length;Q++){let ue=X.added[Q],xe=x.indexOf(ue);if(xe===-1){for(let Ce=0;Ce<_.length;Ce++)if(Ce>=x.length){x.push(ue),xe=Ce;break}else if(x[Ce]===null){x[Ce]=ue,xe=Ce;break}if(xe===-1)break}let he=_[xe];he&&he.connect(ue)}}let D=new w,z=new w;function q(X,Q,ue){D.setFromMatrixPosition(Q.matrixWorld),z.setFromMatrixPosition(ue.matrixWorld);let xe=D.distanceTo(z),he=Q.projectionMatrix.elements,Ce=ue.projectionMatrix.elements,De=he[14]/(he[10]-1),Me=he[14]/(he[10]+1),Ue=(he[9]+1)/he[5],N=(he[9]-1)/he[5],ae=(he[8]-1)/he[0],K=(Ce[8]+1)/Ce[0],re=De*ae,$=De*K,Ee=xe/(-ae+K),me=Ee*-ae;Q.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(me),X.translateZ(Ee),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert();let R=De+Ee,E=Me+Ee,B=re-me,ie=$+(xe-me),te=Ue*Me/E*R,ee=N*Me/E*R;X.projectionMatrix.makePerspective(B,ie,te,ee,R,E),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}function Y(X,Q){Q===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices(Q.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(r===null)return;S.near=M.near=A.near=X.near,S.far=M.far=A.far=X.far,(v!==S.near||L!==S.far)&&(r.updateRenderState({depthNear:S.near,depthFar:S.far}),v=S.near,L=S.far);let Q=X.parent,ue=S.cameras;Y(S,Q);for(let xe=0;xe<ue.length;xe++)Y(ue[xe],Q);ue.length===2?q(S,A,M):S.projectionMatrix.copy(A.projectionMatrix),W(X,S,Q)};function W(X,Q,ue){ue===null?X.matrix.copy(Q.matrixWorld):(X.matrix.copy(ue.matrixWorld),X.matrix.invert(),X.matrix.multiply(Q.matrixWorld)),X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(Q.projectionMatrix),X.projectionMatrixInverse.copy(Q.projectionMatrixInverse),X.isPerspectiveCamera&&(X.fov=Qs*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1)}this.getCamera=function(){return S},this.getFoveation=function(){if(!(f===null&&d===null))return c},this.setFoveation=function(X){c=X,f!==null&&(f.fixedFoveation=X),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=X)};let j=null;function J(X,Q){if(u=Q.getViewerPose(l||o),m=Q,u!==null){let ue=u.views;d!==null&&(e.setRenderTargetFramebuffer(p,d.framebuffer),e.setRenderTarget(p));let xe=!1;ue.length!==S.cameras.length&&(S.cameras.length=0,xe=!0);for(let he=0;he<ue.length;he++){let Ce=ue[he],De=null;if(d!==null)De=d.getViewport(Ce);else{let Ue=h.getViewSubImage(f,Ce);De=Ue.viewport,he===0&&(e.setRenderTargetTextures(p,Ue.colorTexture,f.ignoreDepthValues?void 0:Ue.depthStencilTexture),e.setRenderTarget(p))}let Me=C[he];Me===void 0&&(Me=new vt,Me.layers.enable(he),Me.viewport=new tt,C[he]=Me),Me.matrix.fromArray(Ce.transform.matrix),Me.matrix.decompose(Me.position,Me.quaternion,Me.scale),Me.projectionMatrix.fromArray(Ce.projectionMatrix),Me.projectionMatrixInverse.copy(Me.projectionMatrix).invert(),Me.viewport.set(De.x,De.y,De.width,De.height),he===0&&(S.matrix.copy(Me.matrix),S.matrix.decompose(S.position,S.quaternion,S.scale)),xe===!0&&S.cameras.push(Me)}}for(let ue=0;ue<_.length;ue++){let xe=x[ue],he=_[ue];xe!==null&&he!==void 0&&he.update(xe,Q,l||o)}j&&j(X,Q),Q.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:Q}),m=null}let le=new gx;le.setAnimationLoop(J),this.setAnimationLoop=function(X){j=X},this.dispose=function(){}}};El=class{constructor(e={}){let{canvas:t=dx(),context:i=null,depth:r=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let f;i!==null?f=i.getContextAttributes().alpha:f=o;let d=new Uint32Array(4),m=new Int32Array(4),y=null,g=null,p=[],_=[];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=lt,this._useLegacyLights=!1,this.toneMapping=Oi,this.toneMappingExposure=1;let x=this,b=!1,T=0,A=0,M=null,C=-1,S=null,v=new tt,L=new tt,U=null,G=new oe(0),P=0,D=t.width,z=t.height,q=1,Y=null,W=null,j=new tt(0,0,D,z),J=new tt(0,0,D,z),le=!1,X=new ts,Q=!1,ue=!1,xe=null,he=new we,Ce=new Z,De=new w,Me={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ue(){return M===null?q:1}let N=i;function ae(I,F){for(let k=0;k<I.length;k++){let H=I[k],V=t.getContext(H,F);if(V!==null)return V}return null}try{let I={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r160"),t.addEventListener("webglcontextlost",ce,!1),t.addEventListener("webglcontextrestored",O,!1),t.addEventListener("webglcontextcreationerror",de,!1),N===null){let F=["webgl2","webgl","experimental-webgl"];if(x.isWebGL1Renderer===!0&&F.shift(),N=ae(F,I),N===null)throw ae(F)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&N instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),N.getShaderPrecisionFormat===void 0&&(N.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(I){throw console.error("THREE.WebGLRenderer: "+I.message),I}let K,re,$,Ee,me,R,E,B,ie,te,ee,ve,fe,_e,Re,ke,ne,st,Ke,Fe,Te,be,Xe,ct;function Et(){K=new Pw(N),re=new Ew(N,K,e),K.init(re),be=new Mx(N,K,re),$=new a1(N,K,re),Ee=new Ow(N),me=new $T,R=new c1(N,K,$,me,re,be,Ee),E=new Tw(x),B=new Iw(x),ie=new Gv(N,re),Xe=new vw(N,K,ie,re),te=new Nw(N,ie,Ee,Xe),ee=new Bw(N,te,ie,Ee),Ke=new Fw(N,re,R),ke=new ww(me),ve=new jT(x,E,B,K,re,Xe,ke),fe=new u1(x,me),_e=new ZT,Re=new i1(K,re),st=new Mw(x,E,B,$,ee,f,c),ne=new o1(x,ee,re),ct=new h1(N,Ee,re,$),Fe=new Aw(N,K,Ee,re),Te=new Lw(N,K,Ee,re),Ee.programs=ve.programs,x.capabilities=re,x.extensions=K,x.properties=me,x.renderLists=_e,x.shadowMap=ne,x.state=$,x.info=Ee}Et();let je=new ud(x,N);this.xr=je,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let I=K.get("WEBGL_lose_context");I&&I.loseContext()},this.forceContextRestore=function(){let I=K.get("WEBGL_lose_context");I&&I.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(I){I!==void 0&&(q=I,this.setSize(D,z,!1))},this.getSize=function(I){return I.set(D,z)},this.setSize=function(I,F,k=!0){if(je.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}D=I,z=F,t.width=Math.floor(I*q),t.height=Math.floor(F*q),k===!0&&(t.style.width=I+"px",t.style.height=F+"px"),this.setViewport(0,0,I,F)},this.getDrawingBufferSize=function(I){return I.set(D*q,z*q).floor()},this.setDrawingBufferSize=function(I,F,k){D=I,z=F,q=k,t.width=Math.floor(I*k),t.height=Math.floor(F*k),this.setViewport(0,0,I,F)},this.getCurrentViewport=function(I){return I.copy(v)},this.getViewport=function(I){return I.copy(j)},this.setViewport=function(I,F,k,H){I.isVector4?j.set(I.x,I.y,I.z,I.w):j.set(I,F,k,H),$.viewport(v.copy(j).multiplyScalar(q).floor())},this.getScissor=function(I){return I.copy(J)},this.setScissor=function(I,F,k,H){I.isVector4?J.set(I.x,I.y,I.z,I.w):J.set(I,F,k,H),$.scissor(L.copy(J).multiplyScalar(q).floor())},this.getScissorTest=function(){return le},this.setScissorTest=function(I){$.setScissorTest(le=I)},this.setOpaqueSort=function(I){Y=I},this.setTransparentSort=function(I){W=I},this.getClearColor=function(I){return I.copy(st.getClearColor())},this.setClearColor=function(){st.setClearColor.apply(st,arguments)},this.getClearAlpha=function(){return st.getClearAlpha()},this.setClearAlpha=function(){st.setClearAlpha.apply(st,arguments)},this.clear=function(I=!0,F=!0,k=!0){let H=0;if(I){let V=!1;if(M!==null){let ge=M.texture.format;V=ge===up||ge===lp||ge===cp}if(V){let ge=M.texture.type,Ae=ge===Di||ge===Ri||ge===_u||ge===sr||ge===op||ge===ap,Pe=st.getClearColor(),Le=st.getClearAlpha(),qe=Pe.r,Ve=Pe.g,Ge=Pe.b;Ae?(d[0]=qe,d[1]=Ve,d[2]=Ge,d[3]=Le,N.clearBufferuiv(N.COLOR,0,d)):(m[0]=qe,m[1]=Ve,m[2]=Ge,m[3]=Le,N.clearBufferiv(N.COLOR,0,m))}else H|=N.COLOR_BUFFER_BIT}F&&(H|=N.DEPTH_BUFFER_BIT),k&&(H|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),N.clear(H)},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",ce,!1),t.removeEventListener("webglcontextrestored",O,!1),t.removeEventListener("webglcontextcreationerror",de,!1),_e.dispose(),Re.dispose(),me.dispose(),E.dispose(),B.dispose(),ee.dispose(),Xe.dispose(),ct.dispose(),ve.dispose(),je.dispose(),je.removeEventListener("sessionstart",an),je.removeEventListener("sessionend",mt),xe&&(xe.dispose(),xe=null),cn.stop()};function ce(I){I.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function O(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;let I=Ee.autoReset,F=ne.enabled,k=ne.autoUpdate,H=ne.needsUpdate,V=ne.type;Et(),Ee.autoReset=I,ne.enabled=F,ne.autoUpdate=k,ne.needsUpdate=H,ne.type=V}function de(I){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",I.statusMessage)}function pe(I){let F=I.target;F.removeEventListener("dispose",pe),Ne(F)}function Ne(I){Ie(I),me.remove(I)}function Ie(I){let F=me.get(I).programs;F!==void 0&&(F.forEach(function(k){ve.releaseProgram(k)}),I.isShaderMaterial&&ve.releaseShaderCache(I))}this.renderBufferDirect=function(I,F,k,H,V,ge){F===null&&(F=Me);let Ae=V.isMesh&&V.matrixWorld.determinant()<0,Pe=lM(I,F,k,H,V);$.setMaterial(H,Ae);let Le=k.index,qe=1;if(H.wireframe===!0){if(Le=te.getWireframeAttribute(k),Le===void 0)return;qe=2}let Ve=k.drawRange,Ge=k.attributes.position,Pt=Ve.start*qe,Mn=(Ve.start+Ve.count)*qe;ge!==null&&(Pt=Math.max(Pt,ge.start*qe),Mn=Math.min(Mn,(ge.start+ge.count)*qe)),Le!==null?(Pt=Math.max(Pt,0),Mn=Math.min(Mn,Le.count)):Ge!=null&&(Pt=Math.max(Pt,0),Mn=Math.min(Mn,Ge.count));let Ht=Mn-Pt;if(Ht<0||Ht===1/0)return;Xe.setup(V,H,Pe,k,Le);let bi,bt=Fe;if(Le!==null&&(bi=ie.get(Le),bt=Te,bt.setIndex(bi)),V.isMesh)H.wireframe===!0?($.setLineWidth(H.wireframeLinewidth*Ue()),bt.setMode(N.LINES)):bt.setMode(N.TRIANGLES);else if(V.isLine){let $e=H.linewidth;$e===void 0&&($e=1),$.setLineWidth($e*Ue()),V.isLineSegments?bt.setMode(N.LINES):V.isLineLoop?bt.setMode(N.LINE_LOOP):bt.setMode(N.LINE_STRIP)}else V.isPoints?bt.setMode(N.POINTS):V.isSprite&&bt.setMode(N.TRIANGLES);if(V.isBatchedMesh)bt.renderMultiDraw(V._multiDrawStarts,V._multiDrawCounts,V._multiDrawCount);else if(V.isInstancedMesh)bt.renderInstances(Pt,Ht,V.count);else if(k.isInstancedBufferGeometry){let $e=k._maxInstanceCount!==void 0?k._maxInstanceCount:1/0,bh=Math.min(k.instanceCount,$e);bt.renderInstances(Pt,Ht,bh)}else bt.render(Pt,Ht)};function dt(I,F,k){I.transparent===!0&&I.side===On&&I.forceSinglePass===!1?(I.side=hn,I.needsUpdate=!0,yc(I,F,k),I.side=qn,I.needsUpdate=!0,yc(I,F,k),I.side=On):yc(I,F,k)}this.compile=function(I,F,k=null){k===null&&(k=I),g=Re.get(k),g.init(),_.push(g),k.traverseVisible(function(V){V.isLight&&V.layers.test(F.layers)&&(g.pushLight(V),V.castShadow&&g.pushShadow(V))}),I!==k&&I.traverseVisible(function(V){V.isLight&&V.layers.test(F.layers)&&(g.pushLight(V),V.castShadow&&g.pushShadow(V))}),g.setupLights(x._useLegacyLights);let H=new Set;return I.traverse(function(V){let ge=V.material;if(ge)if(Array.isArray(ge))for(let Ae=0;Ae<ge.length;Ae++){let Pe=ge[Ae];dt(Pe,k,V),H.add(Pe)}else dt(ge,k,V),H.add(ge)}),_.pop(),g=null,H},this.compileAsync=function(I,F,k=null){let H=this.compile(I,F,k);return new Promise(V=>{function ge(){if(H.forEach(function(Ae){me.get(Ae).currentProgram.isReady()&&H.delete(Ae)}),H.size===0){V(I);return}setTimeout(ge,10)}K.get("KHR_parallel_shader_compile")!==null?ge():setTimeout(ge,10)})};let pt=null;function Gt(I){pt&&pt(I)}function an(){cn.stop()}function mt(){cn.start()}let cn=new gx;cn.setAnimationLoop(Gt),typeof self<"u"&&cn.setContext(self),this.setAnimationLoop=function(I){pt=I,je.setAnimationLoop(I),I===null?cn.stop():cn.start()},je.addEventListener("sessionstart",an),je.addEventListener("sessionend",mt),this.render=function(I,F){if(F!==void 0&&F.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),je.enabled===!0&&je.isPresenting===!0&&(je.cameraAutoUpdate===!0&&je.updateCamera(F),F=je.getCamera()),I.isScene===!0&&I.onBeforeRender(x,I,F,M),g=Re.get(I,_.length),g.init(),_.push(g),he.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),X.setFromProjectionMatrix(he),ue=this.localClippingEnabled,Q=ke.init(this.clippingPlanes,ue),y=_e.get(I,p.length),y.init(),p.push(y),ri(I,F,0,x.sortObjects),y.finish(),x.sortObjects===!0&&y.sort(Y,W),this.info.render.frame++,Q===!0&&ke.beginShadows();let k=g.state.shadowsArray;if(ne.render(k,I,F),Q===!0&&ke.endShadows(),this.info.autoReset===!0&&this.info.reset(),st.render(y,I),g.setupLights(x._useLegacyLights),F.isArrayCamera){let H=F.cameras;for(let V=0,ge=H.length;V<ge;V++){let Ae=H[V];Sg(y,I,Ae,Ae.viewport)}}else Sg(y,I,F);M!==null&&(R.updateMultisampleRenderTarget(M),R.updateRenderTargetMipmap(M)),I.isScene===!0&&I.onAfterRender(x,I,F),Xe.resetDefaultState(),C=-1,S=null,_.pop(),_.length>0?g=_[_.length-1]:g=null,p.pop(),p.length>0?y=p[p.length-1]:y=null};function ri(I,F,k,H){if(I.visible===!1)return;if(I.layers.test(F.layers)){if(I.isGroup)k=I.renderOrder;else if(I.isLOD)I.autoUpdate===!0&&I.update(F);else if(I.isLight)g.pushLight(I),I.castShadow&&g.pushShadow(I);else if(I.isSprite){if(!I.frustumCulled||X.intersectsSprite(I)){H&&De.setFromMatrixPosition(I.matrixWorld).applyMatrix4(he);let Ae=ee.update(I),Pe=I.material;Pe.visible&&y.push(I,Ae,Pe,k,De.z,null)}}else if((I.isMesh||I.isLine||I.isPoints)&&(!I.frustumCulled||X.intersectsObject(I))){let Ae=ee.update(I),Pe=I.material;if(H&&(I.boundingSphere!==void 0?(I.boundingSphere===null&&I.computeBoundingSphere(),De.copy(I.boundingSphere.center)):(Ae.boundingSphere===null&&Ae.computeBoundingSphere(),De.copy(Ae.boundingSphere.center)),De.applyMatrix4(I.matrixWorld).applyMatrix4(he)),Array.isArray(Pe)){let Le=Ae.groups;for(let qe=0,Ve=Le.length;qe<Ve;qe++){let Ge=Le[qe],Pt=Pe[Ge.materialIndex];Pt&&Pt.visible&&y.push(I,Ae,Pt,k,De.z,Ge)}}else Pe.visible&&y.push(I,Ae,Pe,k,De.z,null)}}let ge=I.children;for(let Ae=0,Pe=ge.length;Ae<Pe;Ae++)ri(ge[Ae],F,k,H)}function Sg(I,F,k,H){let V=I.opaque,ge=I.transmissive,Ae=I.transparent;g.setupLightsView(k),Q===!0&&ke.setGlobalState(x.clippingPlanes,k),ge.length>0&&cM(V,ge,F,k),H&&$.viewport(v.copy(H)),V.length>0&&gc(V,F,k),ge.length>0&&gc(ge,F,k),Ae.length>0&&gc(Ae,F,k),$.buffers.depth.setTest(!0),$.buffers.depth.setMask(!0),$.buffers.color.setMask(!0),$.setPolygonOffset(!1)}function cM(I,F,k,H){if((k.isScene===!0?k.overrideMaterial:null)!==null)return;let ge=re.isWebGL2;xe===null&&(xe=new Tn(1,1,{generateMipmaps:!0,type:K.has("EXT_color_buffer_half_float")?Zs:Di,minFilter:jn,samples:ge?4:0})),x.getDrawingBufferSize(Ce),ge?xe.setSize(Ce.x,Ce.y):xe.setSize(Sl(Ce.x),Sl(Ce.y));let Ae=x.getRenderTarget();x.setRenderTarget(xe),x.getClearColor(G),P=x.getClearAlpha(),P<1&&x.setClearColor(16777215,.5),x.clear();let Pe=x.toneMapping;x.toneMapping=Oi,gc(I,k,H),R.updateMultisampleRenderTarget(xe),R.updateRenderTargetMipmap(xe);let Le=!1;for(let qe=0,Ve=F.length;qe<Ve;qe++){let Ge=F[qe],Pt=Ge.object,Mn=Ge.geometry,Ht=Ge.material,bi=Ge.group;if(Ht.side===On&&Pt.layers.test(H.layers)){let bt=Ht.side;Ht.side=hn,Ht.needsUpdate=!0,bg(Pt,k,H,Mn,Ht,bi),Ht.side=bt,Ht.needsUpdate=!0,Le=!0}}Le===!0&&(R.updateMultisampleRenderTarget(xe),R.updateRenderTargetMipmap(xe)),x.setRenderTarget(Ae),x.setClearColor(G,P),x.toneMapping=Pe}function gc(I,F,k){let H=F.isScene===!0?F.overrideMaterial:null;for(let V=0,ge=I.length;V<ge;V++){let Ae=I[V],Pe=Ae.object,Le=Ae.geometry,qe=H===null?Ae.material:H,Ve=Ae.group;Pe.layers.test(k.layers)&&bg(Pe,F,k,Le,qe,Ve)}}function bg(I,F,k,H,V,ge){I.onBeforeRender(x,F,k,H,V,ge),I.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,I.matrixWorld),I.normalMatrix.getNormalMatrix(I.modelViewMatrix),V.onBeforeRender(x,F,k,H,I,ge),V.transparent===!0&&V.side===On&&V.forceSinglePass===!1?(V.side=hn,V.needsUpdate=!0,x.renderBufferDirect(k,F,H,V,I,ge),V.side=qn,V.needsUpdate=!0,x.renderBufferDirect(k,F,H,V,I,ge),V.side=On):x.renderBufferDirect(k,F,H,V,I,ge),I.onAfterRender(x,F,k,H,V,ge)}function yc(I,F,k){F.isScene!==!0&&(F=Me);let H=me.get(I),V=g.state.lights,ge=g.state.shadowsArray,Ae=V.state.version,Pe=ve.getParameters(I,V.state,ge,F,k),Le=ve.getProgramCacheKey(Pe),qe=H.programs;H.environment=I.isMeshStandardMaterial?F.environment:null,H.fog=F.fog,H.envMap=(I.isMeshStandardMaterial?B:E).get(I.envMap||H.environment),qe===void 0&&(I.addEventListener("dispose",pe),qe=new Map,H.programs=qe);let Ve=qe.get(Le);if(Ve!==void 0){if(H.currentProgram===Ve&&H.lightsStateVersion===Ae)return vg(I,Pe),Ve}else Pe.uniforms=ve.getUniforms(I),I.onBuild(k,Pe,x),I.onBeforeCompile(Pe,x),Ve=ve.acquireProgram(Pe,Le),qe.set(Le,Ve),H.uniforms=Pe.uniforms;let Ge=H.uniforms;return(!I.isShaderMaterial&&!I.isRawShaderMaterial||I.clipping===!0)&&(Ge.clippingPlanes=ke.uniform),vg(I,Pe),H.needsLights=hM(I),H.lightsStateVersion=Ae,H.needsLights&&(Ge.ambientLightColor.value=V.state.ambient,Ge.lightProbe.value=V.state.probe,Ge.directionalLights.value=V.state.directional,Ge.directionalLightShadows.value=V.state.directionalShadow,Ge.spotLights.value=V.state.spot,Ge.spotLightShadows.value=V.state.spotShadow,Ge.rectAreaLights.value=V.state.rectArea,Ge.ltc_1.value=V.state.rectAreaLTC1,Ge.ltc_2.value=V.state.rectAreaLTC2,Ge.pointLights.value=V.state.point,Ge.pointLightShadows.value=V.state.pointShadow,Ge.hemisphereLights.value=V.state.hemi,Ge.directionalShadowMap.value=V.state.directionalShadowMap,Ge.directionalShadowMatrix.value=V.state.directionalShadowMatrix,Ge.spotShadowMap.value=V.state.spotShadowMap,Ge.spotLightMatrix.value=V.state.spotLightMatrix,Ge.spotLightMap.value=V.state.spotLightMap,Ge.pointShadowMap.value=V.state.pointShadowMap,Ge.pointShadowMatrix.value=V.state.pointShadowMatrix),H.currentProgram=Ve,H.uniformsList=null,Ve}function Mg(I){if(I.uniformsList===null){let F=I.currentProgram.getUniforms();I.uniformsList=$s.seqWithValue(F.seq,I.uniforms)}return I.uniformsList}function vg(I,F){let k=me.get(I);k.outputColorSpace=F.outputColorSpace,k.batching=F.batching,k.instancing=F.instancing,k.instancingColor=F.instancingColor,k.skinning=F.skinning,k.morphTargets=F.morphTargets,k.morphNormals=F.morphNormals,k.morphColors=F.morphColors,k.morphTargetsCount=F.morphTargetsCount,k.numClippingPlanes=F.numClippingPlanes,k.numIntersection=F.numClipIntersection,k.vertexAlphas=F.vertexAlphas,k.vertexTangents=F.vertexTangents,k.toneMapping=F.toneMapping}function lM(I,F,k,H,V){F.isScene!==!0&&(F=Me),R.resetTextureUnits();let ge=F.fog,Ae=H.isMeshStandardMaterial?F.environment:null,Pe=M===null?x.outputColorSpace:M.isXRRenderTarget===!0?M.texture.colorSpace:Dt,Le=(H.isMeshStandardMaterial?B:E).get(H.envMap||Ae),qe=H.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,Ve=!!k.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Ge=!!k.morphAttributes.position,Pt=!!k.morphAttributes.normal,Mn=!!k.morphAttributes.color,Ht=Oi;H.toneMapped&&(M===null||M.isXRRenderTarget===!0)&&(Ht=x.toneMapping);let bi=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,bt=bi!==void 0?bi.length:0,$e=me.get(H),bh=g.state.lights;if(Q===!0&&(ue===!0||I!==S)){let Nn=I===S&&H.id===C;ke.setState(H,I,Nn)}let wt=!1;H.version===$e.__version?($e.needsLights&&$e.lightsStateVersion!==bh.state.version||$e.outputColorSpace!==Pe||V.isBatchedMesh&&$e.batching===!1||!V.isBatchedMesh&&$e.batching===!0||V.isInstancedMesh&&$e.instancing===!1||!V.isInstancedMesh&&$e.instancing===!0||V.isSkinnedMesh&&$e.skinning===!1||!V.isSkinnedMesh&&$e.skinning===!0||V.isInstancedMesh&&$e.instancingColor===!0&&V.instanceColor===null||V.isInstancedMesh&&$e.instancingColor===!1&&V.instanceColor!==null||$e.envMap!==Le||H.fog===!0&&$e.fog!==ge||$e.numClippingPlanes!==void 0&&($e.numClippingPlanes!==ke.numPlanes||$e.numIntersection!==ke.numIntersection)||$e.vertexAlphas!==qe||$e.vertexTangents!==Ve||$e.morphTargets!==Ge||$e.morphNormals!==Pt||$e.morphColors!==Mn||$e.toneMapping!==Ht||re.isWebGL2===!0&&$e.morphTargetsCount!==bt)&&(wt=!0):(wt=!0,$e.__version=H.version);let Tr=$e.currentProgram;wt===!0&&(Tr=yc(H,F,V));let Ag=!1,Do=!1,Mh=!1,Qt=Tr.getUniforms(),Cr=$e.uniforms;if($.useProgram(Tr.program)&&(Ag=!0,Do=!0,Mh=!0),H.id!==C&&(C=H.id,Do=!0),Ag||S!==I){Qt.setValue(N,"projectionMatrix",I.projectionMatrix),Qt.setValue(N,"viewMatrix",I.matrixWorldInverse);let Nn=Qt.map.cameraPosition;Nn!==void 0&&Nn.setValue(N,De.setFromMatrixPosition(I.matrixWorld)),re.logarithmicDepthBuffer&&Qt.setValue(N,"logDepthBufFC",2/(Math.log(I.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&Qt.setValue(N,"isOrthographic",I.isOrthographicCamera===!0),S!==I&&(S=I,Do=!0,Mh=!0)}if(V.isSkinnedMesh){Qt.setOptional(N,V,"bindMatrix"),Qt.setOptional(N,V,"bindMatrixInverse");let Nn=V.skeleton;Nn&&(re.floatVertexTextures?(Nn.boneTexture===null&&Nn.computeBoneTexture(),Qt.setValue(N,"boneTexture",Nn.boneTexture,R)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}V.isBatchedMesh&&(Qt.setOptional(N,V,"batchingTexture"),Qt.setValue(N,"batchingTexture",V._matricesTexture,R));let vh=k.morphAttributes;if((vh.position!==void 0||vh.normal!==void 0||vh.color!==void 0&&re.isWebGL2===!0)&&Ke.update(V,k,Tr),(Do||$e.receiveShadow!==V.receiveShadow)&&($e.receiveShadow=V.receiveShadow,Qt.setValue(N,"receiveShadow",V.receiveShadow)),H.isMeshGouraudMaterial&&H.envMap!==null&&(Cr.envMap.value=Le,Cr.flipEnvMap.value=Le.isCubeTexture&&Le.isRenderTargetTexture===!1?-1:1),Do&&(Qt.setValue(N,"toneMappingExposure",x.toneMappingExposure),$e.needsLights&&uM(Cr,Mh),ge&&H.fog===!0&&fe.refreshFogUniforms(Cr,ge),fe.refreshMaterialUniforms(Cr,H,q,z,xe),$s.upload(N,Mg($e),Cr,R)),H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&($s.upload(N,Mg($e),Cr,R),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&Qt.setValue(N,"center",V.center),Qt.setValue(N,"modelViewMatrix",V.modelViewMatrix),Qt.setValue(N,"normalMatrix",V.normalMatrix),Qt.setValue(N,"modelMatrix",V.matrixWorld),H.isShaderMaterial||H.isRawShaderMaterial){let Nn=H.uniformsGroups;for(let Ah=0,fM=Nn.length;Ah<fM;Ah++)if(re.isWebGL2){let Eg=Nn[Ah];ct.update(Eg,Tr),ct.bind(Eg,Tr)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Tr}function uM(I,F){I.ambientLightColor.needsUpdate=F,I.lightProbe.needsUpdate=F,I.directionalLights.needsUpdate=F,I.directionalLightShadows.needsUpdate=F,I.pointLights.needsUpdate=F,I.pointLightShadows.needsUpdate=F,I.spotLights.needsUpdate=F,I.spotLightShadows.needsUpdate=F,I.rectAreaLights.needsUpdate=F,I.hemisphereLights.needsUpdate=F}function hM(I){return I.isMeshLambertMaterial||I.isMeshToonMaterial||I.isMeshPhongMaterial||I.isMeshStandardMaterial||I.isShadowMaterial||I.isShaderMaterial&&I.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(I,F,k){me.get(I.texture).__webglTexture=F,me.get(I.depthTexture).__webglTexture=k;let H=me.get(I);H.__hasExternalTextures=!0,H.__hasExternalTextures&&(H.__autoAllocateDepthBuffer=k===void 0,H.__autoAllocateDepthBuffer||K.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),H.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(I,F){let k=me.get(I);k.__webglFramebuffer=F,k.__useDefaultFramebuffer=F===void 0},this.setRenderTarget=function(I,F=0,k=0){M=I,T=F,A=k;let H=!0,V=null,ge=!1,Ae=!1;if(I){let Le=me.get(I);Le.__useDefaultFramebuffer!==void 0?($.bindFramebuffer(N.FRAMEBUFFER,null),H=!1):Le.__webglFramebuffer===void 0?R.setupRenderTarget(I):Le.__hasExternalTextures&&R.rebindTextures(I,me.get(I.texture).__webglTexture,me.get(I.depthTexture).__webglTexture);let qe=I.texture;(qe.isData3DTexture||qe.isDataArrayTexture||qe.isCompressedArrayTexture)&&(Ae=!0);let Ve=me.get(I).__webglFramebuffer;I.isWebGLCubeRenderTarget?(Array.isArray(Ve[F])?V=Ve[F][k]:V=Ve[F],ge=!0):re.isWebGL2&&I.samples>0&&R.useMultisampledRTT(I)===!1?V=me.get(I).__webglMultisampledFramebuffer:Array.isArray(Ve)?V=Ve[k]:V=Ve,v.copy(I.viewport),L.copy(I.scissor),U=I.scissorTest}else v.copy(j).multiplyScalar(q).floor(),L.copy(J).multiplyScalar(q).floor(),U=le;if($.bindFramebuffer(N.FRAMEBUFFER,V)&&re.drawBuffers&&H&&$.drawBuffers(I,V),$.viewport(v),$.scissor(L),$.setScissorTest(U),ge){let Le=me.get(I.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+F,Le.__webglTexture,k)}else if(Ae){let Le=me.get(I.texture),qe=F||0;N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,Le.__webglTexture,k||0,qe)}C=-1},this.readRenderTargetPixels=function(I,F,k,H,V,ge,Ae){if(!(I&&I.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Pe=me.get(I).__webglFramebuffer;if(I.isWebGLCubeRenderTarget&&Ae!==void 0&&(Pe=Pe[Ae]),Pe){$.bindFramebuffer(N.FRAMEBUFFER,Pe);try{let Le=I.texture,qe=Le.format,Ve=Le.type;if(qe!==mn&&be.convert(qe)!==N.getParameter(N.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Ge=Ve===Zs&&(K.has("EXT_color_buffer_half_float")||re.isWebGL2&&K.has("EXT_color_buffer_float"));if(Ve!==Di&&be.convert(Ve)!==N.getParameter(N.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Ve===Xn&&(re.isWebGL2||K.has("OES_texture_float")||K.has("WEBGL_color_buffer_float")))&&!Ge){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=I.width-H&&k>=0&&k<=I.height-V&&N.readPixels(F,k,H,V,be.convert(qe),be.convert(Ve),ge)}finally{let Le=M!==null?me.get(M).__webglFramebuffer:null;$.bindFramebuffer(N.FRAMEBUFFER,Le)}}},this.copyFramebufferToTexture=function(I,F,k=0){let H=Math.pow(2,-k),V=Math.floor(F.image.width*H),ge=Math.floor(F.image.height*H);R.setTexture2D(F,0),N.copyTexSubImage2D(N.TEXTURE_2D,k,0,0,I.x,I.y,V,ge),$.unbindTexture()},this.copyTextureToTexture=function(I,F,k,H=0){let V=F.image.width,ge=F.image.height,Ae=be.convert(k.format),Pe=be.convert(k.type);R.setTexture2D(k,0),N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,k.flipY),N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),N.pixelStorei(N.UNPACK_ALIGNMENT,k.unpackAlignment),F.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,H,I.x,I.y,V,ge,Ae,Pe,F.image.data):F.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,H,I.x,I.y,F.mipmaps[0].width,F.mipmaps[0].height,Ae,F.mipmaps[0].data):N.texSubImage2D(N.TEXTURE_2D,H,I.x,I.y,Ae,Pe,F.image),H===0&&k.generateMipmaps&&N.generateMipmap(N.TEXTURE_2D),$.unbindTexture()},this.copyTextureToTexture3D=function(I,F,k,H,V=0){if(x.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let ge=I.max.x-I.min.x+1,Ae=I.max.y-I.min.y+1,Pe=I.max.z-I.min.z+1,Le=be.convert(H.format),qe=be.convert(H.type),Ve;if(H.isData3DTexture)R.setTexture3D(H,0),Ve=N.TEXTURE_3D;else if(H.isDataArrayTexture||H.isCompressedArrayTexture)R.setTexture2DArray(H,0),Ve=N.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,H.flipY),N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),N.pixelStorei(N.UNPACK_ALIGNMENT,H.unpackAlignment);let Ge=N.getParameter(N.UNPACK_ROW_LENGTH),Pt=N.getParameter(N.UNPACK_IMAGE_HEIGHT),Mn=N.getParameter(N.UNPACK_SKIP_PIXELS),Ht=N.getParameter(N.UNPACK_SKIP_ROWS),bi=N.getParameter(N.UNPACK_SKIP_IMAGES),bt=k.isCompressedTexture?k.mipmaps[V]:k.image;N.pixelStorei(N.UNPACK_ROW_LENGTH,bt.width),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,bt.height),N.pixelStorei(N.UNPACK_SKIP_PIXELS,I.min.x),N.pixelStorei(N.UNPACK_SKIP_ROWS,I.min.y),N.pixelStorei(N.UNPACK_SKIP_IMAGES,I.min.z),k.isDataTexture||k.isData3DTexture?N.texSubImage3D(Ve,V,F.x,F.y,F.z,ge,Ae,Pe,Le,qe,bt.data):k.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),N.compressedTexSubImage3D(Ve,V,F.x,F.y,F.z,ge,Ae,Pe,Le,bt.data)):N.texSubImage3D(Ve,V,F.x,F.y,F.z,ge,Ae,Pe,Le,qe,bt),N.pixelStorei(N.UNPACK_ROW_LENGTH,Ge),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Pt),N.pixelStorei(N.UNPACK_SKIP_PIXELS,Mn),N.pixelStorei(N.UNPACK_SKIP_ROWS,Ht),N.pixelStorei(N.UNPACK_SKIP_IMAGES,bi),V===0&&H.generateMipmaps&&N.generateMipmap(Ve),$.unbindTexture()},this.initTexture=function(I){I.isCubeTexture?R.setTextureCube(I,0):I.isData3DTexture?R.setTexture3D(I,0):I.isDataArrayTexture||I.isCompressedArrayTexture?R.setTexture2DArray(I,0):R.setTexture2D(I,0),$.unbindTexture()},this.resetState=function(){T=0,A=0,M=null,$.reset(),Xe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Yn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===bu?"display-p3":"srgb",t.unpackColorSpace=rt.workingColorSpace===Ga?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===lt?ar:pp}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===ar?lt:Dt}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}},wl=class extends El{};wl.prototype.isWebGL1Renderer=!0;Tl=class n{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new oe(e),this.density=t}clone(){return new n(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}},Cl=class n{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new oe(e),this.near=t,this.far=i}clone(){return new n(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},ro=class extends it{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let 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}},Vi=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=aa,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=wn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}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=wn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let 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=wn()),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}}},ln=new w,Yt=class n{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++)ln.fromBufferAttribute(this,t),ln.applyMatrix4(e),this.setXYZ(t,ln.x,ln.y,ln.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ln.fromBufferAttribute(this,t),ln.applyNormalMatrix(e),this.setXYZ(t,ln.x,ln.y,ln.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ln.fromBufferAttribute(this,t),ln.transformDirection(e),this.setXYZ(t,ln.x,ln.y,ln.z);return this}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=We(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=gn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=gn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=gn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=gn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),i=We(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=We(t,this.array),i=We(i,this.array),r=We(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=We(t,this.array),i=We(i,this.array),r=We(r,this.array),s=We(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.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new Ze(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 n(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.");let t=[];for(let i=0;i<this.count;i++){let 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}}},xa=class extends It{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new oe(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}},Go=new w,zs=new w,Vs=new w,ks=new Z,Ho=new Z,vx=new we,kc=new w,Wo=new w,Gc=new w,b0=new Z,Jh=new Z,M0=new Z,Rl=class extends it{constructor(e=new xa){if(super(),this.isSprite=!0,this.type="Sprite",Bs===void 0){Bs=new Be;let 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 Vi(t,5);Bs.setIndex([0,1,2,0,2,3]),Bs.setAttribute("position",new Yt(i,3,0,!1)),Bs.setAttribute("uv",new Yt(i,2,3,!1))}this.geometry=Bs,this.material=e,this.center=new Z(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),zs.setFromMatrixScale(this.matrixWorld),vx.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Vs.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&zs.multiplyScalar(-Vs.z);let i=this.material.rotation,r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));let o=this.center;Hc(kc.set(-.5,-.5,0),Vs,o,zs,r,s),Hc(Wo.set(.5,-.5,0),Vs,o,zs,r,s),Hc(Gc.set(.5,.5,0),Vs,o,zs,r,s),b0.set(0,0),Jh.set(1,0),M0.set(1,1);let a=e.ray.intersectTriangle(kc,Wo,Gc,!1,Go);if(a===null&&(Hc(Wo.set(-.5,.5,0),Vs,o,zs,r,s),Jh.set(0,1),a=e.ray.intersectTriangle(kc,Gc,Wo,!1,Go),a===null))return;let c=e.ray.origin.distanceTo(Go);c<e.near||c>e.far||t.push({distance:c,point:Go.clone(),uv:Pi.getInterpolation(Go,kc,Wo,Gc,b0,Jh,M0,new Z),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}};Wc=new w,v0=new w,Il=class extends it{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);let t=e.levels;for(let i=0,r=t.length;i<r;i++){let 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);let r=this.levels,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}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let 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){Wc.setFromMatrixPosition(this.matrixWorld);let r=e.ray.origin.distanceTo(Wc);this.getObjectForDistance(r).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){Wc.setFromMatrixPosition(e.matrixWorld),v0.setFromMatrixPosition(this.matrixWorld);let i=Wc.distanceTo(v0)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let o=t[r].distance;if(t[r].object.visible&&(o-=o*t[r].hysteresis),i>=o)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){let t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let i=this.levels;for(let r=0,s=i.length;r<s;r++){let o=i[r];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}},A0=new w,E0=new tt,w0=new tt,f1=new w,T0=new we,Xc=new w,Qh=new _t,C0=new we,ef=new ur,so=class extends ft{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=_f,this.bindMatrix=new we,this.bindMatrixInverse=new we,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new xt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Xc),this.boundingBox.expandByPoint(Xc)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new _t),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Xc),this.boundingSphere.expandByPoint(Xc)}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){let i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Qh.copy(this.boundingSphere),Qh.applyMatrix4(r),e.ray.intersectsSphere(Qh)!==!1&&(C0.copy(r).invert(),ef.copy(e.ray).applyMatrix4(C0),!(this.boundingBox!==null&&ef.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,ef)))}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(){let e=new tt,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);let 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===_f?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Wy?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let i=this.skeleton,r=this.geometry;E0.fromBufferAttribute(r.attributes.skinIndex,e),w0.fromBufferAttribute(r.attributes.skinWeight,e),A0.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let o=w0.getComponent(s);if(o!==0){let a=E0.getComponent(s);T0.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),t.addScaledVector(f1.copy(A0).applyMatrix4(T0),o)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}},is=class extends it{constructor(){super(),this.isBone=!0,this.type="Bone"}},Ui=class extends Rt{constructor(e=null,t=1,i=1,r,s,o,a,c,l=Mt,u=Mt,h,f){super(null,o,a,c,l,u,r,s,h,f),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},R0=new we,d1=new we,oo=class n{constructor(e=[],t=[]){this.uuid=wn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let 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 we)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new we;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++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let 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(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,o=e.length;s<o;s++){let a=e[s]?e[s].matrixWorld:d1;R0.multiplyMatrices(a,t[s]),R0.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new n(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Ui(t,e,e,mn,Xn);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let 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++){let s=e.bones[i],o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new is),this.bones.push(o),this.boneInverses.push(new we().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let o=t[r];e.bones.push(o.uuid);let a=i[r];e.boneInverses.push(a.toArray())}return e}},Kn=class extends Ze{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(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Gs=new we,I0=new we,Yc=[],P0=new xt,p1=new we,Xo=new ft,Yo=new _t,ao=class extends ft{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Kn(new Float32Array(i*16),16),this.instanceColor=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,p1)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new xt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Gs),P0.copy(e.boundingBox).applyMatrix4(Gs),this.boundingBox.union(P0)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new _t),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Gs),Yo.copy(e.boundingSphere).applyMatrix4(Gs),this.boundingSphere.union(Yo)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,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)}raycast(e,t){let i=this.matrixWorld,r=this.count;if(Xo.geometry=this.geometry,Xo.material=this.material,Xo.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Yo.copy(this.boundingSphere),Yo.applyMatrix4(i),e.ray.intersectsSphere(Yo)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Gs),I0.multiplyMatrices(i,Gs),Xo.matrixWorld=I0,Xo.raycast(e,Yc);for(let o=0,a=Yc.length;o<a;o++){let c=Yc[o];c.instanceId=s,c.object=this,t.push(c)}Yc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Kn(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}};hd=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t){let i=this.pool,r=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1});let s=i[this.index];r.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=t}reset(){this.list.length=0,this.index=0}},Hs="batchId",nr=new we,N0=new we,y1=new we,L0=new we,tf=new ts,qc=new xt,Or=new _t,qo=new w,nf=new hd,nn=new ft,jc=[];Pl=class extends ft{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,t,i=t*2,r){super(new Be,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=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._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4),i=new Ui(t,e,e,mn,Xn);this._matricesTexture=i}_initializeGeometry(e){let t=this.geometry,i=this._maxVertexCount,r=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(let a in e.attributes){let c=e.getAttribute(a),{array:l,itemSize:u,normalized:h}=c,f=new l.constructor(i*u),d=new c.constructor(f,u,h);d.setUsage(c.usage),t.setAttribute(a,d)}if(e.getIndex()!==null){let a=i>65536?new Uint32Array(s):new Uint16Array(s);t.setIndex(new Ze(a,1))}let o=r>65536?new Uint32Array(i):new Uint16Array(i);t.setAttribute(Hs,new Ze(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Hs))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Hs}"`);let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(let i in t.attributes){if(i===Hs)continue;if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);let 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 xt);let e=this._geometryCount,t=this.boundingBox,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,nr),this.getBoundingBoxAt(r,qc).applyMatrix4(nr),t.union(qc))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new _t);let e=this._geometryCount,t=this.boundingSphere,i=this._active;t.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,nr),this.getBoundingSphereAt(r,Or).applyMatrix4(nr),t.union(Or))}addGeometry(e,t=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");let r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1},s=null,o=this._reservedRanges,a=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(s=o[o.length-1]),t===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=t,s===null?r.vertexStart=0:r.vertexStart=s.vertexStart+s.vertexCount;let l=e.getIndex(),u=l!==null;if(u&&(i===-1?r.indexCount=l.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.");let h=this._visibility,f=this._active,d=this._matricesTexture,m=this._matricesTexture.image.data;h.push(!0),f.push(!0);let y=this._geometryCount;this._geometryCount++,y1.toArray(m,y*16),d.needsUpdate=!0,o.push(r),a.push({start:u?r.indexStart:r.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new xt,sphereInitialized:!1,sphere:new _t});let g=this.geometry.getAttribute(Hs);for(let p=0;p<r.vertexCount;p++)g.setX(r.vertexStart+p,y);return g.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let i=this.geometry,r=i.getIndex()!==null,s=i.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(r&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");let c=a.vertexStart,l=a.vertexCount;for(let d in i.attributes){if(d===Hs)continue;let m=t.getAttribute(d),y=i.getAttribute(d);x1(m,y,c);let g=m.itemSize;for(let p=m.count,_=l;p<_;p++){let x=c+p;for(let b=0;b<g;b++)y.setComponent(x,b,0)}y.needsUpdate=!0}if(r){let d=a.indexStart;for(let m=0;m<o.count;m++)s.setX(d+m,c+o.getX(m));for(let m=o.count,y=a.indexCount;m<y;m++)s.setX(d+m,c);s.needsUpdate=!0}let 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;let h=this._drawRanges[e],f=t.getAttribute("position");return h.count=r?o.count:f.count,this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._active;return e>=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(this._active[e]===!1)return this;let r=this._bounds[e],s=r.box,o=this.geometry;if(r.boxInitialized===!1){s.makeEmpty();let a=o.index,c=o.attributes.position,l=this._drawRanges[e];for(let u=l.start,h=l.start+l.count;u<h;u++){let f=u;a&&(f=a.getX(f)),s.expandByPoint(qo.fromBufferAttribute(c,f))}r.boxInitialized=!0}return t.copy(s),t}getBoundingSphereAt(e,t){if(this._active[e]===!1)return this;let r=this._bounds[e],s=r.sphere,o=this.geometry;if(r.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,qc),qc.getCenter(s.center);let a=o.index,c=o.attributes.position,l=this._drawRanges[e],u=0;for(let h=l.start,f=l.start+l.count;h<f;h++){let d=h;a&&(d=a.getX(d)),qo.fromBufferAttribute(c,d),u=Math.max(u,s.center.distanceToSquared(qo))}s.radius=Math.sqrt(u),r.sphereInitialized=!0}return t.copy(s),t}setMatrixAt(e,t){let i=this._active,r=this._matricesTexture,s=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||i[e]===!1?this:(t.toArray(s,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){let i=this._active,r=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||i[e]===!1?null:t.fromArray(r,e*16)}setVisibleAt(e,t){let i=this._visibility,r=this._active,s=this._geometryCount;return e>=s||r[e]===!1||i[e]===t?this:(i[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){let t=this._visibility,i=this._active,r=this._geometryCount;return e>=r||i[e]===!1?!1:t[e]}raycast(e,t){let i=this._visibility,r=this._active,s=this._drawRanges,o=this._geometryCount,a=this.matrixWorld,c=this.geometry;nn.material=this.material,nn.geometry.index=c.index,nn.geometry.attributes=c.attributes,nn.geometry.boundingBox===null&&(nn.geometry.boundingBox=new xt),nn.geometry.boundingSphere===null&&(nn.geometry.boundingSphere=new _t);for(let l=0;l<o;l++){if(!i[l]||!r[l])continue;let u=s[l];nn.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(l,nn.matrixWorld).premultiply(a),this.getBoundingBoxAt(l,nn.geometry.boundingBox),this.getBoundingSphereAt(l,nn.geometry.boundingSphere),nn.raycast(e,jc);for(let h=0,f=jc.length;h<f;h++){let d=jc[h];d.object=this,d.batchId=l,t.push(d)}jc.length=0}nn.material=null,nn.geometry.index=null,nn.geometry.attributes={},nn.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._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,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.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,i,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let o=r.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,l=this._multiDrawStarts,u=this._multiDrawCounts,h=this._drawRanges,f=this.perObjectFrustumCulled;f&&(L0.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),tf.setFromProjectionMatrix(L0,e.isWebGPURenderer?Js:Yn));let d=0;if(this.sortObjects){N0.copy(this.matrixWorld).invert(),qo.setFromMatrixPosition(i.matrixWorld).applyMatrix4(N0);for(let g=0,p=c.length;g<p;g++)if(c[g]){this.getMatrixAt(g,nr),this.getBoundingSphereAt(g,Or).applyMatrix4(nr);let _=!1;if(f&&(_=!tf.intersectsSphere(Or)),!_){let x=qo.distanceTo(Or.center);nf.push(h[g],x)}}let m=nf.list,y=this.customSort;y===null?m.sort(s.transparent?g1:m1):y.call(this,m,i);for(let g=0,p=m.length;g<p;g++){let _=m[g];l[d]=_.start*a,u[d]=_.count,d++}nf.reset()}else for(let m=0,y=c.length;m<y;m++)if(c[m]){let g=!1;if(f&&(this.getMatrixAt(m,nr),this.getBoundingSphereAt(m,Or).applyMatrix4(nr),g=!tf.intersectsSphere(Or)),!g){let p=h[m];l[d]=p.start*a,u[d]=p.count,d++}}this._multiDrawCount=d,this._visibilityChanged=!1}onBeforeShadow(e,t,i,r,s,o){this.onBeforeRender(e,null,r,s,o)}},Vt=class extends It{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new oe(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}},O0=new w,D0=new w,U0=new we,rf=new ur,$c=new _t,Un=class extends it{constructor(e=new Be,t=new Vt){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(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)O0.fromBufferAttribute(t,r-1),D0.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=O0.distanceTo(D0);e.setAttribute("lineDistance",new ye(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),$c.copy(i.boundingSphere),$c.applyMatrix4(r),$c.radius+=s,e.ray.intersectsSphere($c)===!1)return;U0.copy(r).invert(),rf.copy(e.ray).applyMatrix4(U0);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=new w,u=new w,h=new w,f=new w,d=this.isLineSegments?2:1,m=i.index,g=i.attributes.position;if(m!==null){let p=Math.max(0,o.start),_=Math.min(m.count,o.start+o.count);for(let x=p,b=_-1;x<b;x+=d){let T=m.getX(x),A=m.getX(x+1);if(l.fromBufferAttribute(g,T),u.fromBufferAttribute(g,A),rf.distanceSqToSegment(l,u,f,h)>c)continue;f.applyMatrix4(this.matrixWorld);let C=e.ray.origin.distanceTo(f);C<e.near||C>e.far||t.push({distance:C,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let p=Math.max(0,o.start),_=Math.min(g.count,o.start+o.count);for(let x=p,b=_-1;x<b;x+=d){if(l.fromBufferAttribute(g,x),u.fromBufferAttribute(g,x+1),rf.distanceSqToSegment(l,u,f,h)>c)continue;f.applyMatrix4(this.matrixWorld);let A=e.ray.origin.distanceTo(f);A<e.near||A>e.far||t.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},F0=new w,B0=new w,xn=class extends Un{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)F0.fromBufferAttribute(t,r),B0.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+F0.distanceTo(B0);e.setAttribute("lineDistance",new ye(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},co=class extends Un{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},rs=class extends It{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new oe(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}},z0=new we,fd=new ur,Kc=new _t,Zc=new w,lo=class extends it{constructor(e=new Be,t=new rs){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){let i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Kc.copy(i.boundingSphere),Kc.applyMatrix4(r),Kc.radius+=s,e.ray.intersectsSphere(Kc)===!1)return;z0.copy(r).invert(),fd.copy(e.ray).applyMatrix4(z0);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=i.index,h=i.attributes.position;if(l!==null){let f=Math.max(0,o.start),d=Math.min(l.count,o.start+o.count);for(let m=f,y=d;m<y;m++){let g=l.getX(m);Zc.fromBufferAttribute(h,g),V0(Zc,g,c,r,e,t,this)}}else{let f=Math.max(0,o.start),d=Math.min(h.count,o.start+o.count);for(let m=f,y=d;m<y;m++)Zc.fromBufferAttribute(h,m),V0(Zc,m,c,r,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};dd=class extends Rt{constructor(e,t,i,r,s,o,a,c,l){super(e,t,i,r,s,o,a,c,l),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:yt,this.magFilter=s!==void 0?s:yt,this.generateMipmaps=!1;let 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(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},pd=class extends Rt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Mt,this.minFilter=Mt,this.generateMipmaps=!1,this.needsUpdate=!0}},uo=class extends Rt{constructor(e,t,i,r,s,o,a,c,l,u,h,f){super(null,o,a,c,l,u,r,s,h,f),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},md=class extends uo{constructor(e,t,i,r,s,o){super(e,t,i,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=Xt}},gd=class extends uo{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,Bi),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},_a=class extends Rt{constructor(e,t,i,r,s,o,a,c,l){super(e,t,i,r,s,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Cn=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let 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;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,o;t?o=t:o=e*i[s-1];let a=0,c=s-1,l;for(;a<=c;)if(r=Math.floor(a+(c-a)/2),l=i[r]-o,l<0)a=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,i[r]===o)return r/(s-1);let u=i[r],f=i[r+1]-u,d=(o-u)/f;return(r+d)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),c=t||(o.isVector2?new Z:new w);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new w,r=[],s=[],o=[],a=new w,c=new we;for(let d=0;d<=e;d++){let m=d/e;r[d]=this.getTangentAt(m,new w)}s[0]=new w,o[0]=new w;let l=Number.MAX_VALUE,u=Math.abs(r[0].x),h=Math.abs(r[0].y),f=Math.abs(r[0].z);u<=l&&(l=u,i.set(1,0,0)),h<=l&&(l=h,i.set(0,1,0)),f<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),o[d]=o[d-1].clone(),a.crossVectors(r[d-1],r[d]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(Ct(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(c.makeRotationAxis(a,m))}o[d].crossVectors(r[d],s[d])}if(t===!0){let d=Math.acos(Ct(s[0].dot(s[e]),-1,1));d/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(d=-d);for(let m=1;m<=e;m++)s[m].applyMatrix4(c.makeRotationAxis(r[m],d*m)),o[m].crossVectors(r[m],s[m])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let 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}},ho=class extends Cn{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,a=!1,c=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=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t){let i=t||new Z,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),f=c-this.aX,d=l-this.aY;c=f*u-d*h+this.aX,l=f*h+d*u+this.aY}return i.set(c,l)}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(){let 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}},Nl=class extends ho{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};Jc=new w,sf=new xp,of=new xp,af=new xp,Ll=class extends Cn{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 w){let i=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,u;this.closed||a>0?l=r[(a-1)%s]:(Jc.subVectors(r[0],r[1]).add(r[0]),l=Jc);let h=r[a%s],f=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(Jc.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=Jc),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,m=Math.pow(l.distanceToSquared(h),d),y=Math.pow(h.distanceToSquared(f),d),g=Math.pow(f.distanceToSquared(u),d);y<1e-4&&(y=1),m<1e-4&&(m=y),g<1e-4&&(g=y),sf.initNonuniformCatmullRom(l.x,h.x,f.x,u.x,m,y,g),of.initNonuniformCatmullRom(l.y,h.y,f.y,u.y,m,y,g),af.initNonuniformCatmullRom(l.z,h.z,f.z,u.z,m,y,g)}else this.curveType==="catmullrom"&&(sf.initCatmullRom(l.x,h.x,f.x,u.x,this.tension),of.initCatmullRom(l.y,h.y,f.y,u.y,this.tension),af.initCatmullRom(l.z,h.z,f.z,u.z,this.tension));return i.set(sf.calc(c),of.calc(c),af.calc(c)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let 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++){let r=e.points[t];this.points.push(new w().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};Sa=class extends Cn{constructor(e=new Z,t=new Z,i=new Z,r=new Z){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new Z){let i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(ea(e,r.x,s.x,o.x,a.x),ea(e,r.y,s.y,o.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.v3.copy(e.v3),this}toJSON(){let 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}},Ol=class extends Cn{constructor(e=new w,t=new w,i=new w,r=new w){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new w){let i=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return i.set(ea(e,r.x,s.x,o.x,a.x),ea(e,r.y,s.y,o.y,a.y),ea(e,r.z,s.z,o.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.v3.copy(e.v3),this}toJSON(){let 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}},ba=class extends Cn{constructor(e=new Z,t=new Z){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Z){let 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 Z){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(){let 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}},Dl=class extends Cn{constructor(e=new w,t=new w){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new w){let 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 w){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(){let 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}},Ma=class extends Cn{constructor(e=new Z,t=new Z,i=new Z){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Z){let i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Qo(e,r.x,s.x,o.x),Qo(e,r.y,s.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}toJSON(){let 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}},va=class extends Cn{constructor(e=new w,t=new w,i=new w){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new w){let i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Qo(e,r.x,s.x,o.x),Qo(e,r.y,s.y,o.y),Qo(e,r.z,s.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}toJSON(){let 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}},Aa=class extends Cn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Z){let i=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),a=s-o,c=r[o===0?o:o-1],l=r[o],u=r[o>r.length-2?r.length-1:o+1],h=r[o>r.length-3?r.length-1:o+2];return i.set(k0(a,c.x,l.x,u.x,h.x),k0(a,c.y,l.y,u.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let 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++){let r=e.points[t];this.points.push(new Z().fromArray(r))}return this}},Ul=Object.freeze({__proto__:null,ArcCurve:Nl,CatmullRomCurve3:Ll,CubicBezierCurve:Sa,CubicBezierCurve3:Ol,EllipseCurve:ho,LineCurve:ba,LineCurve3:Dl,QuadraticBezierCurve:Ma,QuadraticBezierCurve3:va,SplineCurve:Aa}),Fl=class extends Cn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Ul[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let o=r[s]-i,a=this.curves[s],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}s++}return null}getLength(){let 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;let e=[],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){let 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){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){let u=c[l];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++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let 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++){let r=e.curves[t];this.curves.push(new Ul[r.type]().fromJSON(r))}return this}},ss=class extends Fl{constructor(e){super(),this.type="Path",this.currentPoint=new Z,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){let i=new ba(this.currentPoint.clone(),new Z(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new Ma(this.currentPoint.clone(),new Z(e,t),new Z(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,o){let a=new Sa(this.currentPoint.clone(),new Z(e,t),new Z(i,r),new Z(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Aa(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,o){let a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,i,r,s,o),this}absarc(e,t,i,r,s,o){return this.absellipse(e,t,i,i,r,s,o),this}ellipse(e,t,i,r,s,o,a,c){let l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,i,r,s,o,a,c),this}absellipse(e,t,i,r,s,o,a,c){let l=new ho(e,t,i,r,s,o,a,c);if(this.curves.length>0){let h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);let u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Ea=class n extends Be{constructor(e=[new Z(0,-.5),new Z(.5,0),new Z(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=Ct(r,0,Math.PI*2);let s=[],o=[],a=[],c=[],l=[],u=1/t,h=new w,f=new Z,d=new w,m=new w,y=new w,g=0,p=0;for(let _=0;_<=e.length-1;_++)switch(_){case 0:g=e[_+1].x-e[_].x,p=e[_+1].y-e[_].y,d.x=p*1,d.y=-g,d.z=p*0,y.copy(d),d.normalize(),c.push(d.x,d.y,d.z);break;case e.length-1:c.push(y.x,y.y,y.z);break;default:g=e[_+1].x-e[_].x,p=e[_+1].y-e[_].y,d.x=p*1,d.y=-g,d.z=p*0,m.copy(d),d.x+=y.x,d.y+=y.y,d.z+=y.z,d.normalize(),c.push(d.x,d.y,d.z),y.copy(m)}for(let _=0;_<=t;_++){let x=i+_*u*r,b=Math.sin(x),T=Math.cos(x);for(let A=0;A<=e.length-1;A++){h.x=e[A].x*b,h.y=e[A].y,h.z=e[A].x*T,o.push(h.x,h.y,h.z),f.x=_/t,f.y=A/(e.length-1),a.push(f.x,f.y);let M=c[3*A+0]*b,C=c[3*A+1],S=c[3*A+0]*T;l.push(M,C,S)}}for(let _=0;_<t;_++)for(let x=0;x<e.length-1;x++){let b=x+_*e.length,T=b,A=b+e.length,M=b+e.length+1,C=b+1;s.push(T,A,C),s.push(M,C,A)}this.setIndex(s),this.setAttribute("position",new ye(o,3)),this.setAttribute("uv",new ye(a,2)),this.setAttribute("normal",new ye(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.points,e.segments,e.phiStart,e.phiLength)}},Bl=class n extends Ea{constructor(e=1,t=1,i=4,r=8){let s=new ss;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 n(e.radius,e.length,e.capSegments,e.radialSegments)}},zl=class n extends Be{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);let s=[],o=[],a=[],c=[],l=new w,u=new Z;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let h=0,f=3;h<=t;h++,f+=3){let d=i+h/t*r;l.x=e*Math.cos(d),l.y=e*Math.sin(d),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[f]/e+1)/2,u.y=(o[f+1]/e+1)/2,c.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 ye(o,3)),this.setAttribute("normal",new ye(a,3)),this.setAttribute("uv",new ye(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.segments,e.thetaStart,e.thetaLength)}},fo=class n extends Be{constructor(e=1,t=1,i=1,r=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};let l=this;r=Math.floor(r),s=Math.floor(s);let u=[],h=[],f=[],d=[],m=0,y=[],g=i/2,p=0;_(),o===!1&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(u),this.setAttribute("position",new ye(h,3)),this.setAttribute("normal",new ye(f,3)),this.setAttribute("uv",new ye(d,2));function _(){let b=new w,T=new w,A=0,M=(t-e)/i;for(let C=0;C<=s;C++){let S=[],v=C/s,L=v*(t-e)+e;for(let U=0;U<=r;U++){let G=U/r,P=G*c+a,D=Math.sin(P),z=Math.cos(P);T.x=L*D,T.y=-v*i+g,T.z=L*z,h.push(T.x,T.y,T.z),b.set(D,M,z).normalize(),f.push(b.x,b.y,b.z),d.push(G,1-v),S.push(m++)}y.push(S)}for(let C=0;C<r;C++)for(let S=0;S<s;S++){let v=y[S][C],L=y[S+1][C],U=y[S+1][C+1],G=y[S][C+1];u.push(v,L,G),u.push(L,U,G),A+=6}l.addGroup(p,A,0),p+=A}function x(b){let T=m,A=new Z,M=new w,C=0,S=b===!0?e:t,v=b===!0?1:-1;for(let U=1;U<=r;U++)h.push(0,g*v,0),f.push(0,v,0),d.push(.5,.5),m++;let L=m;for(let U=0;U<=r;U++){let P=U/r*c+a,D=Math.cos(P),z=Math.sin(P);M.x=S*z,M.y=g*v,M.z=S*D,h.push(M.x,M.y,M.z),f.push(0,v,0),A.x=D*.5+.5,A.y=z*.5*v+.5,d.push(A.x,A.y),m++}for(let U=0;U<r;U++){let G=T+U,P=L+U;b===!0?u.push(P,P+1,G):u.push(P+1,P,G),C+=3}l.addGroup(p,C,b===!0?1:2),p+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Vl=class n extends fo{constructor(e=1,t=1,i=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,i,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new n(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},hr=class n extends Be{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],o=[];a(r),l(i),u(),this.setAttribute("position",new ye(s,3)),this.setAttribute("normal",new ye(s.slice(),3)),this.setAttribute("uv",new ye(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(_){let x=new w,b=new w,T=new w;for(let A=0;A<t.length;A+=3)d(t[A+0],x),d(t[A+1],b),d(t[A+2],T),c(x,b,T,_)}function c(_,x,b,T){let A=T+1,M=[];for(let C=0;C<=A;C++){M[C]=[];let S=_.clone().lerp(b,C/A),v=x.clone().lerp(b,C/A),L=A-C;for(let U=0;U<=L;U++)U===0&&C===A?M[C][U]=S:M[C][U]=S.clone().lerp(v,U/L)}for(let C=0;C<A;C++)for(let S=0;S<2*(A-C)-1;S++){let v=Math.floor(S/2);S%2===0?(f(M[C][v+1]),f(M[C+1][v]),f(M[C][v])):(f(M[C][v+1]),f(M[C+1][v+1]),f(M[C+1][v]))}}function l(_){let x=new w;for(let b=0;b<s.length;b+=3)x.x=s[b+0],x.y=s[b+1],x.z=s[b+2],x.normalize().multiplyScalar(_),s[b+0]=x.x,s[b+1]=x.y,s[b+2]=x.z}function u(){let _=new w;for(let x=0;x<s.length;x+=3){_.x=s[x+0],_.y=s[x+1],_.z=s[x+2];let b=g(_)/2/Math.PI+.5,T=p(_)/Math.PI+.5;o.push(b,1-T)}m(),h()}function h(){for(let _=0;_<o.length;_+=6){let x=o[_+0],b=o[_+2],T=o[_+4],A=Math.max(x,b,T),M=Math.min(x,b,T);A>.9&&M<.1&&(x<.2&&(o[_+0]+=1),b<.2&&(o[_+2]+=1),T<.2&&(o[_+4]+=1))}}function f(_){s.push(_.x,_.y,_.z)}function d(_,x){let b=_*3;x.x=e[b+0],x.y=e[b+1],x.z=e[b+2]}function m(){let _=new w,x=new w,b=new w,T=new w,A=new Z,M=new Z,C=new Z;for(let S=0,v=0;S<s.length;S+=9,v+=6){_.set(s[S+0],s[S+1],s[S+2]),x.set(s[S+3],s[S+4],s[S+5]),b.set(s[S+6],s[S+7],s[S+8]),A.set(o[v+0],o[v+1]),M.set(o[v+2],o[v+3]),C.set(o[v+4],o[v+5]),T.copy(_).add(x).add(b).divideScalar(3);let L=g(T);y(A,v+0,_,L),y(M,v+2,x,L),y(C,v+4,b,L)}}function y(_,x,b,T){T<0&&_.x===1&&(o[x]=_.x-1),b.x===0&&b.z===0&&(o[x]=T/2/Math.PI+.5)}function g(_){return Math.atan2(_.z,-_.x)}function p(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.vertices,e.indices,e.radius,e.details)}},kl=class n extends hr{constructor(e=1,t=0){let 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],o=[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,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new n(e.radius,e.detail)}},Qc=new w,el=new w,cf=new w,tl=new Pi,Gl=class extends Be{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let r=Math.pow(10,4),s=Math.cos(jr*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],h=new Array(3),f={},d=[];for(let m=0;m<c;m+=3){o?(l[0]=o.getX(m),l[1]=o.getX(m+1),l[2]=o.getX(m+2)):(l[0]=m,l[1]=m+1,l[2]=m+2);let{a:y,b:g,c:p}=tl;if(y.fromBufferAttribute(a,l[0]),g.fromBufferAttribute(a,l[1]),p.fromBufferAttribute(a,l[2]),tl.getNormal(cf),h[0]=`${Math.round(y.x*r)},${Math.round(y.y*r)},${Math.round(y.z*r)}`,h[1]=`${Math.round(g.x*r)},${Math.round(g.y*r)},${Math.round(g.z*r)}`,h[2]=`${Math.round(p.x*r)},${Math.round(p.y*r)},${Math.round(p.z*r)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let _=0;_<3;_++){let x=(_+1)%3,b=h[_],T=h[x],A=tl[u[_]],M=tl[u[x]],C=`${b}_${T}`,S=`${T}_${b}`;S in f&&f[S]?(cf.dot(f[S].normal)<=s&&(d.push(A.x,A.y,A.z),d.push(M.x,M.y,M.z)),f[S]=null):C in f||(f[C]={index0:l[_],index1:l[x],normal:cf.clone()})}}for(let m in f)if(f[m]){let{index0:y,index1:g}=f[m];Qc.fromBufferAttribute(a,y),el.fromBufferAttribute(a,g),d.push(Qc.x,Qc.y,Qc.z),d.push(el.x,el.y,el.z)}this.setAttribute("position",new ye(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},Fi=class extends ss{constructor(e){super(e),this.uuid=wn(),this.type="Shape",this.holes=[]}getPointsHoles(e){let 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++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let 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++){let r=e.holes[t];this.holes.push(new ss().fromJSON(r))}return this}},w1={triangulate:function(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,s=Ax(n,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,h,f,d;if(i&&(s=P1(n,e,s,t)),n.length>80*t){a=l=n[0],c=u=n[1];for(let m=t;m<r;m+=t)h=n[m],f=n[m+1],h<a&&(a=h),f<c&&(c=f),h>l&&(l=h),f>u&&(u=f);d=Math.max(l-a,u-c),d=d!==0?32767/d:0}return wa(s,o,t,a,c,d,0),o}};ai=class n{static area(e){let t=e.length,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 n.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];H0(e),W0(i,e);let o=e.length;t.forEach(H0);for(let c=0;c<t.length;c++)r.push(o),o+=t[c].length,W0(i,t[c]);let a=w1.triangulate(i,r);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}};Hl=class n extends Be{constructor(e=new Fi([new Z(.5,.5),new Z(-.5,.5),new Z(-.5,-.5),new Z(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let i=this,r=[],s=[];for(let a=0,c=e.length;a<c;a++){let l=e[a];o(l)}this.setAttribute("position",new ye(r,3)),this.setAttribute("uv",new ye(s,2)),this.computeVertexNormals();function o(a){let c=[],l=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1,f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,d=t.bevelThickness!==void 0?t.bevelThickness:.2,m=t.bevelSize!==void 0?t.bevelSize:d-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3,p=t.extrudePath,_=t.UVGenerator!==void 0?t.UVGenerator:H1,x,b=!1,T,A,M,C;p&&(x=p.getSpacedPoints(u),b=!0,f=!1,T=p.computeFrenetFrames(u,!1),A=new w,M=new w,C=new w),f||(g=0,d=0,m=0,y=0);let S=a.extractPoints(l),v=S.shape,L=S.holes;if(!ai.isClockWise(v)){v=v.reverse();for(let N=0,ae=L.length;N<ae;N++){let K=L[N];ai.isClockWise(K)&&(L[N]=K.reverse())}}let G=ai.triangulateShape(v,L),P=v;for(let N=0,ae=L.length;N<ae;N++){let K=L[N];v=v.concat(K)}function D(N,ae,K){return ae||console.error("THREE.ExtrudeGeometry: vec does not exist"),N.clone().addScaledVector(ae,K)}let z=v.length,q=G.length;function Y(N,ae,K){let re,$,Ee,me=N.x-ae.x,R=N.y-ae.y,E=K.x-N.x,B=K.y-N.y,ie=me*me+R*R,te=me*B-R*E;if(Math.abs(te)>Number.EPSILON){let ee=Math.sqrt(ie),ve=Math.sqrt(E*E+B*B),fe=ae.x-R/ee,_e=ae.y+me/ee,Re=K.x-B/ve,ke=K.y+E/ve,ne=((Re-fe)*B-(ke-_e)*E)/(me*B-R*E);re=fe+me*ne-N.x,$=_e+R*ne-N.y;let st=re*re+$*$;if(st<=2)return new Z(re,$);Ee=Math.sqrt(st/2)}else{let ee=!1;me>Number.EPSILON?E>Number.EPSILON&&(ee=!0):me<-Number.EPSILON?E<-Number.EPSILON&&(ee=!0):Math.sign(R)===Math.sign(B)&&(ee=!0),ee?(re=-R,$=me,Ee=Math.sqrt(ie)):(re=me,$=R,Ee=Math.sqrt(ie/2))}return new Z(re/Ee,$/Ee)}let W=[];for(let N=0,ae=P.length,K=ae-1,re=N+1;N<ae;N++,K++,re++)K===ae&&(K=0),re===ae&&(re=0),W[N]=Y(P[N],P[K],P[re]);let j=[],J,le=W.concat();for(let N=0,ae=L.length;N<ae;N++){let K=L[N];J=[];for(let re=0,$=K.length,Ee=$-1,me=re+1;re<$;re++,Ee++,me++)Ee===$&&(Ee=0),me===$&&(me=0),J[re]=Y(K[re],K[Ee],K[me]);j.push(J),le=le.concat(J)}for(let N=0;N<g;N++){let ae=N/g,K=d*Math.cos(ae*Math.PI/2),re=m*Math.sin(ae*Math.PI/2)+y;for(let $=0,Ee=P.length;$<Ee;$++){let me=D(P[$],W[$],re);he(me.x,me.y,-K)}for(let $=0,Ee=L.length;$<Ee;$++){let me=L[$];J=j[$];for(let R=0,E=me.length;R<E;R++){let B=D(me[R],J[R],re);he(B.x,B.y,-K)}}}let X=m+y;for(let N=0;N<z;N++){let ae=f?D(v[N],le[N],X):v[N];b?(M.copy(T.normals[0]).multiplyScalar(ae.x),A.copy(T.binormals[0]).multiplyScalar(ae.y),C.copy(x[0]).add(M).add(A),he(C.x,C.y,C.z)):he(ae.x,ae.y,0)}for(let N=1;N<=u;N++)for(let ae=0;ae<z;ae++){let K=f?D(v[ae],le[ae],X):v[ae];b?(M.copy(T.normals[N]).multiplyScalar(K.x),A.copy(T.binormals[N]).multiplyScalar(K.y),C.copy(x[N]).add(M).add(A),he(C.x,C.y,C.z)):he(K.x,K.y,h/u*N)}for(let N=g-1;N>=0;N--){let ae=N/g,K=d*Math.cos(ae*Math.PI/2),re=m*Math.sin(ae*Math.PI/2)+y;for(let $=0,Ee=P.length;$<Ee;$++){let me=D(P[$],W[$],re);he(me.x,me.y,h+K)}for(let $=0,Ee=L.length;$<Ee;$++){let me=L[$];J=j[$];for(let R=0,E=me.length;R<E;R++){let B=D(me[R],J[R],re);b?he(B.x,B.y+x[u-1].y,x[u-1].x+K):he(B.x,B.y,h+K)}}}Q(),ue();function Q(){let N=r.length/3;if(f){let ae=0,K=z*ae;for(let re=0;re<q;re++){let $=G[re];Ce($[2]+K,$[1]+K,$[0]+K)}ae=u+g*2,K=z*ae;for(let re=0;re<q;re++){let $=G[re];Ce($[0]+K,$[1]+K,$[2]+K)}}else{for(let ae=0;ae<q;ae++){let K=G[ae];Ce(K[2],K[1],K[0])}for(let ae=0;ae<q;ae++){let K=G[ae];Ce(K[0]+z*u,K[1]+z*u,K[2]+z*u)}}i.addGroup(N,r.length/3-N,0)}function ue(){let N=r.length/3,ae=0;xe(P,ae),ae+=P.length;for(let K=0,re=L.length;K<re;K++){let $=L[K];xe($,ae),ae+=$.length}i.addGroup(N,r.length/3-N,1)}function xe(N,ae){let K=N.length;for(;--K>=0;){let re=K,$=K-1;$<0&&($=N.length-1);for(let Ee=0,me=u+g*2;Ee<me;Ee++){let R=z*Ee,E=z*(Ee+1),B=ae+re+R,ie=ae+$+R,te=ae+$+E,ee=ae+re+E;De(B,ie,te,ee)}}}function he(N,ae,K){c.push(N),c.push(ae),c.push(K)}function Ce(N,ae,K){Me(N),Me(ae),Me(K);let re=r.length/3,$=_.generateTopUV(i,r,re-3,re-2,re-1);Ue($[0]),Ue($[1]),Ue($[2])}function De(N,ae,K,re){Me(N),Me(ae),Me(re),Me(ae),Me(K),Me(re);let $=r.length/3,Ee=_.generateSideWallUV(i,r,$-6,$-3,$-2,$-1);Ue(Ee[0]),Ue(Ee[1]),Ue(Ee[3]),Ue(Ee[1]),Ue(Ee[2]),Ue(Ee[3])}function Me(N){r.push(c[N*3+0]),r.push(c[N*3+1]),r.push(c[N*3+2])}function Ue(N){s.push(N.x),s.push(N.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return W1(t,i,e)}static fromJSON(e,t){let i=[];for(let s=0,o=e.shapes.length;s<o;s++){let a=t[e.shapes[s]];i.push(a)}let r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Ul[r.type]().fromJSON(r)),new n(i,e.options)}},H1={generateTopUV:function(n,e,t,i,r){let s=e[t*3],o=e[t*3+1],a=e[i*3],c=e[i*3+1],l=e[r*3],u=e[r*3+1];return[new Z(s,o),new Z(a,c),new Z(l,u)]},generateSideWallUV:function(n,e,t,i,r,s){let o=e[t*3],a=e[t*3+1],c=e[t*3+2],l=e[i*3],u=e[i*3+1],h=e[i*3+2],f=e[r*3],d=e[r*3+1],m=e[r*3+2],y=e[s*3],g=e[s*3+1],p=e[s*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new Z(o,1-c),new Z(l,1-h),new Z(f,1-m),new Z(y,1-p)]:[new Z(a,1-c),new Z(u,1-h),new Z(d,1-m),new Z(g,1-p)]}};Wl=class n extends hr{constructor(e=1,t=0){let 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 n(e.radius,e.detail)}},Ra=class n extends hr{constructor(e=1,t=0){let 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 n(e.radius,e.detail)}},Xl=class n extends Be{constructor(e=.5,t=1,i=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:o},i=Math.max(3,i),r=Math.max(1,r);let a=[],c=[],l=[],u=[],h=e,f=(t-e)/r,d=new w,m=new Z;for(let y=0;y<=r;y++){for(let g=0;g<=i;g++){let p=s+g/i*o;d.x=h*Math.cos(p),d.y=h*Math.sin(p),c.push(d.x,d.y,d.z),l.push(0,0,1),m.x=(d.x/t+1)/2,m.y=(d.y/t+1)/2,u.push(m.x,m.y)}h+=f}for(let y=0;y<r;y++){let g=y*(i+1);for(let p=0;p<i;p++){let _=p+g,x=_,b=_+i+1,T=_+i+2,A=_+1;a.push(x,b,A),a.push(b,T,A)}}this.setIndex(a),this.setAttribute("position",new ye(c,3)),this.setAttribute("normal",new ye(l,3)),this.setAttribute("uv",new ye(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},Yl=class n extends Be{constructor(e=new Fi([new Z(0,.5),new Z(-.5,-.5),new Z(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let i=[],r=[],s=[],o=[],a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let u=0;u<e.length;u++)l(e[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(i),this.setAttribute("position",new ye(r,3)),this.setAttribute("normal",new ye(s,3)),this.setAttribute("uv",new ye(o,2));function l(u){let h=r.length/3,f=u.extractPoints(t),d=f.shape,m=f.holes;ai.isClockWise(d)===!1&&(d=d.reverse());for(let g=0,p=m.length;g<p;g++){let _=m[g];ai.isClockWise(_)===!0&&(m[g]=_.reverse())}let y=ai.triangulateShape(d,m);for(let g=0,p=m.length;g<p;g++){let _=m[g];d=d.concat(_)}for(let g=0,p=d.length;g<p;g++){let _=d[g];r.push(_.x,_.y,0),s.push(0,0,1),o.push(_.x,_.y)}for(let g=0,p=y.length;g<p;g++){let _=y[g],x=_[0]+h,b=_[1]+h,T=_[2]+h;i.push(x,b,T),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return X1(t,e)}static fromJSON(e,t){let i=[];for(let r=0,s=e.shapes.length;r<s;r++){let o=t[e.shapes[r]];i.push(o)}return new n(i,e.curveSegments)}};Ia=class n extends Be{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let c=Math.min(o+a,Math.PI),l=0,u=[],h=new w,f=new w,d=[],m=[],y=[],g=[];for(let p=0;p<=i;p++){let _=[],x=p/i,b=0;p===0&&o===0?b=.5/t:p===i&&c===Math.PI&&(b=-.5/t);for(let T=0;T<=t;T++){let A=T/t;h.x=-e*Math.cos(r+A*s)*Math.sin(o+x*a),h.y=e*Math.cos(o+x*a),h.z=e*Math.sin(r+A*s)*Math.sin(o+x*a),m.push(h.x,h.y,h.z),f.copy(h).normalize(),y.push(f.x,f.y,f.z),g.push(A+b,1-x),_.push(l++)}u.push(_)}for(let p=0;p<i;p++)for(let _=0;_<t;_++){let x=u[p][_+1],b=u[p][_],T=u[p+1][_],A=u[p+1][_+1];(p!==0||o>0)&&d.push(x,b,A),(p!==i-1||c<Math.PI)&&d.push(b,T,A)}this.setIndex(d),this.setAttribute("position",new ye(m,3)),this.setAttribute("normal",new ye(y,3)),this.setAttribute("uv",new ye(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},ql=class n extends hr{constructor(e=1,t=0){let 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 n(e.radius,e.detail)}},jl=class n extends Be{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);let o=[],a=[],c=[],l=[],u=new w,h=new w,f=new w;for(let d=0;d<=i;d++)for(let m=0;m<=r;m++){let y=m/r*s,g=d/i*Math.PI*2;h.x=(e+t*Math.cos(g))*Math.cos(y),h.y=(e+t*Math.cos(g))*Math.sin(y),h.z=t*Math.sin(g),a.push(h.x,h.y,h.z),u.x=e*Math.cos(y),u.y=e*Math.sin(y),f.subVectors(h,u).normalize(),c.push(f.x,f.y,f.z),l.push(m/r),l.push(d/i)}for(let d=1;d<=i;d++)for(let m=1;m<=r;m++){let y=(r+1)*d+m-1,g=(r+1)*(d-1)+m-1,p=(r+1)*(d-1)+m,_=(r+1)*d+m;o.push(y,g,_),o.push(g,p,_)}this.setIndex(o),this.setAttribute("position",new ye(a,3)),this.setAttribute("normal",new ye(c,3)),this.setAttribute("uv",new ye(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},$l=class n extends Be{constructor(e=1,t=.4,i=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:o},i=Math.floor(i),r=Math.floor(r);let a=[],c=[],l=[],u=[],h=new w,f=new w,d=new w,m=new w,y=new w,g=new w,p=new w;for(let x=0;x<=i;++x){let b=x/i*s*Math.PI*2;_(b,s,o,e,d),_(b+.01,s,o,e,m),g.subVectors(m,d),p.addVectors(m,d),y.crossVectors(g,p),p.crossVectors(y,g),y.normalize(),p.normalize();for(let T=0;T<=r;++T){let A=T/r*Math.PI*2,M=-t*Math.cos(A),C=t*Math.sin(A);h.x=d.x+(M*p.x+C*y.x),h.y=d.y+(M*p.y+C*y.y),h.z=d.z+(M*p.z+C*y.z),c.push(h.x,h.y,h.z),f.subVectors(h,d).normalize(),l.push(f.x,f.y,f.z),u.push(x/i),u.push(T/r)}}for(let x=1;x<=i;x++)for(let b=1;b<=r;b++){let T=(r+1)*(x-1)+(b-1),A=(r+1)*x+(b-1),M=(r+1)*x+b,C=(r+1)*(x-1)+b;a.push(T,A,C),a.push(A,M,C)}this.setIndex(a),this.setAttribute("position",new ye(c,3)),this.setAttribute("normal",new ye(l,3)),this.setAttribute("uv",new ye(u,2));function _(x,b,T,A,M){let C=Math.cos(x),S=Math.sin(x),v=T/b*x,L=Math.cos(v);M.x=A*(2+L)*.5*C,M.y=A*(2+L)*S*.5,M.z=A*Math.sin(v)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},Kl=class n extends Be{constructor(e=new va(new w(-1,-1,0),new w(-1,1,0),new w(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};let o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;let a=new w,c=new w,l=new Z,u=new w,h=[],f=[],d=[],m=[];y(),this.setIndex(m),this.setAttribute("position",new ye(h,3)),this.setAttribute("normal",new ye(f,3)),this.setAttribute("uv",new ye(d,2));function y(){for(let x=0;x<t;x++)g(x);g(s===!1?t:0),_(),p()}function g(x){u=e.getPointAt(x/t,u);let b=o.normals[x],T=o.binormals[x];for(let A=0;A<=r;A++){let M=A/r*Math.PI*2,C=Math.sin(M),S=-Math.cos(M);c.x=S*b.x+C*T.x,c.y=S*b.y+C*T.y,c.z=S*b.z+C*T.z,c.normalize(),f.push(c.x,c.y,c.z),a.x=u.x+i*c.x,a.y=u.y+i*c.y,a.z=u.z+i*c.z,h.push(a.x,a.y,a.z)}}function p(){for(let x=1;x<=t;x++)for(let b=1;b<=r;b++){let T=(r+1)*(x-1)+(b-1),A=(r+1)*x+(b-1),M=(r+1)*x+b,C=(r+1)*(x-1)+b;m.push(T,A,C),m.push(A,M,C)}}function _(){for(let x=0;x<=t;x++)for(let b=0;b<=r;b++)l.x=x/t,l.y=b/r,d.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new n(new Ul[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},po=class extends Be{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){let t=[],i=new Set,r=new w,s=new w;if(e.index!==null){let o=e.attributes.position,a=e.index,c=e.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){let h=c[l],f=h.start,d=h.count;for(let m=f,y=f+d;m<y;m+=3)for(let g=0;g<3;g++){let p=a.getX(m+g),_=a.getX(m+(g+1)%3);r.fromBufferAttribute(o,p),s.fromBufferAttribute(o,_),X0(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{let o=e.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){let u=3*a+l,h=3*a+(l+1)%3;r.fromBufferAttribute(o,u),s.fromBufferAttribute(o,h),X0(r,s,i)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new ye(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};Y0=Object.freeze({__proto__:null,BoxGeometry:Qr,CapsuleGeometry:Bl,CircleGeometry:zl,ConeGeometry:Vl,CylinderGeometry:fo,DodecahedronGeometry:kl,EdgesGeometry:Gl,ExtrudeGeometry:Hl,IcosahedronGeometry:Wl,LatheGeometry:Ea,OctahedronGeometry:Ra,PlaneGeometry:ns,PolyhedronGeometry:hr,RingGeometry:Xl,ShapeGeometry:Yl,SphereGeometry:Ia,TetrahedronGeometry:ql,TorusGeometry:jl,TorusKnotGeometry:$l,TubeGeometry:Kl,WireframeGeometry:po}),mo=class extends It{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new oe(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}},Zl=class extends yn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},fr=class extends It{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new oe(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 oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yr,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},_n=class extends fr{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 Z(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ct(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 oe(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 oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=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 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.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}},Jl=class extends It{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new oe(16777215),this.specular=new oe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yr,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=za,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.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}},Ql=class extends It{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new oe(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yr,this.normalScale=new Z(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}},eu=class extends It{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yr,this.normalScale=new Z(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}},tu=class extends It{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yr,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=za,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.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}},nu=class extends It{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new oe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yr,this.normalScale=new Z(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}},iu=class extends Vt{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}};j1={convertArray:Xr,isTypedArray:Tx,getKeyframeOrder:Cx,sortedArray:_d,flattenJSON:_p,subclip:Y1,makeClipAdditive:q1},ki=class{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){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let o;n:{i:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break t}o=t.length;break n}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let c=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(r=s,s=t[--i-1],e>=s)break t}o=i,i=0;break n}break e}for(;i<o;){let a=i+o>>>1;e<t[a]?o=a:i=a+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){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let o=0;o!==r;++o)t[o]=i[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},ru=class extends ki{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:Hr,endingEnd:Hr}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,o=e+1,a=r[s],c=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case Wr:s=e,a=2*t-i;break;case ia:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(c===void 0)switch(this.getSettings_().endingEnd){case Wr:o=e,c=2*i-t;break;case ia:o=1,c=i+r[1]-r[0];break;default:o=e-1,c=t}let l=(i-t)*.5,u=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-i),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=this._offsetPrev,h=this._offsetNext,f=this._weightPrev,d=this._weightNext,m=(i-t)/(r-t),y=m*m,g=y*m,p=-f*g+2*f*y-f*m,_=(1+f)*g+(-1.5-2*f)*y+(-.5+f)*m+1,x=(-1-d)*g+(1.5+d)*y+.5*m,b=d*g-d*y;for(let T=0;T!==a;++T)s[T]=p*o[u+T]+_*o[l+T]+x*o[c+T]+b*o[h+T];return s}},Pa=class extends ki{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=(i-t)/(r-t),h=1-u;for(let f=0;f!==a;++f)s[f]=o[l+f]*h+o[c+f]*u;return s}},su=class extends ki{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Rn=class{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=Xr(t,this.TimeBufferType),this.values=Xr(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Xr(e.times,Array),values:Xr(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new su(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Pa(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ru(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Jr:t=this.InterpolantFactoryMethodDiscrete;break;case lr:t=this.InterpolantFactoryMethodLinear;break;case gl:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let 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 Jr;case this.InterpolantFactoryMethodLinear:return lr;case this.InterpolantFactoryMethodSmooth:return gl}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,o=r-1;for(;s!==r&&i[s]<e;)++s;for(;o!==-1&&i[o]>t;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let c=i[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(r!==void 0&&Tx(r))for(let a=0,c=r.length;a!==c;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===gl,s=e.length-1,o=1;for(let a=1;a<s;++a){let c=!1,l=e[a],u=e[a+1];if(l!==u&&(a!==1||l!==e[0]))if(r)c=!0;else{let h=a*i,f=h-i,d=h+i;for(let m=0;m!==i;++m){let y=t[h+m];if(y!==t[f+m]||y!==t[d+m]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];let h=a*i,f=o*i;for(let d=0;d!==i;++d)t[f+d]=t[h+d]}++o}}if(s>0){e[o]=e[s];for(let a=s*i,c=o*i,l=0;l!==i;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Rn.prototype.TimeBufferType=Float32Array;Rn.prototype.ValueBufferType=Float32Array;Rn.prototype.DefaultInterpolation=lr;Gi=class extends Rn{};Gi.prototype.ValueTypeName="bool";Gi.prototype.ValueBufferType=Array;Gi.prototype.DefaultInterpolation=Jr;Gi.prototype.InterpolantFactoryMethodLinear=void 0;Gi.prototype.InterpolantFactoryMethodSmooth=void 0;Na=class extends Rn{};Na.prototype.ValueTypeName="color";li=class extends Rn{};li.prototype.ValueTypeName="number";ou=class extends ki{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(i-t)/(r-t),l=e*a;for(let u=l+a;l!==u;l+=4)Ft.slerpFlat(s,0,o,l-a,o,l,c);return s}},Zn=class extends Rn{InterpolantFactoryMethodLinear(e){return new ou(this.times,this.values,this.getValueSize(),e)}};Zn.prototype.ValueTypeName="quaternion";Zn.prototype.DefaultInterpolation=lr;Zn.prototype.InterpolantFactoryMethodSmooth=void 0;Hi=class extends Rn{};Hi.prototype.ValueTypeName="string";Hi.prototype.ValueBufferType=Array;Hi.prototype.DefaultInterpolation=Jr;Hi.prototype.InterpolantFactoryMethodLinear=void 0;Hi.prototype.InterpolantFactoryMethodSmooth=void 0;ui=class extends Rn{};ui.prototype.ValueTypeName="vector";Wi=class{constructor(e,t=-1,i,r=Su){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=wn(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(K1(i[o]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(Rn.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,o=[];for(let a=0;a<s;a++){let c=[],l=[];c.push((a+s-1)%s,a,(a+1)%s),l.push(0,1,0);let u=Cx(c);c=_d(c,1,u),l=_d(l,1,u),!r&&c[0]===0&&(c.push(s),l.push(l[0])),o.push(new li(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let 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){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){let l=e[a],u=l.name.match(s);if(u&&u.length>1){let h=u[1],f=r[h];f||(r[h]=f=[]),f.push(l)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,f,d,m,y){if(d.length!==0){let g=[],p=[];_p(d,g,p,m),g.length!==0&&y.push(new h(f,g,p))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode,c=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let f=l[h].keys;if(!(!f||f.length===0))if(f[0].morphTargets){let d={},m;for(m=0;m<f.length;m++)if(f[m].morphTargets)for(let y=0;y<f[m].morphTargets.length;y++)d[f[m].morphTargets[y]]=-1;for(let y in d){let g=[],p=[];for(let _=0;_!==f[m].morphTargets.length;++_){let x=f[m];g.push(x.time),p.push(x.morphTarget===y?1:0)}r.push(new li(".morphTargetInfluence["+y+"]",g,p))}c=d.length*o}else{let d=".bones["+t[h].name+"]";i(ui,d+".position",f,"pos",r),i(Zn,d+".quaternion",f,"rot",r),i(ui,d+".scale",f,"scl",r)}}return r.length===0?null:new this(s,c,r,a)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let 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(){let 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)}};Ni={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={}}},La=class{constructor(e,t,i){let r=this,s=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){let h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=l.length;h<f;h+=2){let d=l[h],m=l[h+1];if(d.global&&(d.lastIndex=0),d.test(u))return m}return null}}},Rx=new La,qt=class{constructor(e){this.manager=e!==void 0?e:Rx,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let 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}};qt.DEFAULT_MATERIAL_NAME="__DEFAULT";Ti={},Sd=class extends Error{constructor(e,t){super(e),this.response=t}},Sn=class extends qt{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);let s=Ni.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Ti[e]!==void 0){Ti[e].push({onLoad:t,onProgress:i,onError:r});return}Ti[e]=[],Ti[e].push({onLoad:t,onProgress:i,onError:r});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let u=Ti[e],h=l.body.getReader(),f=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),d=f?parseInt(f):0,m=d!==0,y=0,g=new ReadableStream({start(p){_();function _(){h.read().then(({done:x,value:b})=>{if(x)p.close();else{y+=b.byteLength;let T=new ProgressEvent("progress",{lengthComputable:m,loaded:y,total:d});for(let A=0,M=u.length;A<M;A++){let C=u[A];C.onProgress&&C.onProgress(T)}p.enqueue(b),_()}})}}});return new Response(g)}else throw new Sd(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return l.json();default:if(a===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),f=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(f);return l.arrayBuffer().then(m=>d.decode(m))}}}).then(l=>{Ni.add(e,l);let u=Ti[e];delete Ti[e];for(let h=0,f=u.length;h<f;h++){let d=u[h];d.onLoad&&d.onLoad(l)}}).catch(l=>{let u=Ti[e];if(u===void 0)throw this.manager.itemError(e),l;delete Ti[e];for(let h=0,f=u.length;h<f;h++){let d=u[h];d.onError&&d.onError(l)}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}},bd=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Sn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t=[];for(let i=0;i<e.length;i++){let r=Wi.parse(e[i]);t.push(r)}return t}},Md=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=[],a=new uo,c=new Sn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(s.withCredentials);let l=0;function u(h){c.load(e[h],function(f){let d=s.parse(f,!0);o[h]={width:d.width,height:d.height,format:d.format,mipmaps:d.mipmaps},l+=1,l===6&&(d.mipmapCount===1&&(a.minFilter=yt),a.image=o,a.format=d.format,a.needsUpdate=!0,t&&t(a))},i,r)}if(Array.isArray(e))for(let h=0,f=e.length;h<f;++h)u(h);else c.load(e,function(h){let f=s.parse(h,!0);if(f.isCubemap){let d=f.mipmaps.length/f.mipmapCount;for(let m=0;m<d;m++){o[m]={mipmaps:[]};for(let y=0;y<f.mipmapCount;y++)o[m].mipmaps.push(f.mipmaps[m*f.mipmapCount+y]),o[m].format=f.format,o[m].width=f.width,o[m].height=f.height}a.image=o}else a.image.width=f.width,a.image.height=f.height,a.mipmaps=f.mipmaps;f.mipmapCount===1&&(a.minFilter=yt),a.format=f.format,a.needsUpdate=!0,t&&t(a)},i,r);return a}},as=class extends qt{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=Ni.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=ca("img");function c(){u(),Ni.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(h){u(),r&&r(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}},vd=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=new es;s.colorSpace=lt;let o=new as(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(e[l],function(u){s.images[l]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let l=0;l<e.length;++l)c(l);return s}},Ad=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Ui,a=new Sn(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(c){let l;try{l=s.parse(c)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:Xt,o.wrapT=l.wrapT!==void 0?l.wrapT:Xt,o.magFilter=l.magFilter!==void 0?l.magFilter:yt,o.minFilter=l.minFilter!==void 0?l.minFilter:yt,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0?o.colorSpace=l.colorSpace:l.encoding!==void 0&&(o.encoding=l.encoding),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=jn),l.mipmapCount===1&&(o.minFilter=yt),l.generateMipmaps!==void 0&&(o.generateMipmaps=l.generateMipmaps),o.needsUpdate=!0,t&&t(o,l)},i,r),o}},cs=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=new Rt,o=new as(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}},hi=class extends it{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new oe(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){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},go=class extends hi{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(it.DEFAULT_UP),this.updateMatrix(),this.groundColor=new oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},lf=new we,q0=new w,j0=new w,Oa=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Z(512,512),this.map=null,this.mapPass=null,this.matrix=new we,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ts,this._frameExtents=new Z(1,1),this._viewportCount=1,this._viewports=[new tt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;q0.setFromMatrixPosition(e.matrixWorld),t.position.copy(q0),j0.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(j0),t.updateMatrixWorld(),lf.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lf),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(lf)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Ed=class extends Oa{constructor(){super(new vt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=Qs*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}},dr=class extends hi{constructor(e,t,i=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(it.DEFAULT_UP),this.updateMatrix(),this.target=new it,this.distance=i,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Ed}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}},$0=new we,jo=new w,uf=new w,wd=class extends Oa{constructor(){super(new vt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Z(4,2),this._viewportCount=6,this._viewports=[new tt(2,1,1,1),new tt(0,1,1,1),new tt(3,1,1,1),new tt(1,1,1,1),new tt(3,0,1,1),new tt(1,0,1,1)],this._cubeDirections=[new w(1,0,0),new w(-1,0,0),new w(0,0,1),new w(0,0,-1),new w(0,1,0),new w(0,-1,0)],this._cubeUps=[new w(0,1,0),new w(0,1,0),new w(0,1,0),new w(0,1,0),new w(0,0,1),new w(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),jo.setFromMatrixPosition(e.matrixWorld),i.position.copy(jo),uf.copy(i.position),uf.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(uf),i.updateMatrixWorld(),r.makeTranslation(-jo.x,-jo.y,-jo.z),$0.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix($0)}},pr=class extends hi{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 wd}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}},Td=class extends Oa{constructor(){super(new ci(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},mr=class extends hi{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(it.DEFAULT_UP),this.updateMatrix(),this.target=new it,this.shadow=new Td}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},yo=class extends hi{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},au=class extends hi{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){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},cu=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new w)}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){let i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],1.092548*(i*r)),t.addScaledVector(o[5],1.092548*(r*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(i*s)),t.addScaledVector(o[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){let i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*r),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*i),t.addScaledVector(o[4],2*.429043*i*r),t.addScaledVector(o[5],2*.429043*r*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*i*s),t.addScaledVector(o[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){let i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let 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)}},lu=class extends hi{constructor(e=new cu,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){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},uu=class n extends qt{constructor(e){super(e),this.textures={}}load(e,t,i,r){let s=this,o=new Sn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}let r=n.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 oe().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.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(let s in e.uniforms){let o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=i(o.value);break;case"c":r.uniforms[s].value=new oe().setHex(o.value);break;case"v2":r.uniforms[s].value=new Z().fromArray(o.value);break;case"v3":r.uniforms[s].value=new w().fromArray(o.value);break;case"v4":r.uniforms[s].value=new tt().fromArray(o.value);break;case"m3":r.uniforms[s].value=new Ye().fromArray(o.value);break;case"m4":r.uniforms[s].value=new we().fromArray(o.value);break;default:r.uniforms[s].value=o.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(let 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 Z().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.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 Z().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}static createMaterialFromType(e){let t={ShadowMaterial:mo,SpriteMaterial:xa,RawShaderMaterial:Zl,ShaderMaterial:yn,PointsMaterial:rs,MeshPhysicalMaterial:_n,MeshStandardMaterial:fr,MeshPhongMaterial:Jl,MeshToonMaterial:Ql,MeshNormalMaterial:eu,MeshLambertMaterial:tu,MeshDepthMaterial:ga,MeshDistanceMaterial:ya,MeshBasicMaterial:sn,MeshMatcapMaterial:nu,LineDashedMaterial:iu,LineBasicMaterial:Vt,Material:It};return new t[e]}},Jn=class{static decodeText(e){if(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){let 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)}},xo=class extends Be{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},hu=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Sn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(d,m){if(t[m]!==void 0)return t[m];let g=d.interleavedBuffers[m],p=s(d,g.buffer),_=Ws(g.type,p),x=new Vi(_,g.stride);return x.uuid=g.uuid,t[m]=x,x}function s(d,m){if(i[m]!==void 0)return i[m];let g=d.arrayBuffers[m],p=new Uint32Array(g).buffer;return i[m]=p,p}let o=e.isInstancedBufferGeometry?new xo:new Be,a=e.data.index;if(a!==void 0){let d=Ws(a.type,a.array);o.setIndex(new Ze(d,1))}let c=e.data.attributes;for(let d in c){let m=c[d],y;if(m.isInterleavedBufferAttribute){let g=r(e.data,m.data);y=new Yt(g,m.itemSize,m.offset,m.normalized)}else{let g=Ws(m.type,m.array),p=m.isInstancedBufferAttribute?Kn:Ze;y=new p(g,m.itemSize,m.normalized)}m.name!==void 0&&(y.name=m.name),m.usage!==void 0&&y.setUsage(m.usage),o.setAttribute(d,y)}let l=e.data.morphAttributes;if(l)for(let d in l){let m=l[d],y=[];for(let g=0,p=m.length;g<p;g++){let _=m[g],x;if(_.isInterleavedBufferAttribute){let b=r(e.data,_.data);x=new Yt(b,_.itemSize,_.offset,_.normalized)}else{let b=Ws(_.type,_.array);x=new Ze(b,_.itemSize,_.normalized)}_.name!==void 0&&(x.name=_.name),y.push(x)}o.morphAttributes[d]=y}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let d=0,m=h.length;d!==m;++d){let y=h[d];o.addGroup(y.start,y.count,y.materialIndex)}let f=e.data.boundingSphere;if(f!==void 0){let d=new w;f.center!==void 0&&d.fromArray(f.center),o.boundingSphere=new _t(d,f.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}},Cd=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=this.path===""?Jn.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;let a=new Sn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){let l=null;try{l=JSON.parse(c)}catch(h){r!==void 0&&r(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}let u=l.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(l,t)},i,r)}async loadAsync(e,t){let i=this,r=this.path===""?Jn.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let s=new Sn(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);let o=await s.loadAsync(e,t),a=JSON.parse(o),c=a.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(a)}parse(e,t){let i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,function(){t!==void 0&&t(l)}),a=this.parseTextures(e.textures,o),c=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,s,c,a,i),u=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,u),t!==void 0){let h=!1;for(let f in o)if(o[f].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(l)}return l}async parseAsync(e){let t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),a=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,r,a,o,t),l=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,l),c}parseShapes(e){let t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){let s=new Fi().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){let i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=new oo().fromJSON(e[s],r);i[a.uuid]=a}return i}parseGeometries(e,t){let i={};if(e!==void 0){let r=new hu;for(let s=0,o=e.length;s<o;s++){let a,c=e[s];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":a=r.parse(c);break;default:c.type in Y0?a=Y0[c.type].fromJSON(c,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`)}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),c.userData!==void 0&&(a.userData=c.userData),i[c.uuid]=a}}return i}parseMaterials(e,t){let i={},r={};if(e!==void 0){let s=new uu;s.setTextures(t);for(let o=0,a=e.length;o<a;o++){let c=e[o];i[c.uuid]===void 0&&(i[c.uuid]=s.parse(c)),r[c.uuid]=i[c.uuid]}}return r}parseAnimations(e){let t={};if(e!==void 0)for(let i=0;i<e.length;i++){let r=e[i],s=Wi.parse(r);t[s.uuid]=s}return t}parseImages(e,t){let i=this,r={},s;function o(c){return i.manager.itemStart(c),s.load(c,function(){i.manager.itemEnd(c)},void 0,function(){i.manager.itemError(c),i.manager.itemEnd(c)})}function a(c){if(typeof c=="string"){let l=c,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:i.resourcePath+l;return o(u)}else return c.data?{data:Ws(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){let c=new La(t);s=new as(c),s.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l<u;l++){let h=e[l],f=h.url;if(Array.isArray(f)){let d=[];for(let m=0,y=f.length;m<y;m++){let g=f[m],p=a(g);p!==null&&(p instanceof HTMLImageElement?d.push(p):d.push(new Ui(p.data,p.width,p.height)))}r[h.uuid]=new Ii(d)}else{let d=a(h.url);r[h.uuid]=new Ii(d)}}}return r}async parseImagesAsync(e){let t=this,i={},r;async function s(o){if(typeof o=="string"){let a=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await r.loadAsync(c)}else return o.data?{data:Ws(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new as(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.url;if(Array.isArray(l)){let u=[];for(let h=0,f=l.length;h<f;h++){let d=l[h],m=await s(d);m!==null&&(m instanceof HTMLImageElement?u.push(m):u.push(new Ui(m.data,m.width,m.height)))}i[c.uuid]=new Ii(u)}else{let u=await s(c.url);i[c.uuid]=new Ii(u)}}}return i}parseTextures(e,t){function i(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}let r={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=e[s];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);let c=t[a.image],l=c.data,u;Array.isArray(l)?(u=new es,l.length===6&&(u.needsUpdate=!0)):(l&&l.data?u=new Ui:u=new Rt,l&&(u.needsUpdate=!0)),u.source=c,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=i(a.mapping,Z1)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=i(a.wrap[0],K0),u.wrapT=i(a.wrap[1],K0)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.encoding!==void 0&&(u.encoding=a.encoding),a.minFilter!==void 0&&(u.minFilter=i(a.minFilter,Z0)),a.magFilter!==void 0&&(u.magFilter=i(a.magFilter,Z0)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),r[a.uuid]=u}return r}parseObject(e,t,i,r,s){let o;function a(f){return t[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",f),t[f]}function c(f){if(f!==void 0){if(Array.isArray(f)){let d=[];for(let m=0,y=f.length;m<y;m++){let g=f[m];i[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),d.push(i[g])}return d}return i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),i[f]}}function l(f){return r[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",f),r[f]}let u,h;switch(e.type){case"Scene":o=new ro,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new oe(e.background):o.background=l(e.background)),e.environment!==void 0&&(o.environment=l(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new Cl(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Tl(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity);break;case"PerspectiveCamera":o=new vt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new ci(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new yo(e.color,e.intensity);break;case"DirectionalLight":o=new mr(e.color,e.intensity);break;case"PointLight":o=new pr(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new au(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new dr(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new go(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new lu().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),h=c(e.material),o=new so(u,h),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),h=c(e.material),o=new ft(u,h);break;case"InstancedMesh":u=a(e.geometry),h=c(e.material);let f=e.count,d=e.instanceMatrix,m=e.instanceColor;o=new ao(u,h,f),o.instanceMatrix=new Kn(new Float32Array(d.array),16),m!==void 0&&(o.instanceColor=new Kn(new Float32Array(m.array),m.itemSize));break;case"BatchedMesh":u=a(e.geometry),h=c(e.material),o=new Pl(e.maxGeometryCount,e.maxVertexCount,e.maxIndexCount,h),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(y=>{let g=new xt;g.min.fromArray(y.boxMin),g.max.fromArray(y.boxMax);let p=new _t;return p.radius=y.sphereRadius,p.center.fromArray(y.sphereCenter),{boxInitialized:y.boxInitialized,box:g,sphereInitialized:y.sphereInitialized,sphere:p}}),o._maxGeometryCount=e.maxGeometryCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=l(e.matricesTexture.uuid);break;case"LOD":o=new Il;break;case"Line":o=new Un(a(e.geometry),c(e.material));break;case"LineLoop":o=new co(a(e.geometry),c(e.material));break;case"LineSegments":o=new xn(a(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new lo(a(e.geometry),c(e.material));break;case"Sprite":o=new Rl(c(e.material));break;case"Group":o=new Dn;break;case"Bone":o=new is;break;default:o=new it}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){let f=e.children;for(let d=0;d<f.length;d++)o.add(this.parseObject(f[d],t,i,r,s))}if(e.animations!==void 0){let f=e.animations;for(let d=0;d<f.length;d++){let m=f[d];o.animations.push(s[m])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);let f=e.levels;for(let d=0;d<f.length;d++){let m=f[d],y=o.getObjectByProperty("uuid",m.object);y!==void 0&&o.addLevel(y,m.distance,m.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){let r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}},Z1={UVMapping:xu,CubeReflectionMapping:Bi,CubeRefractionMapping:cr,EquirectangularReflectionMapping:$r,EquirectangularRefractionMapping:na,CubeUVReflectionMapping:_o},K0={RepeatWrapping:zi,ClampToEdgeWrapping:Xt,MirroredRepeatWrapping:Kr},Z0={NearestFilter:Mt,NearestMipmapNearestFilter:Ks,NearestMipmapLinearFilter:qr,LinearFilter:yt,LinearMipmapNearestFilter:Va,LinearMipmapLinearFilter:jn},Da=class extends qt{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);let s=this,o=Ni.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(l=>{t&&t(l),s.manager.itemEnd(e)}).catch(l=>{r&&r(l)});return}return setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;let c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){return Ni.add(e,l),t&&t(l),s.manager.itemEnd(e),l}).catch(function(l){r&&r(l),Ni.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});Ni.add(e,c),s.manager.itemStart(e)}},Ua=class{static getContext(){return rl===void 0&&(rl=new(window.AudioContext||window.webkitAudioContext)),rl}static setContext(e){rl=e}},Rd=class extends qt{constructor(e){super(e)}load(e,t,i,r){let s=this,o=new Sn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{let l=c.slice(0);Ua.getContext().decodeAudioData(l,function(h){t(h)}).catch(a)}catch(l){a(l)}},i,r);function a(c){r?r(c):console.error(c),s.manager.itemError(e)}}},J0=new we,Q0=new we,Dr=new we,Id=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new vt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new vt,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){let 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,Dr.copy(e.projectionMatrix);let r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(jr*t.fov*.5)/t.zoom,a,c;Q0.elements[12]=-r,J0.elements[12]=r,a=-o*t.aspect+s,c=o*t.aspect+s,Dr.elements[0]=2*t.near/(c-a),Dr.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(Dr),a=-o*t.aspect-s,c=o*t.aspect-s,Dr.elements[0]=2*t.near/(c-a),Dr.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(Dr)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Q0),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(J0)}},fu=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=ey(),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){let t=ey();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};Ur=new w,ty=new Ft,J1=new w,Fr=new w,Pd=class extends it{constructor(){super(),this.type="AudioListener",this.context=Ua.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new fu}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(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Ur,ty,J1),Fr.set(0,0,-1).applyQuaternion(ty),t.positionX){let r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Ur.x,r),t.positionY.linearRampToValueAtTime(Ur.y,r),t.positionZ.linearRampToValueAtTime(Ur.z,r),t.forwardX.linearRampToValueAtTime(Fr.x,r),t.forwardY.linearRampToValueAtTime(Fr.y,r),t.forwardZ.linearRampToValueAtTime(Fr.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(Ur.x,Ur.y,Ur.z),t.setOrientation(Fr.x,Fr.y,Fr.z,i.x,i.y,i.z)}},du=class extends it{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;let 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.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){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.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){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!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}},Br=new w,ny=new Ft,Q1=new w,zr=new w,Nd=class extends du{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(Br,ny,Q1),zr.set(0,0,1).applyQuaternion(ny);let t=this.panner;if(t.positionX){let i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Br.x,i),t.positionY.linearRampToValueAtTime(Br.y,i),t.positionZ.linearRampToValueAtTime(Br.z,i),t.orientationX.linearRampToValueAtTime(zr.x,i),t.orientationY.linearRampToValueAtTime(zr.y,i),t.orientationZ.linearRampToValueAtTime(zr.z,i)}else t.setPosition(Br.x,Br.y,Br.z),t.setOrientation(zr.x,zr.y,zr.z)}},Ld=class{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,t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}},pu=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,o;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)i[s+a]=i[a];o=t}else{o+=t;let a=t/o;this._mixBufferRegion(i,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(e){let 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){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let c=t*this._origIndex;this._mixBufferRegion(i,r,c,1-s,t)}o>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(i[c]!==i[c+t]){a.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,o=r;s!==o;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let 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(){let 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 o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,r){Ft.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let o=this._workIndex*s;Ft.multiplyQuaternionsFlat(e,o,e,t,e,i),Ft.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,i,r,s){let o=1-r;for(let a=0;a!==s;++a){let c=t+a;e[c]=e[c]*o+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let o=0;o!==s;++o){let a=t+o;e[a]=e[a]+e[i+o]*r}}},Sp="\\[\\]\\.:\\/",eC=new RegExp("["+Sp+"]","g"),bp="[^"+Sp+"]",tC="[^"+Sp.replace("\\.","")+"]",nC=/((?:WC+[\/:])*)/.source.replace("WC",bp),iC=/(WCOD+)?/.source.replace("WCOD",tC),rC=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",bp),sC=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",bp),oC=new RegExp("^"+nC+iC+rC+sC+"$"),aC=["material","materials","bones","map"],Od=class{constructor(e,t,i){let r=i||ot.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},ot=class n{constructor(e,t,i){this.path=t,this.parsedPath=i||n.parseTrackName(t),this.node=n.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 n.Composite(e,t,i):new n(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(eC,"")}static parseTrackName(e){let t=oC.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let 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){let s=i.nodeName.substring(r+1);aC.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){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let c=i(a.children);if(c)return c}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let 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){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let 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){let 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,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=n.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 l=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===l){l=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(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let o=e[r];if(o===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=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])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};ot.Composite=Od;ot.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ot.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ot.prototype.GetterByBindingType=[ot.prototype._getValue_direct,ot.prototype._getValue_array,ot.prototype._getValue_arrayElement,ot.prototype._getValue_toArray];ot.prototype.SetterByBindingTypeAndVersioning=[[ot.prototype._setValue_direct,ot.prototype._setValue_direct_setNeedsUpdate,ot.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_array,ot.prototype._setValue_array_setNeedsUpdate,ot.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_arrayElement,ot.prototype._setValue_arrayElement_setNeedsUpdate,ot.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_fromArray,ot.prototype._setValue_fromArray_setNeedsUpdate,ot.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];Dd=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=wn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let 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={};let 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(){let e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length,a,c=e.length,l=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){let f=arguments[u],d=f.uuid,m=t[d];if(m===void 0){m=c++,t[d]=m,e.push(f);for(let y=0,g=o;y!==g;++y)s[y].push(new ot(f,i[y],r[y]))}else if(m<l){a=e[m];let y=--l,g=e[y];t[g.uuid]=m,e[m]=g,t[d]=y,e[y]=f;for(let p=0,_=o;p!==_;++p){let x=s[p],b=x[y],T=x[m];x[m]=b,T===void 0&&(T=new ot(f,i[p],r[p])),x[y]=T}}else e[m]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){let c=arguments[o],l=c.uuid,u=t[l];if(u!==void 0&&u>=s){let h=s++,f=e[h];t[f.uuid]=u,e[u]=f,t[l]=h,e[h]=c;for(let d=0,m=r;d!==m;++d){let y=i[d],g=y[h],p=y[u];y[u]=g,y[h]=p}}}this.nCachedObjects_=s}uncache(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length,s=this.nCachedObjects_,o=e.length;for(let a=0,c=arguments.length;a!==c;++a){let l=arguments[a],u=l.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<s){let f=--s,d=e[f],m=--o,y=e[m];t[d.uuid]=h,e[h]=d,t[y.uuid]=f,e[f]=y,e.pop();for(let g=0,p=r;g!==p;++g){let _=i[g],x=_[f],b=_[m];_[h]=x,_[f]=b,_.pop()}}else{let f=--o,d=e[f];f>0&&(t[d.uuid]=h),e[h]=d,e.pop();for(let m=0,y=r;m!==y;++m){let g=i[m];g[h]=g[f],g.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){let i=this._bindingsIndicesByPath,r=i[e],s=this._bindings;if(r!==void 0)return s[r];let o=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,h=new Array(l);r=s.length,i[e]=r,o.push(e),a.push(t),s.push(h);for(let f=u,d=c.length;f!==d;++f){let m=c[f];h[f]=new ot(m,e,t)}return h}unsubscribe_(e){let t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){let r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],l=e[a];t[l]=i,o[i]=c,o.pop(),s[i]=s[a],s.pop(),r[i]=r[a],r.pop()}}},mu=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,o=s.length,a=new Array(o),c={endingStart:Hr,endingEnd:Hr};for(let l=0;l!==o;++l){let u=s[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=ex,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){let r=this._clip.duration,s=e._clip.duration,o=s/r,a=r/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let 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){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let c=a.parameterPositions,l=a.sampleValues;return c[0]=s,c[1]=s+i,l[0]=e/o,l[1]=t/o,this}stopWarping(){let 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}let s=this._startTime;if(s!==null){let c=(e-s)*i;c<0||i===0?t=0:(this._startTime=null,t=i*c)}t*=this._updateTimeScale(e);let o=this._updateTime(t),a=this._updateWeight(e);if(a>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case fp:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulateAdditive(a);break;case Su:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let 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;let i=this._timeScaleInterpolant;if(i!==null){let 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){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,o=i===tx;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===Qy){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,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){let a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);let c=this.repetitions-s;if(c<=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(c===1){let l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=Wr,r.endingEnd=Wr):(e?r.endingStart=this.zeroSlopeAtStart?Wr:Hr:r.endingStart=ia,t?r.endingEnd=this.zeroSlopeAtEnd?Wr:Hr:r.endingEnd=ia)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,c=o.sampleValues;return a[0]=s,c[0]=t,a[1]=s+e,c[1]=i,this}},cC=new Float32Array(1),Ud=class extends $n{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,a=e._interpolants,c=i.uuid,l=this._bindingsByRootAndName,u=l[c];u===void 0&&(u={},l[c]=u);for(let h=0;h!==s;++h){let f=r[h],d=f.name,m=u[d];if(m!==void 0)++m.referenceCount,o[h]=m;else{if(m=o[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,c,d));continue}let y=t&&t._propertyBindings[h].binding.parsedPath;m=new pu(ot.create(i,d,y),f.ValueTypeName,f.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,c,d),o[h]=m}a[h].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let 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)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let 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;let 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){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{let a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,o=this._actionsByClip,a=o[s],c=a.knownActions,l=c[c.length-1],u=e._byClipCacheIndex;l._byClipCacheIndex=u,c[u]=l,c.pop(),e._byClipCacheIndex=null;let h=a.actionByRoot,f=(e._localRoot||this._root).uuid;delete h[f],c.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let 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){let 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){let r=this._bindingsByRootAndName,s=this._bindings,o=r[t];o===void 0&&(o={},r[t]=o),o[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,o=this._bindingsByRootAndName,a=o[r],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(e){let 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){let 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(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new Pa(new Float32Array(2),new Float32Array(2),1,cC),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let 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){let r=t||this._root,s=r.uuid,o=typeof e=="string"?Wi.findByName(r,e):e,a=o!==null?o.uuid:e,c=this._actionsByClip[a],l=null;if(i===void 0&&(o!==null?i=o.blendMode:i=Su),c!==void 0){let h=c.actionByRoot[s];if(h!==void 0&&h.blendMode===i)return h;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;let u=new mu(this,o,t,i);return this._bindAction(u,l),this._addInactiveAction(u,a,s),u}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?Wi.findByName(i,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,o);let a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);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){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let o=s.knownActions;for(let a=0,c=o.length;a!==c;++a){let l=o[a];this._deactivateAction(l);let u=l._cacheIndex,h=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let o in i){let a=i[o].actionByRoot,c=a[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},Fd=class n{constructor(e){this.value=e}clone(){return new n(this.value.clone===void 0?this.value:this.value.clone())}},lC=0,Bd=class extends $n{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:lC++}),this.name="",this.usage=aa,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let 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;let t=e.uniforms;this.uniforms.length=0;for(let i=0,r=t.length;i<r;i++){let s=Array.isArray(t[i])?t[i]:[t[i]];for(let o=0;o<s.length;o++)this.uniforms.push(s[o].clone())}return this}clone(){return new this.constructor().copy(this)}},gr=class extends Vi{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){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},zd=class{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}},Vd=class{constructor(e,t,i=0,r=1/0){this.ray=new ur(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new to,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)}intersectObject(e,t=!0,i=[]){return kd(e,this,i,t),i.sort(iy),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)kd(e[r],this,i,t);return i.sort(iy),i}};Gd=class{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(Ct(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},Hd=class{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)}},ry=new Z,Wd=class{constructor(e=new Z(1/0,1/0),t=new Z(-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){let i=ry.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,ry).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)}},sy=new w,sl=new w,Fa=class{constructor(e=new w,t=new w){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){sy.subVectors(e,this.start),sl.subVectors(this.end,this.start);let i=sl.dot(sl),s=sl.dot(sy)/i;return t&&(s=Ct(s,0,1)),s}closestPointToPoint(e,t,i){let 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)}},oy=new w,Xd=class extends it{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Be,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 o=0,a=1,c=32;o<c;o++,a++){let l=o/c*Math.PI*2,u=a/c*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(u),Math.sin(u),1)}i.setAttribute("position",new ye(r,3));let s=new Vt({fog:!1,toneMapped:!1});this.cone=new xn(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);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),oy.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(oy),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},ir=new w,ol=new we,hf=new we,Yd=class extends xn{constructor(e){let t=Ix(e),i=new Be,r=[],s=[],o=new oe(0,0,1),a=new oe(0,1,0);for(let l=0;l<t.length;l++){let u=t[l];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}i.setAttribute("position",new ye(r,3)),i.setAttribute("color",new ye(s,3));let c=new Vt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,c),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let t=this.bones,i=this.geometry,r=i.getAttribute("position");hf.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){let a=t[s];a.parent&&a.parent.isBone&&(ol.multiplyMatrices(hf,a.matrixWorld),ir.setFromMatrixPosition(ol),r.setXYZ(o,ir.x,ir.y,ir.z),ol.multiplyMatrices(hf,a.parent.matrixWorld),ir.setFromMatrixPosition(ol),r.setXYZ(o+1,ir.x,ir.y,ir.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};qd=class extends ft{constructor(e,t,i){let r=new Ia(t,4,2),s=new sn({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)}},uC=new w,ay=new oe,cy=new oe,jd=class extends it{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";let r=new Ra(t);r.rotateY(Math.PI*.5),this.material=new sn({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let s=r.getAttribute("position"),o=new Float32Array(s.count*3);r.setAttribute("color",new Ze(o,3)),this.add(new ft(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let t=e.geometry.getAttribute("color");ay.copy(this.light.color),cy.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){let s=i<r/2?ay:cy;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(uC.setFromMatrixPosition(this.light.matrixWorld).negate())}},Ba=class extends xn{constructor(e=10,t=10,i=4473924,r=8947848){i=new oe(i),r=new oe(r);let s=t/2,o=e/t,a=e/2,c=[],l=[];for(let f=0,d=0,m=-a;f<=t;f++,m+=o){c.push(-a,0,m,a,0,m),c.push(m,0,-a,m,0,a);let y=f===s?i:r;y.toArray(l,d),d+=3,y.toArray(l,d),d+=3,y.toArray(l,d),d+=3,y.toArray(l,d),d+=3}let u=new Be;u.setAttribute("position",new ye(c,3)),u.setAttribute("color",new ye(l,3));let h=new Vt({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},$d=class extends xn{constructor(e=10,t=16,i=8,r=64,s=4473924,o=8947848){s=new oe(s),o=new oe(o);let a=[],c=[];if(t>1)for(let h=0;h<t;h++){let f=h/t*(Math.PI*2),d=Math.sin(f)*e,m=Math.cos(f)*e;a.push(0,0,0),a.push(d,0,m);let y=h&1?s:o;c.push(y.r,y.g,y.b),c.push(y.r,y.g,y.b)}for(let h=0;h<i;h++){let f=h&1?s:o,d=e-e/i*h;for(let m=0;m<r;m++){let y=m/r*(Math.PI*2),g=Math.sin(y)*d,p=Math.cos(y)*d;a.push(g,0,p),c.push(f.r,f.g,f.b),y=(m+1)/r*(Math.PI*2),g=Math.sin(y)*d,p=Math.cos(y)*d,a.push(g,0,p),c.push(f.r,f.g,f.b)}}let l=new Be;l.setAttribute("position",new ye(a,3)),l.setAttribute("color",new ye(c,3));let u=new Vt({vertexColors:!0,toneMapped:!1});super(l,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},ly=new w,al=new w,uy=new w,Kd=class extends it{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 Be;r.setAttribute("position",new ye([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Vt({fog:!1,toneMapped:!1});this.lightPlane=new Un(r,s),this.add(this.lightPlane),r=new Be,r.setAttribute("position",new ye([0,0,0,0,0,1],3)),this.targetLine=new Un(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),ly.setFromMatrixPosition(this.light.matrixWorld),al.setFromMatrixPosition(this.light.target.matrixWorld),uy.subVectors(al,ly),this.lightPlane.lookAt(al),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(al),this.targetLine.scale.z=uy.length()}},cl=new w,Tt=new io,Zd=class extends xn{constructor(e){let t=new Be,i=new Vt({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,y){c(m),c(y)}function c(m){r.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(r.length/3-1)}t.setAttribute("position",new ye(r,3)),t.setAttribute("color",new ye(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=o,this.update();let l=new oe(16755200),u=new oe(16711680),h=new oe(43775),f=new oe(16777215),d=new oe(3355443);this.setColors(l,u,h,f,d)}setColors(e,t,i,r,s){let 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(){let e=this.geometry,t=this.pointMap,i=1,r=1;Tt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Nt("c",t,e,Tt,0,0,-1),Nt("t",t,e,Tt,0,0,1),Nt("n1",t,e,Tt,-i,-r,-1),Nt("n2",t,e,Tt,i,-r,-1),Nt("n3",t,e,Tt,-i,r,-1),Nt("n4",t,e,Tt,i,r,-1),Nt("f1",t,e,Tt,-i,-r,1),Nt("f2",t,e,Tt,i,-r,1),Nt("f3",t,e,Tt,-i,r,1),Nt("f4",t,e,Tt,i,r,1),Nt("u1",t,e,Tt,i*.7,r*1.1,-1),Nt("u2",t,e,Tt,-i*.7,r*1.1,-1),Nt("u3",t,e,Tt,0,r*2,-1),Nt("cf1",t,e,Tt,-i,0,1),Nt("cf2",t,e,Tt,i,0,1),Nt("cf3",t,e,Tt,0,-r,1),Nt("cf4",t,e,Tt,0,r,1),Nt("cn1",t,e,Tt,-i,0,-1),Nt("cn2",t,e,Tt,i,0,-1),Nt("cn3",t,e,Tt,0,-r,-1),Nt("cn4",t,e,Tt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};ll=new xt,Jd=class extends xn{constructor(e,t=16776960){let 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(24),s=new Be;s.setIndex(new Ze(i,1)),s.setAttribute("position",new Ze(r,3)),super(s,new Vt({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&&ll.setFromObject(this.object),ll.isEmpty())return;let t=ll.min,i=ll.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()}},Qd=class extends xn{constructor(e,t=16776960){let 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 Be;s.setIndex(new Ze(i,1)),s.setAttribute("position",new ye(r,3)),super(s,new Vt({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let 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()}},ep=class extends Un{constructor(e,t=1,i=16776960){let 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],o=new Be;o.setAttribute("position",new ye(s,3)),o.computeBoundingSphere(),super(o,new Vt({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;let a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new Be;c.setAttribute("position",new ye(a,3)),c.computeBoundingSphere(),this.add(new ft(c,new sn({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()}},hy=new w,tp=class extends it{constructor(e=new w(0,0,1),t=new w(0,0,0),i=1,r=16776960,s=i*.2,o=s*.2){super(),this.type="ArrowHelper",ul===void 0&&(ul=new Be,ul.setAttribute("position",new ye([0,0,0,0,1,0],3)),ff=new fo(0,.5,1,5,1),ff.translate(0,-.5,0)),this.position.copy(t),this.line=new Un(ul,new Vt({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new ft(ff,new sn({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,o)}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{hy.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(hy,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()}},np=class extends xn{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Be;r.setAttribute("position",new ye(t,3)),r.setAttribute("color",new ye(i,3));let s=new Vt({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new oe,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},ip=class{constructor(){this.type="ShapePath",this.color=new oe,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new ss,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,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(p){let _=[];for(let x=0,b=p.length;x<b;x++){let T=p[x],A=new Fi;A.curves=T.curves,_.push(A)}return _}function i(p,_){let x=_.length,b=!1;for(let T=x-1,A=0;A<x;T=A++){let M=_[T],C=_[A],S=C.x-M.x,v=C.y-M.y;if(Math.abs(v)>Number.EPSILON){if(v<0&&(M=_[A],S=-S,C=_[T],v=-v),p.y<M.y||p.y>C.y)continue;if(p.y===M.y){if(p.x===M.x)return!0}else{let L=v*(p.x-M.x)-S*(p.y-M.y);if(L===0)return!0;if(L<0)continue;b=!b}}else{if(p.y!==M.y)continue;if(C.x<=p.x&&p.x<=M.x||M.x<=p.x&&p.x<=C.x)return!0}}return b}let r=ai.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,c,l=[];if(s.length===1)return a=s[0],c=new Fi,c.curves=a.curves,l.push(c),l;let u=!r(s[0].getPoints());u=e?!u:u;let h=[],f=[],d=[],m=0,y;f[m]=void 0,d[m]=[];for(let p=0,_=s.length;p<_;p++)a=s[p],y=a.getPoints(),o=r(y),o=e?!o:o,o?(!u&&f[m]&&m++,f[m]={s:new Fi,p:y},f[m].s.curves=a.curves,u&&m++,d[m]=[]):d[m].push({h:a,p:y[0]});if(!f[0])return t(s);if(f.length>1){let p=!1,_=0;for(let x=0,b=f.length;x<b;x++)h[x]=[];for(let x=0,b=f.length;x<b;x++){let T=d[x];for(let A=0;A<T.length;A++){let M=T[A],C=!0;for(let S=0;S<f.length;S++)i(M.p,f[S].p)&&(x!==S&&_++,C?(C=!1,h[S].push(M)):p=!0);C&&h[x].push(M)}}_>0&&p===!1&&(d=h)}let g;for(let p=0,_=f.length;p<_;p++){c=f[p].s,l.push(c),g=d[p];for(let x=0,b=g.length;x<b;x++)c.holes.push(g[x].h)}return l}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"160"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="160")});function Dm(n,e){if(e===dp)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===So||e===ka){let t=n.getIndex();if(t===null){let o=[],a=n.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);n.setIndex(o),t=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}let i=t.count-2,r=[];if(e===So)for(let o=1;o<=i;o++)r.push(t.getX(0)),r.push(t.getX(o)),r.push(t.getX(o+1));else for(let o=0;o<i;o++)o%2===0?(r.push(t.getX(o)),r.push(t.getX(o+1)),r.push(t.getX(o+2))):(r.push(t.getX(o+2)),r.push(t.getX(o+1)),r.push(t.getX(o)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let s=n.clone();return s.setIndex(r),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}var Eb=Eh(()=>{ei()});var Pb={};wg(Pb,{GLTFLoader:()=>zm});function NN(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}function DN(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new fr({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:qn})),n.DefaultMaterial}function Ms(n,e,t){for(let i in t.extensions)n[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function wr(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function UN(n,e,t){let i=!1,r=!1,s=!1;for(let l=0,u=e.length;l<u;l++){let h=e[l];if(h.POSITION!==void 0&&(i=!0),h.NORMAL!==void 0&&(r=!0),h.COLOR_0!==void 0&&(s=!0),i&&r&&s)break}if(!i&&!r&&!s)return Promise.resolve(n);let o=[],a=[],c=[];for(let l=0,u=e.length;l<u;l++){let h=e[l];if(i){let f=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):n.attributes.position;o.push(f)}if(r){let f=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):n.attributes.normal;a.push(f)}if(s){let f=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):n.attributes.color;c.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],h=l[1],f=l[2];return i&&(n.morphAttributes.position=u),r&&(n.morphAttributes.normal=h),s&&(n.morphAttributes.color=f),n.morphTargetsRelative=!0,n})}function FN(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){let t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let i=0,r=t.length;i<r;i++)n.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function BN(n){let e,t=n.extensions&&n.extensions[Je.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Bm(t.attributes):e=n.indices+":"+Bm(n.attributes)+":"+n.mode,n.targets!==void 0)for(let i=0,r=n.targets.length;i<r;i++)e+=":"+Bm(n.targets[i]);return e}function Bm(n){let e="",t=Object.keys(n).sort();for(let i=0,r=t.length;i<r;i++)e+=t[i]+":"+n[t[i]]+";";return e}function lg(n){switch(n){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function zN(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}function kN(n,e,t){let i=e.attributes,r=new xt;if(i.POSITION!==void 0){let a=t.json.accessors[i.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(r.set(new w(c[0],c[1],c[2]),new w(l[0],l[1],l[2])),a.normalized){let u=lg(Lo[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=e.targets;if(s!==void 0){let a=new w,c=new w;for(let l=0,u=s.length;l<u;l++){let h=s[l];if(h.POSITION!==void 0){let f=t.json.accessors[h.POSITION],d=f.min,m=f.max;if(d!==void 0&&m!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(m[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(m[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(m[2]))),f.normalized){let y=lg(Lo[f.componentType]);c.multiplyScalar(y)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}n.boundingBox=r;let o=new _t;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,n.boundingSphere=o}function Rb(n,e,t){let i=e.attributes,r=[];function s(o,a){return t.getDependency("accessor",o).then(function(c){n.setAttribute(a,c)})}for(let o in i){let a=cg[o]||o.toLowerCase();a in n.attributes||r.push(s(i[o],a))}if(e.indices!==void 0&&!n.index){let o=t.getDependency("accessor",e.indices).then(function(a){n.setIndex(a)});r.push(o)}return rt.workingColorSpace!==Dt&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${rt.workingColorSpace}" not supported.`),wr(n,e),kN(n,e,t),Promise.all(r).then(function(){return e.targets!==void 0?UN(n,e.targets,t):n})}var zm,Je,Vm,km,Gm,Hm,Wm,Xm,Ym,qm,jm,$m,Km,Zm,Jm,Qm,eg,tg,ng,Ib,dc,wb,ig,rg,sg,og,fh,LN,ag,kn,Lo,Tb,Cb,Um,cg,Er,ON,Fm,VN,ug,Nb=Eh(()=>{ei();Eb();zm=class extends qt{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Hm(t)}),this.register(function(t){return new Jm(t)}),this.register(function(t){return new Qm(t)}),this.register(function(t){return new eg(t)}),this.register(function(t){return new Xm(t)}),this.register(function(t){return new Ym(t)}),this.register(function(t){return new qm(t)}),this.register(function(t){return new jm(t)}),this.register(function(t){return new Gm(t)}),this.register(function(t){return new $m(t)}),this.register(function(t){return new Wm(t)}),this.register(function(t){return new Zm(t)}),this.register(function(t){return new Km(t)}),this.register(function(t){return new Vm(t)}),this.register(function(t){return new tg(t)}),this.register(function(t){return new ng(t)})}load(e,t,i,r){let s=this,o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){let l=Jn.extractUrlBase(e);o=Jn.resolveURL(l,this.path)}else o=Jn.extractUrlBase(e);this.manager.itemStart(e);let a=function(l){r?r(l):console.error(l),s.manager.itemError(e),s.manager.itemEnd(e)},c=new Sn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{s.parse(l,o,function(u){t(u),s.manager.itemEnd(e)},a)}catch(u){a(u)}},i,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,r){let s,o={},a={},c=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===Ib){try{o[Je.KHR_BINARY_GLTF]=new ig(e)}catch(h){r&&r(h);return}s=JSON.parse(o[Je.KHR_BINARY_GLTF].content)}else s=JSON.parse(c.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let l=new ug(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){let h=this.pluginCallbacks[u](l);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[h.name]=h,o[h.name]=!0}if(s.extensionsUsed)for(let u=0;u<s.extensionsUsed.length;++u){let h=s.extensionsUsed[u],f=s.extensionsRequired||[];switch(h){case Je.KHR_MATERIALS_UNLIT:o[h]=new km;break;case Je.KHR_DRACO_MESH_COMPRESSION:o[h]=new rg(s,this.dracoLoader);break;case Je.KHR_TEXTURE_TRANSFORM:o[h]=new sg;break;case Je.KHR_MESH_QUANTIZATION:o[h]=new og;break;default:f.indexOf(h)>=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(i,r)}parseAsync(e,t){let i=this;return new Promise(function(r,s){i.parse(e,t,r,s)})}};Je={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},Vm=class{constructor(e){this.parser=e,this.name=Je.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i<r;i++){let s=t[i];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){let t=this.parser,i="light:"+e,r=t.cache.get(i);if(r)return r;let s=t.json,c=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e],l,u=new oe(16777215);c.color!==void 0&&u.setRGB(c.color[0],c.color[1],c.color[2],Dt);let h=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new mr(u),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new pr(u),l.distance=h;break;case"spot":l=new dr(u),l.distance=h,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),l.decay=2,wr(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),r=Promise.resolve(l),t.cache.add(i,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){let t=this,i=this.parser,s=i.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return i._getNodeRef(t.cache,a,c)})}},km=class{constructor(){this.name=Je.KHR_MATERIALS_UNLIT}getMaterialType(){return sn}extendParams(e,t,i){let r=[];e.color=new oe(1,1,1),e.opacity=1;let s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){let o=s.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],Dt),e.opacity=o[3]}s.baseColorTexture!==void 0&&r.push(i.assignTexture(e,"map",s.baseColorTexture,lt))}return Promise.all(r)}},Gm=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=r.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}},Hm=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&s.push(i.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&s.push(i.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(s.push(i.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){let a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Z(a,a)}return Promise.all(s)}},Wm=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&s.push(i.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&s.push(i.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(s)}},Xm=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SHEEN}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[];t.sheenColor=new oe(0,0,0),t.sheenRoughness=0,t.sheen=1;let o=r.extensions[this.name];if(o.sheenColorFactor!==void 0){let a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],Dt)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&s.push(i.assignTexture(t,"sheenColorMap",o.sheenColorTexture,lt)),o.sheenRoughnessTexture!==void 0&&s.push(i.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(s)}},Ym=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&s.push(i.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(s)}},qm=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_VOLUME}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&s.push(i.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;let a=o.attenuationColor||[1,1,1];return t.attenuationColor=new oe().setRGB(a[0],a[1],a[2],Dt),Promise.all(s)}},jm=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IOR}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=r.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}},$m=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SPECULAR}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&s.push(i.assignTexture(t,"specularIntensityMap",o.specularTexture));let a=o.specularColorFactor||[1,1,1];return t.specularColor=new oe().setRGB(a[0],a[1],a[2],Dt),o.specularColorTexture!==void 0&&s.push(i.assignTexture(t,"specularColorMap",o.specularColorTexture,lt)),Promise.all(s)}},Km=class{constructor(e){this.parser=e,this.name=Je.EXT_MATERIALS_BUMP}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&s.push(i.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(s)}},Zm=class{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){let i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:_n}extendMaterialParams(e,t){let i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&s.push(i.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(s)}},Jm=class{constructor(e){this.parser=e,this.name=Je.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,i=t.json,r=i.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let s=r.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}},Qm=class{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,i=this.parser,r=i.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let o=s.extensions[t],a=r.images[o.source],c=i.textureLoader;if(a.uri){let l=i.options.manager.getHandler(a.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return i.loadTextureImage(e,o.source,c);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},eg=class{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,i=this.parser,r=i.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let o=s.extensions[t],a=r.images[o.source],c=i.textureLoader;if(a.uri){let l=i.options.manager.getHandler(a.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return i.loadTextureImage(e,o.source,c);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},tg=class{constructor(e){this.name=Je.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){let r=i.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){let c=r.byteOffset||0,l=r.byteLength||0,u=r.count,h=r.byteStride,f=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,h,f,r.mode,r.filter).then(function(d){return d.buffer}):o.ready.then(function(){let d=new ArrayBuffer(u*h);return o.decodeGltfBuffer(new Uint8Array(d),u,h,f,r.mode,r.filter),d})})}else return null}},ng=class{constructor(e){this.name=Je.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;let r=t.meshes[i.mesh];for(let l of r.primitives)if(l.mode!==kn.TRIANGLES&&l.mode!==kn.TRIANGLE_STRIP&&l.mode!==kn.TRIANGLE_FAN&&l.mode!==void 0)return null;let o=i.extensions[this.name].attributes,a=[],c={};for(let l in o)a.push(this.parser.getDependency("accessor",o[l]).then(u=>(c[l]=u,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{let u=l.pop(),h=u.isGroup?u.children:[u],f=l[0].count,d=[];for(let m of h){let y=new we,g=new w,p=new Ft,_=new w(1,1,1),x=new ao(m.geometry,m.material,f);for(let b=0;b<f;b++)c.TRANSLATION&&g.fromBufferAttribute(c.TRANSLATION,b),c.ROTATION&&p.fromBufferAttribute(c.ROTATION,b),c.SCALE&&_.fromBufferAttribute(c.SCALE,b),x.setMatrixAt(b,y.compose(g,p,_));for(let b in c)if(b==="_COLOR_0"){let T=c[b];x.instanceColor=new Kn(T.array,T.itemSize,T.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&m.geometry.setAttribute(b,c[b]);it.prototype.copy.call(x,m),this.parser.assignFinalMaterial(x),d.push(x)}return u.isGroup?(u.clear(),u.add(...d),u):d[0]}))}},Ib="glTF",dc=12,wb={JSON:1313821514,BIN:5130562},ig=class{constructor(e){this.name=Je.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,dc),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ib)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let r=this.header.length-dc,s=new DataView(e,dc),o=0;for(;o<r;){let a=s.getUint32(o,!0);o+=4;let c=s.getUint32(o,!0);if(o+=4,c===wb.JSON){let l=new Uint8Array(e,dc+o,a);this.content=i.decode(l)}else if(c===wb.BIN){let l=dc+o;this.body=e.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},rg=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Je.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let i=this.json,r=this.dracoLoader,s=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},c={},l={};for(let u in o){let h=cg[u]||u.toLowerCase();a[h]=o[u]}for(let u in e.attributes){let h=cg[u]||u.toLowerCase();if(o[u]!==void 0){let f=i.accessors[e.attributes[u]],d=Lo[f.componentType];l[h]=d.name,c[h]=f.normalized===!0}}return t.getDependency("bufferView",s).then(function(u){return new Promise(function(h,f){r.decodeDracoFile(u,function(d){for(let m in d.attributes){let y=d.attributes[m],g=c[m];g!==void 0&&(y.normalized=g)}h(d)},a,l,Dt,f)})})}},sg=class{constructor(){this.name=Je.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}},og=class{constructor(){this.name=Je.KHR_MESH_QUANTIZATION}},fh=class extends ki{constructor(e,t,i,r){super(e,t,i,r)}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r*3+r;for(let o=0;o!==r;o++)t[o]=i[s+o];return t}interpolate_(e,t,i,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,u=r-t,h=(i-t)/u,f=h*h,d=f*h,m=e*l,y=m-l,g=-2*d+3*f,p=d-f,_=1-g,x=p-f+h;for(let b=0;b!==a;b++){let T=o[y+b+a],A=o[y+b+c]*u,M=o[m+b+a],C=o[m+b]*u;s[b]=_*T+x*A+g*M+p*C}return s}},LN=new Ft,ag=class extends fh{interpolate_(e,t,i,r){let s=super.interpolate_(e,t,i,r);return LN.fromArray(s).normalize().toArray(s),s}},kn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Lo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Tb={9728:Mt,9729:yt,9984:Ks,9985:Va,9986:qr,9987:jn},Cb={33071:Xt,33648:Kr,10497:zi},Um={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},cg={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Er={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ON={CUBICSPLINE:void 0,LINEAR:lr,STEP:Jr},Fm={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};VN=new we,ug=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new NN,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,r=!1,s=-1;typeof navigator<"u"&&(i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,s=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||i||r&&s<98?this.textureLoader=new cs(this.options.manager):this.textureLoader=new Da(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Sn(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let i=this,r=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(o){let a={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:i,userData:{}};return Ms(s,a,r),wr(a,r),Promise.all(i._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,s=t.length;r<s;r++){let o=t[r].joints;for(let a=0,c=o.length;a<c;a++)e[o[a]].isBone=!0}for(let r=0,s=e.length;r<s;r++){let o=e[r];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(i[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;let r=i.clone(),s=(o,a)=>{let c=this.associations.get(o);c!=null&&this.associations.set(a,c);for(let[l,u]of o.children.entries())s(u,a.children[l])};return s(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let i=[];for(let r=0;r<t.length;r++){let s=e(t[r]);s&&i.push(s)}return i}getDependency(e,t){let i=e+":"+t,r=this.cache.get(i);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":r=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(i,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let i=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(s,o){return i.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],i=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Je.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(s,o){i.load(Jn.resolveURL(t.uri,r.path),s,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(i){let r=t.byteLength||0,s=t.byteOffset||0;return i.slice(s,s+r)})}loadAccessor(e){let t=this,i=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let o=Um[r.type],a=Lo[r.componentType],c=r.normalized===!0,l=new a(r.count*o);return Promise.resolve(new Ze(l,o,c))}let s=[];return r.bufferView!==void 0?s.push(this.getDependency("bufferView",r.bufferView)):s.push(null),r.sparse!==void 0&&(s.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(s).then(function(o){let a=o[0],c=Um[r.type],l=Lo[r.componentType],u=l.BYTES_PER_ELEMENT,h=u*c,f=r.byteOffset||0,d=r.bufferView!==void 0?i.bufferViews[r.bufferView].byteStride:void 0,m=r.normalized===!0,y,g;if(d&&d!==h){let p=Math.floor(f/d),_="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+p+":"+r.count,x=t.cache.get(_);x||(y=new l(a,p*d,r.count*d/u),x=new Vi(y,d/u),t.cache.add(_,x)),g=new Yt(x,c,f%d/u,m)}else a===null?y=new l(r.count*c):y=new l(a,f,r.count*c),g=new Ze(y,c,m);if(r.sparse!==void 0){let p=Um.SCALAR,_=Lo[r.sparse.indices.componentType],x=r.sparse.indices.byteOffset||0,b=r.sparse.values.byteOffset||0,T=new _(o[1],x,r.sparse.count*p),A=new l(o[2],b,r.sparse.count*c);a!==null&&(g=new Ze(g.array.slice(),g.itemSize,g.normalized));for(let M=0,C=T.length;M<C;M++){let S=T[M];if(g.setX(S,A[M*c]),c>=2&&g.setY(S,A[M*c+1]),c>=3&&g.setZ(S,A[M*c+2]),c>=4&&g.setW(S,A[M*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return g})}loadTexture(e){let t=this.json,i=this.options,s=t.textures[e].source,o=t.images[s],a=this.textureLoader;if(o.uri){let c=i.manager.getHandler(o.uri);c!==null&&(a=c)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,i){let r=this,s=this.json,o=s.textures[e],a=s.images[t],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];let l=this.loadImageSource(t,i).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);let f=(s.samplers||{})[o.sampler]||{};return u.magFilter=Tb[f.magFilter]||yt,u.minFilter=Tb[f.minFilter]||jn,u.wrapS=Cb[f.wrapS]||zi,u.wrapT=Cb[f.wrapT]||zi,r.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){let i=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());let o=r.images[e],a=self.URL||self.webkitURL,c=o.uri||"",l=!1;if(o.bufferView!==void 0)c=i.getDependency("bufferView",o.bufferView).then(function(h){l=!0;let f=new Blob([h],{type:o.mimeType});return c=a.createObjectURL(f),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let u=Promise.resolve(c).then(function(h){return new Promise(function(f,d){let m=f;t.isImageBitmapLoader===!0&&(m=function(y){let g=new Rt(y);g.needsUpdate=!0,f(g)}),t.load(Jn.resolveURL(h,s.path),m,void 0,d)})}).then(function(h){return l===!0&&a.revokeObjectURL(c),h.userData.mimeType=o.mimeType||zN(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=u,u}assignTexture(e,t,i,r){let s=this;return this.getDependency("texture",i.index).then(function(o){if(!o)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(o=o.clone(),o.channel=i.texCoord),s.extensions[Je.KHR_TEXTURE_TRANSFORM]){let a=i.extensions!==void 0?i.extensions[Je.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let c=s.associations.get(o);o=s.extensions[Je.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,c)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,i=e.material,r=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+i.uuid,c=this.cache.get(a);c||(c=new rs,It.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,c.sizeAttenuation=!1,this.cache.add(a,c)),i=c}else if(e.isLine){let a="LineBasicMaterial:"+i.uuid,c=this.cache.get(a);c||(c=new Vt,It.prototype.copy.call(c,i),c.color.copy(i.color),c.map=i.map,this.cache.add(a,c)),i=c}if(r||s||o){let a="ClonedMaterial:"+i.uuid+":";r&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=i.clone(),s&&(c.vertexColors=!0),o&&(c.flatShading=!0),r&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(i))),i=c}e.material=i}getMaterialType(){return fr}loadMaterial(e){let t=this,i=this.json,r=this.extensions,s=i.materials[e],o,a={},c=s.extensions||{},l=[];if(c[Je.KHR_MATERIALS_UNLIT]){let h=r[Je.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),l.push(h.extendParams(a,s,t))}else{let h=s.pbrMetallicRoughness||{};if(a.color=new oe(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){let f=h.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],Dt),a.opacity=f[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",h.baseColorTexture,lt)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=On);let u=s.alphaMode||Fm.OPAQUE;if(u===Fm.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===Fm.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==sn&&(l.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Z(1,1),s.normalTexture.scale!==void 0)){let h=s.normalTexture.scale;a.normalScale.set(h,h)}if(s.occlusionTexture!==void 0&&o!==sn&&(l.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==sn){let h=s.emissiveFactor;a.emissive=new oe().setRGB(h[0],h[1],h[2],Dt)}return s.emissiveTexture!==void 0&&o!==sn&&l.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,lt)),Promise.all(l).then(function(){let h=new o(a);return s.name&&(h.name=s.name),wr(h,s),t.associations.set(h,{materials:e}),s.extensions&&Ms(r,h,s),h})}createUniqueName(e){let t=ot.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,i=this.extensions,r=this.primitiveCache;function s(a){return i[Je.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return Rb(c,a,t)})}let o=[];for(let a=0,c=e.length;a<c;a++){let l=e[a],u=BN(l),h=r[u];if(h)o.push(h.promise);else{let f;l.extensions&&l.extensions[Je.KHR_DRACO_MESH_COMPRESSION]?f=s(l):f=Rb(new Be,l,t),r[u]={primitive:l,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){let t=this,i=this.json,r=this.extensions,s=i.meshes[e],o=s.primitives,a=[];for(let c=0,l=o.length;c<l;c++){let u=o[c].material===void 0?DN(this.cache):this.getDependency("material",o[c].material);a.push(u)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(c){let l=c.slice(0,c.length-1),u=c[c.length-1],h=[];for(let d=0,m=u.length;d<m;d++){let y=u[d],g=o[d],p,_=l[d];if(g.mode===kn.TRIANGLES||g.mode===kn.TRIANGLE_STRIP||g.mode===kn.TRIANGLE_FAN||g.mode===void 0)p=s.isSkinnedMesh===!0?new so(y,_):new ft(y,_),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),g.mode===kn.TRIANGLE_STRIP?p.geometry=Dm(p.geometry,ka):g.mode===kn.TRIANGLE_FAN&&(p.geometry=Dm(p.geometry,So));else if(g.mode===kn.LINES)p=new xn(y,_);else if(g.mode===kn.LINE_STRIP)p=new Un(y,_);else if(g.mode===kn.LINE_LOOP)p=new co(y,_);else if(g.mode===kn.POINTS)p=new lo(y,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(p.geometry.morphAttributes).length>0&&FN(p,s),p.name=t.createUniqueName(s.name||"mesh_"+e),wr(p,s),g.extensions&&Ms(r,p,g),t.assignFinalMaterial(p),h.push(p)}for(let d=0,m=h.length;d<m;d++)t.associations.set(h[d],{meshes:e,primitives:d});if(h.length===1)return s.extensions&&Ms(r,h[0],s),h[0];let f=new Dn;s.extensions&&Ms(r,f,s),t.associations.set(f,{meshes:e});for(let d=0,m=h.length;d<m;d++)f.add(h[d]);return f})}loadCamera(e){let t,i=this.json.cameras[e],r=i[i.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new vt(Ha.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):i.type==="orthographic"&&(t=new ci(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),wr(t,i),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],i=[];for(let r=0,s=t.joints.length;r<s;r++)i.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(r){let s=r.pop(),o=r,a=[],c=[];for(let l=0,u=o.length;l<u;l++){let h=o[l];if(h){a.push(h);let f=new we;s!==null&&f.fromArray(s.array,l*16),c.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new oo(a,c)})}loadAnimation(e){let t=this.json,i=this,r=t.animations[e],s=r.name?r.name:"animation_"+e,o=[],a=[],c=[],l=[],u=[];for(let h=0,f=r.channels.length;h<f;h++){let d=r.channels[h],m=r.samplers[d.sampler],y=d.target,g=y.node,p=r.parameters!==void 0?r.parameters[m.input]:m.input,_=r.parameters!==void 0?r.parameters[m.output]:m.output;y.node!==void 0&&(o.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",p)),c.push(this.getDependency("accessor",_)),l.push(m),u.push(y))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(h){let f=h[0],d=h[1],m=h[2],y=h[3],g=h[4],p=[];for(let _=0,x=f.length;_<x;_++){let b=f[_],T=d[_],A=m[_],M=y[_],C=g[_];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();let S=i._createAnimationTracks(b,T,A,M,C);if(S)for(let v=0;v<S.length;v++)p.push(S[v])}return new Wi(s,void 0,p)})}createNodeMesh(e){let t=this.json,i=this,r=t.nodes[e];return r.mesh===void 0?null:i.getDependency("mesh",r.mesh).then(function(s){let o=i._getNodeRef(i.meshCache,r.mesh,s);return r.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let c=0,l=r.weights.length;c<l;c++)a.morphTargetInfluences[c]=r.weights[c]}),o})}loadNode(e){let t=this.json,i=this,r=t.nodes[e],s=i._loadNodeShallow(e),o=[],a=r.children||[];for(let l=0,u=a.length;l<u;l++)o.push(i.getDependency("node",a[l]));let c=r.skin===void 0?Promise.resolve(null):i.getDependency("skin",r.skin);return Promise.all([s,Promise.all(o),c]).then(function(l){let u=l[0],h=l[1],f=l[2];f!==null&&u.traverse(function(d){d.isSkinnedMesh&&d.bind(f,VN)});for(let d=0,m=h.length;d<m;d++)u.add(h[d]);return u})}_loadNodeShallow(e){let t=this.json,i=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let s=t.nodes[e],o=s.name?r.createUniqueName(s.name):"",a=[],c=r._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),s.camera!==void 0&&a.push(r.getDependency("camera",s.camera).then(function(l){return r._getNodeRef(r.cameraCache,s.camera,l)})),r._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let u;if(s.isBone===!0?u=new is:l.length>1?u=new Dn:l.length===1?u=l[0]:u=new it,u!==l[0])for(let h=0,f=l.length;h<f;h++)u.add(l[h]);if(s.name&&(u.userData.name=s.name,u.name=o),wr(u,s),s.extensions&&Ms(i,u,s),s.matrix!==void 0){let h=new we;h.fromArray(s.matrix),u.applyMatrix4(h)}else s.translation!==void 0&&u.position.fromArray(s.translation),s.rotation!==void 0&&u.quaternion.fromArray(s.rotation),s.scale!==void 0&&u.scale.fromArray(s.scale);return r.associations.has(u)||r.associations.set(u,{}),r.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){let t=this.extensions,i=this.json.scenes[e],r=this,s=new Dn;i.name&&(s.name=r.createUniqueName(i.name)),wr(s,i),i.extensions&&Ms(t,s,i);let o=i.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(r.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let u=0,h=c.length;u<h;u++)s.add(c[u]);let l=u=>{let h=new Map;for(let[f,d]of r.associations)(f instanceof It||f instanceof Rt)&&h.set(f,d);return u.traverse(f=>{let d=r.associations.get(f);d!=null&&h.set(f,d)}),h};return r.associations=l(s),s})}_createAnimationTracks(e,t,i,r,s){let o=[],a=e.name?e.name:e.uuid,c=[];Er[s.path]===Er.weights?e.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(a);let l;switch(Er[s.path]){case Er.weights:l=li;break;case Er.rotation:l=Zn;break;case Er.position:case Er.scale:l=ui;break;default:i.itemSize===1?l=li:l=ui;break}let u=r.interpolation!==void 0?ON[r.interpolation]:lr,h=this._getArrayFromAccessor(i);for(let f=0,d=c.length;f<d;f++){let m=new l(c[f]+"."+Er[s.path],t.array,h,u);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let i=lg(t.constructor),r=new Float32Array(t.length);for(let s=0,o=t.length;s<o;s++)r[s]=t[s]*i;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){let r=this instanceof Zn?ag:fh;return new r(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}});var pM={signature:"GIF",version:"89a",trailer:59,extensionIntroducer:33,applicationExtensionLabel:255,graphicControlExtensionLabel:249,imageSeparator:44,signatureSize:3,versionSize:3,globalColorTableFlagMask:128,colorResolutionMask:112,sortFlagMask:8,globalColorTableSizeMask:7,applicationIdentifierSize:8,applicationAuthCodeSize:3,disposalMethodMask:28,userInputFlagMask:2,transparentColorFlagMask:1,localColorTableFlagMask:128,interlaceFlagMask:64,idSortFlagMask:32,localColorTableSizeMask:7};function Ig(n=256){let e=0,t=new Uint8Array(n);return{get buffer(){return t.buffer},reset(){e=0},bytesView(){return t.subarray(0,e)},bytes(){return t.slice(0,e)},writeByte(r){i(e+1),t[e]=r,e++},writeBytes(r,s=0,o=r.length){i(e+o);for(let a=0;a<o;a++)t[e++]=r[a+s]},writeBytesView(r,s=0,o=r.byteLength){i(e+o),t.set(r.subarray(s,s+o),e),e+=o}};function i(r){var s=t.length;if(s>=r)return;var o=1024*1024;r=Math.max(r,s*(s<o?2:1.125)>>>0),s!=0&&(r=Math.max(r,256));let a=t;t=new Uint8Array(r),e>0&&t.set(a.subarray(0,e),0)}}var wh=12,Tg=5003,mM=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];function gM(n,e,t,i,r=Ig(512),s=new Uint8Array(256),o=new Int32Array(Tg),a=new Int32Array(Tg)){let c=o.length,l=Math.max(2,i);s.fill(0),a.fill(0),o.fill(-1);let u=0,h=0,f=l+1,d=f,m=!1,y=d,g=(1<<y)-1,p=1<<f-1,_=p+1,x=p+2,b=0,T=t[0],A=0;for(let S=c;S<65536;S*=2)++A;A=8-A,r.writeByte(l),C(p);let M=t.length;for(let S=1;S<M;S++)e:{let v=t[S],L=(v<<wh)+T,U=v<<A^T;if(o[U]===L){T=a[U];break e}let G=U===0?1:c-U;for(;o[U]>=0;)if(U-=G,U<0&&(U+=c),o[U]===L){T=a[U];break e}C(T),T=v,x<1<<wh?(a[U]=x++,o[U]=L):(o.fill(-1),x=p+2,m=!0,C(p))}return C(T),C(_),r.writeByte(0),r.bytesView();function C(S){for(u&=mM[h],h>0?u|=S<<h:u=S,h+=y;h>=8;)s[b++]=u&255,b>=254&&(r.writeByte(b),r.writeBytesView(s,0,b),b=0),u>>=8,h-=8;if((x>g||m)&&(m?(y=d,g=(1<<y)-1,m=!1):(++y,g=y===wh?1<<y:(1<<y)-1)),S==_){for(;h>0;)s[b++]=u&255,b>=254&&(r.writeByte(b),r.writeBytesView(s,0,b),b=0),u>>=8,h-=8;b>0&&(r.writeByte(b),r.writeBytesView(s,0,b),b=0)}}}var yM=gM;function Pg(n,e,t){return n<<8&63488|e<<2&992|t>>3}function Ng(n,e,t,i){return n>>4|e&240|(t&240)<<4|(i&240)<<8}function Lg(n,e,t){return n>>4<<8|e&240|t>>4}function xc(n,e,t){return n<e?e:n>t?t:n}function Uo(n){return n*n}function Cg(n,e,t){var i=0,r=1e100;let s=n[e],o=s.cnt,a=s.ac,c=s.rc,l=s.gc,u=s.bc;for(var h=s.fw;h!=0;h=n[h].fw){let d=n[h],m=d.cnt,y=o*m/(o+m);if(!(y>=r)){var f=0;t&&(f+=y*Uo(d.ac-a),f>=r)||(f+=y*Uo(d.rc-c),!(f>=r)&&(f+=y*Uo(d.gc-l),!(f>=r)&&(f+=y*Uo(d.bc-u),!(f>=r)&&(r=f,i=h))))}}s.err=r,s.nn=i}function Th(){return{ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0}}function xM(n,e){let t=e==="rgb444"?4096:65536,i=new Array(t),r=n.length;if(e==="rgba4444")for(let s=0;s<r;++s){let o=n[s],a=o>>24&255,c=o>>16&255,l=o>>8&255,u=o&255,h=Ng(u,l,c,a),f=h in i?i[h]:i[h]=Th();f.rc+=u,f.gc+=l,f.bc+=c,f.ac+=a,f.cnt++}else if(e==="rgb444")for(let s=0;s<r;++s){let o=n[s],a=o>>16&255,c=o>>8&255,l=o&255,u=Lg(l,c,a),h=u in i?i[u]:i[u]=Th();h.rc+=l,h.gc+=c,h.bc+=a,h.cnt++}else for(let s=0;s<r;++s){let o=n[s],a=o>>16&255,c=o>>8&255,l=o&255,u=Pg(l,c,a),h=u in i?i[u]:i[u]=Th();h.rc+=l,h.gc+=c,h.bc+=a,h.cnt++}return i}function Og(n,e,t={}){let{format:i="rgb565",clearAlpha:r=!0,clearAlphaColor:s=0,clearAlphaThreshold:o=0,oneBitAlpha:a=!1}=t;if(!n||!n.buffer)throw new Error("quantize() expected RGBA Uint8Array data");if(!(n instanceof Uint8Array)&&!(n instanceof Uint8ClampedArray))throw new Error("quantize() expected RGBA Uint8Array data");let c=new Uint32Array(n.buffer),l=t.useSqrt!==!1,u=i==="rgba4444",h=xM(c,i),f=h.length,d=f-1,m=new Uint32Array(f+1);for(var y=0,g=0;g<f;++g){let P=h[g];if(P!=null){var p=1/P.cnt;u&&(P.ac*=p),P.rc*=p,P.gc*=p,P.bc*=p,h[y++]=P}}Uo(e)/y<.022&&(l=!1);for(var g=0;g<y-1;++g)h[g].fw=g+1,h[g+1].bk=g,l&&(h[g].cnt=Math.sqrt(h[g].cnt));l&&(h[g].cnt=Math.sqrt(h[g].cnt));var _,x,b;for(g=0;g<y;++g){Cg(h,g,!1);var T=h[g].err;for(x=++m[0];x>1&&(b=x>>1,!(h[_=m[b]].err<=T));x=b)m[x]=_;m[x]=g}var A=y-e;for(g=0;g<A;){for(var M;;){var C=m[1];if(M=h[C],M.tm>=M.mtm&&h[M.nn].mtm<=M.tm)break;M.mtm==d?C=m[1]=m[m[0]--]:(Cg(h,C,!1),M.tm=g);var T=h[C].err;for(x=1;(b=x+x)<=m[0]&&(b<m[0]&&h[m[b]].err>h[m[b+1]].err&&b++,!(T<=h[_=m[b]].err));x=b)m[x]=_;m[x]=C}var S=h[M.nn],v=M.cnt,L=S.cnt,p=1/(v+L);u&&(M.ac=p*(v*M.ac+L*S.ac)),M.rc=p*(v*M.rc+L*S.rc),M.gc=p*(v*M.gc+L*S.gc),M.bc=p*(v*M.bc+L*S.bc),M.cnt+=S.cnt,M.mtm=++g,h[S.bk].fw=S.fw,h[S.fw].bk=S.bk,S.mtm=d}let U=[];var G=0;for(g=0;;++G){let P=xc(Math.round(h[g].rc),0,255),D=xc(Math.round(h[g].gc),0,255),z=xc(Math.round(h[g].bc),0,255),q=255;u&&(q=xc(Math.round(h[g].ac),0,255),a&&(q=q<=(typeof a=="number"?a:127)?0:255),r&&q<=o&&(P=D=z=s,q=0));let Y=u?[P,D,z,q]:[P,D,z];if(_M(U,Y)||U.push(Y),(g=h[g].fw)==0)break}return U}function _M(n,e){for(let t=0;t<n.length;t++){let i=n[t],r=i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2],s=i.length>=4&&e.length>=4?i[3]===e[3]:!0;if(r&&s)return!0}return!1}function Dg(n,e,t="rgb565"){if(!n||!n.buffer)throw new Error("quantize() expected RGBA Uint8Array data");if(!(n instanceof Uint8Array)&&!(n instanceof Uint8ClampedArray))throw new Error("quantize() expected RGBA Uint8Array data");if(e.length>256)throw new Error("applyPalette() only works with 256 colors or less");let i=new Uint32Array(n.buffer),r=i.length,s=t==="rgb444"?4096:65536,o=new Uint8Array(r),a=new Array(s),c=t==="rgba4444";if(t==="rgba4444")for(let l=0;l<r;l++){let u=i[l],h=u>>24&255,f=u>>16&255,d=u>>8&255,m=u&255,y=Ng(m,d,f,h),g=y in a?a[y]:a[y]=SM(m,d,f,h,e);o[l]=g}else{let l=t==="rgb444"?Lg:Pg;for(let u=0;u<r;u++){let h=i[u],f=h>>16&255,d=h>>8&255,m=h&255,y=l(m,d,f),g=y in a?a[y]:a[y]=bM(m,d,f,e);o[u]=g}}return o}function SM(n,e,t,i,r){let s=0,o=1e100;for(let a=0;a<r.length;a++){let c=r[a],l=c[3],u=Rr(l-i);if(u>o)continue;let h=c[0];if(u+=Rr(h-n),u>o)continue;let f=c[1];if(u+=Rr(f-e),u>o)continue;let d=c[2];u+=Rr(d-t),!(u>o)&&(o=u,s=a)}return s}function bM(n,e,t,i){let r=0,s=1e100;for(let o=0;o<i.length;o++){let a=i[o],c=a[0],l=Rr(c-n);if(l>s)continue;let u=a[1];if(l+=Rr(u-e),l>s)continue;let h=a[2];l+=Rr(h-t),!(l>s)&&(s=l,r=o)}return r}function Rr(n){return n*n}function Ch(n={}){let{initialCapacity:e=4096,auto:t=!0}=n,i=Ig(e),r=5003,s=new Uint8Array(256),o=new Int32Array(r),a=new Int32Array(r),c=!1;return{reset(){i.reset(),c=!1},finish(){i.writeByte(pM.trailer)},bytes(){return i.bytes()},bytesView(){return i.bytesView()},get buffer(){return i.buffer},get stream(){return i},writeHeader:l,writeFrame(u,h,f,d={}){let{transparent:m=!1,transparentIndex:y=0,delay:g=0,palette:p=null,repeat:_=0,colorDepth:x=8,dispose:b=-1}=d,T=!1;if(t?c||(T=!0,l(),c=!0):T=!!d.first,h=Math.max(0,Math.floor(h)),f=Math.max(0,Math.floor(f)),T){if(!p)throw new Error("First frame must include a { palette } option");vM(i,h,f,p,x),Rg(i,p),_>=0&&AM(i,_)}let A=Math.round(g/10);MM(i,b,A,m,y);let M=!!p&&!T;EM(i,h,f,M?p:null),M&&Rg(i,p),wM(i,u,h,f,x,s,o,a)}};function l(){Ug(i,"GIF89a")}}function MM(n,e,t,i,r){n.writeByte(33),n.writeByte(249),n.writeByte(4),r<0&&(r=0,i=!1);var s,o;i?(s=1,o=2):(s=0,o=0),e>=0&&(o=e&7),o<<=2,n.writeByte(0|o|0|s),Ki(n,t),n.writeByte(r||0),n.writeByte(0)}function vM(n,e,t,i,r=8){let s=1,o=0,a=Rh(i.length)-1,c=s<<7|r-1<<4|o<<3|a;Ki(n,e),Ki(n,t),n.writeBytes([c,0,0])}function AM(n,e){n.writeByte(33),n.writeByte(255),n.writeByte(11),Ug(n,"NETSCAPE2.0"),n.writeByte(3),n.writeByte(1),Ki(n,e),n.writeByte(0)}function Rg(n,e){let t=1<<Rh(e.length);for(let i=0;i<t;i++){let r=[0,0,0];i<e.length&&(r=e[i]),n.writeByte(r[0]),n.writeByte(r[1]),n.writeByte(r[2])}}function EM(n,e,t,i){if(n.writeByte(44),Ki(n,0),Ki(n,0),Ki(n,e),Ki(n,t),i){let r=0,s=0,o=Rh(i.length)-1;n.writeByte(128|r|s|0|o)}else n.writeByte(0)}function wM(n,e,t,i,r=8,s,o,a){yM(t,i,e,r,n,s,o,a)}function Ki(n,e){n.writeByte(e&255),n.writeByte(e>>8&255)}function Ug(n,e){for(var t=0;t<e.length;t++)n.writeByte(e.charCodeAt(t))}function Rh(n){return Math.max(Math.ceil(Math.log2(n)),1)}var Fo=Ch;ei();var Px=Object.freeze(["x","y","z"]),Mp=Object.freeze({x:0,y:0,z:0}),Au=Object.freeze({enabled:!1,axis:"x",offset:Mp.x,offsets:Mp,invert:!1}),Nx=Object.freeze({x:0,y:1,z:2}),hC=1e-6;function Lx(n,e){let t=Number(n);return Number.isFinite(t)?t:e}function fC(n,e,t){return Math.min(Math.max(n,e),t)}function Xa(n=null){let e=n&&typeof n=="object"?n:{},t=Px.includes(String(e.axis||"").toLowerCase())?String(e.axis).toLowerCase():Au.axis,i=e.offsets&&typeof e.offsets=="object"?e.offsets:{},r=Lx(e.offset,Au.offset),s=Object.fromEntries(Px.map(l=>[l,fC(Lx(i[l],l===t?r:Mp[l]),0,1)])),o=s[t],a=o>hC;return{enabled:(e.enabled===!0?!0:e.enabled===!1?!1:a)&&a,axis:t,offset:o,offsets:s,invert:e.invert===!0}}function Ox(n){return Nx[String(n||"").toLowerCase()]??Nx.x}ei();var Bn=Object.freeze([0,0,1]),vp=Object.freeze([0,1,0]),ls=Object.freeze({front:Object.freeze({name:"front",direction:Object.freeze([0,-1,0]),up:Bn}),back:Object.freeze({name:"back",direction:Object.freeze([0,1,0]),up:Bn}),right:Object.freeze({name:"right",direction:Object.freeze([1,0,0]),up:Bn}),left:Object.freeze({name:"left",direction:Object.freeze([-1,0,0]),up:Bn}),top:Object.freeze({name:"top",direction:Object.freeze([0,0,1]),up:vp}),bottom:Object.freeze({name:"bottom",direction:Object.freeze([0,0,-1]),up:vp}),iso:Object.freeze({name:"iso",direction:Object.freeze([1,-1,.8]),up:Bn}),isometric:Object.freeze({name:"iso",direction:Object.freeze([1,-1,.8]),up:Bn}),side:Object.freeze({name:"side",direction:Object.freeze([1,0,0]),up:Bn})});var fi="iso",dC=Object.freeze(["preset","position","target","up","zoom","direction","name"]);function Fx(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function Fn(n,e=0){let t=Number(n);return Number.isFinite(t)?t:e}function Mo(n,{fieldName:e="camera vector",required:t=!1,nonZero:i=!1,strict:r=!0}={}){if(n==null){if(t&&r)throw new Error(`${e} must be a three-number array`);return null}if(!Array.isArray(n)||n.length<3){if(r)throw new Error(`${e} must be a three-number array`);return null}let s=[Number(n[0]),Number(n[1]),Number(n[2])];if(!s.every(Number.isFinite)){if(r)throw new Error(`${e} must contain only finite numbers`);return null}if(i&&s[0]**2+s[1]**2+s[2]**2<=1e-12){if(r)throw new Error(`${e} must not be the zero vector`);return null}return s}function Eu(n,e=1,{fieldName:t="camera.zoom",strict:i=!1}={}){if(n==null||n==="")return e;let r=Number(n);if(Number.isFinite(r)&&r>0)return r;if(i)throw new Error(`${t} must be a positive finite number`);return e}function Dx(n){return{name:n.name,direction:[...n.direction],up:[...n.up]}}function Ux(n,{presets:e=ls,strict:t=!0}={}){let i=String(n||fi).trim().toLowerCase();if(e[i])return Dx(e[i]);let r=i.split(":").map(s=>Number(s));if(r.length>=2&&r.every(Number.isFinite)){let s=r[0]*Math.PI/180,o=r[1]*Math.PI/180,a=Math.cos(o);return{name:`${r[0]}:${r[1]}`,direction:[Math.sin(s)*a,-Math.cos(s)*a,Math.sin(o)],up:[...Bn]}}if(t)throw new Error(`Unknown camera preset: ${n}`);return Dx(e[fi])}function pC(n,{strict:e=!0}={}){let t=String(n||"").trim();if(!t.startsWith("{"))return null;try{let i=JSON.parse(t);if(!Fx(i))throw new Error("camera JSON must be an object");return i}catch(i){if(e){let r=i instanceof Error?i.message:String(i);throw new Error(`Invalid camera JSON: ${r}`)}return null}}function mC(n){let e=Object.keys(n).filter(t=>!dC.includes(t));if(e.length)throw new Error(`Unsupported camera fields: ${e.join(", ")}`)}function Ap(n=fi,{presets:e=ls,strict:t=!0}={}){let r=(typeof n=="string"?pC(n,{strict:t}):null)||n;if(!Fx(r)){let f=Ux(r||fi,{presets:e,strict:t});return{sourceKind:"string",name:f.name,preset:f.name,direction:f.direction,position:null,target:null,up:f.up,zoom:1,hasExplicitPosition:!1,hasExplicitTarget:!1,hasExplicitUp:!1,hasExplicitZoom:!1}}mC(r);let s=r.preset??fi,o=Ux(s,{presets:e,strict:t}),a=Mo(r.direction,{fieldName:"camera.direction",nonZero:!0,strict:t})||o.direction,c=Mo(r.position,{fieldName:"camera.position",strict:t}),l=Mo(r.target,{fieldName:"camera.target",strict:t}),u=Mo(r.up,{fieldName:"camera.up",nonZero:!0,strict:t})||o.up||[...Bn],h=Object.prototype.hasOwnProperty.call(r,"zoom");return{sourceKind:"object",name:String(r.name||o.name||"custom"),preset:o.name,direction:a,position:c,target:l,up:u,zoom:Eu(r.zoom,1,{strict:t,fieldName:"camera.zoom"}),hasExplicitPosition:Object.prototype.hasOwnProperty.call(r,"position"),hasExplicitTarget:Object.prototype.hasOwnProperty.call(r,"target"),hasExplicitUp:Object.prototype.hasOwnProperty.call(r,"up"),hasExplicitZoom:h}}function Bx(n,e){return e?.[n]?e[n]:e?.cad?e.cad:{minBoundsSpan:1,minModelRadius:1,minCameraDistance:10,minCameraFar:1e3}}function gC(n,e,t){let i=Bx(e,t),r=Array.isArray(n?.min)?n.min:[0,0,0],s=Array.isArray(n?.max)?n.max:[1,1,1],o=new w((Fn(r[0])+Fn(s[0],1))/2,(Fn(r[1])+Fn(s[1],1))/2,(Fn(r[2])+Fn(s[2],1))/2),a=new w(Math.max(Fn(s[0],1)-Fn(r[0]),i.minBoundsSpan),Math.max(Fn(s[1],1)-Fn(r[1]),i.minBoundsSpan),Math.max(Fn(s[2],1)-Fn(r[2]),i.minBoundsSpan));return{center:o,radius:Math.max(a.length()/2,i.minModelRadius),size:a}}function vo(n){return new w(n[0],n[1],n[2])}function zx(n=fi,e={}){let t=Ap(n,e),i=t.target?vo(t.target):null,r=t.position?vo(t.position):null,s=r&&i?r.clone().sub(i).normalize().toArray():Mo(t.direction,{fieldName:"camera.direction",nonZero:!0,strict:!1})||[...ls[fi].direction];return{name:t.name,direction:s,up:[...t.up||Bn],zoom:t.zoom}}function Ep(n=fi,e=null,{sceneScale:t="cad",settingsByScale:i=null,presets:r=ls,strict:s=!0}={}){let o=Ap(n,{presets:r,strict:s}),a=Bx(t,i),{center:c,radius:l,size:u}=gC(e,t,i),h=o.target?vo(o.target):c.clone(),f=Mo(o.direction,{fieldName:"camera.direction",nonZero:!0,strict:s})||[...ls[fi].direction],d=o.position?vo(o.position):h.clone().add(vo(f).normalize().multiplyScalar(Math.max(l*3.2,a.minCameraDistance||a.minModelRadius*10||10))),m=d.clone().sub(h);if(m.lengthSq()<=1e-12)throw new Error("camera.position must differ from camera.target");let y=vo(o.up||Bn);if(y.lengthSq()<=1e-12)throw new Error("camera.up must not be the zero vector");return{name:o.name,preset:o.preset,position:d.toArray(),target:h.toArray(),up:y.normalize().toArray(),zoom:o.zoom,direction:m.normalize().toArray(),view:{name:o.name,direction:m.normalize().toArray(),up:y.normalize().toArray(),zoom:o.zoom},sourceKind:o.sourceKind,hasExplicitPosition:o.hasExplicitPosition,hasExplicitTarget:o.hasExplicitTarget,hasExplicitUp:o.hasExplicitUp,hasExplicitZoom:o.hasExplicitZoom,radius:l,size:u.toArray()}}function Vx(n=fi,e={}){let t=Ap(n,e);return t.sourceKind==="object"&&(t.hasExplicitPosition||t.hasExplicitTarget||t.hasExplicitUp)}var bn=Object.freeze({PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"});function wu(n,e=bn.PERSPECTIVE){let t=String(n||"").trim().toLowerCase();return t===bn.ORTHOGRAPHIC?bn.ORTHOGRAPHIC:t===bn.PERSPECTIVE?bn.PERSPECTIVE:e===bn.ORTHOGRAPHIC?bn.ORTHOGRAPHIC:bn.PERSPECTIVE}var at=Object.freeze({HIDDEN_EDGES:"hidden_edges",HIDDEN_LINES_REMOVED:"hidden_lines_removed",RENDERED:"rendered",SOLID:"solid",TRANSPARENT:"transparent",UNSHADED:"unshaded",WIREFRAME:"wireframe"}),yC=Object.freeze(Object.values(at)),xC=Object.freeze(["x","y","z","radial"]),VL=Object.freeze(["positive","negative"]),Tu=8,_C=/^#(?:[0-9a-fA-F]{3}){1,2}$/,us="#132232",kx="#8dc5ff",SC=Object.freeze(["feature","tangent","seam","degenerate"]),wp=Object.freeze({feature:Object.freeze({color:us,opacity:1,thickness:1.15}),tangent:Object.freeze({color:us,opacity:.5,thickness:1.15}),seam:Object.freeze({color:us,opacity:.85,thickness:1.15}),degenerate:Object.freeze({color:us,opacity:1,thickness:0})}),Ya=Object.freeze({enabled:!0,contrastMode:"manual",color:us,thickness:1,classes:wp,highlightColor:kx,highlightOpacity:1,highlightThickness:3,silhouette:!1,silhouetteScale:0}),Gx=Object.freeze({...Ya,enabled:!1}),Xi=Object.freeze({enabled:!1,axis:"z",direction:"positive",spacing:1.45,depth:1,keepBaseGrounded:!0,mergeCoplanar:!1,autoFrame:!0}),bC=Object.freeze({projection:bn.ORTHOGRAPHIC,mode:at.SOLID,clip:Au,exploded:Xi,edges:Ya});function fs(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function Hx(n,e,t){return Math.min(Math.max(n,e),t)}function hs(n,e,t=-1/0,i=1/0){let r=Number(n);return Number.isFinite(r)?Hx(r,t,i):e}function Cu(n,e){let t=String(n||"").trim();return _C.test(t)?t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`.toLowerCase():t.toLowerCase():e}function Ao(n,e=!1){return typeof n=="boolean"?n:e}function MC(n,e="manual"){let t=String(n||"").trim().toLowerCase();return["auto","manual"].includes(t)?t:e}function vC(n={},e=wp,t=us){let i=fs(n)?n:{},r=Cu(t,us);return Object.fromEntries(SC.map(s=>{let o=fs(i[s])?i[s]:{},a=e?.[s]||wp[s],c=o.enabled===!1;return[s,{color:Cu(o.color,r),opacity:hs(o.opacity,a.opacity,0,1),thickness:c?0:hs(o.thickness,a.thickness,0,6)}]}))}function qa(n=null,e=Ya){let t=fs(n)?n:{},i=Cu(t.color,e.color),r={enabled:Ao(t.enabled,e.enabled),contrastMode:MC(t.contrastMode,e.contrastMode),color:i,thickness:hs(t.thickness,e.thickness,.5,6),classes:vC(t.classes,e.classes,i),highlightColor:Cu(t.highlightColor,e.highlightColor||kx),highlightOpacity:hs(t.highlightOpacity,e.highlightOpacity||1,0,1),highlightThickness:hs(t.highlightThickness,e.highlightThickness||3,.5,6),silhouette:Ao(t.silhouette,e.silhouette||!1),silhouetteScale:hs(t.silhouetteScale,e.silhouetteScale||0,0,.04)};return typeof t.depthTest=="boolean"&&(r.depthTest=t.depthTest),r}function AC(n){return String(n||"").trim().toLowerCase().replace(/\s+/g,"_").replace(/-/g,"_")}function ti(n){let e=AC(n);return e?e==="wire"||e==="wire_frame"?at.WIREFRAME:e==="edges"||e==="edge"||e==="shaded_edges"||e==="shaded_with_edges"||e==="with_edges"?at.SOLID:e==="shaded"||e==="shaded_without_edges"||e==="without_edges"?at.RENDERED:e==="translucent"||e==="xray"||e==="x_ray"||e==="see_through"?at.TRANSPARENT:e==="hidden_edge"||e==="hidden_edges_visible"||e==="hidden_edge_display"||e==="shaded_hidden_edges"?at.HIDDEN_EDGES:e==="visible_edges"||e==="visible_edges_only"||e==="hidden_lines"||e==="hidden_line_removed"||e==="hidden_lines_removed"||e==="hidden_edges_removed"?at.HIDDEN_LINES_REMOVED:e==="flat"?at.UNSHADED:e==="appearance"||e==="material"||e==="materials"?at.RENDERED:yC.includes(e)?e:at.SOLID:at.SOLID}function EC(n,e=Xi.axis){let t=String(n||"").trim().toLowerCase(),i=t.startsWith("-")?t.slice(1):t;return xC.includes(i)?i:e}function wC(n,e=Xi.direction){let t=String(n||"").trim().toLowerCase();return["negative","reverse","down","backward","-","-1"].includes(t)?"negative":["positive","forward","up","+","+1","1"].includes(t)?"positive":e}function TC(n,e=Xi.depth){let t=String(n??"").trim().toLowerCase();if(["all","full","parts","leaves","leaf"].includes(t))return Tu;let i=Math.round(Number(n));return Number.isFinite(i)?Hx(i,1,Tu):e}function Tp(n=null,e={}){let t=fs(n)?n:{},i=fs(e)?{...t,...e}:t,r=String(i.axis||"").trim().toLowerCase();return{enabled:Ao(i.enabled,Xi.enabled),axis:EC(i.axis),direction:wC(i.direction||(r.startsWith("-")?"negative":"positive")),spacing:hs(i.spacing??i.distance??i.distanceScale,Xi.spacing,.25,4),depth:TC(i.depth??i.levels??i.scopeDepth),keepBaseGrounded:Ao(i.keepBaseGrounded??i.groundBase,Xi.keepBaseGrounded),mergeCoplanar:Ao(i.mergeCoplanar??i.mergeLayers??i.coalesceLayers,Xi.mergeCoplanar),autoFrame:Ao(i.autoFrame,Xi.autoFrame)}}function Ru(n=null){let e=fs(n)?n:{},t={};return fs(e.exploded)&&e.exploded.enabled!==void 0&&(t.enabled=e.exploded.enabled),{projection:wu(e.projection,bC.projection),mode:ti(e.mode),clip:Xa(e.clip),exploded:Tp(e.exploded,t),edges:qa(e.edges)}}function Wx(n){return Ru(n).edges}function di(n){return ti(n)===at.WIREFRAME}function ja(n){return[at.SOLID,at.TRANSPARENT,at.HIDDEN_EDGES,at.HIDDEN_LINES_REMOVED].includes(ti(n))}function Xx(n){return![at.RENDERED,at.UNSHADED].includes(ti(n))}function Yx(n,e=null){let t=ti(n);return t===at.WIREFRAME||ja(t)}function Eo(n){return[at.TRANSPARENT,at.HIDDEN_EDGES].includes(ti(n))}function qx(n){return[at.UNSHADED,at.HIDDEN_LINES_REMOVED,at.WIREFRAME].includes(ti(n))}function Iu(n,e=1){let t=ti(n);if(t===at.WIREFRAME)return .035;if(t===at.TRANSPARENT)return .22;if(t===at.HIDDEN_LINES_REMOVED)return .045;let i=Number(e);return Number.isFinite(i)?i:1}var CC=/^#(?:[0-9a-fA-F]{3}){1,2}$/,RC=50,tc=Ya,nc=Gx;function Qx(n,e,t){return Math.min(Math.max(n,e),t)}function nt(n,e,t=-1/0,i=1/0){let r=Number(n);return Number.isFinite(r)?Qx(r,t,i):e}function St(n,e){let t=String(n||"").trim();return CC.test(t)?t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`.toLowerCase():t.toLowerCase():e}function e_(n,e=Se?.materials?.defaultColor||"#ffffff"){let i=(Array.isArray(n)?n:[n]).map(r=>St(r,"")).filter(Boolean).slice(0,RC);return i.length?i:[St(e,"#ffffff")]}function Pp(n={},e=0){let t=e_(n.fillColors,n.defaultColor||Se?.materials?.defaultColor||"#ffffff"),r=In(n.cycleColors,Se?.materials?.cycleColors||!1)?Math.max(Math.floor(Number(e)||0),0)%t.length:0;return t[r]}function IC(n,e="#000000"){let t=St(n,e),i=t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t,r=s=>{let o=parseInt(i.slice(s,s+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return{r:r(1),g:r(3),b:r(5)}}function PC(n,e="#000000"){let t=IC(n,e);return .2126*t.r+.7152*t.g+.0722*t.b}function In(n,e=!1){return typeof n=="boolean"?n:e}function NC(n,e="solid"){let t=String(n||"").trim().toLowerCase();return["solid","linear","radial","transparent"].includes(t)?t:e}function LC(n,e="multiply"){let t=String(n||"").trim().toLowerCase();return["multiply","blend"].includes(t)?t:e}var Lt=Object.freeze({STAGE:"stage",GRID:"grid",NONE:"none"}),$t=Object.freeze({SYSTEM:"system",LIGHT:"light",DARK:"dark"}),OC=Object.freeze(Object.values($t));function Pu(n,e=$t.SYSTEM){let t=String(n||"").trim().toLowerCase();return OC.includes(t)?t:e}var t_=Object.freeze([Object.freeze(["background","solidColor"]),Object.freeze(["background","linearStart"]),Object.freeze(["background","linearEnd"]),Object.freeze(["background","radialInner"]),Object.freeze(["background","radialOuter"]),Object.freeze(["floor","color"]),Object.freeze(["floor","gridCenterColor"]),Object.freeze(["floor","gridCellColor"]),Object.freeze(["floor","grid","centerColor"]),Object.freeze(["floor","grid","cellColor"]),Object.freeze(["lighting","directional","color"]),Object.freeze(["lighting","spot","color"]),Object.freeze(["lighting","point","color"]),Object.freeze(["lighting","ambient","color"]),Object.freeze(["lighting","hemisphere","skyColor"]),Object.freeze(["lighting","hemisphere","groundColor"])]);function Rp(n,e){return e.reduce((t,i)=>t&&typeof t=="object"?t[i]:void 0,n)}function n_(n,e,t){let i=n;for(let r=0;r<e.length-1;r+=1){let s=e[r];(!i[s]||typeof i[s]!="object"||Array.isArray(i[s]))&&(i[s]={}),i=i[s]}i[e[e.length-1]]=t}function i_(n){return JSON.parse(JSON.stringify(n))}function Nu(n={},e=n){let t={};for(let i of t_){let r=Rp(e,i)||"#ffffff";n_(t,i,St(Rp(n,i),r))}return t}function Np(n={},e=n){return Object.freeze({light:Nu(n,n),dark:Nu(e,n)})}function wo(n,e,t=Np(n,n)){return Object.freeze({...n,colorMode:Pu(e),modeColors:t})}function DC(n={},e=Se){let t=n&&typeof n=="object"?n:{},i=e&&typeof e=="object"?e:Se,r=i?.modeColors&&typeof i.modeColors=="object"?i.modeColors:Np(i,i);return{light:Nu(t.light,r.light||i),dark:Nu(t.dark,r.dark||i)}}function UC(n,e={}){for(let t of t_){let i=Rp(e,t);i&&n_(n,t,i)}}var Du=.25,Uu=4,ds=Object.freeze({enabled:!0,gridCenterColor:"#6b7280",gridCellColor:"#cbd5e1",gridOpacity:.18,gridDensity:1,centerColor:"#6b7280",cellColor:"#cbd5e1",opacity:.18,density:1});function FC(n,e=Lt.STAGE){let t=String(n||"").trim().toLowerCase();return t==="glass"?Lt.STAGE:Object.values(Lt).includes(t)?t:e}var Ip=Object.freeze([{id:"studio-hdri-43",label:"Studio HDRI 43",url:"https://static.morflax.com/textures/env/Studio_HDRI_43.jpg"},{id:"studio-hdri-41",label:"Studio HDRI 41",url:"https://static.morflax.com/textures/env/Studio_HDRI_41.jpg"},{id:"studio-hdri-12",label:"Studio HDRI 12",url:"https://static.morflax.com/textures/env/Studio_HDRI_12.jpg"},{id:"studio-hdri-17",label:"Studio HDRI 17",url:"https://static.morflax.com/textures/env/Studio_HDRI_17.jpg"},{id:"studio-hdri-22",label:"Studio HDRI 22",url:"https://static.morflax.com/textures/env/Studio_HDRI_22.jpg"},{id:"colorful-1",label:"Colorful 1",url:"https://static.morflax.com/textures/env/colorful-1.jpg"},{id:"colorful-dark-1",label:"Colorful Dark 1",url:"https://static.morflax.com/textures/env/colorful-dark-1.jpg"}]),Lu=Object.freeze(["#b6c4ce","#f4a7a7","#f8c77e","#f7e38d","#b9e88f","#8fe3c0","#92d7f5","#a9b8ff","#c7a8ff","#f2a7d9"]),Za=Object.freeze(["#4cc9f0"]),Ja=Object.freeze(["#ff4faf"]),Qa=Object.freeze(["#b9856e"]),Sr=Object.freeze(["#178f9f","#ef7459"]),ec=Object.freeze(["#0b7a3f"]),r_="#66ff99",BC="#b7ffc9",zC=Object.freeze({feature:Object.freeze({opacity:1,thickness:1.15}),tangent:Object.freeze({opacity:.84,thickness:.95}),seam:Object.freeze({opacity:.92,thickness:1}),degenerate:Object.freeze({opacity:.72,thickness:.8})}),VC=Object.freeze({...tc,enabled:!0,color:r_,classes:zC,highlightColor:BC,highlightOpacity:1,highlightThickness:3}),jx=Object.freeze(["#b6c4ce","#8f9aa3","#d3dae0","#68737d"]);function zn(n,e,t=.5){let i=St(n,"#000000"),r=St(e,i),s=Qx(Number(t),0,1),o=a=>{let c=parseInt(i.slice(a,a+2),16),l=parseInt(r.slice(a,a+2),16);return Math.round(c+(l-c)*s).toString(16).padStart(2,"0")};return`#${o(1)}${o(3)}${o(5)}`}function kC(n,e){let t=Array.isArray(n)?n:[],i=Array.isArray(e)?e:[],r=Math.max(t.length,i.length);return Object.freeze(r?Array.from({length:r},(s,o)=>{let a=t[o]||t.at(-1)||"#ffffff",c=i[o]||i.at(-1)||a;return zn(a,c)}):["#ffffff"])}function ni(n,e={}){let t=St(n,"#f1f5f9"),i=In(e.enabled,!1),r=PC(t)>=.36,s=St(e.centerColor,r?zn(t,"#0f172a",.48):zn(t,"#f8fafc",.46)),o=St(e.cellColor,r?zn(t,"#475569",.26):zn(t,"#cbd5e1",.22)),a=nt(e.opacity,ds.opacity,0,1),c=nt(e.density,ds.density,Du,Uu);return{gridCenterColor:s,gridCellColor:o,gridOpacity:a,gridDensity:c,grid:{enabled:i,centerColor:s,cellColor:o,opacity:a,density:c},centerColor:s,cellColor:o,opacity:a,density:c}}var Vn=Object.freeze({materials:{defaultColor:Lu[0],fillColors:Lu,cycleColors:!1,overrideSourceColors:!1,tintMode:"blend",tintStrength:0,saturation:1.18,contrast:1.12,brightness:1.02,roughness:.58,metalness:.02,clearcoat:.12,clearcoatRoughness:.42,opacity:1,envMapIntensity:.42,emissiveIntensity:.02},edges:{...tc},background:{type:"linear",solidColor:"#edf5fb",linearStart:"#fbfdff",linearEnd:"#b8cadb",linearAngle:135,radialInner:"#ffffff",radialOuter:"#b3c4d4"},floor:{mode:Lt.STAGE,color:"#edf3f8",roughness:.7,reflectivity:.14,shadowOpacity:.16,horizonBlend:.18,...ni("#edf3f8",{opacity:.2}),enabled:!1},environment:{enabled:!0,presetId:"studio-hdri-43",intensity:.32,rotationY:-.25,useAsBackground:!1},lighting:{toneMappingExposure:1.16,directional:{enabled:!0,color:"#ffffff",intensity:1.16,position:{x:-210,y:260,z:270}},spot:{enabled:!0,color:"#f4fbff",intensity:.52,angle:.74,distance:0,position:{x:190,y:210,z:170}},point:{enabled:!0,color:"#ffe2ba",intensity:.28,distance:0,position:{x:-240,y:110,z:-210}},ambient:{enabled:!0,color:"#ffffff",intensity:.4},hemisphere:{enabled:!0,skyColor:"#ffffff",groundColor:"#d6e2ee",intensity:1.12}}}),ht=Object.freeze({materials:{defaultColor:Lu[0],fillColors:Lu,cycleColors:!1,overrideSourceColors:!1,tintMode:"blend",tintStrength:0,saturation:1.2,contrast:1.14,brightness:1.06,roughness:.54,metalness:.02,clearcoat:.14,clearcoatRoughness:.4,opacity:1,envMapIntensity:.5,emissiveIntensity:.03},edges:{...nc},background:{type:"linear",solidColor:"#081b2d",linearStart:"#18304a",linearEnd:"#030914",linearAngle:135,radialInner:"#174267",radialOuter:"#030914"},floor:{mode:Lt.STAGE,color:"#0a2238",roughness:.38,reflectivity:.1,shadowOpacity:.42,horizonBlend:.1,...ni("#0a2238",{opacity:.22}),enabled:!1},environment:{enabled:!0,presetId:"studio-hdri-43",intensity:.18,rotationY:-.25,useAsBackground:!1},lighting:{toneMappingExposure:1.22,directional:{enabled:!0,color:"#ffffff",intensity:1.42,position:{x:-210,y:260,z:270}},spot:{enabled:!0,color:"#70c4ff",intensity:.24,angle:.74,distance:0,position:{x:190,y:210,z:170}},point:{enabled:!0,color:"#9bd0ff",intensity:.36,distance:0,position:{x:-240,y:110,z:-210}},ambient:{enabled:!0,color:"#c6d8ea",intensity:.24},hemisphere:{enabled:!0,skyColor:"#ffffff",groundColor:"#020713",intensity:.98}}}),_r=Object.freeze({...ht,materials:{...ht.materials,defaultColor:jx[0],fillColors:jx},background:{...ht.background,solidColor:"#151617",linearStart:"#2a2b2d",linearEnd:"#070809",radialInner:"#303133",radialOuter:"#070809"},floor:{...ht.floor,color:"#171819",...ni("#171819",{opacity:.22})}}),$x=kC(ht.materials.fillColors,_r.materials.fillColors),xr=Object.freeze({...ht,materials:{...ht.materials,defaultColor:$x[0],fillColors:$x},edges:{...tc},background:{...ht.background,solidColor:zn(ht.background.solidColor,_r.background.solidColor),linearStart:zn(ht.background.linearStart,_r.background.linearStart),linearEnd:zn(ht.background.linearEnd,_r.background.linearEnd),radialInner:zn(ht.background.radialInner,_r.background.radialInner),radialOuter:zn(ht.background.radialOuter,_r.background.radialOuter)},floor:{...ht.floor,color:zn(ht.floor.color,_r.floor.color),...ni(zn(ht.floor.color,_r.floor.color),{opacity:.22})}}),GC=Object.freeze({materials:{...ht.materials,defaultColor:Za[0],fillColors:Za,cycleColors:!1},edges:{...nc},background:{type:"radial",solidColor:"#04131f",linearStart:"#07253a",linearEnd:"#0b8edc",linearAngle:128,radialInner:"#0b8edc",radialOuter:"#02070c"},floor:{mode:Lt.STAGE,color:"#06324f",roughness:.58,reflectivity:.2,shadowOpacity:.3,horizonBlend:.18,...ni("#06324f",{opacity:.24}),enabled:!1},environment:ht.environment,lighting:ht.lighting}),HC=Object.freeze({materials:{...ht.materials,defaultColor:Ja[0],fillColors:Ja,cycleColors:!1},edges:{...nc},background:{type:"radial",solidColor:"#281323",linearStart:"#7a1a52",linearEnd:"#301426",linearAngle:140,radialInner:"#7f1a55",radialOuter:"#25101f"},floor:{mode:Lt.STAGE,color:"#4a1833",roughness:.56,reflectivity:.2,shadowOpacity:.26,horizonBlend:.22,...ni("#4a1833",{opacity:.24}),enabled:!1},environment:ht.environment,lighting:ht.lighting}),WC=Object.freeze({materials:{...ht.materials,defaultColor:Qa[0],fillColors:Qa,cycleColors:!1},edges:{...nc},background:{type:"linear",solidColor:"#f3eadc",linearStart:"#f7ead8",linearEnd:"#c88d5d",linearAngle:162,radialInner:"#f7ead8",radialOuter:"#b06c43"},floor:{mode:Lt.STAGE,color:"#d4a070",roughness:.72,reflectivity:.14,shadowOpacity:.34,horizonBlend:.12,...ni("#d4a070",{opacity:.18}),enabled:!1},environment:ht.environment,lighting:ht.lighting}),XC=Object.freeze({materials:{...Vn.materials,defaultColor:Sr[0],fillColors:Sr,cycleColors:!0},edges:{...nc},background:{type:"linear",solidColor:"#dff7f7",linearStart:"#fff4d6",linearEnd:"#47c5d6",linearAngle:152,radialInner:"#fff8e8",radialOuter:"#1a8fb5"},floor:{mode:Lt.STAGE,color:"#f2d59b",roughness:.74,reflectivity:.18,shadowOpacity:.2,horizonBlend:.2,...ni("#f2d59b",{opacity:.18}),enabled:!1},environment:{enabled:!0,presetId:"studio-hdri-12",intensity:.36,rotationY:-.18,useAsBackground:!1},lighting:{toneMappingExposure:1.18,directional:{enabled:!0,color:"#fff7df",intensity:1.3,position:{x:-220,y:280,z:250}},spot:{enabled:!0,color:"#e4fbff",intensity:.36,angle:.72,distance:0,position:{x:190,y:210,z:170}},point:{enabled:!0,color:"#ffd08a",intensity:.24,distance:0,position:{x:-240,y:110,z:-210}},ambient:{enabled:!0,color:"#fff8e6",intensity:.34},hemisphere:{enabled:!0,skyColor:"#bff8ff",groundColor:"#f2d59b",intensity:1.04}}}),YC=Object.freeze({materials:{...ht.materials,defaultColor:ec[0],fillColors:ec,cycleColors:!1},edges:{...VC},background:{type:"radial",solidColor:"#020403",linearStart:"#031109",linearEnd:"#000000",linearAngle:180,radialInner:"#062414",radialOuter:"#000201"},floor:{mode:Lt.GRID,color:"#020403",roughness:.58,reflectivity:.12,shadowOpacity:.35,horizonBlend:0,gridCenterColor:r_,gridCellColor:"#0c3d22",gridOpacity:.34,gridDensity:1.15},environment:ht.environment,lighting:ht.lighting}),$a="#f0f4f9",Kx="#e2e9f0",Zx=Object.freeze({...Vn,background:{...Vn.background,type:"solid",solidColor:$a,linearStart:$a,linearEnd:$a,radialInner:$a,radialOuter:$a},edges:{...tc},floor:{...Vn.floor,color:Kx,enabled:!0,...ni(Kx,{enabled:!0,opacity:.2})},environment:{...Vn.environment,enabled:!1},lighting:{...Vn.lighting,hemisphere:{...Vn.lighting.hemisphere,groundColor:"#c7d5e3"}}}),Jx="#202832",qC=Object.freeze({...xr,edges:{...tc,color:"#1c2836"},background:{...xr.background,solidColor:"#181f28",linearStart:"#242e3a",linearEnd:"#0c1016",radialInner:"#293443",radialOuter:"#0c1016"},floor:{...xr.floor,color:Jx,enabled:!0,...ni(Jx,{enabled:!0,opacity:.22})},lighting:{...xr.lighting,spot:{...xr.lighting.spot,color:"#b3d4f2"},point:{...xr.lighting.point,color:"#bfd8f0"},ambient:{...xr.lighting.ambient,color:"#dfe7f0"},hemisphere:{...xr.lighting.hemisphere,groundColor:"#333d4b"}}}),Lp=wo(Zx,$t.SYSTEM,Np(Zx,qC)),jC=wo(GC,$t.DARK),$C=wo(HC,$t.DARK),KC=wo(WC,$t.LIGHT),ZC=wo(XC,$t.LIGHT),JC=wo(YC,$t.DARK),Ou=Object.freeze([{id:"workbench",label:"Workbench",description:"Balanced CAD workbench lighting with system-aware light and dark canvas colors.",preview:{background:"#f0f4f9",modelColor:"#b6c4ce",accentColor:"#4ea7d8"},settings:Lp},{id:"blue",label:"Blue",description:"Single cyan fill against deep-navy CAD lighting.",preview:{background:Za[0],modelColor:Za[0],accentColor:Za[0]},settings:jC},{id:"pink",label:"Magenta",description:"Single saturated magenta fill against a near-black studio backdrop.",preview:{background:Ja[0],modelColor:Ja[0],accentColor:Ja[0]},settings:$C},{id:"clay-sunrise",label:"Clay",description:"Single warm clay fill with a soft presentation stage.",preview:{background:Qa[0],modelColor:Qa[0],accentColor:Qa[0]},settings:KC},{id:"beach",label:"Beach",description:"Two-color aqua-and-coral fill with warm beach presentation lighting.",preview:{background:`linear-gradient(135deg, ${Sr[0]} 0%, ${Sr[0]} 50%, ${Sr[1]} 50%, ${Sr[1]} 100%)`,modelColor:Sr[0],accentColor:Sr[1]},settings:ZC},{id:"terminal",label:"Terminal",description:"Single terminal-green fill with green CAD edge linework and a dark grid floor.",preview:{background:ec[0],modelColor:ec[0],accentColor:ec[0]},settings:JC}]),QC=Object.freeze({cinematic:"workbench",light:"workbench",dark:"workbench",charcoal:"workbench",darkoal:"workbench","dark-2":"workbench"}),eR="workbench",s_=Object.freeze(Ou.find(n=>n.id===eR)||Ou[0]),Se=Object.freeze(s_.settings);var tR=new Set(Ip.map(n=>n.id)),nR=Object.freeze({defaultColor:"#aeb9c3",tintStrength:.28,saturation:.42,contrast:1.02,brightness:.94,roughness:.46,metalness:.02,clearcoat:.18,clearcoatRoughness:.34,opacity:1,envMapIntensity:.58}),iR=Object.freeze({defaultColor:"#aeb9c3",tintMode:"blend",tintStrength:.08,saturation:1,contrast:1.04,brightness:1.02,roughness:.46,metalness:.02,clearcoat:.18,clearcoatRoughness:.34,opacity:1,envMapIntensity:.58,emissiveIntensity:.06}),rR=Object.freeze({defaultColor:"#aeb9c3",tintMode:"blend",tintStrength:0,saturation:1.34,contrast:1.02,brightness:.82,roughness:.76,metalness:0,clearcoat:0,clearcoatRoughness:.72,opacity:1,envMapIntensity:.08,emissiveIntensity:.01}),sR=Object.freeze({defaultColor:"#bcc8d4",tintMode:"blend",tintStrength:0,saturation:1.18,contrast:1.07,brightness:1.04,roughness:.58,metalness:.02,clearcoat:.12,clearcoatRoughness:.42,opacity:1,envMapIntensity:.42,emissiveIntensity:.02}),oR=Object.freeze({defaultColor:"#748899",tintMode:"blend",tintStrength:0,saturation:1.18,contrast:1.07,brightness:1.04,roughness:.58,metalness:.02,clearcoat:.12,clearcoatRoughness:.42,opacity:1,envMapIntensity:.42,emissiveIntensity:.02}),aR=Object.freeze({defaultColor:"#556c7f",tintMode:"blend",tintStrength:0,saturation:1.18,contrast:1.12,brightness:1.02,roughness:.58,metalness:.02,clearcoat:.12,clearcoatRoughness:.42,opacity:1,envMapIntensity:.42,emissiveIntensity:.02}),HL=Object.freeze({enabled:!1,color:"#8fa1b5",thickness:1}),WL=Object.freeze({enabled:!0,color:"#8fa1b5",thickness:1.65}),XL=Object.freeze({enabled:!1,color:"#8fa1b5",thickness:1}),YL=Object.freeze({enabled:!1,color:"#8fa1b5",thickness:1}),o_=Object.freeze({solidColor:"#050711",linearStart:"#02040b",linearEnd:"#252f47",linearAngle:90,radialInner:"#171d30",radialOuter:"#02040b"}),cR=o_,lR=Object.freeze({solidColor:"#0a0f18",linearStart:"#08111c",linearEnd:"#1f2c3d",linearAngle:90,radialInner:"#182337",radialOuter:"#08111c"}),uR=Object.freeze({mode:Lt.STAGE,color:"#141a29",roughness:.62,reflectivity:.22,shadowOpacity:.24,horizonBlend:.28}),hR=Object.freeze({mode:Lt.STAGE,color:"#141a29",roughness:.62,reflectivity:.06,shadowOpacity:.24,horizonBlend:.12}),fR=Object.freeze({mode:Lt.STAGE,color:"#121a24",roughness:.86,reflectivity:.06,shadowOpacity:.24,horizonBlend:.28}),dR=Object.freeze({enabled:!0,presetId:"studio-hdri-43",intensity:.46,rotationY:-.35,useAsBackground:!1}),pR=Object.freeze({enabled:!1,presetId:"studio-hdri-43",intensity:0,rotationY:-.35,useAsBackground:!1}),mR=Object.freeze({toneMappingExposure:1.2,directional:{enabled:!0,color:"#f1f6fb",intensity:2.45,position:{x:-190,y:300,z:210}},spot:{enabled:!0,color:"#dbeafe",intensity:1.34,angle:.72,distance:0,position:{x:160,y:245,z:126}},point:{enabled:!0,color:"#8fb6d8",intensity:.34,distance:0,position:{x:-260,y:95,z:-220}},ambient:{enabled:!0,color:"#1e293b",intensity:.2},hemisphere:{enabled:!0,skyColor:"#dbe7f3",groundColor:"#070a14",intensity:.68}}),gR=Object.freeze({toneMappingExposure:1.03,directional:{enabled:!0,color:"#f1f6fb",intensity:1.28,position:{x:-190,y:300,z:210}},spot:{enabled:!0,color:"#dbeafe",intensity:.18,angle:.72,distance:0,position:{x:160,y:245,z:126}},point:{enabled:!0,color:"#8fb6d8",intensity:.08,distance:0,position:{x:-260,y:95,z:-220}},ambient:{enabled:!0,color:"#1e293b",intensity:.42},hemisphere:{enabled:!0,skyColor:"#dbe7f3",groundColor:"#070a14",intensity:.92}});function yR(n){let e=String(n||"").trim();return tR.has(e)?e:Se.environment.presetId}function Cp(n,e){return{x:nt(n?.x,e.x,-5e3,5e3),y:nt(n?.y,e.y,-5e3,5e3),z:nt(n?.z,e.z,-5e3,5e3)}}function a_(n,e){return typeof e=="number"?Math.abs((Number(n)||0)-e)<1e-6:e&&typeof e=="object"?!n||typeof n!="object"?!1:Object.entries(e).every(([t,i])=>a_(n[t],i)):n===e}function Ka(n,e){return e.some(t=>a_(n,t))}function xR(n){let e=Ka(n?.materials,[nR,iR,rR,sR,oR,aR,Vn.materials]),t=Ka(n?.floor,[uR,hR,fR,Vn.floor]),i=Ka(n?.environment,[dR,pR,Vn.environment,Lp.environment]),r=Ka(n?.background,[o_,cR,lR,Vn.background]),s=Ka(n?.lighting,[mR,gR,Vn.lighting]);return e&&r&&t&&i&&s}function br(n={}){let e=n&&typeof n=="object"?n:{},t=e.materials&&typeof e.materials=="object"?e.materials:{},i=e.background&&typeof e.background=="object"?e.background:{},r=e.environment&&typeof e.environment=="object"?e.environment:{},s=e.floor&&typeof e.floor=="object"?e.floor:{},o=e.lighting&&typeof e.lighting=="object"?e.lighting:{},a=!!(e.materials&&typeof e.materials=="object"),c=a&&!Object.hasOwn(t,"tintMode"),l=a&&!Object.hasOwn(t,"emissiveIntensity"),u=St(t.defaultColor||t.tintColor,Se.materials.defaultColor),h=e_(t.fillColors,u),f=St(s.color,Se.floor?.color||"#141416"),d=FC(s.mode,Se.floor?.mode||Lt.STAGE),m=s.grid&&typeof s.grid=="object"&&!Array.isArray(s.grid)?s.grid:{},y=ni(f),g=St(m.centerColor??s.gridCenterColor??s.gridCenter,y.centerColor),p=St(m.cellColor??s.gridCellColor??s.gridCell,y.cellColor),_=nt(m.opacity??s.gridOpacity,y.opacity,0,1),x=nt(m.density??s.gridDensity,y.density,Du,Uu),T={colorMode:Pu(e.colorMode,Se?.colorMode||$t.SYSTEM),materials:{defaultColor:h[0]||u,fillColors:h,cycleColors:In(t.cycleColors,Se.materials.cycleColors||!1),overrideSourceColors:In(t.overrideSourceColors,Se.materials.overrideSourceColors||!1),tintMode:LC(t.tintMode,c?"multiply":Se.materials.tintMode),tintStrength:nt(t.tintStrength,Se.materials.tintStrength,0,1),saturation:nt(t.saturation,Se.materials.saturation,0,2.5),contrast:nt(t.contrast,Se.materials.contrast,0,2.5),brightness:nt(t.brightness,Se.materials.brightness,0,2),roughness:nt(t.roughness,Se.materials.roughness,0,1),metalness:nt(t.metalness,Se.materials.metalness,0,1),clearcoat:nt(t.clearcoat,Se.materials.clearcoat,0,1),clearcoatRoughness:nt(t.clearcoatRoughness,Se.materials.clearcoatRoughness,0,1),opacity:nt(t.opacity,Se.materials.opacity,0,1),envMapIntensity:nt(t.envMapIntensity,Se.materials.envMapIntensity,0,4),emissiveIntensity:nt(t.emissiveIntensity,l?0:Se.materials.emissiveIntensity,0,2)},background:{type:NC(i.type,Se.background.type),solidColor:St(i.solidColor,Se.background.solidColor),linearStart:St(i.linearStart,Se.background.linearStart),linearEnd:St(i.linearEnd,Se.background.linearEnd),linearAngle:nt(i.linearAngle,Se.background.linearAngle,-360,360),radialInner:St(i.radialInner,Se.background.radialInner),radialOuter:St(i.radialOuter,Se.background.radialOuter)},floor:{mode:d,enabled:In(s.enabled,d!==Lt.NONE),color:f,roughness:nt(s.roughness,Se.floor?.roughness??.72,0,1),reflectivity:nt(s.reflectivity,Se.floor?.reflectivity??.12,0,1),shadowOpacity:nt(s.shadowOpacity,Se.floor?.shadowOpacity??.45,0,1),horizonBlend:nt(s.horizonBlend,Se.floor?.horizonBlend??0,0,1),gridCenterColor:g,gridCellColor:p,gridOpacity:_,gridDensity:x,grid:{enabled:In(m.enabled,d===Lt.GRID),centerColor:g,cellColor:p,opacity:_,density:x}},environment:{enabled:In(r.enabled,Se.environment.enabled),presetId:yR(r.presetId),intensity:nt(r.intensity,Se.environment.intensity,0,4),rotationY:nt(r.rotationY,Se.environment.rotationY,-Math.PI*2,Math.PI*2),useAsBackground:In(r.useAsBackground,Se.environment.useAsBackground)},lighting:{toneMappingExposure:nt(o.toneMappingExposure,Se.lighting.toneMappingExposure,.05,6),directional:{enabled:In(o.directional?.enabled,Se.lighting.directional.enabled),color:St(o.directional?.color,Se.lighting.directional.color),intensity:nt(o.directional?.intensity,Se.lighting.directional.intensity,0,20),position:Cp(o.directional?.position,Se.lighting.directional.position)},spot:{enabled:In(o.spot?.enabled,Se.lighting.spot.enabled),color:St(o.spot?.color,Se.lighting.spot.color),intensity:nt(o.spot?.intensity,Se.lighting.spot.intensity,0,20),angle:nt(o.spot?.angle,Se.lighting.spot.angle,.01,Math.PI/2),distance:nt(o.spot?.distance,Se.lighting.spot.distance,0,5e3),position:Cp(o.spot?.position,Se.lighting.spot.position)},point:{enabled:In(o.point?.enabled,Se.lighting.point.enabled),color:St(o.point?.color,Se.lighting.point.color),intensity:nt(o.point?.intensity,Se.lighting.point.intensity,0,20),distance:nt(o.point?.distance,Se.lighting.point.distance,0,5e3),position:Cp(o.point?.position,Se.lighting.point.position)},ambient:{enabled:In(o.ambient?.enabled,Se.lighting.ambient.enabled),color:St(o.ambient?.color,Se.lighting.ambient.color),intensity:nt(o.ambient?.intensity,Se.lighting.ambient.intensity,0,20)},hemisphere:{enabled:In(o.hemisphere?.enabled,Se.lighting.hemisphere.enabled),skyColor:St(o.hemisphere?.skyColor,Se.lighting.hemisphere.skyColor),groundColor:St(o.hemisphere?.groundColor,Se.lighting.hemisphere.groundColor),intensity:nt(o.hemisphere?.intensity,Se.lighting.hemisphere.intensity,0,20)}}};return T.modeColors=DC(e.modeColors,T),!Object.hasOwn(e,"colorMode")&&!Object.hasOwn(e,"modeColors")&&xR(T)?br(i_(Lp)):T}function _R(n=Se){return br(JSON.parse(JSON.stringify(n)))}function SR(n){let e=String(n||"").trim(),t=QC[e]||e;return Ou.some(i=>i.id===t)?t:""}function bR(n){let e=SR(n);return Ou.find(t=>t.id===e)||s_}function MR(n){return _R(bR(n).settings)}function c_(n){return MR(n)}function vR(n={},{prefersDark:e=!1,systemFallback:t=$t.LIGHT}={}){let i=Pu(n?.colorMode,Se?.colorMode||$t.SYSTEM);return i===$t.SYSTEM?e===!0||Pu(t,$t.LIGHT)===$t.DARK?$t.DARK:$t.LIGHT:i}function l_(n={},e={}){let t=br(n),i=vR(t,e),r=i_(t);return r.colorMode=i,UC(r,t.modeColors?.[i]),br(r)}function u_(n){return Ip.find(e=>e.id===n)||Ip[0]}function AR(n){return n instanceof Float32Array}function Bp(n){return n instanceof Uint32Array}function pi(n,e){return Math.hypot(Number(e?.[0]||0)-Number(n?.[0]||0),Number(e?.[1]||0)-Number(n?.[1]||0),Number(e?.[2]||0)-Number(n?.[2]||0))}function ER(n){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0];for(let i of n)for(let r=0;r+2<i.length;r+=3)e[0]=Math.min(e[0],i[r]),e[1]=Math.min(e[1],i[r+1]),e[2]=Math.min(e[2],i[r+2]),t[0]=Math.max(t[0],i[r]),t[1]=Math.max(t[1],i[r+1]),t[2]=Math.max(t[2],i[r+2]);return!Number.isFinite(e[0])||!Number.isFinite(t[0])?null:{min:e,max:t}}function wR(n){let e=ER(n);return e?Math.max(1e-5,pi(e.min,e.max)*1e-7):1e-5}function Bu(n,e){let t=Number(e)*3;return!Number.isInteger(e)||t<0||t+2>=n.edgePositions.length?null:[n.edgePositions[t],n.edgePositions[t+1],n.edgePositions[t+2]]}function zu(n){return new Set((Array.isArray(n)?n:[n]).map(e=>String(e||"").trim()).filter(Boolean))}function p_(n){let e=(Array.isArray(n)?n:[n]).map(t=>String(t||"").trim().toLowerCase()).filter(Boolean);return e.length?new Set(e):null}function TR(n,e){let t=String(n||"").trim();if(!t||!e?.size)return!1;for(let i of e)if(t===i||t.startsWith(`${i}.`))return!0;return!1}function h_(n,e){return TR(n?.occurrenceId||n?.partId||n?.id,e)}function CR(n,e,t){return!(e.size&&!h_(n,e)||t.size&&h_(n,t))}function RR(n,e){if(!e?.size)return!0;let t=String(n?.visibilityClass||"feature").trim().toLowerCase()||"feature";return e.has(t)}function m_(n,e,t,i){return CR(n,e,t)&&RR(n,i)}function Op(n,e,t=1e-7){if(!e)return;let i=n.length>=3?[n[n.length-3],n[n.length-2],n[n.length-1]]:null;(!i||pi(i,e)>t)&&n.push(e[0],e[1],e[2])}function Dp(n,e,t){let i=[],r=[],s=null;for(let o=e;o<e+t;o+=1){let a=Number(n.edgeIndices[o*2]),c=Number(n.edgeIndices[o*2+1]),l=Bu(n,a),u=Bu(n,c);!l||!u||pi(l,u)<=1e-10||(s&&pi(s,l)>1e-5&&(r.length>=6&&i.push(new Float32Array(r)),r=[],s=null),s||Op(r,l),Op(r,u),s=u)}return r.length>=6&&i.push(new Float32Array(r)),i}function IR(n,e,t,i){let r=[],s=-1,o=0,a=()=>{s>=0&&o>0&&r.push(...Dp(n,s,o)),s=-1,o=0};for(let c=0;c<i;c+=1)Number(e[c])===t?(s<0&&(s=c),o+=1):a();return a(),r}function g_(n,e){let t=e*3;return[n[t],n[t+1],n[t+2]]}function Up(n){return g_(n,0)}function Fp(n){return g_(n,Math.floor(n.length/3)-1)}function f_(n){let e=[];for(let t=n.length-3;t>=0;t-=3)e.push(n[t],n[t+1],n[t+2]);return e}function Fu(n,e,{skipFirst:t=!0,tolerance:i=1e-7}={}){let r=t?3:0;for(let s=r;s+2<e.length;s+=3)Op(n,[e[s],e[s+1],e[s+2]],i)}function PR(n,e){if(n.length<12)return n;let t=Up(n),i=Fp(n);if(pi(t,i)>e)return n;let r=Array.from(n);return r[r.length-3]=r[0],r[r.length-2]=r[1],r[r.length-1]=r[2],new Float32Array(r)}function d_(n){if(!Array.isArray(n)||n.length<=1)return n||[];let e=wR(n),t=n.filter(i=>i?.length>=6).map(i=>Array.from(i));for(let i=0;i<t.length;i+=1){let r=!0;for(;r;){r=!1;for(let s=i+1;s<t.length;s+=1){let o=t[i],a=t[s],c=Up(o),l=Fp(o),u=Up(a),h=Fp(a),f=null;if(pi(l,u)<=e?(f=[...o],Fu(f,a,{tolerance:e})):pi(l,h)<=e?(f=[...o],Fu(f,f_(a),{tolerance:e})):pi(c,h)<=e?(f=[...a],Fu(f,o,{tolerance:e})):pi(c,u)<=e&&(f=f_(a),Fu(f,o,{tolerance:e})),f){t[i]=f,t.splice(s,1),r=!0;break}}}}return t.filter(i=>i.length>=6).map(i=>PR(new Float32Array(i),e))}function zp(n){let e=n?.proxy||{};return AR(e.edgePositions)&&Bp(e.edgeIndices)&&e.edgePositions.length>=6&&e.edgeIndices.length>=2}function y_(n){return!n?.surfaceEdgeRendering&&Number(n?.schemaVersion||0)<3&&zp(n)}function Vp(n,{includePartIds:e=[],excludePartIds:t=[],visibilityClasses:i=null}={}){if(!zp(n))return null;let r=n.proxy,s=Math.floor(r.edgeIndices.length/2);if(s<=0)return null;let o=zu(e),a=zu(t),c=o.size>0||a.size>0,l=p_(i),u=Array.isArray(n.edges)?n.edges:[],h=!!(l?.size&&u.length),f=c||h,d=Bp(r.edgeIds)?r.edgeIds:null,m=new Float32Array(s*6),y=0,g=p=>{let _=Number(r.edgeIndices[p*2]),x=Number(r.edgeIndices[p*2+1]),b=Bu(r,_),T=Bu(r,x);!b||!T||pi(b,T)<=1e-10||(m[y]=b[0],m[y+1]=b[1],m[y+2]=b[2],m[y+3]=T[0],m[y+4]=T[1],m[y+5]=T[2],y+=6)};if(f){if(!u.length)return null;for(let p=0;p<u.length;p+=1){let _=u[p];if(!m_(_,o,a,l))continue;let x=Number(_?.segmentStart||0),b=Number(_?.segmentCount||0);if(Number.isInteger(x)&&Number.isInteger(b)&&x>=0&&b>0&&x+b<=s){for(let T=x;T<x+b;T+=1)g(T);continue}if(d)for(let T=0;T<s;T+=1)Number(d[T])===p&&g(T)}}else for(let p=0;p<s;p+=1)g(p);return y<=0?null:y===m.length?m:m.subarray(0,y)}function x_(n,{includePartIds:e=[],excludePartIds:t=[],visibilityClasses:i=null}={}){if(!zp(n))return[];let r=n.proxy,s=Math.floor(r.edgeIndices.length/2);if(s<=0)return[];let o=Array.isArray(n.edges)?n.edges:[],a=Bp(r.edgeIds)?r.edgeIds:null,c=zu(e),l=zu(t),u=c.size>0||l.size>0,h=p_(i),f=!!(h?.size&&o.length),d=u||f,m=[];if(o.length){for(let y=0;y<o.length;y+=1){let g=o[y];if(!g||!m_(g,c,l,h))continue;let p=Number(g.segmentStart||0),_=Number(g.segmentCount||0);Number.isInteger(p)&&Number.isInteger(_)&&p>=0&&_>0&&p+_<=s?m.push(...Dp(r,p,_)):a&&m.push(...IR(r,a,y,s))}return d_(m)}if(d)return[];for(let y=0;y<s;y+=1){let g=a?Number(a[y]):-1;m.push(...Dp(r,y,1))}return d_(m)}function on(n,e,t){return Math.min(Math.max(n,e),t)}var To=0,NR=.0045,LR=25e-5,OR=.006,kp=new Set(["tangent","seam"]),DR=.006,UR=25e-5,FR=.008,v_=Object.freeze(["feature"]),BR=Object.freeze(["feature","tangent","seam","degenerate"]),A_=1200,E_=18e4,zR=/^#(?:[0-9a-fA-F]{3}){1,2}$/,Gp=Object.freeze({feature:Object.freeze({color:"#132232",opacity:1,thickness:1.15}),tangent:Object.freeze({color:"#132232",opacity:.5,thickness:1.15}),seam:Object.freeze({color:"#132232",opacity:.85,thickness:1.15}),degenerate:Object.freeze({color:"#132232",opacity:1,thickness:0})});function Hp(n=1,{visibilityClass:e=""}={}){let t=Number.isFinite(Number(n))?Math.max(1,Number(n)):1,i=String(e||"").trim().toLowerCase(),r=kp.has(i)?DR:NR,s=kp.has(i)?UR:LR,o=kp.has(i)?FR:OR;return on(r+Math.max(0,t-1)*s,r,o)}function VR(n){let e=n?.getAttribute?.("position"),t=e?.array;return!e?.count||!t?.length?null:t}function kR(n,e){if(!n)return;let t=on(Number(e)||0,0,1),i=t<.999;n.opacity=t,n.depthWrite=!1,n.transparent!==i&&(n.transparent=i,n.needsUpdate=!0)}function ku(n,e,t){let i=Math.max(1,Math.floor(Number(e)||1)),r=Math.max(1,Math.floor(Number(t)||1));for(let s of n||[])s?.resolution?.set?.(i,r)}function w_(n={},e,t=null){t?.add?.(e),n.registerScreenSpaceLineMaterial?.(e)}function T_(n={},e,t=null){t?.delete?.(e),n.unregisterScreenSpaceLineMaterial?.(e)}function Vu(n){return(Array.isArray(n)?n:[n]).map(e=>String(e||"").trim()).filter(Boolean)}function GR(n,e=[]){let t=String(n||"").trim();return!t||!e.length?!1:e.some(i=>t===i||t.startsWith(`${i}.`))}function __(n,e=[]){return GR(n?.occurrenceId||n?.partId||n?.id,e)}function HR(n,{includePartIds:e=[],excludePartIds:t=[],visibilityClasses:i=[]}={}){if(e.length&&!__(n,e)||t.length&&__(n,t))return!1;if(i.length){let r=String(n?.visibilityClass||"feature").trim().toLowerCase()||"feature";if(!i.includes(r))return!1}return!0}function WR(n,e={}){let t=Array.isArray(n?.edges)?n.edges:[];if(!t.length)return!1;let i=0,r=0;for(let s of t){if(!HR(s,e))continue;let o=Number.isFinite(Number(s?.segmentCount))?Math.max(1,Number(s.segmentCount)):1;if(i+=1,r+=(o+1)*3,i>A_||r>E_)return!1}return i>0}function XR(n,e=v_){let t=(Array.isArray(n)?n:[n]).map(i=>String(i||"").trim().toLowerCase()).filter(Boolean);return t.length?t:e}function S_(n,e){let t=String(n||"").trim();return zR.test(t)?t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`.toLowerCase():t.toLowerCase():e}function YR(n={},e={},t=v_){let i=n?.classes&&typeof n.classes=="object"?n.classes:null,r=i?[]:XR(n?.visibilityClasses,t),s=Number.isFinite(Number(n?.opacity))?on(Number(n.opacity),0,1):e?.edgeOpacity??.84,o=Number.isFinite(Number(n?.thickness))?on(Number(n.thickness),.5,6):e?.edgeThickness??1,a=S_(n?.color,e?.edge||"#18181b");return i?BR.map(c=>{let l=i[c]||Gp[c],u=Number.isFinite(Number(l.opacity))?on(Number(l.opacity),0,1):Gp[c].opacity,h=Number.isFinite(Number(l.thickness))?on(Number(l.thickness),0,6):Gp[c].thickness,f=S_(l.color,a);return h<=0||u<=0?null:{classId:c,color:f,opacity:u,thickness:h}}).filter(Boolean):r.map(c=>({classId:c,color:a,opacity:s,thickness:o}))}function qR(n){return Array.isArray(n?.edges)&&n.edges.some(e=>String(e?.visibilityClass||"").trim())}function C_(n={},e,{color:t,opacity:i=1,lineWidth:r=1,renderOrder:s=3,depthTest:o=!0,depthWrite:a=!1,depthBias:c=To}={},l=null){let u=n.LineSegments2,h=n.LineSegmentsGeometry,f=n.LineMaterial;if(!u||!h||!f||!(Array.isArray(e)||ArrayBuffer.isView(e))||!e.length)return null;let d=new h;d.setPositions(e);let m=R_(f,{color:t,opacity:i,lineWidth:r,depthTest:o,depthWrite:a,depthBias:c});w_(n,m,l);let y=new u(d,m);return y.renderOrder=s,y.frustumCulled=!1,y.userData.beforeDispose=()=>{T_(n,m,l)},y.userData.disposeGeometry=!0,y.userData.disposeMaterial=!0,y}function R_(n,{color:e,opacity:t=1,lineWidth:i=1,depthTest:r=!0,depthWrite:s=!1,depthBias:o=To}={}){let a=new n({color:e,linewidth:i,opacity:t,depthTest:r,depthWrite:s,toneMapped:!1,worldUnits:!1});return kR(a,t),Wp(a,o),a}function Wp(n,e=To){let t=on(Number(e)||0,0,.01);return!n||t<=0||(n.polygonOffset=!0,n.polygonOffsetFactor=0,n.polygonOffsetUnits=-on(Math.round(t*1e3),1,10),n.needsUpdate=!0),n}function b_(n={},e,{color:t,opacity:i=1,lineWidth:r=1,renderOrder:s=3,depthTest:o=!0,depthWrite:a=!1,depthBias:c=To}={},l=null){let u=n.Line2,h=n.LineGeometry,f=n.LineMaterial;if(!u||!h||!f||!(Array.isArray(e)||ArrayBuffer.isView(e))||e.length<6)return null;let d=new h;d.setPositions(e);let m=R_(f,{color:t,opacity:i,lineWidth:r,depthTest:o,depthWrite:a,depthBias:c});w_(n,m,l);let y=new u(d,m);return y.renderOrder=s,y.frustumCulled=!1,y.userData.beforeDispose=()=>{T_(n,m,l)},y.userData.disposeGeometry=!0,y.userData.disposeMaterial=!0,y}function M_(n={},e,{color:t,opacity:i=1,lineWidth:r=1,renderOrder:s=3,depthTest:o=!0,depthWrite:a=!1,depthBias:c=To}={}){let l=n.THREE;if(!l||!(Array.isArray(e)||ArrayBuffer.isView(e))||e.length<6)return null;let u=new l.BufferGeometry,h=e instanceof Float32Array?e:new Float32Array(e);u.setAttribute("position",new l.BufferAttribute(h,3));let f=new l.LineBasicMaterial({color:t,linewidth:Number.isFinite(Number(r))?Number(r):1,transparent:Number(i)<.999,opacity:on(Number(i)||0,0,1),depthTest:o,depthWrite:a,toneMapped:!1});Wp(f,c);let d=new l.Line(u,f);return d.renderOrder=s,d.frustumCulled=!1,d.userData.disposeGeometry=!0,d.userData.disposeMaterial=!0,d}function jR(n={},e,{color:t,opacity:i=1,renderOrder:r=3,depthTest:s=!0,depthWrite:o=!1,depthBias:a=To}={}){let c=n.THREE;if(!c||!(Array.isArray(e)||ArrayBuffer.isView(e))||e.length<6)return null;let l=new c.BufferGeometry,u=e instanceof Float32Array?e:new Float32Array(e);l.setAttribute("position",new c.BufferAttribute(u,3));let h=new c.LineBasicMaterial({color:t,transparent:Number(i)<.999,opacity:on(Number(i)||0,0,1),depthTest:s,depthWrite:o,toneMapped:!1});Wp(h,a);let f=new c.LineSegments(l,h);return f.renderOrder=r,f.frustumCulled=!1,f.userData.disposeGeometry=!0,f.userData.disposeMaterial=!0,f}function $R(n,e,t,i=null){let r=VR(e);return r?C_(n,r,t,i):null}function I_(n={},{geometry:e,edgeSettings:t,baseTheme:i,partId:r,displayMode:s,thickness:o,wireframeEdgeColor:a=""},c=null){let l=n.THREE,u=di(s),h=t?.depthTest!==!1,f=Number.isFinite(Number(t?.opacity))?on(Number(t.opacity),0,1):i?.edgeOpacity??.84,d=u?a||t?.color||i?.edge||"#18181b":t?.color||i?.edge||"#18181b";if(u&&l){let y=Math.max(f,.9),g=new l.LineBasicMaterial({color:d,transparent:y<.999,opacity:y,depthTest:!1,depthWrite:!1,toneMapped:!1}),p=new l.LineSegments(e,g);return p.renderOrder=4,p.frustumCulled=!1,p.userData.partId=r,{edgeMesh:p,edgeMaterial:g}}let m=$R(n,e,{color:d,opacity:f,lineWidth:Number.isFinite(Number(o))?Number(o):1,renderOrder:3,depthTest:h,depthWrite:!1,depthBias:Hp(o)},c);return m?(m.userData.partId=r,{edgeMesh:m,edgeMaterial:m.material}):{edgeMesh:null,edgeMaterial:null}}function Xp(n={},e,t,i,r=null){let s=Vu(t?.includePartIds),o=Vu(t?.excludePartIds),a=Vu(t?.focusedPartIds),c=Vu(t?.highlightPartIds),l=YR(t,i).filter(M=>M.classId==="feature"||qR(e)),u=l.map(M=>M.classId),h=Number.isFinite(Number(t?.opacity))?on(Number(t.opacity),0,1):i?.edgeOpacity??.84,f=Number.isFinite(Number(t?.highlightOpacity))?on(Number(t.highlightOpacity),0,1):h,d=Number.isFinite(Number(t?.dimmedOpacity))?on(Number(t.dimmedOpacity),0,1):h,m=Number.isFinite(Number(t?.thickness))?on(Number(t.thickness),.5,6):i?.edgeThickness??1,y={color:t?.color||i?.edge||"#18181b",lineWidth:m,renderOrder:3,depthTest:t?.depthTest!==!1,depthWrite:!1,depthBias:Hp(m)},g=(M,C)=>C_(n,M,C,r)||jR(n,M,C),p=(M,C={})=>(Number.isFinite(Number(C.lineWidth))?Number(C.lineWidth):1)<=1.05?M_(n,M,C)||b_(n,M,C,r):b_(n,M,C,r)||M_(n,M,C),_=M=>{let C=M.filter(Boolean);if(!C.length)return null;if(C.length===1)return C[0];let S=n.THREE?new n.THREE.Group:null;if(!S)return C[0];for(let v of C)S.add(v);return S},x=(M,C)=>{if(!n.THREE||!Array.isArray(M)||!M.length)return null;let S=M.reduce((v,L)=>v+(L?.length||0),0);return M.length>A_||S>E_?null:_(M.map(v=>p(v,C)))},b=(M,C={})=>{let S=Number.isFinite(Number(C.lineWidth))?Number(C.lineWidth):M.thickness,v={includePartIds:C.includePartIds||s,excludePartIds:C.excludePartIds||o,visibilityClasses:[M.classId]},L={...y,...C,color:C.color||M.color||y.color,lineWidth:S,opacity:Number.isFinite(Number(C.opacity))?C.opacity:M.opacity,depthBias:Number.isFinite(Number(C.depthBias))?C.depthBias:Hp(S,{visibilityClass:M.classId})},U=WR(e,v)?x_(e,v):[],G=x(U,L);if(G)return G;let P=Vp(e,{...v});return P?.length?g(P,L):null};if(c.length){let M=Vp(e,{includePartIds:c,visibilityClasses:u});if(!M?.length)return null;let C=g(M,{...y,color:t?.highlightColor||y.color,opacity:f,depthBias:Number.isFinite(Number(t?.highlightDepthBias))?on(Number(t.highlightDepthBias),0,.01):0,renderOrder:Number.isFinite(Number(t?.highlightRenderOrder))?Number(t.highlightRenderOrder):26});return C&&(C.name="TopologyDisplayEdgeHighlights",C.userData.partId="__topology_highlight__"),C}if(a.length&&n.THREE){let M=new n.THREE.Group;for(let C of l){let S=b(C,{excludePartIds:a,opacity:Math.min(d,C.opacity),renderOrder:3}),v=b(C,{includePartIds:a,opacity:C.opacity,renderOrder:4});S&&M.add(S),v&&M.add(v)}return M.children.length?(M.name="TopologyDisplayEdges",M.userData.partId="__topology__",M):null}let T=l.map(M=>b(M)),A=_(T);return A?(A.name="TopologyDisplayEdges",A.userData.partId="__topology__",A):null}var KR=/^\s*#([^\s]*)/,ZR=/^o((?:\d+)(?:\.\d+)*)$/,JR=/^o((?:\d+)(?:\.\d+)*)\.([sfev])(\d+)$/,QR=/^([sfev])(\d+)$/;function Yp(n){return n==="s"?"shape":n==="f"?"face":n==="e"?"edge":"vertex"}function Gu(n){let e=String(n||"").replace(/\\/g,"/").trim().replace(/^\/+|\/+$/g,"");return!e||e.split("/").some(t=>!t||t==="."||t==="..")?"":e}function qp(n,{inheritedOccurrenceId:e=""}={}){let t=String(n||"").trim().replace(/^#/,"");if(!t)return null;let i=t.match(JR);if(i){let o=`o${i[1]}`,a=i[2],c=Number(i[3]);return{selectorType:Yp(a),occurrenceId:o,ordinal:c,kind:a,canonical:`${o}.${a}${c}`}}let r=t.match(ZR);if(r)return{selectorType:"occurrence",occurrenceId:`o${r[1]}`,ordinal:null,kind:"",canonical:`o${r[1]}`};let s=t.match(QR);if(s){let o=s[1],a=Number(s[2]);return e?{selectorType:Yp(o),occurrenceId:e,ordinal:a,kind:o,canonical:`${e}.${o}${a}`}:{selectorType:Yp(o),occurrenceId:"",ordinal:a,kind:o,canonical:`${o}${a}`}}return{selectorType:"opaque",occurrenceId:"",ordinal:null,kind:"",canonical:t}}function N_(n,e={}){return qp(n,e)}function Hu(n){let e=Array.isArray(n)?n.flatMap(r=>String(r||"").split(",")):String(n||"").split(","),t=[],i="";for(let r of e){let s=qp(r,{inheritedOccurrenceId:i});s&&(t.push(s.canonical),s.occurrenceId&&(i=s.occurrenceId))}return t}function P_(n){let e=Hu(n),t=[...new Set(e.filter(Boolean))],i={occurrence:1,shape:2,face:3,edge:4,vertex:5,opaque:6};return t.map((r,s)=>({selector:r,index:s,parsed:qp(r)})).sort((r,s)=>{let o=r.parsed?.occurrenceId||"",a=s.parsed?.occurrenceId||"";if(o!==a)return o.localeCompare(a);let c=i[r.parsed?.selectorType]??99,l=i[s.parsed?.selectorType]??99;if(c!==l)return c-l;let u=Number(r.parsed?.ordinal||0),h=Number(s.parsed?.ordinal||0);return u!==h?u-h:r.selector!==s.selector?r.selector.localeCompare(s.selector):r.index-s.index}).map(r=>r.selector)}function Wu(n){let e=String(n||"").trim().match(KR);if(!e)return null;let t=String(e[1]||"").trim();return{token:e[0],cadPath:"",selectors:Hu(t)}}function ic({cadPath:n="",selector:e="",selectors:t}={}){let i=P_(t!==void 0?t:e?[e]:[]);return i.length?`#${i.join(",")}`:"#"}var L_=1,eI=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function fn(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function ut(n,e=""){return String(n??e).trim()||e}function Ut(n,e=0){let t=Number(n);return Number.isFinite(t)?t:e}function tI(n,e,t){return Math.min(Math.max(n,e),t)}function D_(n){let e=ut(n,"number").toLowerCase();return["number","boolean","enum","select","color","string","button"].includes(e)?e==="select"?"enum":e:"number"}function nI(n){return(Array.isArray(n)?n:[]).map(e=>{if(fn(e)){let i=ut(e.value);return i?{value:i,label:ut(e.label,i)}:null}let t=ut(e);return t?{value:t,label:t}:null}).filter(Boolean)}function iI(n,e){let t=fn(e)?e:{},i=D_(t.type),r=Ut(t.min,0),s=Math.max(Ut(t.max,i==="number"?1:r),r),o=nI(t.options||t.values),a=i==="boolean"?!1:i==="color"?"#ffffff":i==="enum"?o[0]?.value||"":i==="string"?"":0;return{id:n,type:i,label:ut(t.label,n),description:ut(t.description),unit:ut(t.unit),min:r,max:s,step:Math.max(Ut(t.step,i==="number"?.01:1),0),defaultValue:Xu({type:i,min:r,max:s,options:o},t.default??t.defaultValue??a),options:o}}function Xu(n,e){let t=D_(n?.type);if(t==="boolean")return e===!0;if(t==="color"){let s=ut(e,ut(n?.defaultValue,"#ffffff"));return eI.test(s)?s:"#ffffff"}if(t==="enum"){let s=Array.isArray(n?.options)?n.options:[],o=ut(e,s[0]?.value||"");return s.some(a=>a.value===o)?o:s[0]?.value||""}if(t==="string")return String(e??"");if(t==="button")return Math.max(0,Math.floor(Ut(e,0)));let i=Ut(n?.min,0),r=Math.max(Ut(n?.max,i),i);return tI(Ut(e,Ut(n?.defaultValue,i)),i,r)}function rI(n){return Object.entries(fn(n)?n:{}).map(([e,t])=>iI(ut(e),t)).filter(e=>e.id)}function sI(n){let e=String(n||"").split("?")[0].split("#")[0].replace(/\\/g,"/").trim();if(!e)return"";try{e=new URL(e,"http://localhost").pathname}catch{}let t=e.replace(/^\/+|\/+$/g,""),i=t.lastIndexOf("/"),r=i>=0?t.slice(0,i):"",o=(i>=0?t.slice(i+1):t).match(/^\.?(.+)\.step\.js$/);return o?.[1]?Gu([r,o[1]].filter(Boolean).join("/")):""}function oI(n){let e=ut(n).replace(/\\/g,"/");if(!e||e.startsWith("/")||/^[A-Za-z]:\//.test(e)||/^[a-z][a-z0-9+.-]*:/i.test(e))return"";let t=e.split("/").filter(r=>r&&r!==".");if(!t.length||t.some(r=>r===".."))return"";let i=t.join("/");return/\.(step|stp)$/i.test(i)?i:""}function aI(n){return Gu(String(n||"").replace(/\.(step|stp)$/i,""))}function cI(n){let e=fn(n)?n:{};return{...e,path:oI(e.path)}}function lI(n,e){if(!fn(n)&&!e.path)return null;let t=fn(n)?{...n}:{};return e.path?t.path=e.path:delete t.path,Object.keys(t).length?t:null}function uI(n,e=""){let t=fn(n)?n:{},i=ut(t.ref),r=Wu(i);if(r)return ic({selectors:r.selectors});let s=i.startsWith("#")?i.slice(1):"",o=Hu(s||t.selector||t.selectors||t.occurrence||t.occurrences||[]);return o.length?ic({selectors:o}):i}function hI(n,{cadPath:e=""}={}){return Object.entries(fn(n)?n:{}).map(([t,i])=>{let r=fn(i)?i:{},s=ut(t);return s?{id:s,label:ut(r.label,s),description:ut(r.description),ref:uI(r,e),partIds:Array.isArray(r.partIds)?r.partIds.map(o=>ut(o)).filter(Boolean):[],axis:U_(r.axis,[0,0,1]),origin:dI(r.origin,null)}:null}).filter(Boolean)}function fI(n){return Object.entries(fn(n)?n:{}).map(([e,t])=>{let i=fn(t)?t:{},r=ut(e);return r?{id:r,label:ut(i.label,r),description:ut(i.description),duration:Math.max(Ut(i.duration??i.durationSeconds,1),.001),loop:i.loop!==!1,update:typeof i.update=="function"?i.update:null,raw:i}:null}).filter(Boolean)}function U_(n,e=[0,0,0]){let t=Array.isArray(n)?n:e;return[Ut(t?.[0],e[0]||0),Ut(t?.[1],e[1]||0),Ut(t?.[2],e[2]||0)]}function dI(n,e=[0,0,0]){return!Array.isArray(n)&&e===null?null:U_(n,e||[0,0,0])}function pI(n,{url:e="",cadPath:t=""}={}){if(!fn(n))throw new Error("STEP runtime module must export an object");let i=fn(n.manifest)?n.manifest:n,r=Number(i.schemaVersion||n.schemaVersion||1);if(r!==L_)throw new Error(`Unsupported STEP runtime module schemaVersion ${r||"unknown"}`);let s=cI(i.step),o=aI(s.path),a=o||Gu(t)||sI(e),c=rI(i.parameters),l=Object.fromEntries(c.map(d=>[d.id,d])),u=Object.fromEntries(c.map(d=>[d.id,d.defaultValue])),h=lI(i.step,s),f={...i,schemaVersion:L_};return h?f.step=h:delete f.step,{url:ut(e),cadPath:a,step:{path:s.path,cadPath:o||a,explicit:!!s.path,inferred:!s.path&&!!a},module:n,manifest:f,features:hI(i.features,{cadPath:a}),parameters:c,parameterMap:l,defaultParameterValues:u,animations:fI(i.animations)}}async function F_(n,e={}){let t=await import(n);return pI(t?.default??t,{url:n,...e})}function B_(n,e={}){let t=n?.parameterMap||{};return Object.fromEntries(Object.values(t).map(i=>[i.id,Xu(i,fn(e)&&Object.hasOwn(e,i.id)?e[i.id]:i.defaultValue)]))}function mI(n){let e=Array.isArray(n?.min)?n.min:[0,0,0],t=Array.isArray(n?.max)?n.max:e;return[(Ut(e[0])+Ut(t[0]))/2,(Ut(e[1])+Ut(t[1]))/2,(Ut(e[2])+Ut(t[2]))/2]}function gI(n){let e=(Array.isArray(n)?n:[]).filter(r=>Array.isArray(r?.min)&&Array.isArray(r?.max));if(!e.length)return null;let t=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(let r of e)for(let s=0;s<3;s+=1)t[s]=Math.min(t[s],Ut(r.min[s])),i[s]=Math.max(i[s],Ut(r.max[s]));return{min:t,max:i}}function jp(n,e){let t=ut(n),i=Array.isArray(e?.parts)?e.parts:[];return!t||!i.length?[]:i.filter(r=>[r?.id,r?.occurrenceId].map(o=>ut(o)).filter(Boolean).some(o=>o===t||o.startsWith(`${t}.`)||t.startsWith(`${o}.`))).map(r=>ut(r.id||r.occurrenceId)).filter(Boolean)}function O_(n,e){let t=ut(n);return!t||!e?null:e.referenceByNormalizedSelector?.get(t)||e.referenceByDisplaySelector?.get(t)||e.referenceMap?.get(t)||null}function Mr(n){return[...new Set((Array.isArray(n)?n:[]).map(e=>ut(e)).filter(Boolean))]}function yI(n){let e=Wu(n?.ref);return e?e.selectors.length?e.selectors:["__model__"]:[]}function $p(n,{meshData:e=null,selectorRuntime:t=null}={}){let i=Array.isArray(e?.parts)?e.parts:[],r=new Map(i.map(o=>[ut(o.id||o.occurrenceId),o])),s=i.length?i.map(o=>ut(o.id||o.occurrenceId)).filter(Boolean):["__model__"];return Object.fromEntries((Array.isArray(n?.features)?n.features:[]).map(o=>{let a=yI(o),c=a.map(d=>d==="__model__"?null:O_(d,t)).filter(Boolean),l=a.flatMap(d=>{if(d==="__model__")return s;let m=N_(d);if(m?.occurrenceId)return jp(m.occurrenceId,e);let y=O_(d,t);return jp(y?.partId||y?.occurrenceId||d,e)}),u=Mr([...o.partIds,...l]),h=u.map(d=>r.get(d)).filter(Boolean),f=gI(h.map(d=>d.bounds))||e?.bounds||null;return[o.id,{...o,selectors:a,references:c,partIds:u,parts:h,bounds:f,center:o.origin||mI(f),transform:h.length===1&&h[0]?.transform||null,transforms:h.map(d=>d?.transform||null),missing:a.length>0&&u.length===0&&a[0]!=="__model__"}]}))}function ps(n,e,t){if(Array.isArray(n))return Mr(n.flatMap(o=>ps(o,e,t)));if(fn(n)){if(Array.isArray(n.partIds))return Mr(n.partIds);if(n.partId)return Mr([n.partId]);if(n.feature)return ps(n.feature,e,t);if(n.ref)return ps(n.ref,e,t)}let i=ut(n);if(!i)return[];if(i==="*"||i==="all"||i==="__all__"){let o=Array.isArray(t?.parts)?t.parts:[];return o.length?Mr(o.map(a=>a?.id||a?.occurrenceId)):["__model__"]}let r=e?.[i];if(r)return Mr(r.partIds);let s=Wu(i);if(s){let o=s.selectors.length?s.selectors:["*"];return Mr(o.flatMap(a=>ps(a,e,t)))}return Mr(jp(i,t))}function mi(n,e=0){let t=Number(n);return Number.isFinite(t)?t:e}function xI(n,e,t){return Math.min(Math.max(n,e),t)}function Yu(n){return[...new Set((Array.isArray(n)?n:[]).map(e=>String(e||"").trim()).filter(Boolean))]}function rc(n,e){let t=new n.Matrix4;return!Array.isArray(e)||e.length!==16?(t.identity(),t):(t.set(Number(e[0])||0,Number(e[1])||0,Number(e[2])||0,Number(e[3])||0,Number(e[4])||0,Number(e[5])||0,Number(e[6])||0,Number(e[7])||0,Number(e[8])||0,Number(e[9])||0,Number(e[10])||0,Number(e[11])||0,Number(e[12])||0,Number(e[13])||0,Number(e[14])||0,Number(e[15])||0),t)}function z_(n,e,t=!0){return!t||n?.partTransformsBaked===!0?null:e?.transform||null}function Jp(n,e=[0,0,0]){return Array.isArray(n)||ArrayBuffer.isView(n)?[mi(n[0],e[0]||0),mi(n[1],e[1]||0),mi(n[2],e[2]||0)]:n&&typeof n=="object"?[mi(n.x,e[0]||0),mi(n.y,e[1]||0),mi(n.z,e[2]||0)]:[...e]}function Kp(n,e,t=[0,0,0]){let i=Jp(e,t);return new n.Vector3(i[0],i[1],i[2])}function _I(n,e={}){let t=Kp(n,e.axis,[0,0,1]);t.lengthSq()<=1e-12&&t.set(0,0,1),t.normalize();let i=Kp(n,e.origin,[0,0,0]),r=Number.isFinite(Number(e.angleRad))?Number(e.angleRad):mi(e.angleDeg,0)*Math.PI/180;return new n.Matrix4().makeTranslation(i.x,i.y,i.z).multiply(new n.Matrix4().makeRotationAxis(t,r)).multiply(new n.Matrix4().makeTranslation(-i.x,-i.y,-i.z))}function SI(n,e={}){let t=e.scale??e,i=Array.isArray(t)||ArrayBuffer.isView(t)?Jp(t,[1,1,1]):[mi(t,1),mi(t,1),mi(t,1)],r=Kp(n,e.origin,[0,0,0]);return new n.Matrix4().makeTranslation(r.x,r.y,r.z).multiply(new n.Matrix4().makeScale(i[0],i[1],i[2])).multiply(new n.Matrix4().makeTranslation(-r.x,-r.y,-r.z))}function bI(n,e){let t=Jp(e,[0,0,0]);return new n.Matrix4().makeTranslation(t[0],t[1],t[2])}function MI(n,e={}){if(!e||typeof e!="object")return new n.Matrix4;if(Array.isArray(e.matrix)&&e.matrix.length===16)return rc(n,e.matrix);let t=new n.Matrix4;return e.scale!==void 0&&t.premultiply(SI(n,e)),e.rotate&&typeof e.rotate=="object"&&t.premultiply(_I(n,e.rotate)),e.translate!==void 0&&t.premultiply(bI(n,e.translate)),t}function vI(n,e={}){if(!e||typeof e!="object")return new n.Matrix4;let t=Array.isArray(e.transforms)?e.transforms:[e],i=new n.Matrix4;for(let r of t)i.premultiply(MI(n,r));return i}function AI(n,e=1e-6){if(!n?.elements||n.elements.length!==16)return!1;let t=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return n.elements.some((i,r)=>Math.abs(Number(i)-t[r])>e)}function EI(n){for(let e of Array.isArray(n)?n:[])e.effectMatrix=null,e.effectStyle=null,e.effectVisible=null,e.effectHighlighted=!1}function wI(n,e){let t=Array.isArray(n?.parts)?n.parts.map(r=>String(r?.id||r?.occurrenceId||"").trim()).filter(Boolean):[];if(t.length)return Yu(t);let i=(Array.isArray(e)?e:[]).map(r=>String(r?.partId||"").trim()).filter(Boolean);return Yu(i.length?i:["__model__"])}function Zp(n,e,t,i){if(n&&typeof n=="object"&&!Array.isArray(n)){if(Array.isArray(n.partIds))return Yu(n.partIds);if(n.partId)return Yu([n.partId]);if(n.feature)return Zp(n.feature,e,t,i);if(n.ref)return ps(String(n.ref),e,t)}let r=String(n||"").trim();return r==="*"||r==="all"||r==="__all__"?wI(t,i):ps(n,e,t)}function Qp(n,{meshData:e,features:t,runtime:i,effectsByPartId:r,onTransformEffect:s}){let o=c=>{let l=String(c||"").trim();if(!l)return null;let u=r.get(l)||{matrix:null,style:null,visible:null,highlighted:!1};return r.set(l,u),u},a=(c,l)=>{let u=Zp(c,t,e,i?.displayRecords);for(let h of u){let f=o(h);f&&l(f,h)}return u};return{transform(c,l){let u=vI(n,l),h=a(c,f=>{f.matrix=f.matrix?f.matrix.clone().premultiply(u):u.clone()});h.length&&AI(u)&&s?.({target:c,spec:l,partIds:h,matrix:u.clone()})},style(c,l={}){!l||typeof l!="object"||a(c,u=>{u.style={...u.style||{},...l}})},visible(c,l=!0){a(c,u=>{u.visible=l!==!1})},highlight(c,l=!0){a(c,u=>{u.highlighted=l!==!1})},clear(c){let l=Zp(c,t,e,i?.displayRecords);for(let u of l)r.delete(u)}}}function TI(n={}){let e=Math.max(Number(n.duration)||0,0),t=Math.max(Number(n.elapsedSec)||0,0);return{elapsed:t,elapsedSec:t,duration:e,progress:e>0?xI(t/e,0,1):0,cycle:e>0?t/e:0,playing:n.playing===!0,speed:Math.max(Number(n.speed)||1,0)}}function qu({runtime:n,stepModuleRuntime:e,features:t,effects:i,cleanup:r}){let s=e?.definition||null;return{THREE:n?.THREE,scene:n?.scene,modelGroup:n?.modelGroup,edgesGroup:n?.edgesGroup,runtime:n,manifest:s?.manifest||{},module:s?.module||null,cadPath:e?.cadPath||s?.cadPath||"",params:e?.parameterValues||{},features:t,effects:i,time:TI(e?.animationState),cleanup:typeof r=="function"?r:()=>{},requestRender:()=>n?.requestRender?.()}}function V_(n,e,t){EI(e);for(let i of Array.isArray(e)?e:[]){let r=t.get(String(i?.partId||"").trim());r&&(i.effectMatrix=r.matrix instanceof n.Matrix4?r.matrix.clone():null,i.effectStyle=r.style&&typeof r.style=="object"?{...r.style}:null,i.effectVisible=r.visible,i.effectHighlighted=r.highlighted===!0)}}function em(n,e,t){if(!e||!(t instanceof n.Matrix4))return;e.matrixAutoUpdate=!1;let i=e.matrix instanceof n.Matrix4?e.matrix:new n.Matrix4;i.copy(t),e.matrix=i,e.matrixWorldNeedsUpdate=!0}function tm(n,e){if(!e||!n?.Matrix4)return null;let t=[e.effectMatrix,e.explodedViewMatrix].filter(r=>r instanceof n.Matrix4);if(!t.length)return null;let i=new n.Matrix4;for(let r of t)i.premultiply(r);return i}function CI(n,e){let t=rc(n,e?.baseTransform),i=tm(n,e);return i?i.multiply(t):t}function ms(n,e){if(!e)return;let t=CI(n,e);em(n,e.mesh,t),em(n,e.edges,t),em(n,e.silhouette,t)}var Yi=Object.freeze({CAD:"cad",URDF:"urdf"}),RI=Object.freeze({[Yi.CAD]:Object.freeze({minModelRadius:1,minGridSize:280,lightingScopeRadius:140,lightingReferenceModelRadius:760}),[Yi.URDF]:Object.freeze({minModelRadius:.05,minGridSize:.28,lightingScopeRadius:.14,lightingReferenceModelRadius:.76})}),sO=Object.freeze({[Yi.CAD]:Object.freeze({minExtent:60,normalBias:.024,radius:14}),[Yi.URDF]:Object.freeze({minExtent:.55,normalBias:12e-6,radius:14})});function nm(n){return n===Yi.URDF?Yi.URDF:Yi.CAD}function im(n){return RI[nm(n)]}function k_(n,e){let t=Number(n);return Math.max(Number.isFinite(t)?t:0,im(e).minModelRadius)}var II=Yi,lm=.84,G_=16,H_="#8dc5ff",ju="#4f9dff",PI=.08,NI=.12,LI=23,OI=26,DI=.035,UI=/^#(?:[0-9a-fA-F]{3}){1,2}$/,Co="__model__",kt=Object.freeze({surface:"#f4f4f5",surfaceRoughness:.92,surfaceMetalness:.03,surfaceClearcoat:0,surfaceClearcoatRoughness:.6,edge:"#18181b",edgeThickness:1,edgeOpacity:lm}),Zu="_cad_edge_barycentric",Ju="_cad_edge_class",FI=Object.freeze(["feature","tangent","seam","degenerate"]),W_=Object.freeze({feature:Object.freeze({color:"#132232",thickness:1.15,opacity:1}),tangent:Object.freeze({color:"#132232",thickness:1.15,opacity:.5}),seam:Object.freeze({color:"#132232",thickness:1.15,opacity:.85}),degenerate:Object.freeze({color:"#132232",thickness:0,opacity:1})}),X_=new WeakMap;function BI(n){let e=n?.geometrySource;return e&&typeof e=="object"?e:n}function Qe(n,e,t){return Math.min(Math.max(n,e),t)}function ze(n,e=0){return Number.isFinite(Number(n))?Number(n):e}function Y_(n){return Array.isArray(n)?n:[]}function gi(n,e=1){return(Array.isArray(n)||ArrayBuffer.isView(n))&&n.length>=e&&n.length%e===0}function iS(n){return nm(n)}function cm(n){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0];for(let i=0;i+2<(n?.length||0);i+=3){let r=Number(n[i]),s=Number(n[i+1]),o=Number(n[i+2]);[r,s,o].every(Number.isFinite)&&(e[0]=Math.min(e[0],r),e[1]=Math.min(e[1],s),e[2]=Math.min(e[2],o),t[0]=Math.max(t[0],r),t[1]=Math.max(t[1],s),t[2]=Math.max(t[2],o))}return!e.every(Number.isFinite)||!t.every(Number.isFinite)?{min:[0,0,0],max:[1,1,1]}:{min:e,max:t}}function Ku(n,e,t=II.CAD){let i=iS(t),r=im(i),s=Array.isArray(e?.min)?e.min:[0,0,0],o=Array.isArray(e?.max)?e.max:[1,1,1],a=new n.Vector3((ze(s[0])+ze(o[0],1))/2,(ze(s[1])+ze(o[1],1))/2,(ze(s[2])+ze(o[2],1))/2),c=new n.Vector3(Math.max(ze(o[0],1)-ze(s[0]),r.minModelRadius),Math.max(ze(o[1],1)-ze(s[1]),r.minModelRadius),Math.max(ze(o[2],1)-ze(s[2]),r.minModelRadius));return{center:a,size:c,radius:k_(c.length()/2,i)}}function rS(n){let e=BI(n),t=X_.get(e);return t||(t={whole:new Map,part:new Map,edge:new Map},X_.set(e,t)),t}function zI(n){return n.map((e,t)=>String(e?.id||e?.occurrenceId||`part:${t}`)).join("|")}function sS(n){return n&&(n.userData={...n.userData||{},cadSceneCachedGeometry:!0}),n}function VI(n){let e=Array.isArray(n)?n:[n];for(let t of e)t?.map?.dispose?.(),t?.alphaMap?.dispose?.(),t?.dispose?.()}function oS(n,{disposeCachedGeometry:e=!1}={}){if(n){for(;n.children?.length;)oS(n.children[0],{disposeCachedGeometry:e});n.parent?.remove(n),typeof n.userData?.beforeDispose=="function"&&(n.userData.beforeDispose(n),delete n.userData.beforeDispose),(e||n.geometry?.userData?.cadSceneCachedGeometry!==!0)&&n.geometry?.dispose?.(),VI(n.material)}}function rm(n,e={}){for(;n?.children?.length;)oS(n.children[0],e)}function aS(n,e,t,i){let r=gi(t,3);if(!i&&r){e.setAttribute("normal",new n.BufferAttribute(new Float32Array(t),3));return}e.computeVertexNormals()}function cS(n,e,t,i=0,r=0){let s=t?.surfaceEdgeBarycentric,o=t?.surfaceEdgeClass,a=Math.max(0,Math.floor(Number(i)||0))*3,c=Math.max(0,Math.floor(Number(r)||0))*3;!(s instanceof Float32Array)||!(o instanceof Uint8Array)||c<=0||s.length<a+c||o.length<a+c||(e.setAttribute(Zu,new n.BufferAttribute(s.slice(a,a+c),3)),e.setAttribute(Ju,new n.BufferAttribute(o.slice(a,a+c),3)))}function kI(n){let e=n?.getAttribute?.(Zu),t=n?.getAttribute?.(Ju);return e?.itemSize===3&&t?.itemSize===3&&e.count>0&&e.count===t.count}function gs(n,e){let t=String(e||"").trim();if(!UI.test(t))return null;let i=t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t;return new n.Color(i)}function um(n,e,t={},{applyTint:i=!0}={}){let r=(e||new n.Color("#ffffff")).clone(),s=Qe(Number(t.tintStrength)||0,0,1);if(i&&s>0){let l=new n.Color(t.defaultColor||t.tintColor||"#ffffff");t.tintMode==="blend"?r.lerp(l,s):r.lerp(r.clone().multiply(l),s)}let o=Qe(Number(t.saturation)||1,0,2.5);if(Math.abs(o-1)>1e-4){let l={};r.getHSL(l),r.setHSL(l.h,Qe(l.s*o,0,1),l.l)}let a=Qe(Number(t.contrast)||1,0,2.5),c=Qe(Number(t.brightness)||1,0,2);return r.r=Qe(((r.r-.5)*a+.5)*c,0,1),r.g=Qe(((r.g-.5)*a+.5)*c,0,1),r.b=Qe(((r.b-.5)*a+.5)*c,0,1),r}function GI(n,e,t={}){if(!gi(e,3))return null;let i=new Float32Array(e.length),r=new n.Color;for(let s=0;s+2<e.length;s+=3){r.setRGB(Qe(Number(e[s])||0,0,1),Qe(Number(e[s+1])||0,0,1),Qe(Number(e[s+2])||0,0,1));let o=um(n,r,t);i[s]=o.r,i[s+1]=o.g,i[s+2]=o.b}return i}function lS(n){return!!n?.has_source_colors&&gi(n?.colors,3)}function HI(n,e){return lS(n)?e&&Object.hasOwn(e,"hasSourceColors")?!!e.hasSourceColors:!0:!1}function WI(n,e={},t=0){return new n.Color(Pp(e,t))}function q_(n,e={},t=0){return um(n,WI(n,e,t),e,{applyTint:!1})}function uS(n,{hasVertexColors:e=!1,sourceColor:t=null,materialSettings:i,fallbackColor:r="#ffffff",fillIndex:s=0,forceFill:o=!1}){return o?q_(n,i,s):e?new n.Color("#ffffff"):t?um(n,t,i):q_(n,{...i,defaultColor:r||i?.defaultColor},s)}function XI(n={},e,t="#132232"){let i=W_[e]||W_.feature,r=n?.classes?.[e]||{};return{color:r.color||t||i.color,thickness:Qe(Number.isFinite(Number(r.thickness))?Number(r.thickness):i.thickness,0,6),opacity:Qe(Number.isFinite(Number(r.opacity))?Number(r.opacity):i.opacity,0,1)}}function YI(n,e,t={},i=kt){let r=t?.color||i?.edge||kt.edge,s=Object.fromEntries(FI.map(c=>[c,XI(t,c,r)])),o=new n.Color(r),a=Object.fromEntries(Object.entries(s).map(([c,l])=>[c,gs(n,l.color)||o.clone()]));e.userData.cadSurfaceEdges=!0,e.userData.cadSurfaceEdgeBaseColor=o.clone(),e.userData.cadSurfaceEdgeColor=o.clone(),e.userData.cadSurfaceEdgeBaseClassSettings=Object.fromEntries(Object.entries(s).map(([c,l])=>[c,{...l}])),e.extensions={...e.extensions||{},derivatives:!0},e.onBeforeCompile=c=>{let l=e.userData.cadSurfaceEdgeColor?.isColor?e.userData.cadSurfaceEdgeColor:o;e.userData.cadSurfaceEdgeShader=c,c.uniforms.cadSurfaceEdgeColor={value:l.clone()},c.uniforms.cadSurfaceFeatureColor={value:a.feature.clone()},c.uniforms.cadSurfaceTangentColor={value:a.tangent.clone()},c.uniforms.cadSurfaceSeamColor={value:a.seam.clone()},c.uniforms.cadSurfaceDegenerateColor={value:a.degenerate.clone()},c.uniforms.cadSurfaceFeatureThickness={value:s.feature.thickness},c.uniforms.cadSurfaceTangentThickness={value:s.tangent.thickness},c.uniforms.cadSurfaceSeamThickness={value:s.seam.thickness},c.uniforms.cadSurfaceDegenerateThickness={value:s.degenerate.thickness},c.uniforms.cadSurfaceFeatureOpacity={value:s.feature.opacity},c.uniforms.cadSurfaceTangentOpacity={value:s.tangent.opacity},c.uniforms.cadSurfaceSeamOpacity={value:s.seam.opacity},c.uniforms.cadSurfaceDegenerateOpacity={value:s.degenerate.opacity},c.vertexShader=c.vertexShader.replace("#include <common>",`#include <common> |