@co0ontty/wand 4.89.2-beta.gbb4a633 → 4.89.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/build-info.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"commit": "
|
|
3
|
-
"builtAt": "2026-10-10T03:
|
|
4
|
-
"version": "4.89.2
|
|
5
|
-
"channel": "
|
|
2
|
+
"commit": "d071c20396020d559bc1d7ed8bcc036d9379ca0e",
|
|
3
|
+
"builtAt": "2026-10-10T03:24:36.047Z",
|
|
4
|
+
"version": "4.89.2",
|
|
5
|
+
"channel": "stable"
|
|
6
6
|
}
|
|
@@ -4217,4 +4217,4 @@ void main() {
|
|
|
4217
4217
|
|
|
4218
4218
|
}
|
|
4219
4219
|
|
|
4220
|
-
}`,yl=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new ms(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){let e=t.cameras[0].viewport,n=new qe({vertexShader:Mg,fragmentShader:Sg,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new kt(new bs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Ml=class extends gn{constructor(t,e){super();let n=this,s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,u=null,p=null,_=null,M=typeof XRWebGLBinding<"u",m=new yl,f={},T=e.getContextAttributes(),R=null,y=null,S=[],b=[],A=new xt,x=null,w=null,D=new ze;D.viewport=new he;let U=new ze;U.viewport=new he;let z=[D,U],G=new Yr,N=null,V=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let $=S[q];return $===void 0&&($=new Li,S[q]=$),$.getTargetRaySpace()},this.getControllerGrip=function(q){let $=S[q];return $===void 0&&($=new Li,S[q]=$),$.getGripSpace()},this.getHand=function(q){let $=S[q];return $===void 0&&($=new Li,S[q]=$),$.getHandSpace()};function Z(q){let $=b.indexOf(q.inputSource);if($===-1)return;let pt=S[$];pt!==void 0&&(pt.update(q.inputSource,q.frame,c||a),pt.dispatchEvent({type:q.type,data:q.inputSource}))}function X(){s.removeEventListener("select",Z),s.removeEventListener("selectstart",Z),s.removeEventListener("selectend",Z),s.removeEventListener("squeeze",Z),s.removeEventListener("squeezestart",Z),s.removeEventListener("squeezeend",Z),s.removeEventListener("end",X),s.removeEventListener("inputsourceschange",nt);for(let q=0;q<S.length;q++){let $=b[q];$!==null&&(b[q]=null,S[q].disconnect($))}N=null,V=null,m.reset();for(let q in f)delete f[q];if(t.setRenderTarget(R),p=null,u=null,d=null,s=null,y=null,Xt.stop(),n.isPresenting=!1,t.setPixelRatio(x),t.setSize(A.width,A.height,!1),w!==null){let q=w.camera;q.fov=w.fov,q.zoom=w.zoom,q.updateProjectionMatrix(),w=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(q){r=q,n.isPresenting===!0&&Ct("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(q){o=q,n.isPresenting===!0&&Ct("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(q){c=q},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return d===null&&M&&(d=new XRWebGLBinding(s,e)),d},this.getFrame=function(){return _},this.getSession=function(){return s},this.setSession=async function(q){if(s=q,s!==null){if(R=t.getRenderTarget(),s.addEventListener("select",Z),s.addEventListener("selectstart",Z),s.addEventListener("selectend",Z),s.addEventListener("squeeze",Z),s.addEventListener("squeezestart",Z),s.addEventListener("squeezeend",Z),s.addEventListener("end",X),s.addEventListener("inputsourceschange",nt),T.xrCompatible!==!0&&await e.makeXRCompatible(),x=t.getPixelRatio(),t.getSize(A),M&&"createProjectionLayer"in XRWebGLBinding.prototype){let pt=null,Pt=null,gt=null;T.depth&&(gt=T.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,pt=T.stencil?Zn:mn,Pt=T.stencil?Gi:ln);let Bt={colorFormat:e.RGBA8,depthFormat:gt,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(Bt),s.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),y=new Ve(u.textureWidth,u.textureHeight,{format:Qe,type:He,depthTexture:new Vn(u.textureWidth,u.textureHeight,Pt,void 0,void 0,void 0,void 0,void 0,void 0,pt),stencilBuffer:T.stencil,colorSpace:t.outputColorSpace,samples:T.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1,storeMultisampledDepthBuffer:u.ignoreDepthValues===!1,storeMultisampledStencilBuffer:u.ignoreDepthValues===!1})}else{let pt={antialias:T.antialias,alpha:!0,depth:T.depth,stencil:T.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(s,e,pt),s.updateRenderState({baseLayer:p}),t.setPixelRatio(1),t.setSize(p.framebufferWidth,p.framebufferHeight,!1),y=new Ve(p.framebufferWidth,p.framebufferHeight,{format:Qe,type:He,colorSpace:t.outputColorSpace,stencilBuffer:T.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1,storeMultisampledDepthBuffer:p.ignoreDepthValues===!1,storeMultisampledStencilBuffer:p.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await s.requestReferenceSpace(o),Xt.setContext(s),Xt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function nt(q){for(let $=0;$<q.removed.length;$++){let pt=q.removed[$],Pt=b.indexOf(pt);Pt>=0&&(b[Pt]=null,S[Pt].disconnect(pt))}for(let $=0;$<q.added.length;$++){let pt=q.added[$],Pt=b.indexOf(pt);if(Pt===-1){for(let Bt=0;Bt<S.length;Bt++)if(Bt>=b.length){b.push(pt),Pt=Bt;break}else if(b[Bt]===null){b[Bt]=pt,Pt=Bt;break}if(Pt===-1)break}let gt=S[Pt];gt&>.connect(pt)}}let W=new C,j=new C;function tt(q,$,pt){W.setFromMatrixPosition($.matrixWorld),j.setFromMatrixPosition(pt.matrixWorld);let Pt=W.distanceTo(j),gt=$.projectionMatrix.elements,Bt=pt.projectionMatrix.elements,_e=gt[14]/(gt[10]-1),Vt=gt[14]/(gt[10]+1),Yt=(gt[9]+1)/gt[5],ie=(gt[9]-1)/gt[5],Gt=(gt[8]-1)/gt[0],le=(Bt[8]+1)/Bt[0],Me=_e*Gt,Be=_e*le,ue=Pt/(-Gt+le),pe=ue*-Gt;if($.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(pe),q.translateZ(ue),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),gt[10]===-1)q.projectionMatrix.copy($.projectionMatrix),q.projectionMatrixInverse.copy($.projectionMatrixInverse);else{let L=_e+ue,Te=Vt+ue,Qt=Me-pe,E=Be+(Pt-pe),g=Yt*Vt/Te*L,F=ie*Vt/Te*L;q.projectionMatrix.makePerspective(Qt,E,g,F,L,Te),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}function At(q,$){$===null?q.matrixWorld.copy(q.matrix):q.matrixWorld.multiplyMatrices($.matrixWorld,q.matrix),q.matrixWorldInverse.copy(q.matrixWorld).invert()}this.updateCamera=function(q){if(s===null)return;let $=q.near,pt=q.far;m.texture!==null&&(m.depthNear>0&&($=m.depthNear),m.depthFar>0&&(pt=m.depthFar)),G.near=U.near=D.near=$,G.far=U.far=D.far=pt,(N!==G.near||V!==G.far)&&(s.updateRenderState({depthNear:G.near,depthFar:G.far}),N=G.near,V=G.far),G.layers.mask=q.layers.mask|6,D.layers.mask=G.layers.mask&-5,U.layers.mask=G.layers.mask&-3;let Pt=q.parent,gt=G.cameras;At(G,Pt);for(let Bt=0;Bt<gt.length;Bt++)At(gt[Bt],Pt);gt.length===2?tt(G,D,U):G.projectionMatrix.copy(D.projectionMatrix),w===null&&q.isPerspectiveCamera&&(w={camera:q,fov:q.fov,zoom:q.zoom}),St(q,G,Pt)};function St(q,$,pt){pt===null?q.matrix.copy($.matrixWorld):(q.matrix.copy(pt.matrixWorld),q.matrix.invert(),q.matrix.multiply($.matrixWorld)),q.matrix.decompose(q.position,q.quaternion,q.scale),q.updateMatrixWorld(!0),q.projectionMatrix.copy($.projectionMatrix),q.projectionMatrixInverse.copy($.projectionMatrixInverse),q.isPerspectiveCamera&&(q.fov=Pi*2*Math.atan(1/q.projectionMatrix.elements[5]),q.zoom=1)}this.getCamera=function(){return G},this.getFoveation=function(){if(!(u===null&&p===null))return l},this.setFoveation=function(q){l=q,u!==null&&(u.fixedFoveation=q),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=q)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(G)},this.getCameraTexture=function(q){return f[q]};let Zt=null;function zt(q,$){if(h=$.getViewerPose(c||a),_=$,h!==null){let pt=h.views;p!==null&&(t.setRenderTargetFramebuffer(y,p.framebuffer),t.setRenderTarget(y));let Pt=!1;pt.length!==G.cameras.length&&(G.cameras.length=0,Pt=!0);for(let Vt=0;Vt<pt.length;Vt++){let Yt=pt[Vt],ie=null;if(p!==null)ie=p.getViewport(Yt);else{let le=d.getViewSubImage(u,Yt);ie=le.viewport,Vt===0&&(t.setRenderTargetTextures(y,le.colorTexture,le.depthStencilTexture),t.setRenderTarget(y))}let Gt=z[Vt];Gt===void 0&&(Gt=new ze,Gt.layers.enable(Vt),Gt.viewport=new he,z[Vt]=Gt),Gt.matrix.fromArray(Yt.transform.matrix),Gt.matrix.decompose(Gt.position,Gt.quaternion,Gt.scale),Gt.projectionMatrix.fromArray(Yt.projectionMatrix),Gt.projectionMatrixInverse.copy(Gt.projectionMatrix).invert(),Gt.viewport.set(ie.x,ie.y,ie.width,ie.height),Vt===0&&(G.matrix.copy(Gt.matrix),G.matrix.decompose(G.position,G.quaternion,G.scale)),Pt===!0&&G.cameras.push(Gt)}let gt=s.enabledFeatures;if(gt&>.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&M){d=n.getBinding();let Vt=d.getDepthInformation(pt[0]);Vt&&Vt.isValid&&Vt.texture&&m.init(Vt,s.renderState)}if(gt&>.includes("camera-access")&&M){t.state.unbindTexture(),d=n.getBinding();for(let Vt=0;Vt<pt.length;Vt++){let Yt=pt[Vt].camera;if(Yt){let ie=f[Yt];ie||(ie=new ms,f[Yt]=ie);let Gt=d.getCameraImage(Yt);ie.sourceTexture=Gt}}}}for(let pt=0;pt<S.length;pt++){let Pt=b[pt],gt=S[pt];Pt!==null&>!==void 0&>.update(Pt,$,c||a)}Zt&&Zt(q,$),$.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:$}),_=null}let Xt=new ph;Xt.setAnimationLoop(zt),this.setAnimationLoop=function(q){Zt=q},this.dispose=function(){}}},bg=new ce,yh=new Dt;yh.set(-1,0,0,0,1,0,0,0,1);function Eg(i,t){function e(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function n(m,f){f.color.getRGB(m.fogColor.value,Qo(i)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function s(m,f,T,R,y){f.isNodeMaterial?f.uniformsNeedUpdate=!1:f.isMeshBasicMaterial?r(m,f):f.isMeshLambertMaterial?(r(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(r(m,f),d(m,f)):f.isMeshPhongMaterial?(r(m,f),h(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(r(m,f),u(m,f),f.isMeshPhysicalMaterial&&p(m,f,y)):f.isMeshMatcapMaterial?(r(m,f),_(m,f)):f.isMeshDepthMaterial?r(m,f):f.isMeshDistanceMaterial?(r(m,f),M(m,f)):f.isMeshNormalMaterial?r(m,f):f.isLineBasicMaterial?(a(m,f),f.isLineDashedMaterial&&o(m,f)):f.isPointsMaterial?l(m,f,T,R):f.isSpriteMaterial?c(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,e(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,e(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Fe&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,e(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Fe&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,e(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,e(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,e(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);let T=t.get(f),R=T.envMap,y=T.envMapRotation;R&&(m.envMap.value=R,m.envMapRotation.value.setFromMatrix4(bg.makeRotationFromEuler(y)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(yh),m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,e(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,e(f.aoMap,m.aoMapTransform))}function a(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,e(f.map,m.mapTransform))}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,T,R){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*T,m.scale.value=R*.5,f.map&&(m.map.value=f.map,e(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function c(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,e(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function h(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function d(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function u(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,e(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,e(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,T){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,e(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,e(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,e(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,e(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,e(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Fe&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.retroreflectivity>0&&(m.retroreflectivity.value=f.retroreflectivity),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,e(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,e(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=T.texture,m.transmissionSamplerSize.value.set(T.width,T.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,e(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,e(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,e(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,e(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,e(f.specularIntensityMap,m.specularIntensityMapTransform))}function _(m,f){f.matcap&&(m.matcap.value=f.matcap)}function M(m,f){let T=t.get(f).light;m.referencePosition.value.setFromMatrixPosition(T.matrixWorld),m.nearDistance.value=T.shadow.camera.near,m.farDistance.value=T.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Tg(i,t,e,n){let s={},r={},a=[],o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,S){let b=S.program;n.uniformBlockBinding(y,b)}function c(y,S){let b=s[y.id];b===void 0&&(m(y),b=h(y),s[y.id]=b,y.addEventListener("dispose",T));let A=S.program;n.updateUBOMapping(y,A);let x=t.render.frame;r[y.id]!==x&&(u(y),r[y.id]=x)}function h(y){let S=d();y.__bindingPointIndex=S;let b=i.createBuffer(),A=y.__size,x=y.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,A,x),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,b),b}function d(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return It("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(y){let S=s[y.id],b=y.uniforms,A=y.__cache;i.bindBuffer(i.UNIFORM_BUFFER,S);for(let x=0,w=b.length;x<w;x++){let D=b[x];if(Array.isArray(D))for(let U=0,z=D.length;U<z;U++)p(D[U],x,U,A);else p(D,x,0,A)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(y,S,b,A){if(M(y,S,b,A)===!0){let x=y.__offset,w=y.value;if(Array.isArray(w)){let D=0;for(let U=0;U<w.length;U++){let z=w[U],G=f(z);_(z,y.__data,D),typeof z!="number"&&typeof z!="boolean"&&!z.isMatrix3&&!ArrayBuffer.isView(z)&&(D+=G.storage/Float32Array.BYTES_PER_ELEMENT)}}else _(w,y.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,x,y.__data)}}function _(y,S,b){typeof y=="number"||typeof y=="boolean"?S[0]=y:y.isMatrix3?(S[0]=y.elements[0],S[1]=y.elements[1],S[2]=y.elements[2],S[3]=0,S[4]=y.elements[3],S[5]=y.elements[4],S[6]=y.elements[5],S[7]=0,S[8]=y.elements[6],S[9]=y.elements[7],S[10]=y.elements[8],S[11]=0):ArrayBuffer.isView(y)?S.set(new y.constructor(y.buffer,y.byteOffset,S.length)):y.toArray(S,b)}function M(y,S,b,A){let x=y.value,w=S+"_"+b;if(A[w]===void 0)return typeof x=="number"||typeof x=="boolean"?A[w]=x:ArrayBuffer.isView(x)?A[w]=x.slice():A[w]=x.clone(),!0;{let D=A[w];if(typeof x=="number"||typeof x=="boolean"){if(D!==x)return A[w]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(D.equals(x)===!1)return D.copy(x),!0}}return!1}function m(y){let S=y.uniforms,b=0,A=16;for(let w=0,D=S.length;w<D;w++){let U=Array.isArray(S[w])?S[w]:[S[w]];for(let z=0,G=U.length;z<G;z++){let N=U[z],V=Array.isArray(N.value)?N.value:[N.value];for(let Z=0,X=V.length;Z<X;Z++){let nt=V[Z],W=f(nt),j=b%A,tt=j%W.boundary,At=j+tt;b+=tt,At!==0&&A-At<W.storage&&(b+=A-At),N.__data=new Float32Array(W.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=b,b+=W.storage}}}let x=b%A;return x>0&&(b+=A-x),y.__size=b,y.__cache={},this}function f(y){let S={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(S.boundary=4,S.storage=4):y.isVector2?(S.boundary=8,S.storage=8):y.isVector3||y.isColor?(S.boundary=16,S.storage=12):y.isVector4?(S.boundary=16,S.storage=16):y.isMatrix3?(S.boundary=48,S.storage=48):y.isMatrix4?(S.boundary=64,S.storage=64):y.isTexture?Ct("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(S.boundary=16,S.storage=y.byteLength):Ct("WebGLRenderer: Unsupported uniform value type.",y),S}function T(y){let S=y.target;S.removeEventListener("dispose",T);let b=a.indexOf(S.__bindingPointIndex);a.splice(b,1),i.deleteBuffer(s[S.id]),delete s[S.id],delete r[S.id]}function R(){for(let y in s)i.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:R}}var wg=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),vn=null;function Ag(){return vn===null&&(vn=new wr(wg,16,16,Jn,hn),vn.name="DFG_LUT",vn.minFilter=Ee,vn.magFilter=Ee,vn.wrapS=pn,vn.wrapT=pn,vn.generateMipmaps=!1,vn.needsUpdate=!0),vn}var ka=class{constructor(t={}){let{canvas:e=zc(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:p=He}=t;this.isWebGLRenderer=!0;let _;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");_=n.getContextAttributes().alpha}else _=a;let M=p,m=new Set([ia,na,ea]),f=new Set([He,ln,ki,Gi,jr,ta]),T=new Uint32Array(4),R=new Int32Array(4),y=new C,S=null,b=null,A=[],x=[],w=null;this.domElement=e,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=on,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let D=this,U=!1,z=null,G=null,N=null,V=null;this._outputColorSpace=Ne;let Z=0,X=0,nt=null,W=-1,j=null,tt=new he,At=new he,St=null,Zt=new Lt(0),zt=0,Xt=e.width,q=e.height,$=1,pt=null,Pt=null,gt=new he(0,0,Xt,q),Bt=new he(0,0,Xt,q),_e=!1,Vt=new Ni,Yt=!1,ie=!1,Gt=new ce,le=new C,Me=new he,Be={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ue=!1;function pe(){return nt===null?$:1}let L=n;function Te(v,P){return e.getContext(v,P)}let Qt,E,g,F,H,Y,it,st,J,Q,rt,Et,ct,at,Tt,Rt,Nt,I,ot,K,lt,ft,et;try{let v={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${"186"}`),e.addEventListener("webglcontextlost",se,!1),e.addEventListener("webglcontextrestored",Jt,!1),e.addEventListener("webglcontextcreationerror",je,!1),L===null){let P="webgl2";if(L=Te(P,v),L===null)throw Te(P)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}wt()}catch(v){throw e.removeEventListener("webglcontextlost",se,!1),e.removeEventListener("webglcontextrestored",Jt,!1),e.removeEventListener("webglcontextcreationerror",je,!1),It("WebGLRenderer: "+v.message),v}function wt(){Qt=new Np(L),Qt.init(),lt=new yg(L,Qt),E=new Ep(L,Qt,t,lt),g=new xg(L,Qt),E.reversedDepthBuffer&&u&&g.buffers.depth.setReversed(!0),G=L.createFramebuffer(),N=L.createFramebuffer(),V=L.createFramebuffer(),F=new Op(L),H=new sg,Y=new vg(L,Qt,g,H,E,lt,F),it=new Dp(D),st=new Bu(L),ft=new Sp(L,st),J=new Up(L,st,F,ft),Q=new zp(L,J,st,ft,F),I=new Bp(L,E,Y),Tt=new Tp(H),rt=new ig(D,it,Qt,E,ft,Tt),Et=new Eg(D,H),ct=new ag,at=new dg(Qt),Nt=new Mp(D,it,g,Q,_,l),Rt=new _g(D,Q,E),et=new Tg(L,F,E,g),ot=new bp(L,Qt,F),K=new Fp(L,Qt,F),F.programs=rt.programs,D.capabilities=E,D.extensions=Qt,D.properties=H,D.renderLists=ct,D.shadowMap=Rt,D.state=g,D.info=F}M!==He&&(w=new Hp(M,e.width,e.height,o,s,r));let Mt=new Ml(D,L);this.xr=Mt,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let v=Qt.get("WEBGL_lose_context");v&&v.loseContext()},this.forceContextRestore=function(){let v=Qt.get("WEBGL_lose_context");v&&v.restoreContext()},this.getPixelRatio=function(){return $},this.setPixelRatio=function(v){v!==void 0&&($=v,this.setSize(Xt,q,!1))},this.getSize=function(v){return v.set(Xt,q)},this.setSize=function(v,P,k=!0){if(Mt.isPresenting){Ct("WebGLRenderer: Can't change size while VR device is presenting.");return}Xt=v,q=P,e.width=Math.floor(v*$),e.height=Math.floor(P*$),k===!0&&(e.style.width=v+"px",e.style.height=P+"px"),w!==null&&w.setSize(e.width,e.height),this.setViewport(0,0,v,P)},this.getDrawingBufferSize=function(v){return v.set(Xt*$,q*$).floor()},this.setDrawingBufferSize=function(v,P,k){Xt=v,q=P,$=k,e.width=Math.floor(v*k),e.height=Math.floor(P*k),this.setViewport(0,0,v,P)},this.setEffects=function(v){if(M===He){It("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(v){for(let P=0;P<v.length;P++)if(v[P].isOutputPass===!0){Ct("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}w.setEffects(v||[])},this.getCurrentViewport=function(v){return v.copy(tt)},this.getViewport=function(v){return v.copy(gt)},this.setViewport=function(v,P,k,O){v.isVector4?gt.set(v.x,v.y,v.z,v.w):gt.set(v,P,k,O),g.viewport(tt.copy(gt).multiplyScalar($).round())},this.getScissor=function(v){return v.copy(Bt)},this.setScissor=function(v,P,k,O){v.isVector4?Bt.set(v.x,v.y,v.z,v.w):Bt.set(v,P,k,O),g.scissor(At.copy(Bt).multiplyScalar($).round())},this.getScissorTest=function(){return _e},this.setScissorTest=function(v){g.setScissorTest(_e=v)},this.setOpaqueSort=function(v){pt=v},this.setTransparentSort=function(v){Pt=v},this.getClearColor=function(v){return v.copy(Nt.getClearColor())},this.setClearColor=function(){Nt.setClearColor(...arguments)},this.getClearAlpha=function(){return Nt.getClearAlpha()},this.setClearAlpha=function(){Nt.setClearAlpha(...arguments)},this.clear=function(v=!0,P=!0,k=!0){let O=0;if(v){let B=!1;if(nt!==null){let dt=nt.texture.format;B=m.has(dt)}if(B){let dt=nt.texture.type,_t=f.has(dt),ut=Nt.getClearColor(),vt=Nt.getClearAlpha(),bt=ut.r,Ut=ut.g,Ht=ut.b;_t?(T[0]=bt,T[1]=Ut,T[2]=Ht,T[3]=vt,L.clearBufferuiv(L.COLOR,0,T)):(R[0]=bt,R[1]=Ut,R[2]=Ht,R[3]=vt,L.clearBufferiv(L.COLOR,0,R))}else O|=L.COLOR_BUFFER_BIT}P&&(O|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),k&&(O|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),O!==0&&L.clear(O)},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.setNodesHandler=function(v){v.setRenderer(this),z=v},this.dispose=function(){e.removeEventListener("webglcontextlost",se,!1),e.removeEventListener("webglcontextrestored",Jt,!1),e.removeEventListener("webglcontextcreationerror",je,!1),Nt.dispose(),ct.dispose(),at.dispose(),H.dispose(),it.dispose(),Q.dispose(),ft.dispose(),et.dispose(),rt.dispose(),Mt.dispose(),Mt.removeEventListener("sessionstart",Tl),Mt.removeEventListener("sessionend",wl),$n.stop()};function se(v){v.preventDefault(),as("WebGLRenderer: Context Lost."),U=!0}function Jt(){as("WebGLRenderer: Context Restored."),U=!1;let v=F.autoReset,P=Rt.enabled,k=Rt.autoUpdate,O=Rt.needsUpdate,B=Rt.type;wt(),F.autoReset=v,Rt.enabled=P,Rt.autoUpdate=k,Rt.needsUpdate=O,Rt.type=B}function je(v){It("WebGLRenderer: A WebGL context could not be created. Reason: ",v.statusMessage)}function un(v){let P=v.target;P.removeEventListener("dispose",un),Th(P)}function Th(v){wh(v),H.remove(v)}function wh(v){let P=H.get(v).programs;P!==void 0&&(P.forEach(function(k){rt.releaseProgram(k)}),v.isShaderMaterial&&rt.releaseShaderCache(v))}this.renderBufferDirect=function(v,P,k,O,B,dt){P===null&&(P=Be);let _t=B.isMesh&&B.matrixWorld.determinantAffine()<0,ut=Ch(v,P,k,O,B);g.setMaterial(O,_t);let vt=k.index,bt=1;if(O.wireframe===!0){if(vt=J.getWireframeAttribute(k),vt===void 0)return;bt=2}let Ut=k.drawRange,Ht=k.attributes.position,yt=Ut.start*bt,$t=(Ut.start+Ut.count)*bt;dt!==null&&(yt=Math.max(yt,dt.start*bt),$t=Math.min($t,(dt.start+dt.count)*bt)),vt!==null?(yt=Math.max(yt,0),$t=Math.min($t,vt.count)):Ht!=null&&(yt=Math.max(yt,0),$t=Math.min($t,Ht.count));let me=$t-yt;if(me<0||me===1/0)return;ft.setup(B,O,ut,k,vt);let ae,ne=ot;if(vt!==null&&(ae=st.get(vt),ne=K,ne.setIndex(ae)),B.isMesh)O.wireframe===!0?(g.setLineWidth(O.wireframeLinewidth*pe()),ne.setMode(L.LINES)):ne.setMode(L.TRIANGLES);else if(B.isLine){let we=O.linewidth;we===void 0&&(we=1),g.setLineWidth(we*pe()),B.isLineSegments?ne.setMode(L.LINES):B.isLineLoop?ne.setMode(L.LINE_LOOP):ne.setMode(L.LINE_STRIP)}else B.isPoints?ne.setMode(L.POINTS):B.isSprite&&ne.setMode(L.TRIANGLES);if(B.isBatchedMesh)if(Qt.get("WEBGL_multi_draw"))ne.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else{let we=B._multiDrawStarts,mt=B._multiDrawCounts,Le=B._multiDrawCount,qt=vt?st.get(vt).bytesPerElement:1,Ze=H.get(O).currentProgram.getUniforms();for(let dn=0;dn<Le;dn++)Ze.setValue(L,"_gl_DrawID",dn),ne.render(we[dn]/qt,mt[dn])}else if(B.isInstancedMesh)ne.renderInstances(yt,me,B.count);else if(k.isInstancedBufferGeometry){let we=k._maxInstanceCount!==void 0?k._maxInstanceCount:1/0,mt=Math.min(k.instanceCount,we);ne.renderInstances(yt,me,mt)}else ne.render(yt,me)};function El(v,P,k,O){z!==null&&v.isNodeMaterial&&z.setObject(O,v),Yt===!0&&Tt.setState(v,k,!1),v.transparent===!0&&v.side===Oe&&v.forceSinglePass===!1?(v.side=Fe,v.needsUpdate=!0,Xs(v,P,O),v.side=Xn,v.needsUpdate=!0,Xs(v,P,O),v.side=Oe):Xs(v,P,O)}this.compile=function(v,P,k=null){k===null&&(k=v),z!==null&&z.renderStart(v,P,k),b=at.get(k),b.init(P),x.push(b),k.traverseVisible(function(B){B.isLight&&B.layers.test(P.layers)&&(b.pushLight(B),B.castShadow&&b.pushShadow(B))}),v!==k&&v.traverseVisible(function(B){B.isLight&&B.layers.test(P.layers)&&(b.pushLight(B),B.castShadow&&b.pushShadow(B))}),b.setupLights(),z!==null&&z.updateLights(b.state.lightsArray),ie=this.localClippingEnabled,Yt=Tt.init(this.clippingPlanes,ie),Yt===!0&&Tt.setGlobalState(this.clippingPlanes,P),z!==null&&Rt.render(b.state.shadowsArray,k,P);let O=new Set;return v.traverse(function(B){if(!(B.isMesh||B.isPoints||B.isLine||B.isSprite))return;let dt=B.material;if(dt)if(Array.isArray(dt))for(let _t=0;_t<dt.length;_t++){let ut=dt[_t];El(ut,k,P,B),O.add(ut)}else El(dt,k,P,B),O.add(dt)}),b=x.pop(),z!==null&&z.renderEnd(),O},this.compileAsync=function(v,P,k=null){let O=this.compile(v,P,k);return new Promise(B=>{function dt(){if(O.forEach(function(_t){let vt=H.get(_t).currentProgram;(vt===void 0||vt.isReady())&&O.delete(_t)}),O.size===0){B(v);return}setTimeout(dt,10)}Qt.get("KHR_parallel_shader_compile")!==null?dt():setTimeout(dt,10)})};let Ya=null;function Ah(v){Ya&&Ya(v)}function Tl(){$n.stop()}function wl(){$n.start()}let $n=new ph;$n.setAnimationLoop(Ah),typeof self<"u"&&$n.setContext(self),this.setAnimationLoop=function(v){Ya=v,Mt.setAnimationLoop(v),v===null?$n.stop():$n.start()},Mt.addEventListener("sessionstart",Tl),Mt.addEventListener("sessionend",wl),this.render=function(v,P){if(P!==void 0&&P.isCamera!==!0){It("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(U===!0)return;z!==null&&z.renderStart(v,P);let k=Mt.enabled===!0&&Mt.isPresenting===!0,O=w!==null&&(nt===null||k)&&w.begin(D,nt);if(v.matrixWorldAutoUpdate===!0&&v.updateMatrixWorld(),P.parent===null&&P.matrixWorldAutoUpdate===!0&&P.updateMatrixWorld(),Mt.enabled===!0&&Mt.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(Mt.cameraAutoUpdate===!0&&Mt.updateCamera(P),P=Mt.getCamera()),v.isScene===!0&&v.onBeforeRender(D,v,P,nt),b=at.get(v,x.length),b.init(P),b.state.textureUnits=Y.getTextureUnits(),x.push(b),Gt.multiplyMatrices(P.projectionMatrix,P.matrixWorldInverse),Vt.setFromProjectionMatrix(Gt,an,P.reversedDepth),ie=this.localClippingEnabled,Yt=Tt.init(this.clippingPlanes,ie),S=ct.get(v,A.length),S.init(),A.push(S),Mt.enabled===!0&&Mt.isPresenting===!0){let _t=D.xr.getDepthSensingMesh();_t!==null&&Za(_t,P,-1/0,D.sortObjects)}Za(v,P,0,D.sortObjects),S.finish(),z!==null&&z.updateLights(b.state.lightsArray),D.sortObjects===!0&&S.sort(pt,Pt),ue=Mt.enabled===!1||Mt.isPresenting===!1||Mt.hasDepthSensing()===!1,ue&&Nt.addToRenderList(S,v),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Yt===!0&&Tt.beginShadows();let B=b.state.shadowsArray;if(Rt.render(B,v,P),Yt===!0&&Tt.endShadows(),(O&&w.hasRenderPass())===!1){let _t=S.opaque,ut=S.transmissive;if(b.setupLights(),P.isArrayCamera){let vt=P.cameras;if(ut.length>0)for(let bt=0,Ut=vt.length;bt<Ut;bt++){let Ht=vt[bt];Rl(_t,ut,v,Ht)}ue&&Nt.render(v);for(let bt=0,Ut=vt.length;bt<Ut;bt++){let Ht=vt[bt];Al(S,v,Ht,Ht.viewport)}}else ut.length>0&&Rl(_t,ut,v,P),ue&&Nt.render(v),Al(S,v,P)}nt!==null&&X===0&&(Y.updateMultisampleRenderTarget(nt),Y.updateRenderTargetMipmap(nt)),O&&w.end(D),v.isScene===!0&&v.onAfterRender(D,v,P),ft.resetDefaultState(),W=-1,j=null,x.pop(),x.length>0?(b=x[x.length-1],Y.setTextureUnits(b.state.textureUnits),Yt===!0&&Tt.setGlobalState(D.clippingPlanes,b.state.camera)):b=null,A.pop(),A.length>0?S=A[A.length-1]:S=null,z!==null&&z.renderEnd()};function Za(v,P,k,O){if(v.visible===!1)return;if(v.layers.test(P.layers)){if(v.isGroup)k=v.renderOrder;else if(v.isLOD)v.autoUpdate===!0&&v.update(P);else if(v.isLightProbeGrid)b.pushLightProbeGrid(v);else if(v.isLight)b.pushLight(v),v.castShadow&&b.pushShadow(v);else if(v.isSprite){if(!v.frustumCulled||v.intersectsFrustum(Vt)){O&&Me.setFromMatrixPosition(v.matrixWorld).applyMatrix4(Gt);let _t=Q.update(v),ut=v.material;ut.visible&&S.push(v,_t,ut,k,Me.z,null,P)}}else if((v.isMesh||v.isLine||v.isPoints)&&(!v.frustumCulled||v.intersectsFrustum(Vt))){let _t=Q.update(v),ut=v.material;if(O&&(v.boundingSphere!==void 0?(v.boundingSphere===null&&v.computeBoundingSphere(),Me.copy(v.boundingSphere.center)):(_t.boundingSphere===null&&_t.computeBoundingSphere(),Me.copy(_t.boundingSphere.center)),Me.applyMatrix4(v.matrixWorld).applyMatrix4(Gt)),Array.isArray(ut)){let vt=_t.groups;for(let bt=0,Ut=vt.length;bt<Ut;bt++){let Ht=vt[bt],yt=ut[Ht.materialIndex];yt&&yt.visible&&S.push(v,_t,yt,k,Me.z,Ht,P)}}else ut.visible&&S.push(v,_t,ut,k,Me.z,null,P)}}let dt=v.children;for(let _t=0,ut=dt.length;_t<ut;_t++)Za(dt[_t],P,k,O)}function Al(v,P,k,O){let{opaque:B,transmissive:dt,transparent:_t}=v;b.setupLightsView(k),Yt===!0&&Tt.setGlobalState(D.clippingPlanes,k),O&&g.viewport(tt.copy(O)),B.length>0&&Ws(B,P,k),dt.length>0&&Ws(dt,P,k),_t.length>0&&Ws(_t,P,k),g.buffers.depth.setTest(!0),g.buffers.depth.setMask(!0),g.buffers.color.setMask(!0),g.setPolygonOffset(!1)}function Rl(v,P,k,O){if((k.isScene===!0?k.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[O.id]===void 0){let yt=Qt.has("EXT_color_buffer_half_float")||Qt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[O.id]=new Ve(1,1,{generateMipmaps:!0,type:yt?hn:He,minFilter:Yn,samples:Math.max(4,E.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:Wt.workingColorSpace})}let dt=b.state.transmissionRenderTarget[O.id],_t=O.viewport||tt;dt.setSize(_t.z*D.transmissionResolutionScale,_t.w*D.transmissionResolutionScale);let ut=D.getRenderTarget(),vt=D.getActiveCubeFace(),bt=D.getActiveMipmapLevel();D.setRenderTarget(dt),D.getClearColor(Zt),zt=D.getClearAlpha(),zt<1&&D.setClearColor(16777215,.5),D.clear(),ue&&Nt.render(k);let Ut=D.toneMapping;D.toneMapping=on;let Ht=O.viewport;if(O.viewport!==void 0&&(O.viewport=void 0),b.setupLightsView(O),Yt===!0&&Tt.setGlobalState(D.clippingPlanes,O),Ws(v,k,O),Y.updateMultisampleRenderTarget(dt),Y.updateRenderTargetMipmap(dt),Qt.has("WEBGL_multisampled_render_to_texture")===!1){let yt=!1;for(let $t=0,me=P.length;$t<me;$t++){let ae=P[$t],{object:ne,geometry:we,material:mt,group:Le}=ae;if(mt.side===Oe&&ne.layers.test(O.layers)){let qt=mt.side;mt.side=Fe,mt.needsUpdate=!0,Cl(ne,k,O,we,mt,Le),mt.side=qt,mt.needsUpdate=!0,yt=!0}}yt===!0&&(Y.updateMultisampleRenderTarget(dt),Y.updateRenderTargetMipmap(dt))}D.setRenderTarget(ut,vt,bt),D.setClearColor(Zt,zt),Ht!==void 0&&(O.viewport=Ht),D.toneMapping=Ut}function Ws(v,P,k){let O=P.isScene===!0?P.overrideMaterial:null;for(let B=0,dt=v.length;B<dt;B++){let _t=v[B],{object:ut,geometry:vt,group:bt}=_t,Ut=_t.material;Ut.allowOverride===!0&&O!==null&&(Ut=O),ut.layers.test(k.layers)&&Cl(ut,P,k,vt,Ut,bt)}}function Cl(v,P,k,O,B,dt){z!==null&&B.isNodeMaterial&&z.setObject(v,B),v.onBeforeRender(D,P,k,O,B,dt),v.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,v.matrixWorld),v.normalMatrix.getNormalMatrix(v.modelViewMatrix),B.onBeforeRender(D,P,k,O,v,dt),B.transparent===!0&&B.side===Oe&&B.forceSinglePass===!1?(B.side=Fe,B.needsUpdate=!0,D.renderBufferDirect(k,P,O,B,v,dt),B.side=Xn,B.needsUpdate=!0,D.renderBufferDirect(k,P,O,B,v,dt),B.side=Oe):D.renderBufferDirect(k,P,O,B,v,dt),v.onAfterRender(D,P,k,O,B,dt)}function Xs(v,P,k){P.isScene!==!0&&(P=Be);let O=H.get(v),B=b.state.lights,dt=b.state.shadowsArray,_t=B.state.version,ut=rt.getParameters(v,B.state,dt,P,k,b.state.lightProbeGridArray),vt=rt.getProgramCacheKey(ut),bt=O.programs;O.environment=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?P.environment:null,O.fog=P.fog;let Ut=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap;O.envMap=it.get(v.envMap||O.environment,Ut),O.envMapRotation=O.environment!==null&&v.envMap===null?P.environmentRotation:v.envMapRotation,bt===void 0&&(v.addEventListener("dispose",un),bt=new Map,O.programs=bt);let Ht=bt.get(vt);if(Ht!==void 0){if(O.currentProgram===Ht&&O.lightsStateVersion===_t)return Il(v,ut),Ht}else ut.uniforms=rt.getUniforms(v),z!==null&&v.isNodeMaterial&&z.build(v,k,ut),v.onBeforeCompile(ut,D),Ht=rt.acquireProgram(ut,vt),bt.set(vt,Ht),O.uniforms=ut.uniforms;let yt=O.uniforms;return(!v.isShaderMaterial&&!v.isRawShaderMaterial||v.clipping===!0)&&(yt.clippingPlanes=Tt.uniform),Il(v,ut),O.needsLights=Ih(v),O.lightsStateVersion=_t,O.needsLights&&(yt.ambientLightColor.value=B.state.ambient,yt.lightProbe.value=B.state.probe,yt.sunLights.value=B.state.sun,yt.sunLightShadows.value=B.state.sunShadow,yt.directionalLights.value=B.state.directional,yt.directionalLightShadows.value=B.state.directionalShadow,yt.spotLights.value=B.state.spot,yt.spotLightShadows.value=B.state.spotShadow,yt.rectAreaLights.value=B.state.rectArea,yt.ltc_1.value=B.state.rectAreaLTC1,yt.ltc_2.value=B.state.rectAreaLTC2,yt.pointLights.value=B.state.point,yt.pointLightShadows.value=B.state.pointShadow,yt.hemisphereLights.value=B.state.hemi,yt.sunShadowMatrix.value=B.state.sunShadowMatrix,yt.sunShadowCascade.value=B.state.sunShadowCascade,yt.directionalShadowMatrix.value=B.state.directionalShadowMatrix,yt.spotLightMatrix.value=B.state.spotLightMatrix,yt.spotLightMap.value=B.state.spotLightMap,yt.pointShadowMatrix.value=B.state.pointShadowMatrix),O.lightProbeGrid=b.state.lightProbeGridArray.length>0,O.currentProgram=Ht,O.uniformsList=null,Ht}function Pl(v){if(v.uniformsList===null){let P=v.currentProgram.getUniforms();v.uniformsList=qi.seqWithValue(P.seq,v.uniforms)}return v.uniformsList}function Il(v,P){let k=H.get(v);k.outputColorSpace=P.outputColorSpace,k.batching=P.batching,k.batchingColor=P.batchingColor,k.instancing=P.instancing,k.instancingColor=P.instancingColor,k.instancingMorph=P.instancingMorph,k.skinning=P.skinning,k.morphTargets=P.morphTargets,k.morphNormals=P.morphNormals,k.morphColors=P.morphColors,k.morphTargetsCount=P.morphTargetsCount,k.numClippingPlanes=P.numClippingPlanes,k.numIntersection=P.numClipIntersection,k.vertexAlphas=P.vertexAlphas,k.vertexTangents=P.vertexTangents,k.toneMapping=P.toneMapping}function Rh(v,P){if(v.length===0)return null;if(v.length===1)return v[0].texture!==null?v[0]:null;y.setFromMatrixPosition(P.matrixWorld);for(let k=0,O=v.length;k<O;k++){let B=v[k];if(B.texture!==null&&B.boundingBox.containsPoint(y))return B}return null}function Ch(v,P,k,O,B){P.isScene!==!0&&(P=Be),Y.resetTextureUnits();let dt=P.fog,_t=O.isMeshStandardMaterial||O.isMeshLambertMaterial||O.isMeshPhongMaterial?P.environment:null,ut=nt===null?D.outputColorSpace:nt.isXRRenderTarget===!0?nt.texture.colorSpace:Wt.workingColorSpace,vt=O.isMeshStandardMaterial||O.isMeshLambertMaterial&&!O.envMap||O.isMeshPhongMaterial&&!O.envMap,bt=it.get(O.envMap||_t,vt),Ut=O.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,Ht=!!k.attributes.tangent&&(!!O.normalMap||O.anisotropy>0),yt=!!k.morphAttributes.position,$t=!!k.morphAttributes.normal,me=!!k.morphAttributes.color,ae=on;O.toneMapped&&(nt===null||nt.isXRRenderTarget===!0)&&(ae=D.toneMapping);let ne=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,we=ne!==void 0?ne.length:0,mt=H.get(O),Le=b.state.lights;if(Yt===!0&&(ie===!0||v!==j)){let re=v===j&&O.id===W;Tt.setState(O,v,re)}let qt=!1;O.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==Le.state.version||mt.outputColorSpace!==ut||B.isBatchedMesh&&mt.batching===!1||!B.isBatchedMesh&&mt.batching===!0||B.isBatchedMesh&&mt.batchingColor===!0&&B._colorsTexture===null||B.isBatchedMesh&&mt.batchingColor===!1&&B._colorsTexture!==null||B.isInstancedMesh&&mt.instancing===!1||!B.isInstancedMesh&&mt.instancing===!0||B.isSkinnedMesh&&mt.skinning===!1||!B.isSkinnedMesh&&mt.skinning===!0||B.isInstancedMesh&&mt.instancingColor===!0&&B.instanceColor===null||B.isInstancedMesh&&mt.instancingColor===!1&&B.instanceColor!==null||B.isInstancedMesh&&mt.instancingMorph===!0&&B.morphTexture===null||B.isInstancedMesh&&mt.instancingMorph===!1&&B.morphTexture!==null||mt.envMap!==bt||O.fog===!0&&mt.fog!==dt||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==Tt.numPlanes||mt.numIntersection!==Tt.numIntersection)||mt.vertexAlphas!==Ut||mt.vertexTangents!==Ht||mt.morphTargets!==yt||mt.morphNormals!==$t||mt.morphColors!==me||mt.toneMapping!==ae||mt.morphTargetsCount!==we||!!mt.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(qt=!0):(qt=!0,mt.__version=O.version);let Ze=mt.currentProgram;qt===!0&&(Ze=Xs(O,P,B),z&&O.isNodeMaterial&&z.onUpdateProgram(O,Ze,mt));let dn=!1,Cn=!1,hi=!1,te=Ze.getUniforms(),de=mt.uniforms;if(g.useProgram(Ze.program)&&(dn=!0,Cn=!0,hi=!0),O.id!==W&&(W=O.id,Cn=!0),mt.needsLights){let re=Rh(b.state.lightProbeGridArray,B);mt.lightProbeGrid!==re&&(mt.lightProbeGrid=re,Cn=!0)}if(dn||j!==v){g.buffers.depth.getReversed()&&v.reversedDepth!==!0&&(v._reversedDepth=!0,v.updateProjectionMatrix()),te.setValue(L,"projectionMatrix",v.projectionMatrix),te.setValue(L,"viewMatrix",v.matrixWorldInverse);let In=te.map.cameraPosition;In!==void 0&&In.setValue(L,le.setFromMatrixPosition(v.matrixWorld)),E.logarithmicDepthBuffer&&te.setValue(L,"logDepthBufFC",2/(Math.log(v.far+1)/Math.LN2)),(O.isMeshPhongMaterial||O.isMeshToonMaterial||O.isMeshLambertMaterial||O.isMeshBasicMaterial||O.isMeshStandardMaterial||O.isShaderMaterial)&&te.setValue(L,"isOrthographic",v.isOrthographicCamera===!0),j!==v&&(j=v,Cn=!0,hi=!0)}if(mt.needsLights&&(Le.state.sunShadowMap.length>0&&te.setValue(L,"sunShadowMap",Le.state.sunShadowMap,Y),Le.state.directionalShadowMap.length>0&&te.setValue(L,"directionalShadowMap",Le.state.directionalShadowMap,Y),Le.state.spotShadowMap.length>0&&te.setValue(L,"spotShadowMap",Le.state.spotShadowMap,Y),Le.state.pointShadowMap.length>0&&te.setValue(L,"pointShadowMap",Le.state.pointShadowMap,Y)),B.isSkinnedMesh){te.setOptional(L,B,"bindMatrix"),te.setOptional(L,B,"bindMatrixInverse");let re=B.skeleton;re&&(re.boneTexture===null&&re.computeBoneTexture(),te.setValue(L,"boneTexture",re.boneTexture,Y))}B.isBatchedMesh&&(te.setOptional(L,B,"batchingTexture"),te.setValue(L,"batchingTexture",B._matricesTexture,Y),te.setOptional(L,B,"batchingIdTexture"),te.setValue(L,"batchingIdTexture",B._indirectTexture,Y),te.setOptional(L,B,"batchingColorTexture"),B._colorsTexture!==null&&te.setValue(L,"batchingColorTexture",B._colorsTexture,Y));let Pn=k.morphAttributes;if((Pn.position!==void 0||Pn.normal!==void 0||Pn.color!==void 0)&&I.update(B,k,Ze),(Cn||mt.receiveShadow!==B.receiveShadow)&&(mt.receiveShadow=B.receiveShadow,te.setValue(L,"receiveShadow",B.receiveShadow)),(O.isMeshStandardMaterial||O.isMeshLambertMaterial||O.isMeshPhongMaterial)&&O.envMap===null&&P.environment!==null&&(de.envMapIntensity.value=P.environmentIntensity),de.dfgLUT!==void 0&&(de.dfgLUT.value=Ag()),Cn){if(te.setValue(L,"toneMappingExposure",D.toneMappingExposure),mt.needsLights&&Ph(de,hi),dt&&O.fog===!0&&Et.refreshFogUniforms(de,dt),Et.refreshMaterialUniforms(de,O,$,q,b.state.transmissionRenderTarget[v.id]),mt.needsLights&&mt.lightProbeGrid){let re=mt.lightProbeGrid;de.probesSH.value=re.texture,de.probesMin.value.copy(re.boundingBox.min),de.probesMax.value.copy(re.boundingBox.max),de.probesResolution.value.copy(re.resolution)}qi.upload(L,Pl(mt),de,Y)}if(O.isShaderMaterial&&O.uniformsNeedUpdate===!0&&(qi.upload(L,Pl(mt),de,Y),O.uniformsNeedUpdate=!1),O.isSpriteMaterial&&te.setValue(L,"center",B.center),te.setValue(L,"modelViewMatrix",B.modelViewMatrix),te.setValue(L,"normalMatrix",B.normalMatrix),te.setValue(L,"modelMatrix",B.matrixWorld),O.uniformsGroups!==void 0){let re=O.uniformsGroups;for(let In=0,ui=re.length;In<ui;In++){let Dl=re[In];et.update(Dl,Ze),et.bind(Dl,Ze)}}return Ze}function Ph(v,P){v.ambientLightColor.needsUpdate=P,v.lightProbe.needsUpdate=P,v.sunLights.needsUpdate=P,v.sunLightShadows.needsUpdate=P,v.directionalLights.needsUpdate=P,v.directionalLightShadows.needsUpdate=P,v.pointLights.needsUpdate=P,v.pointLightShadows.needsUpdate=P,v.spotLights.needsUpdate=P,v.spotLightShadows.needsUpdate=P,v.rectAreaLights.needsUpdate=P,v.hemisphereLights.needsUpdate=P}function Ih(v){return v.isMeshLambertMaterial||v.isMeshToonMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isShadowMaterial||v.isShaderMaterial&&v.lights===!0}this.getActiveCubeFace=function(){return Z},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return nt},this.setRenderTargetTextures=function(v,P,k){let O=H.get(v);O.__autoAllocateDepthBuffer=v.resolveDepthBuffer===!1,O.__autoAllocateDepthBuffer===!1&&(O.__useRenderToTexture=!1),H.get(v.texture).__webglTexture=P,H.get(v.depthTexture).__webglTexture=O.__autoAllocateDepthBuffer?void 0:k,O.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(v,P){let k=H.get(v);k.__webglFramebuffer=P,k.__useDefaultFramebuffer=P===void 0},this.setRenderTarget=function(v,P=0,k=0){nt=v,Z=P,X=k;let O=null,B=!1,dt=!1;if(v){let ut=H.get(v);if(ut.__useDefaultFramebuffer!==void 0){g.bindFramebuffer(L.FRAMEBUFFER,ut.__webglFramebuffer),tt.copy(v.viewport),At.copy(v.scissor),St=v.scissorTest,g.viewport(tt),g.scissor(At),g.setScissorTest(St),W=-1;return}else if(ut.__webglFramebuffer===void 0)Y.setupRenderTarget(v);else if(ut.__hasExternalTextures)Y.rebindTextures(v,H.get(v.texture).__webglTexture,H.get(v.depthTexture).__webglTexture);else if(v.depthBuffer){let Ut=v.depthTexture;if(ut.__boundDepthTexture!==Ut){if(Ut!==null&&H.has(Ut)&&(v.width!==Ut.image.width||v.height!==Ut.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Y.setupDepthRenderbuffer(v)}}let vt=v.texture;(vt.isData3DTexture||vt.isDataArrayTexture||vt.isCompressedArrayTexture)&&(dt=!0);let bt=H.get(v).__webglFramebuffer;v.isWebGLCubeRenderTarget?(Array.isArray(bt[P])?O=bt[P][k]:O=bt[P],B=!0):v.samples>0&&Y.useMultisampledRTT(v)===!1?O=H.get(v).__webglMultisampledFramebuffer:Array.isArray(bt)?O=bt[k]:O=bt,tt.copy(v.viewport),At.copy(v.scissor),St=v.scissorTest}else tt.copy(gt).multiplyScalar($).floor(),At.copy(Bt).multiplyScalar($).floor(),St=_e;if(k!==0&&(O=G),g.bindFramebuffer(L.FRAMEBUFFER,O)&&g.drawBuffers(v,O),g.viewport(tt),g.scissor(At),g.setScissorTest(St),B){let ut=H.get(v.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+P,ut.__webglTexture,k)}else if(dt){let ut=P;for(let vt=0;vt<v.textures.length;vt++){let bt=H.get(v.textures[vt]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+vt,bt.__webglTexture,k,ut)}}else if(v!==null&&k!==0){let ut=H.get(v.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,ut.__webglTexture,k)}W=-1};function Ll(v){let P=H.get(v);return(P.__readFormat!==v.format||P.__readType!==v.type)&&(P.__readFormat=v.format,P.__readType=v.type,P.__formatReadable=E.textureFormatReadable(v.format),P.__typeReadable=E.textureTypeReadable(v.type)),P}this.readRenderTargetPixels=function(v,P,k,O,B,dt,_t,ut=0){if(!(v&&v.isWebGLRenderTarget)){It("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let vt=H.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&_t!==void 0&&(vt=vt[_t]),vt){g.bindFramebuffer(L.FRAMEBUFFER,vt);try{let bt=v.textures[ut],Ut=bt.format,Ht=bt.type;v.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+ut);let yt=Ll(bt);if(yt.__formatReadable===!1){It("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(yt.__typeReadable===!1){It("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}P>=0&&P<=v.width-O&&k>=0&&k<=v.height-B&&L.readPixels(P,k,O,B,lt.convert(Ut),lt.convert(Ht),dt)}finally{let bt=nt!==null?H.get(nt).__webglFramebuffer:null;g.bindFramebuffer(L.FRAMEBUFFER,bt)}}},this.readRenderTargetPixelsAsync=async function(v,P,k,O,B,dt,_t,ut=0){if(!(v&&v.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let vt=H.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&_t!==void 0&&(vt=vt[_t]),vt)if(P>=0&&P<=v.width-O&&k>=0&&k<=v.height-B){g.bindFramebuffer(L.FRAMEBUFFER,vt);let bt=v.textures[ut],Ut=bt.format,Ht=bt.type;v.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+ut);let yt=Ll(bt);if(yt.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(yt.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let $t=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,$t),L.bufferData(L.PIXEL_PACK_BUFFER,dt.byteLength,L.STREAM_READ),L.readPixels(P,k,O,B,lt.convert(Ut),lt.convert(Ht),0),L.bindBuffer(L.PIXEL_PACK_BUFFER,null);let me=nt!==null?H.get(nt).__webglFramebuffer:null;g.bindFramebuffer(L.FRAMEBUFFER,me);let ae=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Hc(L,ae,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,$t),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,dt),L.bindBuffer(L.PIXEL_PACK_BUFFER,null),L.deleteBuffer($t),L.deleteSync(ae),dt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(v,P=null,k=0){let O=Math.pow(2,-k),B=Math.floor(v.image.width*O),dt=Math.floor(v.image.height*O),_t=P!==null?P.x:0,ut=P!==null?P.y:0;Y.setTexture2D(v,0),L.copyTexSubImage2D(L.TEXTURE_2D,k,0,0,_t,ut,B,dt),g.unbindTexture()},this.copyTextureToTexture=function(v,P,k=null,O=null,B=0,dt=0){let _t,ut,vt,bt,Ut,Ht,yt,$t,me,ae=v.isCompressedTexture?v.mipmaps[dt]:v.image;if(k!==null)_t=k.max.x-k.min.x,ut=k.max.y-k.min.y,vt=k.isBox3?k.max.z-k.min.z:1,bt=k.min.x,Ut=k.min.y,Ht=k.isBox3?k.min.z:0;else{let de=Math.pow(2,-B);_t=Math.floor(ae.width*de),ut=Math.floor(ae.height*de),v.isDataArrayTexture?vt=ae.depth:v.isData3DTexture?vt=Math.floor(ae.depth*de):vt=1,bt=0,Ut=0,Ht=0}O!==null?(yt=O.x,$t=O.y,me=O.z):(yt=0,$t=0,me=0);let ne=lt.convert(P.format),we=lt.convert(P.type),mt;P.isData3DTexture?(Y.setTexture3D(P,0),mt=L.TEXTURE_3D):P.isDataArrayTexture||P.isCompressedArrayTexture?(Y.setTexture2DArray(P,0),mt=L.TEXTURE_2D_ARRAY):(Y.setTexture2D(P,0),mt=L.TEXTURE_2D),g.activeTexture(L.TEXTURE0),g.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,P.flipY),g.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),g.pixelStorei(L.UNPACK_ALIGNMENT,P.unpackAlignment);let Le=g.getParameter(L.UNPACK_ROW_LENGTH),qt=g.getParameter(L.UNPACK_IMAGE_HEIGHT),Ze=g.getParameter(L.UNPACK_SKIP_PIXELS),dn=g.getParameter(L.UNPACK_SKIP_ROWS),Cn=g.getParameter(L.UNPACK_SKIP_IMAGES);g.pixelStorei(L.UNPACK_ROW_LENGTH,ae.width),g.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ae.height),g.pixelStorei(L.UNPACK_SKIP_PIXELS,bt),g.pixelStorei(L.UNPACK_SKIP_ROWS,Ut),g.pixelStorei(L.UNPACK_SKIP_IMAGES,Ht);let hi=v.isDataArrayTexture||v.isData3DTexture,te=P.isDataArrayTexture||P.isData3DTexture;if(v.isDepthTexture){let de=H.get(v),Pn=H.get(P),re=H.get(de.__renderTarget),In=H.get(Pn.__renderTarget);g.bindFramebuffer(L.READ_FRAMEBUFFER,re.__webglFramebuffer),g.bindFramebuffer(L.DRAW_FRAMEBUFFER,In.__webglFramebuffer);for(let ui=0;ui<vt;ui++)hi&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,H.get(v).__webglTexture,B,Ht+ui),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,H.get(P).__webglTexture,dt,me+ui)),L.blitFramebuffer(bt,Ut,_t,ut,yt,$t,_t,ut,L.DEPTH_BUFFER_BIT,L.NEAREST);g.bindFramebuffer(L.READ_FRAMEBUFFER,null),g.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(B!==0||v.isRenderTargetTexture||H.has(v)){let de=H.get(v),Pn=H.get(P);g.bindFramebuffer(L.READ_FRAMEBUFFER,N),g.bindFramebuffer(L.DRAW_FRAMEBUFFER,V);for(let re=0;re<vt;re++)hi?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,de.__webglTexture,B,Ht+re):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,de.__webglTexture,B),te?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Pn.__webglTexture,dt,me+re):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Pn.__webglTexture,dt),B!==0?L.blitFramebuffer(bt,Ut,_t,ut,yt,$t,_t,ut,L.COLOR_BUFFER_BIT,L.NEAREST):te?L.copyTexSubImage3D(mt,dt,yt,$t,me+re,bt,Ut,_t,ut):L.copyTexSubImage2D(mt,dt,yt,$t,bt,Ut,_t,ut);g.bindFramebuffer(L.READ_FRAMEBUFFER,null),g.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else te?v.isDataTexture||v.isData3DTexture?L.texSubImage3D(mt,dt,yt,$t,me,_t,ut,vt,ne,we,ae.data):P.isCompressedArrayTexture?L.compressedTexSubImage3D(mt,dt,yt,$t,me,_t,ut,vt,ne,ae.data):L.texSubImage3D(mt,dt,yt,$t,me,_t,ut,vt,ne,we,ae):v.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,dt,yt,$t,_t,ut,ne,we,ae.data):v.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,dt,yt,$t,ae.width,ae.height,ne,ae.data):L.texSubImage2D(L.TEXTURE_2D,dt,yt,$t,_t,ut,ne,we,ae);g.pixelStorei(L.UNPACK_ROW_LENGTH,Le),g.pixelStorei(L.UNPACK_IMAGE_HEIGHT,qt),g.pixelStorei(L.UNPACK_SKIP_PIXELS,Ze),g.pixelStorei(L.UNPACK_SKIP_ROWS,dn),g.pixelStorei(L.UNPACK_SKIP_IMAGES,Cn),dt===0&&P.generateMipmaps&&L.generateMipmap(mt),g.unbindTexture()},this.initRenderTarget=function(v){H.get(v).__webglFramebuffer===void 0&&Y.setupRenderTarget(v)},this.initTexture=function(v){v.isCubeTexture?Y.setTextureCube(v,0):v.isData3DTexture?Y.setTexture3D(v,0):v.isDataArrayTexture||v.isCompressedArrayTexture?Y.setTexture2DArray(v,0):Y.setTexture2D(v,0),g.unbindTexture()},this.resetState=function(){Z=0,X=0,nt=null,g.reset(),ft.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return an}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=Wt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Wt._getUnpackColorSpace()}};var Mh=[{id:"coral",label:"\u73CA\u745A",color:"#E99589"},{id:"sage",label:"\u7070\u7EFF",color:"#A9BDA7"},{id:"lavender",label:"\u6DE1\u7D2B",color:"#BFB0D9"},{id:"cream",label:"\u5976\u6CB9",color:"#E8D8B8"},{id:"blue",label:"\u96FE\u84DD",color:"#A9C6D5"},{id:"ochre",label:"\u8D6D\u9EC4",color:"#D4AE65"}];function Sl(i){return"kind"in i&&i.kind==="cat"}var Cg=8,Pg=80,Ig=48*1024*1024,Lg=16*1024*1024,Dg=4,Ng=2,Ug=12,Fg=480;function Eh(i){let t=i>>>0;return()=>(t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296)}function Gs(i){let t=2166136261;for(let e of JSON.stringify(i))t=Math.imul(t^e.charCodeAt(0),16777619);return t>>>0}function Og(i){let t=[];if(i==="triangle"){let e=new Ss;return e.moveTo(-.18,.93),e.quadraticCurveTo(0,1.22,.18,.93),e.lineTo(.87,-.48),e.quadraticCurveTo(1.03,-.8,.66,-.83),e.quadraticCurveTo(0,-.92,-.66,-.83),e.quadraticCurveTo(-1.03,-.8,-.87,-.48),e.lineTo(-.18,.93),e.getSpacedPoints(128).slice(0,-1)}for(let e=0;e<128;e++){let n=e/128*Math.PI*2,s=Math.cos(n),r=Math.sin(n),a,o;if(i==="heart")a=16*Math.pow(r,3)/17,o=(13*s-5*Math.cos(2*n)-2*Math.cos(3*n)-Math.cos(4*n)+2)/17;else if(i==="square"||i==="diamond"||i==="capsule"){let l=i==="capsule"?.82:i==="diamond"?.72:.5;a=Math.sign(s)*Math.pow(Math.abs(s),l),o=Math.sign(r)*Math.pow(Math.abs(r),l),i==="diamond"&&([a,o]=[(a-o)*.68,(a+o)*.68]),i==="square"&&(a*=.85,o*=.87),i==="capsule"&&(a*=.7,o*=1.02)}else a=s*.93,o=r*.96;t.push(new xt(a,o))}return t}function Xa(i){let t=Og(i),e=48,n=t.length,s=[],r=[],a=[];for(let d=0;d<=e;d++){let u=-Math.PI/2+d/e*Math.PI,p=Math.max(1e-4,Math.cos(u));for(let _=0;_<=n;_++){let M=t[_%n];if(s.push(M.x*p,M.y*p,Math.sin(u)*.6),r.push(_/n,d/e),d<e&&_<n){let m=d*(n+1)+_,f=m+n+1;a.push(m,f,m+1,f,f+1,m+1)}}}let o=new Pe;o.setAttribute("position",new ee(s,3)),o.setAttribute("uv",new ee(r,2)),o.setIndex(a),o.computeVertexNormals();let l=o.getAttribute("position"),c=o.getAttribute("normal"),h=0;for(let d=0;d<l.count;d++)h+=l.getZ(d)*c.getZ(d);if(h<0){for(let d=0;d<a.length;d+=3)[a[d+1],a[d+2]]=[a[d+2],a[d+1]];o.setIndex(a),o.computeVertexNormals()}return o}function Bg(){let i=document.createElement("canvas");i.width=i.height=256;let t=i.getContext("2d"),e=Eh(8447);t.fillStyle="#a6a6a6",t.fillRect(0,0,256,256);for(let s=0;s<22e3;s++){let r=e()*256,a=e()*256,o=Math.round(90+e()*130);t.strokeStyle=`rgb(${o},${o},${o})`,t.lineWidth=.5,t.beginPath(),t.moveTo(r,a),t.lineTo(r+e()*3-1.5,a+e()*5),t.stroke()}let n=new ps(i);return n.wrapS=n.wrapT=Ai,n.repeat.set(3,2),n}function qa(i,t,e,n,s){let r=Eh(e),a=i.getAttribute("position"),o=i.getAttribute("normal"),l=i.getIndex(),c=[],h=new C,d=new C,u=new C,p=0;for(let A=0;A<l.count;A+=3)h.fromBufferAttribute(a,l.getX(A)),d.fromBufferAttribute(a,l.getX(A+1)),u.fromBufferAttribute(a,l.getX(A+2)),p+=d.clone().sub(h).cross(u.clone().sub(h)).length()*.5,c.push(p);let _=[],M=[],m=[],f=new C,T=new C,R=new C,y=new C,S=new C;for(let A=0;A<n;A++){let x=r()*p,w=0,D=c.length-1;for(;w<D;){let $=w+D>>>1;c[$]<x?w=$+1:D=$}let U=w*3,z=l.getX(U),G=l.getX(U+1),N=l.getX(U+2),V=r(),Z=r();V+Z>1&&(V=1-V,Z=1-Z),h.fromBufferAttribute(a,z),d.fromBufferAttribute(a,G),u.fromBufferAttribute(a,N);let X=h.multiplyScalar(1-V-Z).addScaledVector(d,V).addScaledVector(u,Z);f.fromBufferAttribute(o,z).multiplyScalar(1-V-Z),T.fromBufferAttribute(o,G),R.fromBufferAttribute(o,N),f.addScaledVector(T,V).addScaledVector(R,Z).normalize(),y.set(r()*.5-.25,-1,r()*.5-.25),y.addScaledVector(f,-y.dot(f)).normalize(),S.crossVectors(f,y).normalize();let nt=.03+Math.pow(r(),1.7)*.047,W=.0017+r()*.0018,j=X.clone().addScaledVector(f,nt*.6).addScaledVector(y,nt*.3),tt=X.clone().addScaledVector(f,nt*.85).addScaledVector(y,nt*.7),At=X.clone().addScaledVector(S,W),St=X.clone().addScaledVector(S,-W),Zt=j.clone().addScaledVector(S,W*.65),zt=j.clone().addScaledVector(S,-W*.65),Xt=.7+r()*.38,q=s?.(X)??t;[At,St,Zt,St,zt,Zt,Zt,zt,tt].forEach(($,pt)=>{_.push($.x,$.y,$.z),m.push(f.x,f.y,f.z);let Pt=Xt*(pt===8?1.24:pt<2||pt===3?.78:1.08);M.push(q.r*Pt,q.g*Pt,q.b*Pt)})}let b=new Pe;return b.setAttribute("position",new ee(_,3)),b.setAttribute("normal",new ee(m,3)),b.setAttribute("color",new ee(M,3)),b.computeBoundingSphere(),b}function ci(i,t,e){return new kt(new Es(new Oi(i),24,t,6,!1),e)}function zg(i,t,e){let n=new $e,s=i.coat==="silver",r=new Lt(s?"#9dabb8":"#f49335"),a=new Lt(s?"#657789":"#b85d18"),o=new Lt(s?"#ced6dc":"#ffd29a"),l=new Lt,c=S=>{let b=Oa.clamp((S.y-.15)*.55,0,.3),A=Oa.clamp((-S.y-.1)*.45,0,.35);return l.copy(r).lerp(a,b).lerp(o,A)},h=Xa("square"),d=h.getAttribute("position"),u=[],p=new C;for(let S=0;S<d.count;S++){d.setXYZ(S,d.getX(S)*1.08,d.getY(S)*.86-.1,d.getZ(S));let b=c(p.fromBufferAttribute(d,S));u.push(b.r,b.g,b.b)}h.computeVertexNormals(),h.setAttribute("color",new ee(u,3)),n.add(new kt(h,new fe({vertexColors:!0,roughness:1,bumpMap:t,bumpScale:.023}))),n.add(new kt(qa(h,r,Gs(i),e?28e3:4500,c),new fe({vertexColors:!0,roughness:1,side:Oe})));let _=(S,b,A)=>{let x=new $e;return x.add(new kt(S,new fe({color:b,roughness:1,bumpMap:t,bumpScale:.024}))),x.add(new kt(qa(S,b,Gs(i)+A,A),new fe({vertexColors:!0,roughness:1,side:Oe}))),x};for(let S of[-1,1]){let b=_(Xa("triangle"),a,e?4e3:650);b.scale.set(.3,.38,.4),b.position.set(S*.64,.69,-.015),b.rotation.z=S*-.12,n.add(b);let A=_(Xa("triangle"),r.clone().lerp(o,.12),e?1800:300);A.scale.set(.19,.27,.11),A.position.set(S*.64,.69,.25),A.rotation.z=S*-.12,n.add(A)}let M=[],m=()=>new Ke(1,28,20);for(let S of[-.32,.32]){let b=new kt(m(),new fe({color:"#faf8ee",roughness:.56}));b.position.set(S,.12,.635),b.scale.set(.18,.145,.045),b.userData.restY=.145,n.add(b),M.push(b);let A=new kt(m(),new Bi({color:s?"#3e8b59":"#25211d",roughness:.28,clearcoat:.35}));if(A.position.set(S+Math.sign(S)*-.027,.13,.679),A.scale.set(.094,.108,.024),A.userData.restY=.108,n.add(A),M.push(A),s){let w=new kt(m(),new fe({color:"#1f3e2b",roughness:.5}));w.position.set(A.position.x,.13,.7),w.scale.set(.019,.088,.009),w.userData.restY=.088,n.add(w),M.push(w)}let x=new kt(m(),new ni({color:"#ffffff"}));x.position.set(A.position.x-.024,.174,.707),x.scale.set(.017,.025,.005),x.userData.restY=.025,n.add(x),M.push(x)}let f=new kt(new Ke(1,28,16),new fe({color:"#ee889a",roughness:.68}));f.position.set(0,-.145,.66),f.scale.set(.112,.063,.035),n.add(f);let T=new fe({color:s?"#607183":"#b16a29",roughness:1});n.add(ci([new C(0,-.18,.679),new C(0,-.255,.681)],.013,T));let R=ci([new C(-.15,-.27,.672),new C(-.08,-.31,.675),new C(0,-.255,.681),new C(.08,-.31,.675),new C(.15,-.27,.672)],.013,T);n.add(R);let y=new kt(m(),new fe({color:"#492c2b",roughness:.9}));y.position.set(0,-.3,.677),y.scale.set(.085,.032,.021),y.visible=!1,n.add(y);for(let S of[-1,1])for(let b=0;b<2;b++){let A=_(new Ke(1,20,14),a,e?700:160);A.scale.set(.055,.11,.02),A.rotation.z=S*-.36,A.position.set(S*(.68+b*.12),-.24+b*.075,.49-b*.1),n.add(A)}return{root:n,eyes:M,smile:R,mouth:y,ready:!1,preparing:!1}}function Vg(i,t,e){let n=new $e,s=new Lt(Mh.find(h=>h.id===i.color).color),r=Xa(i.shape);n.add(new kt(r,new fe({color:s,roughness:1,bumpMap:t,bumpScale:.022}))),n.add(new kt(qa(r,s,Gs(i),e?28e3:4500),new fe({vertexColors:!0,roughness:1,side:Oe})));let a=new Bi({color:"#161413",roughness:.29,clearcoat:.3}),o=[-.3,.3].map(h=>{let d=new kt(new Ke(1,20,16),a);return d.position.set(h,.035,.645),d.scale.set(.056,.086,.042),n.add(d),d}),l=ci([new C(-.105,-.22,.665),new C(0,-.277,.675),new C(.105,-.22,.665)],.017,new fe({color:"#221a18",roughness:.65}));n.add(l);let c=new kt(new Ke(1,20,12),new fe({color:"#39201d",roughness:.8}));if(c.position.set(0,-.23,.672),c.scale.set(.089,.048,.019),c.visible=!1,n.add(c),i.glasses!=="none"){let h=new fe({color:i.glasses==="gold"?"#bd985c":"#2b2622",metalness:i.glasses==="gold"?.78:.12,roughness:.32}),d=i.glasses==="gold"?.013:.028;for(let u of[-.3,.3]){let p=new kt(new ii(.232,d,10,56),h);p.position.set(u,.045,.733),n.add(p),n.add(ci([new C(u+Math.sign(u)*.232,.065,.733),new C(Math.sign(u)*.73,.08,.53),new C(Math.sign(u)*.8,.06,.2)],d,h))}n.add(ci([new C(-.066,.06,.733),new C(0,.1,.748),new C(.066,.06,.733)],d,h))}if(i.hat!=="none"){let h=new $e,d=i.shape==="heart"?.79:i.shape==="triangle"?.94:i.shape==="diamond"?1.05:.91,u=new fe({color:i.hat==="beanie"?"#bd6844":"#e4d9bd",roughness:1,bumpMap:t,bumpScale:.045}),p=(_,M)=>{let m=new kt(qa(_.geometry,new Lt(u.color),Gs(i)+41,M),new fe({vertexColors:!0,roughness:1,side:Oe}));m.position.copy(_.position),m.scale.copy(_.scale),m.rotation.copy(_.rotation),h.add(m)};if(i.hat==="beanie"){let _=new kt(new Ke(1,48,24,0,Math.PI*2,0,Math.PI/2),u);_.scale.set(.79,.53,.64),_.position.y=d-.18,h.add(_),e&&p(_,5e3);let M=new kt(new ii(.73,.095,12,64),u);M.rotation.x=Math.PI/2,M.scale.y=.83,M.position.y=d-.17,h.add(M);for(let T=0;T<40;T++){let R=T/40*Math.PI*2,y=[];for(let S=0;S<=10;S++){let b=S/10*Math.PI*.46;y.push(new C(Math.cos(R)*Math.cos(b)*.798,d-.18+Math.sin(b)*.54,Math.sin(R)*Math.cos(b)*.65))}h.add(ci(y,.012,u))}let m=new Ke(.145,24,16),f=new kt(m,u);f.position.set(0,d+.43,0),h.add(f),p(f,e?1400:350)}else{let _=new kt(new Ke(1,48,24),u);_.scale.set(.87,.22,.7),_.position.set(.04,d-.015,0),h.add(_),e&&p(_,5e3);let M=new kt(new ii(.65,.04,10,56),u);M.rotation.x=Math.PI/2,M.scale.y=.83,M.position.y=d-.13,h.add(M),h.add(ci([new C(.14,d+.16,0),new C(.14,d+.27,0),new C(.19,d+.3,0)],.031,u))}h.rotation.z=i.hat==="beret"?-.17:.1,n.add(h)}return{root:n,eyes:o,smile:l,mouth:c,ready:!1,preparing:!1}}function Sh(i){let t=new Set;i.root.traverse(e=>{if(e instanceof kt){e.geometry.dispose();for(let n of Array.isArray(e.material)?e.material:[e.material])t.add(n)}});for(let e of t)e.dispose()}function bh(i){let t=0;return i.root.traverse(e=>{if(e instanceof kt){for(let n of Object.keys(e.geometry.attributes)){let s=e.geometry.getAttribute(n);t+=s instanceof ds?s.data.array.byteLength:s.array.byteLength}t+=e.geometry.getIndex()?.array.byteLength??0}}),t}var bl=class{constructor(){xe(this,"renderer",null);xe(this,"scene",new cs);xe(this,"camera",new Wn(-1.4,1.4,1.48,-1.32,.1,20));xe(this,"texture",null);xe(this,"registrations",new Set);xe(this,"models",new Map);xe(this,"frames",new Map);xe(this,"timer",0);xe(this,"observer");xe(this,"lost",!1);xe(this,"blocked",!1);xe(this,"totalFrames",0);xe(this,"maxRenderMs",0);xe(this,"renderMs",0);xe(this,"createdContexts",0);xe(this,"contextGeneration",0);xe(this,"maxCompileWaitMs",0);xe(this,"releaseTimer",0);this.camera.position.set(.12,.14,5),this.camera.lookAt(0,.05,0),this.scene.add(new ws(16775146,11643295,1.7)),this.scene.add(new Cs(16775665,.72));let t=[[16774111,2.7,-3,4,4],[15397631,1.5,3,1,2],[16777215,2.2,0,3,-3]];for(let[e,n,s,r,a]of t){let o=new Rs(e,n);o.position.set(s,r,a),this.scene.add(o)}this.observer=new IntersectionObserver(e=>{for(let n of e)for(let s of this.registrations)s.canvas===n.target&&(s.visible=n.isIntersecting,s.dirty=!0);this.schedule()}),document.addEventListener("visibilitychange",()=>{if(window.clearTimeout(this.timer),this.timer=0,document.hidden)for(let e of this.registrations)this.setState(e,"paused");else{for(let e of this.registrations)e.dirty=!0;this.schedule()}}),globalThis.__wandPlushDiagnostics=()=>({webglBlocked:this.blocked,contexts:this.renderer?1:0,createdContexts:this.createdContexts,registrations:this.registrations.size,visible:[...this.registrations].filter(e=>e.visible).length,animated:[...this.registrations].filter(e=>e.activity==="active").length,frames:this.totalFrames,renderMs:this.renderMs,maxRenderMs:this.maxRenderMs,models:this.models.size,cachedFrames:this.frames.size,hidden:document.hidden,contextLost:this.lost,geometryBytes:[...this.models.values()].reduce((e,n)=>e+bh(n),0),cachedFrameBytes:[...this.frames.values()].reduce((e,n)=>e+n.width*n.height*4,0),maxCompileWaitMs:this.maxCompileWaitMs,reducedMotion:[...this.registrations].every(e=>e.options.reducedMotion)})}init(){if(this.blocked)return!1;if(this.renderer)return!this.lost;try{let t=new ka({alpha:!0,antialias:!0,preserveDrawingBuffer:!0,powerPreference:"low-power"});return t.setPixelRatio(1),t.setClearColor(0,0),t.outputColorSpace=Ne,t.toneMapping=Is,t.toneMappingExposure=1.05,t.domElement.addEventListener("webglcontextlost",e=>{if(this.renderer===t){e.preventDefault(),this.lost=!0,this.contextGeneration++;for(let n of this.models.values())n.ready=!1,n.preparing=!1;window.clearTimeout(this.timer),this.timer=0;for(let n of this.registrations)n.state("fallback","fallback","context-lost")}}),t.domElement.addEventListener("webglcontextrestored",()=>{if(this.renderer===t){this.lost=!1,this.frames.clear();for(let e of this.registrations)e.dirty=!0,e.activity="";this.schedule()}}),this.renderer=t,this.lost=!1,this.createdContexts++,this.contextGeneration++,this.texture=Bg(),!0}catch{return this.blocked=!0,!1}}attach(t,e,n){window.clearTimeout(this.releaseTimer);let s=t.getContext("2d",{alpha:!0});if(!s||!this.init())return n("fallback","fallback",s?this.lost?"context-lost":"webgl-unavailable":"canvas-unavailable"),{update(){},dispose(){}};let r={canvas:t,context:s,options:e,state:n,visible:!1,dirty:!0,lastFrame:0,phase:Gs(e.config)%1e3/100,frames:0,activity:"",tiltX:0,tiltY:0};this.registrations.add(r),this.observer.observe(t);let a=c=>{if(!r.options.interactive||r.options.reducedMotion)return;let h=t.getBoundingClientRect();r.tiltX=((c.clientX-h.left)/h.width-.5)*.3,r.tiltY=((c.clientY-h.top)/h.height-.5)*.16,r.dirty=!0,this.schedule()},o=()=>{r.tiltX=r.tiltY=0,r.dirty=!0,this.schedule()},l=t.parentElement;return l?.addEventListener("pointermove",a),l?.addEventListener("pointerleave",o),{update:c=>{r.options=c,r.dirty=!0,this.schedule()},dispose:()=>{this.registrations.delete(r),this.observer.unobserve(t),l?.removeEventListener("pointermove",a),l?.removeEventListener("pointerleave",o),this.registrations.size||(window.clearTimeout(this.timer),this.timer=0,this.releaseTimer=window.setTimeout(()=>{if(!this.registrations.size){for(let c of this.models.values())Sh(c);this.models.clear(),this.frames.clear(),this.texture?.dispose(),this.texture=null,this.renderer?.dispose(),this.renderer?.forceContextLoss(),this.renderer=null,this.lost=!1}},5e3))}}}setState(t,e){t.activity!==e&&(t.activity=e,t.frames&&t.state("webgl",e))}schedule(){this.timer||document.hidden||this.lost||!this.registrations.size||(this.timer=window.setTimeout(()=>{this.timer=0,this.tick()},16))}tick(){if(document.hidden||this.lost||!this.renderer)return;let t=performance.now(),e=0,n=0,s=!1,r=[...this.registrations].sort((a,o)=>Number(o.options.interactive)-Number(a.options.interactive)||Number(o.options.speaking)-Number(a.options.speaking));for(let a of r){if(!a.visible||!a.canvas.isConnected){this.setState(a,"paused");continue}let o=!a.options.reducedMotion&&(a.options.interactive?n++<Ng:e++<Dg);if(this.setState(a,o?"active":"static"),!a.dirty&&(!o||t-a.lastFrame<(a.options.interactive?1e3/24:125))){s||(s=o);continue}if(performance.now()-t>Ug){s=!0;continue}try{this.render(a,o?t/1e3:0)}catch{a.state("fallback","fallback","render-failed"),a.dirty=!1,a.visible=!1}s||(s=o)}s&&this.schedule()}render(t,e){let n=performance.now();try{this.paint(t,e)}finally{this.renderMs=performance.now()-n,this.maxRenderMs=Math.max(this.maxRenderMs,this.renderMs)}}paint(t,e){let{config:n,size:s,reducedMotion:r,speaking:a}=t.options,o=Math.min(Fg,Math.max(24,Math.round(s*Math.min(window.devicePixelRatio||1,2)))),l=`${JSON.stringify(n)}:${t.options.interactive||s>=96?"preview":"list"}`,c=`${l}:${o}`;t.canvas.width!==o&&(t.canvas.width=o,t.canvas.height=o);let h=e===0?this.frames.get(c):void 0;if(h)t.context.clearRect(0,0,o,o),t.context.drawImage(h,0,0);else{let d=this.models.get(l);if(d)this.models.delete(l),this.models.set(l,d);else for(d=Sl(n)?zg(n,this.texture,t.options.interactive||s>=96):Vg(n,this.texture,t.options.interactive||s>=96),this.models.set(l,d);this.models.size>Cg||this.models.size>1&&[...this.models.values()].reduce((m,f)=>m+bh(f),0)>Ig;){let m=this.models.entries().next().value;this.scene.remove(m[1].root),Sh(m[1]),this.models.delete(m[0])}if(!d.ready){if(!d.preparing){d.preparing=!0;let m=this.renderer,f=this.contextGeneration,T=performance.now();m.compileAsync(d.root,this.camera,this.scene).then(()=>{this.renderer!==m||f!==this.contextGeneration||this.models.get(l)!==d||(d.ready=!0,d.preparing=!1,this.maxCompileWaitMs=Math.max(this.maxCompileWaitMs,performance.now()-T),this.schedule())},()=>{this.models.get(l)===d&&(d.preparing=!1,t.visible=!1,t.state("fallback","fallback","shader-compile-failed"))})}return}let u=e?e+t.phase:0;d.root.rotation.set(e?Math.sin(u*.57)*.035+t.tiltY:0,-.085+(e?Math.sin(u*.65)*.1+t.tiltX:0),e?Math.sin(u*.47)*.025:0),d.root.position.y=Sl(n)?-.03:n.hat==="none"?0:-.13;let p=(u+t.phase)%5.4,_=e&&!r&&p<.16?Math.max(.12,Math.abs(p-.08)/.08):1;for(let m of d.eyes)m.scale.y=(m.userData.restY??.086)*_;let M=a&&!r&&e!==0;if(d.mouth.visible=M,d.smile.visible=!M,d.mouth.scale.y=.032+(M?(Math.sin(u*13)*.5+.5)*.053:0),M&&(d.root.rotation.x+=Math.sin(u*8)*.025),this.scene.add(d.root),this.renderer.setSize(o,o,!1),this.renderer.render(this.scene,this.camera),this.scene.remove(d.root),t.context.clearRect(0,0,o,o),t.context.drawImage(this.renderer.domElement,0,0,o,o),t.canvas.dataset.sceneRotation=d.root.rotation.y.toFixed(4),t.canvas.dataset.mouthScale=d.mouth.scale.y.toFixed(4),t.canvas.dataset.blink=_.toFixed(3),e===0){let m=document.createElement("canvas");for(m.width=m.height=o,m.getContext("2d").drawImage(t.canvas,0,0),this.frames.set(c,m);this.frames.size>Pg||this.frames.size>1&&[...this.frames.values()].reduce((f,T)=>f+T.width*T.height*4,0)>Lg;)this.frames.delete(this.frames.keys().next().value)}}t.canvas.dataset.frame=String(++t.frames),this.totalFrames++,t.state("webgl",t.activity),t.dirty=!1,t.lastFrame=performance.now()}};globalThis.__wandPlushRuntime??(globalThis.__wandPlushRuntime=new bl);})();
|
|
4220
|
+
}`,yl=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new ms(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){let e=t.cameras[0].viewport,n=new qe({vertexShader:Mg,fragmentShader:Sg,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new kt(new bs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Ml=class extends gn{constructor(t,e){super();let n=this,s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,u=null,p=null,_=null,M=typeof XRWebGLBinding<"u",m=new yl,f={},T=e.getContextAttributes(),R=null,y=null,S=[],b=[],A=new xt,x=null,w=null,D=new ze;D.viewport=new he;let U=new ze;U.viewport=new he;let z=[D,U],G=new Yr,N=null,V=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let $=S[q];return $===void 0&&($=new Li,S[q]=$),$.getTargetRaySpace()},this.getControllerGrip=function(q){let $=S[q];return $===void 0&&($=new Li,S[q]=$),$.getGripSpace()},this.getHand=function(q){let $=S[q];return $===void 0&&($=new Li,S[q]=$),$.getHandSpace()};function Z(q){let $=b.indexOf(q.inputSource);if($===-1)return;let pt=S[$];pt!==void 0&&(pt.update(q.inputSource,q.frame,c||a),pt.dispatchEvent({type:q.type,data:q.inputSource}))}function X(){s.removeEventListener("select",Z),s.removeEventListener("selectstart",Z),s.removeEventListener("selectend",Z),s.removeEventListener("squeeze",Z),s.removeEventListener("squeezestart",Z),s.removeEventListener("squeezeend",Z),s.removeEventListener("end",X),s.removeEventListener("inputsourceschange",nt);for(let q=0;q<S.length;q++){let $=b[q];$!==null&&(b[q]=null,S[q].disconnect($))}N=null,V=null,m.reset();for(let q in f)delete f[q];if(t.setRenderTarget(R),p=null,u=null,d=null,s=null,y=null,Xt.stop(),n.isPresenting=!1,t.setPixelRatio(x),t.setSize(A.width,A.height,!1),w!==null){let q=w.camera;q.fov=w.fov,q.zoom=w.zoom,q.updateProjectionMatrix(),w=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(q){r=q,n.isPresenting===!0&&Ct("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(q){o=q,n.isPresenting===!0&&Ct("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(q){c=q},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return d===null&&M&&(d=new XRWebGLBinding(s,e)),d},this.getFrame=function(){return _},this.getSession=function(){return s},this.setSession=async function(q){if(s=q,s!==null){if(R=t.getRenderTarget(),s.addEventListener("select",Z),s.addEventListener("selectstart",Z),s.addEventListener("selectend",Z),s.addEventListener("squeeze",Z),s.addEventListener("squeezestart",Z),s.addEventListener("squeezeend",Z),s.addEventListener("end",X),s.addEventListener("inputsourceschange",nt),T.xrCompatible!==!0&&await e.makeXRCompatible(),x=t.getPixelRatio(),t.getSize(A),M&&"createProjectionLayer"in XRWebGLBinding.prototype){let pt=null,Pt=null,gt=null;T.depth&&(gt=T.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,pt=T.stencil?Zn:mn,Pt=T.stencil?Gi:ln);let Bt={colorFormat:e.RGBA8,depthFormat:gt,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(Bt),s.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),y=new Ve(u.textureWidth,u.textureHeight,{format:Qe,type:He,depthTexture:new Vn(u.textureWidth,u.textureHeight,Pt,void 0,void 0,void 0,void 0,void 0,void 0,pt),stencilBuffer:T.stencil,colorSpace:t.outputColorSpace,samples:T.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1,storeMultisampledDepthBuffer:u.ignoreDepthValues===!1,storeMultisampledStencilBuffer:u.ignoreDepthValues===!1})}else{let pt={antialias:T.antialias,alpha:!0,depth:T.depth,stencil:T.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(s,e,pt),s.updateRenderState({baseLayer:p}),t.setPixelRatio(1),t.setSize(p.framebufferWidth,p.framebufferHeight,!1),y=new Ve(p.framebufferWidth,p.framebufferHeight,{format:Qe,type:He,colorSpace:t.outputColorSpace,stencilBuffer:T.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1,storeMultisampledDepthBuffer:p.ignoreDepthValues===!1,storeMultisampledStencilBuffer:p.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await s.requestReferenceSpace(o),Xt.setContext(s),Xt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function nt(q){for(let $=0;$<q.removed.length;$++){let pt=q.removed[$],Pt=b.indexOf(pt);Pt>=0&&(b[Pt]=null,S[Pt].disconnect(pt))}for(let $=0;$<q.added.length;$++){let pt=q.added[$],Pt=b.indexOf(pt);if(Pt===-1){for(let Bt=0;Bt<S.length;Bt++)if(Bt>=b.length){b.push(pt),Pt=Bt;break}else if(b[Bt]===null){b[Bt]=pt,Pt=Bt;break}if(Pt===-1)break}let gt=S[Pt];gt&>.connect(pt)}}let W=new C,j=new C;function tt(q,$,pt){W.setFromMatrixPosition($.matrixWorld),j.setFromMatrixPosition(pt.matrixWorld);let Pt=W.distanceTo(j),gt=$.projectionMatrix.elements,Bt=pt.projectionMatrix.elements,_e=gt[14]/(gt[10]-1),Vt=gt[14]/(gt[10]+1),Yt=(gt[9]+1)/gt[5],ie=(gt[9]-1)/gt[5],Gt=(gt[8]-1)/gt[0],le=(Bt[8]+1)/Bt[0],Me=_e*Gt,Be=_e*le,ue=Pt/(-Gt+le),pe=ue*-Gt;if($.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(pe),q.translateZ(ue),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),gt[10]===-1)q.projectionMatrix.copy($.projectionMatrix),q.projectionMatrixInverse.copy($.projectionMatrixInverse);else{let L=_e+ue,Te=Vt+ue,Qt=Me-pe,E=Be+(Pt-pe),g=Yt*Vt/Te*L,F=ie*Vt/Te*L;q.projectionMatrix.makePerspective(Qt,E,g,F,L,Te),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}function At(q,$){$===null?q.matrixWorld.copy(q.matrix):q.matrixWorld.multiplyMatrices($.matrixWorld,q.matrix),q.matrixWorldInverse.copy(q.matrixWorld).invert()}this.updateCamera=function(q){if(s===null)return;let $=q.near,pt=q.far;m.texture!==null&&(m.depthNear>0&&($=m.depthNear),m.depthFar>0&&(pt=m.depthFar)),G.near=U.near=D.near=$,G.far=U.far=D.far=pt,(N!==G.near||V!==G.far)&&(s.updateRenderState({depthNear:G.near,depthFar:G.far}),N=G.near,V=G.far),G.layers.mask=q.layers.mask|6,D.layers.mask=G.layers.mask&-5,U.layers.mask=G.layers.mask&-3;let Pt=q.parent,gt=G.cameras;At(G,Pt);for(let Bt=0;Bt<gt.length;Bt++)At(gt[Bt],Pt);gt.length===2?tt(G,D,U):G.projectionMatrix.copy(D.projectionMatrix),w===null&&q.isPerspectiveCamera&&(w={camera:q,fov:q.fov,zoom:q.zoom}),St(q,G,Pt)};function St(q,$,pt){pt===null?q.matrix.copy($.matrixWorld):(q.matrix.copy(pt.matrixWorld),q.matrix.invert(),q.matrix.multiply($.matrixWorld)),q.matrix.decompose(q.position,q.quaternion,q.scale),q.updateMatrixWorld(!0),q.projectionMatrix.copy($.projectionMatrix),q.projectionMatrixInverse.copy($.projectionMatrixInverse),q.isPerspectiveCamera&&(q.fov=Pi*2*Math.atan(1/q.projectionMatrix.elements[5]),q.zoom=1)}this.getCamera=function(){return G},this.getFoveation=function(){if(!(u===null&&p===null))return l},this.setFoveation=function(q){l=q,u!==null&&(u.fixedFoveation=q),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=q)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(G)},this.getCameraTexture=function(q){return f[q]};let Zt=null;function zt(q,$){if(h=$.getViewerPose(c||a),_=$,h!==null){let pt=h.views;p!==null&&(t.setRenderTargetFramebuffer(y,p.framebuffer),t.setRenderTarget(y));let Pt=!1;pt.length!==G.cameras.length&&(G.cameras.length=0,Pt=!0);for(let Vt=0;Vt<pt.length;Vt++){let Yt=pt[Vt],ie=null;if(p!==null)ie=p.getViewport(Yt);else{let le=d.getViewSubImage(u,Yt);ie=le.viewport,Vt===0&&(t.setRenderTargetTextures(y,le.colorTexture,le.depthStencilTexture),t.setRenderTarget(y))}let Gt=z[Vt];Gt===void 0&&(Gt=new ze,Gt.layers.enable(Vt),Gt.viewport=new he,z[Vt]=Gt),Gt.matrix.fromArray(Yt.transform.matrix),Gt.matrix.decompose(Gt.position,Gt.quaternion,Gt.scale),Gt.projectionMatrix.fromArray(Yt.projectionMatrix),Gt.projectionMatrixInverse.copy(Gt.projectionMatrix).invert(),Gt.viewport.set(ie.x,ie.y,ie.width,ie.height),Vt===0&&(G.matrix.copy(Gt.matrix),G.matrix.decompose(G.position,G.quaternion,G.scale)),Pt===!0&&G.cameras.push(Gt)}let gt=s.enabledFeatures;if(gt&>.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&M){d=n.getBinding();let Vt=d.getDepthInformation(pt[0]);Vt&&Vt.isValid&&Vt.texture&&m.init(Vt,s.renderState)}if(gt&>.includes("camera-access")&&M){t.state.unbindTexture(),d=n.getBinding();for(let Vt=0;Vt<pt.length;Vt++){let Yt=pt[Vt].camera;if(Yt){let ie=f[Yt];ie||(ie=new ms,f[Yt]=ie);let Gt=d.getCameraImage(Yt);ie.sourceTexture=Gt}}}}for(let pt=0;pt<S.length;pt++){let Pt=b[pt],gt=S[pt];Pt!==null&>!==void 0&>.update(Pt,$,c||a)}Zt&&Zt(q,$),$.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:$}),_=null}let Xt=new ph;Xt.setAnimationLoop(zt),this.setAnimationLoop=function(q){Zt=q},this.dispose=function(){}}},bg=new ce,yh=new Dt;yh.set(-1,0,0,0,1,0,0,0,1);function Eg(i,t){function e(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function n(m,f){f.color.getRGB(m.fogColor.value,Qo(i)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function s(m,f,T,R,y){f.isNodeMaterial?f.uniformsNeedUpdate=!1:f.isMeshBasicMaterial?r(m,f):f.isMeshLambertMaterial?(r(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(r(m,f),d(m,f)):f.isMeshPhongMaterial?(r(m,f),h(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(r(m,f),u(m,f),f.isMeshPhysicalMaterial&&p(m,f,y)):f.isMeshMatcapMaterial?(r(m,f),_(m,f)):f.isMeshDepthMaterial?r(m,f):f.isMeshDistanceMaterial?(r(m,f),M(m,f)):f.isMeshNormalMaterial?r(m,f):f.isLineBasicMaterial?(a(m,f),f.isLineDashedMaterial&&o(m,f)):f.isPointsMaterial?l(m,f,T,R):f.isSpriteMaterial?c(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,e(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,e(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Fe&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,e(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Fe&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,e(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,e(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,e(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);let T=t.get(f),R=T.envMap,y=T.envMapRotation;R&&(m.envMap.value=R,m.envMapRotation.value.setFromMatrix4(bg.makeRotationFromEuler(y)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(yh),m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,e(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,e(f.aoMap,m.aoMapTransform))}function a(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,e(f.map,m.mapTransform))}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,T,R){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*T,m.scale.value=R*.5,f.map&&(m.map.value=f.map,e(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function c(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,e(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function h(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function d(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function u(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,e(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,e(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,T){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,e(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,e(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,e(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,e(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,e(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Fe&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.retroreflectivity>0&&(m.retroreflectivity.value=f.retroreflectivity),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,e(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,e(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=T.texture,m.transmissionSamplerSize.value.set(T.width,T.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,e(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,e(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,e(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,e(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,e(f.specularIntensityMap,m.specularIntensityMapTransform))}function _(m,f){f.matcap&&(m.matcap.value=f.matcap)}function M(m,f){let T=t.get(f).light;m.referencePosition.value.setFromMatrixPosition(T.matrixWorld),m.nearDistance.value=T.shadow.camera.near,m.farDistance.value=T.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Tg(i,t,e,n){let s={},r={},a=[],o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,S){let b=S.program;n.uniformBlockBinding(y,b)}function c(y,S){let b=s[y.id];b===void 0&&(m(y),b=h(y),s[y.id]=b,y.addEventListener("dispose",T));let A=S.program;n.updateUBOMapping(y,A);let x=t.render.frame;r[y.id]!==x&&(u(y),r[y.id]=x)}function h(y){let S=d();y.__bindingPointIndex=S;let b=i.createBuffer(),A=y.__size,x=y.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,A,x),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,b),b}function d(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return It("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(y){let S=s[y.id],b=y.uniforms,A=y.__cache;i.bindBuffer(i.UNIFORM_BUFFER,S);for(let x=0,w=b.length;x<w;x++){let D=b[x];if(Array.isArray(D))for(let U=0,z=D.length;U<z;U++)p(D[U],x,U,A);else p(D,x,0,A)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(y,S,b,A){if(M(y,S,b,A)===!0){let x=y.__offset,w=y.value;if(Array.isArray(w)){let D=0;for(let U=0;U<w.length;U++){let z=w[U],G=f(z);_(z,y.__data,D),typeof z!="number"&&typeof z!="boolean"&&!z.isMatrix3&&!ArrayBuffer.isView(z)&&(D+=G.storage/Float32Array.BYTES_PER_ELEMENT)}}else _(w,y.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,x,y.__data)}}function _(y,S,b){typeof y=="number"||typeof y=="boolean"?S[0]=y:y.isMatrix3?(S[0]=y.elements[0],S[1]=y.elements[1],S[2]=y.elements[2],S[3]=0,S[4]=y.elements[3],S[5]=y.elements[4],S[6]=y.elements[5],S[7]=0,S[8]=y.elements[6],S[9]=y.elements[7],S[10]=y.elements[8],S[11]=0):ArrayBuffer.isView(y)?S.set(new y.constructor(y.buffer,y.byteOffset,S.length)):y.toArray(S,b)}function M(y,S,b,A){let x=y.value,w=S+"_"+b;if(A[w]===void 0)return typeof x=="number"||typeof x=="boolean"?A[w]=x:ArrayBuffer.isView(x)?A[w]=x.slice():A[w]=x.clone(),!0;{let D=A[w];if(typeof x=="number"||typeof x=="boolean"){if(D!==x)return A[w]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(D.equals(x)===!1)return D.copy(x),!0}}return!1}function m(y){let S=y.uniforms,b=0,A=16;for(let w=0,D=S.length;w<D;w++){let U=Array.isArray(S[w])?S[w]:[S[w]];for(let z=0,G=U.length;z<G;z++){let N=U[z],V=Array.isArray(N.value)?N.value:[N.value];for(let Z=0,X=V.length;Z<X;Z++){let nt=V[Z],W=f(nt),j=b%A,tt=j%W.boundary,At=j+tt;b+=tt,At!==0&&A-At<W.storage&&(b+=A-At),N.__data=new Float32Array(W.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=b,b+=W.storage}}}let x=b%A;return x>0&&(b+=A-x),y.__size=b,y.__cache={},this}function f(y){let S={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(S.boundary=4,S.storage=4):y.isVector2?(S.boundary=8,S.storage=8):y.isVector3||y.isColor?(S.boundary=16,S.storage=12):y.isVector4?(S.boundary=16,S.storage=16):y.isMatrix3?(S.boundary=48,S.storage=48):y.isMatrix4?(S.boundary=64,S.storage=64):y.isTexture?Ct("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(S.boundary=16,S.storage=y.byteLength):Ct("WebGLRenderer: Unsupported uniform value type.",y),S}function T(y){let S=y.target;S.removeEventListener("dispose",T);let b=a.indexOf(S.__bindingPointIndex);a.splice(b,1),i.deleteBuffer(s[S.id]),delete s[S.id],delete r[S.id]}function R(){for(let y in s)i.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:R}}var wg=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),vn=null;function Ag(){return vn===null&&(vn=new wr(wg,16,16,Jn,hn),vn.name="DFG_LUT",vn.minFilter=Ee,vn.magFilter=Ee,vn.wrapS=pn,vn.wrapT=pn,vn.generateMipmaps=!1,vn.needsUpdate=!0),vn}var ka=class{constructor(t={}){let{canvas:e=zc(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:p=He}=t;this.isWebGLRenderer=!0;let _;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");_=n.getContextAttributes().alpha}else _=a;let M=p,m=new Set([ia,na,ea]),f=new Set([He,ln,ki,Gi,jr,ta]),T=new Uint32Array(4),R=new Int32Array(4),y=new C,S=null,b=null,A=[],x=[],w=null;this.domElement=e,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=on,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let D=this,U=!1,z=null,G=null,N=null,V=null;this._outputColorSpace=Ne;let Z=0,X=0,nt=null,W=-1,j=null,tt=new he,At=new he,St=null,Zt=new Lt(0),zt=0,Xt=e.width,q=e.height,$=1,pt=null,Pt=null,gt=new he(0,0,Xt,q),Bt=new he(0,0,Xt,q),_e=!1,Vt=new Ni,Yt=!1,ie=!1,Gt=new ce,le=new C,Me=new he,Be={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ue=!1;function pe(){return nt===null?$:1}let L=n;function Te(v,P){return e.getContext(v,P)}let Qt,E,g,F,H,Y,it,st,J,Q,rt,Et,ct,at,Tt,Rt,Nt,I,ot,K,lt,ft,et;try{let v={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${"186"}`),e.addEventListener("webglcontextlost",se,!1),e.addEventListener("webglcontextrestored",Jt,!1),e.addEventListener("webglcontextcreationerror",je,!1),L===null){let P="webgl2";if(L=Te(P,v),L===null)throw Te(P)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}wt()}catch(v){throw e.removeEventListener("webglcontextlost",se,!1),e.removeEventListener("webglcontextrestored",Jt,!1),e.removeEventListener("webglcontextcreationerror",je,!1),It("WebGLRenderer: "+v.message),v}function wt(){Qt=new Np(L),Qt.init(),lt=new yg(L,Qt),E=new Ep(L,Qt,t,lt),g=new xg(L,Qt),E.reversedDepthBuffer&&u&&g.buffers.depth.setReversed(!0),G=L.createFramebuffer(),N=L.createFramebuffer(),V=L.createFramebuffer(),F=new Op(L),H=new sg,Y=new vg(L,Qt,g,H,E,lt,F),it=new Dp(D),st=new Bu(L),ft=new Sp(L,st),J=new Up(L,st,F,ft),Q=new zp(L,J,st,ft,F),I=new Bp(L,E,Y),Tt=new Tp(H),rt=new ig(D,it,Qt,E,ft,Tt),Et=new Eg(D,H),ct=new ag,at=new dg(Qt),Nt=new Mp(D,it,g,Q,_,l),Rt=new _g(D,Q,E),et=new Tg(L,F,E,g),ot=new bp(L,Qt,F),K=new Fp(L,Qt,F),F.programs=rt.programs,D.capabilities=E,D.extensions=Qt,D.properties=H,D.renderLists=ct,D.shadowMap=Rt,D.state=g,D.info=F}M!==He&&(w=new Hp(M,e.width,e.height,o,s,r));let Mt=new Ml(D,L);this.xr=Mt,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){let v=Qt.get("WEBGL_lose_context");v&&v.loseContext()},this.forceContextRestore=function(){let v=Qt.get("WEBGL_lose_context");v&&v.restoreContext()},this.getPixelRatio=function(){return $},this.setPixelRatio=function(v){v!==void 0&&($=v,this.setSize(Xt,q,!1))},this.getSize=function(v){return v.set(Xt,q)},this.setSize=function(v,P,k=!0){if(Mt.isPresenting){Ct("WebGLRenderer: Can't change size while VR device is presenting.");return}Xt=v,q=P,e.width=Math.floor(v*$),e.height=Math.floor(P*$),k===!0&&(e.style.width=v+"px",e.style.height=P+"px"),w!==null&&w.setSize(e.width,e.height),this.setViewport(0,0,v,P)},this.getDrawingBufferSize=function(v){return v.set(Xt*$,q*$).floor()},this.setDrawingBufferSize=function(v,P,k){Xt=v,q=P,$=k,e.width=Math.floor(v*k),e.height=Math.floor(P*k),this.setViewport(0,0,v,P)},this.setEffects=function(v){if(M===He){It("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(v){for(let P=0;P<v.length;P++)if(v[P].isOutputPass===!0){Ct("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}w.setEffects(v||[])},this.getCurrentViewport=function(v){return v.copy(tt)},this.getViewport=function(v){return v.copy(gt)},this.setViewport=function(v,P,k,O){v.isVector4?gt.set(v.x,v.y,v.z,v.w):gt.set(v,P,k,O),g.viewport(tt.copy(gt).multiplyScalar($).round())},this.getScissor=function(v){return v.copy(Bt)},this.setScissor=function(v,P,k,O){v.isVector4?Bt.set(v.x,v.y,v.z,v.w):Bt.set(v,P,k,O),g.scissor(At.copy(Bt).multiplyScalar($).round())},this.getScissorTest=function(){return _e},this.setScissorTest=function(v){g.setScissorTest(_e=v)},this.setOpaqueSort=function(v){pt=v},this.setTransparentSort=function(v){Pt=v},this.getClearColor=function(v){return v.copy(Nt.getClearColor())},this.setClearColor=function(){Nt.setClearColor(...arguments)},this.getClearAlpha=function(){return Nt.getClearAlpha()},this.setClearAlpha=function(){Nt.setClearAlpha(...arguments)},this.clear=function(v=!0,P=!0,k=!0){let O=0;if(v){let B=!1;if(nt!==null){let dt=nt.texture.format;B=m.has(dt)}if(B){let dt=nt.texture.type,_t=f.has(dt),ut=Nt.getClearColor(),vt=Nt.getClearAlpha(),bt=ut.r,Ut=ut.g,Ht=ut.b;_t?(T[0]=bt,T[1]=Ut,T[2]=Ht,T[3]=vt,L.clearBufferuiv(L.COLOR,0,T)):(R[0]=bt,R[1]=Ut,R[2]=Ht,R[3]=vt,L.clearBufferiv(L.COLOR,0,R))}else O|=L.COLOR_BUFFER_BIT}P&&(O|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),k&&(O|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),O!==0&&L.clear(O)},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.setNodesHandler=function(v){v.setRenderer(this),z=v},this.dispose=function(){e.removeEventListener("webglcontextlost",se,!1),e.removeEventListener("webglcontextrestored",Jt,!1),e.removeEventListener("webglcontextcreationerror",je,!1),Nt.dispose(),ct.dispose(),at.dispose(),H.dispose(),it.dispose(),Q.dispose(),ft.dispose(),et.dispose(),rt.dispose(),Mt.dispose(),Mt.removeEventListener("sessionstart",Tl),Mt.removeEventListener("sessionend",wl),$n.stop()};function se(v){v.preventDefault(),as("WebGLRenderer: Context Lost."),U=!0}function Jt(){as("WebGLRenderer: Context Restored."),U=!1;let v=F.autoReset,P=Rt.enabled,k=Rt.autoUpdate,O=Rt.needsUpdate,B=Rt.type;wt(),F.autoReset=v,Rt.enabled=P,Rt.autoUpdate=k,Rt.needsUpdate=O,Rt.type=B}function je(v){It("WebGLRenderer: A WebGL context could not be created. Reason: ",v.statusMessage)}function un(v){let P=v.target;P.removeEventListener("dispose",un),Th(P)}function Th(v){wh(v),H.remove(v)}function wh(v){let P=H.get(v).programs;P!==void 0&&(P.forEach(function(k){rt.releaseProgram(k)}),v.isShaderMaterial&&rt.releaseShaderCache(v))}this.renderBufferDirect=function(v,P,k,O,B,dt){P===null&&(P=Be);let _t=B.isMesh&&B.matrixWorld.determinantAffine()<0,ut=Ch(v,P,k,O,B);g.setMaterial(O,_t);let vt=k.index,bt=1;if(O.wireframe===!0){if(vt=J.getWireframeAttribute(k),vt===void 0)return;bt=2}let Ut=k.drawRange,Ht=k.attributes.position,yt=Ut.start*bt,$t=(Ut.start+Ut.count)*bt;dt!==null&&(yt=Math.max(yt,dt.start*bt),$t=Math.min($t,(dt.start+dt.count)*bt)),vt!==null?(yt=Math.max(yt,0),$t=Math.min($t,vt.count)):Ht!=null&&(yt=Math.max(yt,0),$t=Math.min($t,Ht.count));let me=$t-yt;if(me<0||me===1/0)return;ft.setup(B,O,ut,k,vt);let ae,ne=ot;if(vt!==null&&(ae=st.get(vt),ne=K,ne.setIndex(ae)),B.isMesh)O.wireframe===!0?(g.setLineWidth(O.wireframeLinewidth*pe()),ne.setMode(L.LINES)):ne.setMode(L.TRIANGLES);else if(B.isLine){let we=O.linewidth;we===void 0&&(we=1),g.setLineWidth(we*pe()),B.isLineSegments?ne.setMode(L.LINES):B.isLineLoop?ne.setMode(L.LINE_LOOP):ne.setMode(L.LINE_STRIP)}else B.isPoints?ne.setMode(L.POINTS):B.isSprite&&ne.setMode(L.TRIANGLES);if(B.isBatchedMesh)if(Qt.get("WEBGL_multi_draw"))ne.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else{let we=B._multiDrawStarts,mt=B._multiDrawCounts,Le=B._multiDrawCount,qt=vt?st.get(vt).bytesPerElement:1,Ze=H.get(O).currentProgram.getUniforms();for(let dn=0;dn<Le;dn++)Ze.setValue(L,"_gl_DrawID",dn),ne.render(we[dn]/qt,mt[dn])}else if(B.isInstancedMesh)ne.renderInstances(yt,me,B.count);else if(k.isInstancedBufferGeometry){let we=k._maxInstanceCount!==void 0?k._maxInstanceCount:1/0,mt=Math.min(k.instanceCount,we);ne.renderInstances(yt,me,mt)}else ne.render(yt,me)};function El(v,P,k,O){z!==null&&v.isNodeMaterial&&z.setObject(O,v),Yt===!0&&Tt.setState(v,k,!1),v.transparent===!0&&v.side===Oe&&v.forceSinglePass===!1?(v.side=Fe,v.needsUpdate=!0,Xs(v,P,O),v.side=Xn,v.needsUpdate=!0,Xs(v,P,O),v.side=Oe):Xs(v,P,O)}this.compile=function(v,P,k=null){k===null&&(k=v),z!==null&&z.renderStart(v,P,k),b=at.get(k),b.init(P),x.push(b),k.traverseVisible(function(B){B.isLight&&B.layers.test(P.layers)&&(b.pushLight(B),B.castShadow&&b.pushShadow(B))}),v!==k&&v.traverseVisible(function(B){B.isLight&&B.layers.test(P.layers)&&(b.pushLight(B),B.castShadow&&b.pushShadow(B))}),b.setupLights(),z!==null&&z.updateLights(b.state.lightsArray),ie=this.localClippingEnabled,Yt=Tt.init(this.clippingPlanes,ie),Yt===!0&&Tt.setGlobalState(this.clippingPlanes,P),z!==null&&Rt.render(b.state.shadowsArray,k,P);let O=new Set;return v.traverse(function(B){if(!(B.isMesh||B.isPoints||B.isLine||B.isSprite))return;let dt=B.material;if(dt)if(Array.isArray(dt))for(let _t=0;_t<dt.length;_t++){let ut=dt[_t];El(ut,k,P,B),O.add(ut)}else El(dt,k,P,B),O.add(dt)}),b=x.pop(),z!==null&&z.renderEnd(),O},this.compileAsync=function(v,P,k=null){let O=this.compile(v,P,k);return new Promise(B=>{function dt(){if(O.forEach(function(_t){let vt=H.get(_t).currentProgram;(vt===void 0||vt.isReady())&&O.delete(_t)}),O.size===0){B(v);return}setTimeout(dt,10)}Qt.get("KHR_parallel_shader_compile")!==null?dt():setTimeout(dt,10)})};let Ya=null;function Ah(v){Ya&&Ya(v)}function Tl(){$n.stop()}function wl(){$n.start()}let $n=new ph;$n.setAnimationLoop(Ah),typeof self<"u"&&$n.setContext(self),this.setAnimationLoop=function(v){Ya=v,Mt.setAnimationLoop(v),v===null?$n.stop():$n.start()},Mt.addEventListener("sessionstart",Tl),Mt.addEventListener("sessionend",wl),this.render=function(v,P){if(P!==void 0&&P.isCamera!==!0){It("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(U===!0)return;z!==null&&z.renderStart(v,P);let k=Mt.enabled===!0&&Mt.isPresenting===!0,O=w!==null&&(nt===null||k)&&w.begin(D,nt);if(v.matrixWorldAutoUpdate===!0&&v.updateMatrixWorld(),P.parent===null&&P.matrixWorldAutoUpdate===!0&&P.updateMatrixWorld(),Mt.enabled===!0&&Mt.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(Mt.cameraAutoUpdate===!0&&Mt.updateCamera(P),P=Mt.getCamera()),v.isScene===!0&&v.onBeforeRender(D,v,P,nt),b=at.get(v,x.length),b.init(P),b.state.textureUnits=Y.getTextureUnits(),x.push(b),Gt.multiplyMatrices(P.projectionMatrix,P.matrixWorldInverse),Vt.setFromProjectionMatrix(Gt,an,P.reversedDepth),ie=this.localClippingEnabled,Yt=Tt.init(this.clippingPlanes,ie),S=ct.get(v,A.length),S.init(),A.push(S),Mt.enabled===!0&&Mt.isPresenting===!0){let _t=D.xr.getDepthSensingMesh();_t!==null&&Za(_t,P,-1/0,D.sortObjects)}Za(v,P,0,D.sortObjects),S.finish(),z!==null&&z.updateLights(b.state.lightsArray),D.sortObjects===!0&&S.sort(pt,Pt),ue=Mt.enabled===!1||Mt.isPresenting===!1||Mt.hasDepthSensing()===!1,ue&&Nt.addToRenderList(S,v),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Yt===!0&&Tt.beginShadows();let B=b.state.shadowsArray;if(Rt.render(B,v,P),Yt===!0&&Tt.endShadows(),(O&&w.hasRenderPass())===!1){let _t=S.opaque,ut=S.transmissive;if(b.setupLights(),P.isArrayCamera){let vt=P.cameras;if(ut.length>0)for(let bt=0,Ut=vt.length;bt<Ut;bt++){let Ht=vt[bt];Rl(_t,ut,v,Ht)}ue&&Nt.render(v);for(let bt=0,Ut=vt.length;bt<Ut;bt++){let Ht=vt[bt];Al(S,v,Ht,Ht.viewport)}}else ut.length>0&&Rl(_t,ut,v,P),ue&&Nt.render(v),Al(S,v,P)}nt!==null&&X===0&&(Y.updateMultisampleRenderTarget(nt),Y.updateRenderTargetMipmap(nt)),O&&w.end(D),v.isScene===!0&&v.onAfterRender(D,v,P),ft.resetDefaultState(),W=-1,j=null,x.pop(),x.length>0?(b=x[x.length-1],Y.setTextureUnits(b.state.textureUnits),Yt===!0&&Tt.setGlobalState(D.clippingPlanes,b.state.camera)):b=null,A.pop(),A.length>0?S=A[A.length-1]:S=null,z!==null&&z.renderEnd()};function Za(v,P,k,O){if(v.visible===!1)return;if(v.layers.test(P.layers)){if(v.isGroup)k=v.renderOrder;else if(v.isLOD)v.autoUpdate===!0&&v.update(P);else if(v.isLightProbeGrid)b.pushLightProbeGrid(v);else if(v.isLight)b.pushLight(v),v.castShadow&&b.pushShadow(v);else if(v.isSprite){if(!v.frustumCulled||v.intersectsFrustum(Vt)){O&&Me.setFromMatrixPosition(v.matrixWorld).applyMatrix4(Gt);let _t=Q.update(v),ut=v.material;ut.visible&&S.push(v,_t,ut,k,Me.z,null,P)}}else if((v.isMesh||v.isLine||v.isPoints)&&(!v.frustumCulled||v.intersectsFrustum(Vt))){let _t=Q.update(v),ut=v.material;if(O&&(v.boundingSphere!==void 0?(v.boundingSphere===null&&v.computeBoundingSphere(),Me.copy(v.boundingSphere.center)):(_t.boundingSphere===null&&_t.computeBoundingSphere(),Me.copy(_t.boundingSphere.center)),Me.applyMatrix4(v.matrixWorld).applyMatrix4(Gt)),Array.isArray(ut)){let vt=_t.groups;for(let bt=0,Ut=vt.length;bt<Ut;bt++){let Ht=vt[bt],yt=ut[Ht.materialIndex];yt&&yt.visible&&S.push(v,_t,yt,k,Me.z,Ht,P)}}else ut.visible&&S.push(v,_t,ut,k,Me.z,null,P)}}let dt=v.children;for(let _t=0,ut=dt.length;_t<ut;_t++)Za(dt[_t],P,k,O)}function Al(v,P,k,O){let{opaque:B,transmissive:dt,transparent:_t}=v;b.setupLightsView(k),Yt===!0&&Tt.setGlobalState(D.clippingPlanes,k),O&&g.viewport(tt.copy(O)),B.length>0&&Ws(B,P,k),dt.length>0&&Ws(dt,P,k),_t.length>0&&Ws(_t,P,k),g.buffers.depth.setTest(!0),g.buffers.depth.setMask(!0),g.buffers.color.setMask(!0),g.setPolygonOffset(!1)}function Rl(v,P,k,O){if((k.isScene===!0?k.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[O.id]===void 0){let yt=Qt.has("EXT_color_buffer_half_float")||Qt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[O.id]=new Ve(1,1,{generateMipmaps:!0,type:yt?hn:He,minFilter:Yn,samples:Math.max(4,E.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:Wt.workingColorSpace})}let dt=b.state.transmissionRenderTarget[O.id],_t=O.viewport||tt;dt.setSize(_t.z*D.transmissionResolutionScale,_t.w*D.transmissionResolutionScale);let ut=D.getRenderTarget(),vt=D.getActiveCubeFace(),bt=D.getActiveMipmapLevel();D.setRenderTarget(dt),D.getClearColor(Zt),zt=D.getClearAlpha(),zt<1&&D.setClearColor(16777215,.5),D.clear(),ue&&Nt.render(k);let Ut=D.toneMapping;D.toneMapping=on;let Ht=O.viewport;if(O.viewport!==void 0&&(O.viewport=void 0),b.setupLightsView(O),Yt===!0&&Tt.setGlobalState(D.clippingPlanes,O),Ws(v,k,O),Y.updateMultisampleRenderTarget(dt),Y.updateRenderTargetMipmap(dt),Qt.has("WEBGL_multisampled_render_to_texture")===!1){let yt=!1;for(let $t=0,me=P.length;$t<me;$t++){let ae=P[$t],{object:ne,geometry:we,material:mt,group:Le}=ae;if(mt.side===Oe&&ne.layers.test(O.layers)){let qt=mt.side;mt.side=Fe,mt.needsUpdate=!0,Cl(ne,k,O,we,mt,Le),mt.side=qt,mt.needsUpdate=!0,yt=!0}}yt===!0&&(Y.updateMultisampleRenderTarget(dt),Y.updateRenderTargetMipmap(dt))}D.setRenderTarget(ut,vt,bt),D.setClearColor(Zt,zt),Ht!==void 0&&(O.viewport=Ht),D.toneMapping=Ut}function Ws(v,P,k){let O=P.isScene===!0?P.overrideMaterial:null;for(let B=0,dt=v.length;B<dt;B++){let _t=v[B],{object:ut,geometry:vt,group:bt}=_t,Ut=_t.material;Ut.allowOverride===!0&&O!==null&&(Ut=O),ut.layers.test(k.layers)&&Cl(ut,P,k,vt,Ut,bt)}}function Cl(v,P,k,O,B,dt){z!==null&&B.isNodeMaterial&&z.setObject(v,B),v.onBeforeRender(D,P,k,O,B,dt),v.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,v.matrixWorld),v.normalMatrix.getNormalMatrix(v.modelViewMatrix),B.onBeforeRender(D,P,k,O,v,dt),B.transparent===!0&&B.side===Oe&&B.forceSinglePass===!1?(B.side=Fe,B.needsUpdate=!0,D.renderBufferDirect(k,P,O,B,v,dt),B.side=Xn,B.needsUpdate=!0,D.renderBufferDirect(k,P,O,B,v,dt),B.side=Oe):D.renderBufferDirect(k,P,O,B,v,dt),v.onAfterRender(D,P,k,O,B,dt)}function Xs(v,P,k){P.isScene!==!0&&(P=Be);let O=H.get(v),B=b.state.lights,dt=b.state.shadowsArray,_t=B.state.version,ut=rt.getParameters(v,B.state,dt,P,k,b.state.lightProbeGridArray),vt=rt.getProgramCacheKey(ut),bt=O.programs;O.environment=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?P.environment:null,O.fog=P.fog;let Ut=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap;O.envMap=it.get(v.envMap||O.environment,Ut),O.envMapRotation=O.environment!==null&&v.envMap===null?P.environmentRotation:v.envMapRotation,bt===void 0&&(v.addEventListener("dispose",un),bt=new Map,O.programs=bt);let Ht=bt.get(vt);if(Ht!==void 0){if(O.currentProgram===Ht&&O.lightsStateVersion===_t)return Il(v,ut),Ht}else ut.uniforms=rt.getUniforms(v),z!==null&&v.isNodeMaterial&&z.build(v,k,ut),v.onBeforeCompile(ut,D),Ht=rt.acquireProgram(ut,vt),bt.set(vt,Ht),O.uniforms=ut.uniforms;let yt=O.uniforms;return(!v.isShaderMaterial&&!v.isRawShaderMaterial||v.clipping===!0)&&(yt.clippingPlanes=Tt.uniform),Il(v,ut),O.needsLights=Ih(v),O.lightsStateVersion=_t,O.needsLights&&(yt.ambientLightColor.value=B.state.ambient,yt.lightProbe.value=B.state.probe,yt.sunLights.value=B.state.sun,yt.sunLightShadows.value=B.state.sunShadow,yt.directionalLights.value=B.state.directional,yt.directionalLightShadows.value=B.state.directionalShadow,yt.spotLights.value=B.state.spot,yt.spotLightShadows.value=B.state.spotShadow,yt.rectAreaLights.value=B.state.rectArea,yt.ltc_1.value=B.state.rectAreaLTC1,yt.ltc_2.value=B.state.rectAreaLTC2,yt.pointLights.value=B.state.point,yt.pointLightShadows.value=B.state.pointShadow,yt.hemisphereLights.value=B.state.hemi,yt.sunShadowMatrix.value=B.state.sunShadowMatrix,yt.sunShadowCascade.value=B.state.sunShadowCascade,yt.directionalShadowMatrix.value=B.state.directionalShadowMatrix,yt.spotLightMatrix.value=B.state.spotLightMatrix,yt.spotLightMap.value=B.state.spotLightMap,yt.pointShadowMatrix.value=B.state.pointShadowMatrix),O.lightProbeGrid=b.state.lightProbeGridArray.length>0,O.currentProgram=Ht,O.uniformsList=null,Ht}function Pl(v){if(v.uniformsList===null){let P=v.currentProgram.getUniforms();v.uniformsList=qi.seqWithValue(P.seq,v.uniforms)}return v.uniformsList}function Il(v,P){let k=H.get(v);k.outputColorSpace=P.outputColorSpace,k.batching=P.batching,k.batchingColor=P.batchingColor,k.instancing=P.instancing,k.instancingColor=P.instancingColor,k.instancingMorph=P.instancingMorph,k.skinning=P.skinning,k.morphTargets=P.morphTargets,k.morphNormals=P.morphNormals,k.morphColors=P.morphColors,k.morphTargetsCount=P.morphTargetsCount,k.numClippingPlanes=P.numClippingPlanes,k.numIntersection=P.numClipIntersection,k.vertexAlphas=P.vertexAlphas,k.vertexTangents=P.vertexTangents,k.toneMapping=P.toneMapping}function Rh(v,P){if(v.length===0)return null;if(v.length===1)return v[0].texture!==null?v[0]:null;y.setFromMatrixPosition(P.matrixWorld);for(let k=0,O=v.length;k<O;k++){let B=v[k];if(B.texture!==null&&B.boundingBox.containsPoint(y))return B}return null}function Ch(v,P,k,O,B){P.isScene!==!0&&(P=Be),Y.resetTextureUnits();let dt=P.fog,_t=O.isMeshStandardMaterial||O.isMeshLambertMaterial||O.isMeshPhongMaterial?P.environment:null,ut=nt===null?D.outputColorSpace:nt.isXRRenderTarget===!0?nt.texture.colorSpace:Wt.workingColorSpace,vt=O.isMeshStandardMaterial||O.isMeshLambertMaterial&&!O.envMap||O.isMeshPhongMaterial&&!O.envMap,bt=it.get(O.envMap||_t,vt),Ut=O.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,Ht=!!k.attributes.tangent&&(!!O.normalMap||O.anisotropy>0),yt=!!k.morphAttributes.position,$t=!!k.morphAttributes.normal,me=!!k.morphAttributes.color,ae=on;O.toneMapped&&(nt===null||nt.isXRRenderTarget===!0)&&(ae=D.toneMapping);let ne=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,we=ne!==void 0?ne.length:0,mt=H.get(O),Le=b.state.lights;if(Yt===!0&&(ie===!0||v!==j)){let re=v===j&&O.id===W;Tt.setState(O,v,re)}let qt=!1;O.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==Le.state.version||mt.outputColorSpace!==ut||B.isBatchedMesh&&mt.batching===!1||!B.isBatchedMesh&&mt.batching===!0||B.isBatchedMesh&&mt.batchingColor===!0&&B._colorsTexture===null||B.isBatchedMesh&&mt.batchingColor===!1&&B._colorsTexture!==null||B.isInstancedMesh&&mt.instancing===!1||!B.isInstancedMesh&&mt.instancing===!0||B.isSkinnedMesh&&mt.skinning===!1||!B.isSkinnedMesh&&mt.skinning===!0||B.isInstancedMesh&&mt.instancingColor===!0&&B.instanceColor===null||B.isInstancedMesh&&mt.instancingColor===!1&&B.instanceColor!==null||B.isInstancedMesh&&mt.instancingMorph===!0&&B.morphTexture===null||B.isInstancedMesh&&mt.instancingMorph===!1&&B.morphTexture!==null||mt.envMap!==bt||O.fog===!0&&mt.fog!==dt||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==Tt.numPlanes||mt.numIntersection!==Tt.numIntersection)||mt.vertexAlphas!==Ut||mt.vertexTangents!==Ht||mt.morphTargets!==yt||mt.morphNormals!==$t||mt.morphColors!==me||mt.toneMapping!==ae||mt.morphTargetsCount!==we||!!mt.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(qt=!0):(qt=!0,mt.__version=O.version);let Ze=mt.currentProgram;qt===!0&&(Ze=Xs(O,P,B),z&&O.isNodeMaterial&&z.onUpdateProgram(O,Ze,mt));let dn=!1,Cn=!1,hi=!1,te=Ze.getUniforms(),de=mt.uniforms;if(g.useProgram(Ze.program)&&(dn=!0,Cn=!0,hi=!0),O.id!==W&&(W=O.id,Cn=!0),mt.needsLights){let re=Rh(b.state.lightProbeGridArray,B);mt.lightProbeGrid!==re&&(mt.lightProbeGrid=re,Cn=!0)}if(dn||j!==v){g.buffers.depth.getReversed()&&v.reversedDepth!==!0&&(v._reversedDepth=!0,v.updateProjectionMatrix()),te.setValue(L,"projectionMatrix",v.projectionMatrix),te.setValue(L,"viewMatrix",v.matrixWorldInverse);let In=te.map.cameraPosition;In!==void 0&&In.setValue(L,le.setFromMatrixPosition(v.matrixWorld)),E.logarithmicDepthBuffer&&te.setValue(L,"logDepthBufFC",2/(Math.log(v.far+1)/Math.LN2)),(O.isMeshPhongMaterial||O.isMeshToonMaterial||O.isMeshLambertMaterial||O.isMeshBasicMaterial||O.isMeshStandardMaterial||O.isShaderMaterial)&&te.setValue(L,"isOrthographic",v.isOrthographicCamera===!0),j!==v&&(j=v,Cn=!0,hi=!0)}if(mt.needsLights&&(Le.state.sunShadowMap.length>0&&te.setValue(L,"sunShadowMap",Le.state.sunShadowMap,Y),Le.state.directionalShadowMap.length>0&&te.setValue(L,"directionalShadowMap",Le.state.directionalShadowMap,Y),Le.state.spotShadowMap.length>0&&te.setValue(L,"spotShadowMap",Le.state.spotShadowMap,Y),Le.state.pointShadowMap.length>0&&te.setValue(L,"pointShadowMap",Le.state.pointShadowMap,Y)),B.isSkinnedMesh){te.setOptional(L,B,"bindMatrix"),te.setOptional(L,B,"bindMatrixInverse");let re=B.skeleton;re&&(re.boneTexture===null&&re.computeBoneTexture(),te.setValue(L,"boneTexture",re.boneTexture,Y))}B.isBatchedMesh&&(te.setOptional(L,B,"batchingTexture"),te.setValue(L,"batchingTexture",B._matricesTexture,Y),te.setOptional(L,B,"batchingIdTexture"),te.setValue(L,"batchingIdTexture",B._indirectTexture,Y),te.setOptional(L,B,"batchingColorTexture"),B._colorsTexture!==null&&te.setValue(L,"batchingColorTexture",B._colorsTexture,Y));let Pn=k.morphAttributes;if((Pn.position!==void 0||Pn.normal!==void 0||Pn.color!==void 0)&&I.update(B,k,Ze),(Cn||mt.receiveShadow!==B.receiveShadow)&&(mt.receiveShadow=B.receiveShadow,te.setValue(L,"receiveShadow",B.receiveShadow)),(O.isMeshStandardMaterial||O.isMeshLambertMaterial||O.isMeshPhongMaterial)&&O.envMap===null&&P.environment!==null&&(de.envMapIntensity.value=P.environmentIntensity),de.dfgLUT!==void 0&&(de.dfgLUT.value=Ag()),Cn){if(te.setValue(L,"toneMappingExposure",D.toneMappingExposure),mt.needsLights&&Ph(de,hi),dt&&O.fog===!0&&Et.refreshFogUniforms(de,dt),Et.refreshMaterialUniforms(de,O,$,q,b.state.transmissionRenderTarget[v.id]),mt.needsLights&&mt.lightProbeGrid){let re=mt.lightProbeGrid;de.probesSH.value=re.texture,de.probesMin.value.copy(re.boundingBox.min),de.probesMax.value.copy(re.boundingBox.max),de.probesResolution.value.copy(re.resolution)}qi.upload(L,Pl(mt),de,Y)}if(O.isShaderMaterial&&O.uniformsNeedUpdate===!0&&(qi.upload(L,Pl(mt),de,Y),O.uniformsNeedUpdate=!1),O.isSpriteMaterial&&te.setValue(L,"center",B.center),te.setValue(L,"modelViewMatrix",B.modelViewMatrix),te.setValue(L,"normalMatrix",B.normalMatrix),te.setValue(L,"modelMatrix",B.matrixWorld),O.uniformsGroups!==void 0){let re=O.uniformsGroups;for(let In=0,ui=re.length;In<ui;In++){let Dl=re[In];et.update(Dl,Ze),et.bind(Dl,Ze)}}return Ze}function Ph(v,P){v.ambientLightColor.needsUpdate=P,v.lightProbe.needsUpdate=P,v.sunLights.needsUpdate=P,v.sunLightShadows.needsUpdate=P,v.directionalLights.needsUpdate=P,v.directionalLightShadows.needsUpdate=P,v.pointLights.needsUpdate=P,v.pointLightShadows.needsUpdate=P,v.spotLights.needsUpdate=P,v.spotLightShadows.needsUpdate=P,v.rectAreaLights.needsUpdate=P,v.hemisphereLights.needsUpdate=P}function Ih(v){return v.isMeshLambertMaterial||v.isMeshToonMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isShadowMaterial||v.isShaderMaterial&&v.lights===!0}this.getActiveCubeFace=function(){return Z},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return nt},this.setRenderTargetTextures=function(v,P,k){let O=H.get(v);O.__autoAllocateDepthBuffer=v.resolveDepthBuffer===!1,O.__autoAllocateDepthBuffer===!1&&(O.__useRenderToTexture=!1),H.get(v.texture).__webglTexture=P,H.get(v.depthTexture).__webglTexture=O.__autoAllocateDepthBuffer?void 0:k,O.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(v,P){let k=H.get(v);k.__webglFramebuffer=P,k.__useDefaultFramebuffer=P===void 0},this.setRenderTarget=function(v,P=0,k=0){nt=v,Z=P,X=k;let O=null,B=!1,dt=!1;if(v){let ut=H.get(v);if(ut.__useDefaultFramebuffer!==void 0){g.bindFramebuffer(L.FRAMEBUFFER,ut.__webglFramebuffer),tt.copy(v.viewport),At.copy(v.scissor),St=v.scissorTest,g.viewport(tt),g.scissor(At),g.setScissorTest(St),W=-1;return}else if(ut.__webglFramebuffer===void 0)Y.setupRenderTarget(v);else if(ut.__hasExternalTextures)Y.rebindTextures(v,H.get(v.texture).__webglTexture,H.get(v.depthTexture).__webglTexture);else if(v.depthBuffer){let Ut=v.depthTexture;if(ut.__boundDepthTexture!==Ut){if(Ut!==null&&H.has(Ut)&&(v.width!==Ut.image.width||v.height!==Ut.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Y.setupDepthRenderbuffer(v)}}let vt=v.texture;(vt.isData3DTexture||vt.isDataArrayTexture||vt.isCompressedArrayTexture)&&(dt=!0);let bt=H.get(v).__webglFramebuffer;v.isWebGLCubeRenderTarget?(Array.isArray(bt[P])?O=bt[P][k]:O=bt[P],B=!0):v.samples>0&&Y.useMultisampledRTT(v)===!1?O=H.get(v).__webglMultisampledFramebuffer:Array.isArray(bt)?O=bt[k]:O=bt,tt.copy(v.viewport),At.copy(v.scissor),St=v.scissorTest}else tt.copy(gt).multiplyScalar($).floor(),At.copy(Bt).multiplyScalar($).floor(),St=_e;if(k!==0&&(O=G),g.bindFramebuffer(L.FRAMEBUFFER,O)&&g.drawBuffers(v,O),g.viewport(tt),g.scissor(At),g.setScissorTest(St),B){let ut=H.get(v.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+P,ut.__webglTexture,k)}else if(dt){let ut=P;for(let vt=0;vt<v.textures.length;vt++){let bt=H.get(v.textures[vt]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+vt,bt.__webglTexture,k,ut)}}else if(v!==null&&k!==0){let ut=H.get(v.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,ut.__webglTexture,k)}W=-1};function Ll(v){let P=H.get(v);return(P.__readFormat!==v.format||P.__readType!==v.type)&&(P.__readFormat=v.format,P.__readType=v.type,P.__formatReadable=E.textureFormatReadable(v.format),P.__typeReadable=E.textureTypeReadable(v.type)),P}this.readRenderTargetPixels=function(v,P,k,O,B,dt,_t,ut=0){if(!(v&&v.isWebGLRenderTarget)){It("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let vt=H.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&_t!==void 0&&(vt=vt[_t]),vt){g.bindFramebuffer(L.FRAMEBUFFER,vt);try{let bt=v.textures[ut],Ut=bt.format,Ht=bt.type;v.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+ut);let yt=Ll(bt);if(yt.__formatReadable===!1){It("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(yt.__typeReadable===!1){It("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}P>=0&&P<=v.width-O&&k>=0&&k<=v.height-B&&L.readPixels(P,k,O,B,lt.convert(Ut),lt.convert(Ht),dt)}finally{let bt=nt!==null?H.get(nt).__webglFramebuffer:null;g.bindFramebuffer(L.FRAMEBUFFER,bt)}}},this.readRenderTargetPixelsAsync=async function(v,P,k,O,B,dt,_t,ut=0){if(!(v&&v.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let vt=H.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&_t!==void 0&&(vt=vt[_t]),vt)if(P>=0&&P<=v.width-O&&k>=0&&k<=v.height-B){g.bindFramebuffer(L.FRAMEBUFFER,vt);let bt=v.textures[ut],Ut=bt.format,Ht=bt.type;v.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+ut);let yt=Ll(bt);if(yt.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(yt.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let $t=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,$t),L.bufferData(L.PIXEL_PACK_BUFFER,dt.byteLength,L.STREAM_READ),L.readPixels(P,k,O,B,lt.convert(Ut),lt.convert(Ht),0),L.bindBuffer(L.PIXEL_PACK_BUFFER,null);let me=nt!==null?H.get(nt).__webglFramebuffer:null;g.bindFramebuffer(L.FRAMEBUFFER,me);let ae=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Hc(L,ae,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,$t),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,dt),L.bindBuffer(L.PIXEL_PACK_BUFFER,null),L.deleteBuffer($t),L.deleteSync(ae),dt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(v,P=null,k=0){let O=Math.pow(2,-k),B=Math.floor(v.image.width*O),dt=Math.floor(v.image.height*O),_t=P!==null?P.x:0,ut=P!==null?P.y:0;Y.setTexture2D(v,0),L.copyTexSubImage2D(L.TEXTURE_2D,k,0,0,_t,ut,B,dt),g.unbindTexture()},this.copyTextureToTexture=function(v,P,k=null,O=null,B=0,dt=0){let _t,ut,vt,bt,Ut,Ht,yt,$t,me,ae=v.isCompressedTexture?v.mipmaps[dt]:v.image;if(k!==null)_t=k.max.x-k.min.x,ut=k.max.y-k.min.y,vt=k.isBox3?k.max.z-k.min.z:1,bt=k.min.x,Ut=k.min.y,Ht=k.isBox3?k.min.z:0;else{let de=Math.pow(2,-B);_t=Math.floor(ae.width*de),ut=Math.floor(ae.height*de),v.isDataArrayTexture?vt=ae.depth:v.isData3DTexture?vt=Math.floor(ae.depth*de):vt=1,bt=0,Ut=0,Ht=0}O!==null?(yt=O.x,$t=O.y,me=O.z):(yt=0,$t=0,me=0);let ne=lt.convert(P.format),we=lt.convert(P.type),mt;P.isData3DTexture?(Y.setTexture3D(P,0),mt=L.TEXTURE_3D):P.isDataArrayTexture||P.isCompressedArrayTexture?(Y.setTexture2DArray(P,0),mt=L.TEXTURE_2D_ARRAY):(Y.setTexture2D(P,0),mt=L.TEXTURE_2D),g.activeTexture(L.TEXTURE0),g.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,P.flipY),g.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),g.pixelStorei(L.UNPACK_ALIGNMENT,P.unpackAlignment);let Le=g.getParameter(L.UNPACK_ROW_LENGTH),qt=g.getParameter(L.UNPACK_IMAGE_HEIGHT),Ze=g.getParameter(L.UNPACK_SKIP_PIXELS),dn=g.getParameter(L.UNPACK_SKIP_ROWS),Cn=g.getParameter(L.UNPACK_SKIP_IMAGES);g.pixelStorei(L.UNPACK_ROW_LENGTH,ae.width),g.pixelStorei(L.UNPACK_IMAGE_HEIGHT,ae.height),g.pixelStorei(L.UNPACK_SKIP_PIXELS,bt),g.pixelStorei(L.UNPACK_SKIP_ROWS,Ut),g.pixelStorei(L.UNPACK_SKIP_IMAGES,Ht);let hi=v.isDataArrayTexture||v.isData3DTexture,te=P.isDataArrayTexture||P.isData3DTexture;if(v.isDepthTexture){let de=H.get(v),Pn=H.get(P),re=H.get(de.__renderTarget),In=H.get(Pn.__renderTarget);g.bindFramebuffer(L.READ_FRAMEBUFFER,re.__webglFramebuffer),g.bindFramebuffer(L.DRAW_FRAMEBUFFER,In.__webglFramebuffer);for(let ui=0;ui<vt;ui++)hi&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,H.get(v).__webglTexture,B,Ht+ui),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,H.get(P).__webglTexture,dt,me+ui)),L.blitFramebuffer(bt,Ut,_t,ut,yt,$t,_t,ut,L.DEPTH_BUFFER_BIT,L.NEAREST);g.bindFramebuffer(L.READ_FRAMEBUFFER,null),g.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(B!==0||v.isRenderTargetTexture||H.has(v)){let de=H.get(v),Pn=H.get(P);g.bindFramebuffer(L.READ_FRAMEBUFFER,N),g.bindFramebuffer(L.DRAW_FRAMEBUFFER,V);for(let re=0;re<vt;re++)hi?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,de.__webglTexture,B,Ht+re):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,de.__webglTexture,B),te?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,Pn.__webglTexture,dt,me+re):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,Pn.__webglTexture,dt),B!==0?L.blitFramebuffer(bt,Ut,_t,ut,yt,$t,_t,ut,L.COLOR_BUFFER_BIT,L.NEAREST):te?L.copyTexSubImage3D(mt,dt,yt,$t,me+re,bt,Ut,_t,ut):L.copyTexSubImage2D(mt,dt,yt,$t,bt,Ut,_t,ut);g.bindFramebuffer(L.READ_FRAMEBUFFER,null),g.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else te?v.isDataTexture||v.isData3DTexture?L.texSubImage3D(mt,dt,yt,$t,me,_t,ut,vt,ne,we,ae.data):P.isCompressedArrayTexture?L.compressedTexSubImage3D(mt,dt,yt,$t,me,_t,ut,vt,ne,ae.data):L.texSubImage3D(mt,dt,yt,$t,me,_t,ut,vt,ne,we,ae):v.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,dt,yt,$t,_t,ut,ne,we,ae.data):v.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,dt,yt,$t,ae.width,ae.height,ne,ae.data):L.texSubImage2D(L.TEXTURE_2D,dt,yt,$t,_t,ut,ne,we,ae);g.pixelStorei(L.UNPACK_ROW_LENGTH,Le),g.pixelStorei(L.UNPACK_IMAGE_HEIGHT,qt),g.pixelStorei(L.UNPACK_SKIP_PIXELS,Ze),g.pixelStorei(L.UNPACK_SKIP_ROWS,dn),g.pixelStorei(L.UNPACK_SKIP_IMAGES,Cn),dt===0&&P.generateMipmaps&&L.generateMipmap(mt),g.unbindTexture()},this.initRenderTarget=function(v){H.get(v).__webglFramebuffer===void 0&&Y.setupRenderTarget(v)},this.initTexture=function(v){v.isCubeTexture?Y.setTextureCube(v,0):v.isData3DTexture?Y.setTexture3D(v,0):v.isDataArrayTexture||v.isCompressedArrayTexture?Y.setTexture2DArray(v,0):Y.setTexture2D(v,0),g.unbindTexture()},this.resetState=function(){Z=0,X=0,nt=null,g.reset(),ft.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return an}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=Wt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Wt._getUnpackColorSpace()}};var Mh=[{id:"coral",label:"\u73CA\u745A",color:"#E99589"},{id:"sage",label:"\u7070\u7EFF",color:"#A9BDA7"},{id:"lavender",label:"\u6DE1\u7D2B",color:"#BFB0D9"},{id:"cream",label:"\u5976\u6CB9",color:"#E8D8B8"},{id:"blue",label:"\u96FE\u84DD",color:"#A9C6D5"},{id:"ochre",label:"\u8D6D\u9EC4",color:"#D4AE65"}];function Sl(i){return"kind"in i&&i.kind==="cat"}var Cg=8,Pg=80,Ig=48*1024*1024,Lg=16*1024*1024,Dg=4,Ng=2,Ug=12,Fg=480;function Eh(i){let t=i>>>0;return()=>(t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296)}function Gs(i){let t=2166136261;for(let e of JSON.stringify(i))t=Math.imul(t^e.charCodeAt(0),16777619);return t>>>0}function Og(i){let t=[];if(i==="triangle"){let e=new Ss;return e.moveTo(-.18,.93),e.quadraticCurveTo(0,1.22,.18,.93),e.lineTo(.87,-.48),e.quadraticCurveTo(1.03,-.8,.66,-.83),e.quadraticCurveTo(0,-.92,-.66,-.83),e.quadraticCurveTo(-1.03,-.8,-.87,-.48),e.lineTo(-.18,.93),e.getSpacedPoints(128).slice(0,-1)}for(let e=0;e<128;e++){let n=e/128*Math.PI*2,s=Math.cos(n),r=Math.sin(n),a,o;if(i==="heart")a=16*Math.pow(r,3)/17,o=(13*s-5*Math.cos(2*n)-2*Math.cos(3*n)-Math.cos(4*n)+2)/17;else if(i==="square"||i==="diamond"||i==="capsule"){let l=i==="capsule"?.82:i==="diamond"?.72:.5;a=Math.sign(s)*Math.pow(Math.abs(s),l),o=Math.sign(r)*Math.pow(Math.abs(r),l),i==="diamond"&&([a,o]=[(a-o)*.68,(a+o)*.68]),i==="square"&&(a*=.85,o*=.87),i==="capsule"&&(a*=.7,o*=1.02)}else a=s*.93,o=r*.96;t.push(new xt(a,o))}return t}function Xa(i){let t=Og(i),e=48,n=t.length,s=[],r=[],a=[];for(let d=0;d<=e;d++){let u=-Math.PI/2+d/e*Math.PI,p=Math.max(1e-4,Math.cos(u));for(let _=0;_<=n;_++){let M=t[_%n];if(s.push(M.x*p,M.y*p,Math.sin(u)*.6),r.push(_/n,d/e),d<e&&_<n){let m=d*(n+1)+_,f=m+n+1;a.push(m,f,m+1,f,f+1,m+1)}}}let o=new Pe;o.setAttribute("position",new ee(s,3)),o.setAttribute("uv",new ee(r,2)),o.setIndex(a),o.computeVertexNormals();let l=o.getAttribute("position"),c=o.getAttribute("normal"),h=0;for(let d=0;d<l.count;d++)h+=l.getZ(d)*c.getZ(d);if(h<0){for(let d=0;d<a.length;d+=3)[a[d+1],a[d+2]]=[a[d+2],a[d+1]];o.setIndex(a),o.computeVertexNormals()}return o}function Bg(){let i=document.createElement("canvas");i.width=i.height=256;let t=i.getContext("2d"),e=Eh(8447);t.fillStyle="#a6a6a6",t.fillRect(0,0,256,256);for(let s=0;s<22e3;s++){let r=e()*256,a=e()*256,o=Math.round(90+e()*130);t.strokeStyle=`rgb(${o},${o},${o})`,t.lineWidth=.5,t.beginPath(),t.moveTo(r,a),t.lineTo(r+e()*3-1.5,a+e()*5),t.stroke()}let n=new ps(i);return n.wrapS=n.wrapT=Ai,n.repeat.set(3,2),n}function qa(i,t,e,n,s){let r=Eh(e),a=i.getAttribute("position"),o=i.getAttribute("normal"),l=i.getIndex(),c=[],h=new C,d=new C,u=new C,p=0;for(let A=0;A<l.count;A+=3)h.fromBufferAttribute(a,l.getX(A)),d.fromBufferAttribute(a,l.getX(A+1)),u.fromBufferAttribute(a,l.getX(A+2)),p+=d.clone().sub(h).cross(u.clone().sub(h)).length()*.5,c.push(p);let _=[],M=[],m=[],f=new C,T=new C,R=new C,y=new C,S=new C;for(let A=0;A<n;A++){let x=r()*p,w=0,D=c.length-1;for(;w<D;){let $=w+D>>>1;c[$]<x?w=$+1:D=$}let U=w*3,z=l.getX(U),G=l.getX(U+1),N=l.getX(U+2),V=r(),Z=r();V+Z>1&&(V=1-V,Z=1-Z),h.fromBufferAttribute(a,z),d.fromBufferAttribute(a,G),u.fromBufferAttribute(a,N);let X=h.multiplyScalar(1-V-Z).addScaledVector(d,V).addScaledVector(u,Z);f.fromBufferAttribute(o,z).multiplyScalar(1-V-Z),T.fromBufferAttribute(o,G),R.fromBufferAttribute(o,N),f.addScaledVector(T,V).addScaledVector(R,Z).normalize(),y.set(r()*.5-.25,-1,r()*.5-.25),y.addScaledVector(f,-y.dot(f)).normalize(),S.crossVectors(f,y).normalize();let nt=.03+Math.pow(r(),1.7)*.047,W=.0017+r()*.0018,j=X.clone().addScaledVector(f,nt*.6).addScaledVector(y,nt*.3),tt=X.clone().addScaledVector(f,nt*.85).addScaledVector(y,nt*.7),At=X.clone().addScaledVector(S,W),St=X.clone().addScaledVector(S,-W),Zt=j.clone().addScaledVector(S,W*.65),zt=j.clone().addScaledVector(S,-W*.65),Xt=.7+r()*.38,q=s?.(X)??t;[At,St,Zt,St,zt,Zt,Zt,zt,tt].forEach(($,pt)=>{_.push($.x,$.y,$.z),m.push(f.x,f.y,f.z);let Pt=Xt*(pt===8?1.24:pt<2||pt===3?.78:1.08);M.push(q.r*Pt,q.g*Pt,q.b*Pt)})}let b=new Pe;return b.setAttribute("position",new ee(_,3)),b.setAttribute("normal",new ee(m,3)),b.setAttribute("color",new ee(M,3)),b.computeBoundingSphere(),b}function ci(i,t,e){return new kt(new Es(new Oi(i),24,t,6,!1),e)}function zg(i,t,e){let n=new $e,s=i.coat==="silver",r=new Lt(s?"#9dabb8":"#f49335"),a=new Lt(s?"#657789":"#b85d18"),o=new Lt(s?"#ced6dc":"#ffd29a"),l=new Lt,c=S=>{let b=Oa.clamp((S.y-.15)*.55,0,.3),A=Oa.clamp((-S.y-.1)*.45,0,.35);return l.copy(r).lerp(a,b).lerp(o,A)},h=Xa("square"),d=h.getAttribute("position"),u=[],p=new C;for(let S=0;S<d.count;S++){d.setXYZ(S,d.getX(S)*1.08,d.getY(S)*.86-.1,d.getZ(S));let b=c(p.fromBufferAttribute(d,S));u.push(b.r,b.g,b.b)}h.computeVertexNormals(),h.setAttribute("color",new ee(u,3)),n.add(new kt(h,new fe({vertexColors:!0,roughness:1,bumpMap:t,bumpScale:.023}))),n.add(new kt(qa(h,r,Gs(i),e?28e3:4500,c),new fe({vertexColors:!0,roughness:1,side:Oe})));let _=(S,b,A)=>{let x=new $e;return x.add(new kt(S,new fe({color:b,roughness:1,bumpMap:t,bumpScale:.024}))),x.add(new kt(qa(S,b,Gs(i)+A,A),new fe({vertexColors:!0,roughness:1,side:Oe}))),x};for(let S of[-1,1]){let b=_(Xa("triangle"),a,e?4e3:650);b.scale.set(.3,.38,.4),b.position.set(S*.64,.69,-.015),b.rotation.z=S*-.12,n.add(b);let A=_(Xa("triangle"),r.clone().lerp(o,.12),e?1800:300);A.scale.set(.19,.27,.11),A.position.set(S*.64,.69,.25),A.rotation.z=S*-.12,n.add(A)}let M=[],m=()=>new Ke(1,28,20);for(let S of[-.32,.32]){let b=new kt(m(),new fe({color:"#faf8ee",roughness:.56}));b.position.set(S,.12,.635),b.scale.set(.18,.145,.045),b.userData.restY=.145,n.add(b),M.push(b);let A=new kt(m(),new Bi({color:s?"#3e8b59":"#25211d",roughness:.28,clearcoat:.35}));if(A.position.set(S+Math.sign(S)*-.027,.13,.679),A.scale.set(.094,.108,.024),A.userData.restY=.108,n.add(A),M.push(A),s){let w=new kt(m(),new fe({color:"#1f3e2b",roughness:.5}));w.position.set(A.position.x,.13,.7),w.scale.set(.019,.088,.009),w.userData.restY=.088,n.add(w),M.push(w)}let x=new kt(m(),new ni({color:"#ffffff"}));x.position.set(A.position.x-.024,.174,.707),x.scale.set(.017,.025,.005),x.userData.restY=.025,n.add(x),M.push(x)}let f=new kt(new Ke(1,28,16),new fe({color:"#ee889a",roughness:.68}));f.position.set(0,-.145,.66),f.scale.set(.112,.063,.035),n.add(f);let T=new fe({color:s?"#607183":"#b16a29",roughness:1});n.add(ci([new C(0,-.18,.679),new C(0,-.255,.681)],.013,T));let R=ci([new C(-.15,-.27,.672),new C(-.08,-.31,.675),new C(0,-.255,.681),new C(.08,-.31,.675),new C(.15,-.27,.672)],.013,T);n.add(R);let y=new kt(m(),new fe({color:"#492c2b",roughness:.9}));y.position.set(0,-.3,.677),y.scale.set(.085,.032,.021),y.visible=!1,n.add(y);for(let S of[-1,1])for(let b=0;b<2;b++){let A=_(new Ke(1,20,14),a,e?700:160);A.scale.set(.055,.11,.02),A.rotation.z=S*-.36,A.position.set(S*(.68+b*.12),-.24+b*.075,.49-b*.1),n.add(A)}return{root:n,eyes:M,smile:R,mouth:y,ready:!1,preparing:!1}}function Vg(i,t,e){let n=new $e,s=new Lt(Mh.find(h=>h.id===i.color).color),r=Xa(i.shape);n.add(new kt(r,new fe({color:s,roughness:1,bumpMap:t,bumpScale:.022}))),n.add(new kt(qa(r,s,Gs(i),e?28e3:4500),new fe({vertexColors:!0,roughness:1,side:Oe})));let a=new Bi({color:"#161413",roughness:.29,clearcoat:.3}),o=[-.3,.3].map(h=>{let d=new kt(new Ke(1,20,16),a);return d.position.set(h,.035,.645),d.scale.set(.056,.086,.042),n.add(d),d}),l=ci([new C(-.105,-.22,.665),new C(0,-.277,.675),new C(.105,-.22,.665)],.017,new fe({color:"#221a18",roughness:.65}));n.add(l);let c=new kt(new Ke(1,20,12),new fe({color:"#39201d",roughness:.8}));if(c.position.set(0,-.23,.672),c.scale.set(.089,.048,.019),c.visible=!1,n.add(c),i.glasses!=="none"){let h=new fe({color:i.glasses==="gold"?"#bd985c":"#2b2622",metalness:i.glasses==="gold"?.78:.12,roughness:.32}),d=i.glasses==="gold"?.013:.028;for(let u of[-.3,.3]){let p=new kt(new ii(.232,d,10,56),h);p.position.set(u,.045,.733),n.add(p),n.add(ci([new C(u+Math.sign(u)*.232,.065,.733),new C(Math.sign(u)*.73,.08,.53),new C(Math.sign(u)*.8,.06,.2)],d,h))}n.add(ci([new C(-.066,.06,.733),new C(0,.1,.748),new C(.066,.06,.733)],d,h))}if(i.hat!=="none"){let h=new $e,d=i.shape==="heart"?.79:i.shape==="triangle"?.94:i.shape==="diamond"?1.05:.91,u=new fe({color:i.hat==="beanie"?"#bd6844":"#e4d9bd",roughness:1,bumpMap:t,bumpScale:.045}),p=(_,M)=>{let m=new kt(qa(_.geometry,new Lt(u.color),Gs(i)+41,M),new fe({vertexColors:!0,roughness:1,side:Oe}));m.position.copy(_.position),m.scale.copy(_.scale),m.rotation.copy(_.rotation),h.add(m)};if(i.hat==="beanie"){let _=new kt(new Ke(1,48,24,0,Math.PI*2,0,Math.PI/2),u);_.scale.set(.79,.53,.64),_.position.y=d-.18,h.add(_),e&&p(_,5e3);let M=new kt(new ii(.73,.095,12,64),u);M.rotation.x=Math.PI/2,M.scale.y=.83,M.position.y=d-.17,h.add(M);for(let T=0;T<40;T++){let R=T/40*Math.PI*2,y=[];for(let S=0;S<=10;S++){let b=S/10*Math.PI*.46;y.push(new C(Math.cos(R)*Math.cos(b)*.798,d-.18+Math.sin(b)*.54,Math.sin(R)*Math.cos(b)*.65))}h.add(ci(y,.012,u))}let m=new Ke(.145,24,16),f=new kt(m,u);f.position.set(0,d+.43,0),h.add(f),p(f,e?1400:350)}else{let _=new kt(new Ke(1,48,24),u);_.scale.set(.87,.22,.7),_.position.set(.04,d-.015,0),h.add(_),e&&p(_,5e3);let M=new kt(new ii(.65,.04,10,56),u);M.rotation.x=Math.PI/2,M.scale.y=.83,M.position.y=d-.13,h.add(M),h.add(ci([new C(.14,d+.16,0),new C(.14,d+.27,0),new C(.19,d+.3,0)],.031,u))}h.rotation.z=i.hat==="beret"?-.17:.1,n.add(h)}return{root:n,eyes:o,smile:l,mouth:c,ready:!1,preparing:!1}}function Sh(i){let t=new Set;i.root.traverse(e=>{if(e instanceof kt){e.geometry.dispose();for(let n of Array.isArray(e.material)?e.material:[e.material])t.add(n)}});for(let e of t)e.dispose()}function bh(i){let t=0;return i.root.traverse(e=>{if(e instanceof kt){for(let n of Object.keys(e.geometry.attributes)){let s=e.geometry.getAttribute(n);t+=s instanceof ds?s.data.array.byteLength:s.array.byteLength}t+=e.geometry.getIndex()?.array.byteLength??0}}),t}var bl=class{constructor(){xe(this,"renderer",null);xe(this,"scene",new cs);xe(this,"camera",new Wn(-1.4,1.4,1.48,-1.32,.1,20));xe(this,"texture",null);xe(this,"registrations",new Set);xe(this,"models",new Map);xe(this,"frames",new Map);xe(this,"timer",0);xe(this,"observer");xe(this,"lost",!1);xe(this,"blocked",!1);xe(this,"totalFrames",0);xe(this,"maxRenderMs",0);xe(this,"renderMs",0);xe(this,"createdContexts",0);xe(this,"contextGeneration",0);xe(this,"maxCompileWaitMs",0);xe(this,"releaseTimer",0);this.camera.position.set(.12,.14,5),this.camera.lookAt(0,.05,0),this.scene.add(new ws(16775146,11643295,1.7)),this.scene.add(new Cs(16775665,.72));let t=[[16774111,2.7,-3,4,4],[15397631,1.5,3,1,2],[16777215,2.2,0,3,-3]];for(let[e,n,s,r,a]of t){let o=new Rs(e,n);o.position.set(s,r,a),this.scene.add(o)}this.observer=new IntersectionObserver(e=>{for(let n of e)for(let s of this.registrations)s.canvas===n.target&&(s.visible=n.isIntersecting,s.dirty=!0);this.schedule()}),document.addEventListener("visibilitychange",()=>{if(window.clearTimeout(this.timer),this.timer=0,document.hidden)for(let e of this.registrations)this.setState(e,"paused");else{for(let e of this.registrations)e.dirty=!0;this.schedule()}}),globalThis.__wandPlushDiagnostics=()=>({webglBlocked:this.blocked,contexts:this.renderer?1:0,createdContexts:this.createdContexts,registrations:this.registrations.size,visible:[...this.registrations].filter(e=>e.visible).length,animated:[...this.registrations].filter(e=>e.activity==="active").length,frames:this.totalFrames,renderMs:this.renderMs,maxRenderMs:this.maxRenderMs,models:this.models.size,cachedFrames:this.frames.size,hidden:document.hidden,contextLost:this.lost,geometryBytes:[...this.models.values()].reduce((e,n)=>e+bh(n),0),cachedFrameBytes:[...this.frames.values()].reduce((e,n)=>e+n.width*n.height*4,0),maxCompileWaitMs:this.maxCompileWaitMs,reducedMotion:[...this.registrations].every(e=>e.options.reducedMotion)})}init(){if(this.blocked)return!1;if(this.renderer)return!this.lost;try{let t=new ka({alpha:!0,antialias:!0,preserveDrawingBuffer:!0,powerPreference:"low-power"});return t.setPixelRatio(1),t.setClearColor(0,0),t.outputColorSpace=Ne,t.toneMapping=Is,t.toneMappingExposure=1.05,t.domElement.addEventListener("webglcontextlost",e=>{if(this.renderer===t){e.preventDefault(),this.lost=!0,this.contextGeneration++;for(let n of this.models.values())n.ready=!1,n.preparing=!1;window.clearTimeout(this.timer),this.timer=0;for(let n of this.registrations)n.state("fallback","fallback","context-lost")}}),t.domElement.addEventListener("webglcontextrestored",()=>{if(this.renderer===t){this.lost=!1,this.frames.clear();for(let e of this.registrations)e.dirty=!0,e.activity="";this.schedule()}}),this.renderer=t,this.lost=!1,this.createdContexts++,this.contextGeneration++,this.texture=Bg(),!0}catch{return this.blocked=!0,!1}}attach(t,e,n){window.clearTimeout(this.releaseTimer);let s=t.getContext("2d",{alpha:!0});if(!s||!this.init())return n("fallback","fallback",s?this.lost?"context-lost":"webgl-unavailable":"canvas-unavailable"),{update(){},dispose(){}};let r={canvas:t,context:s,options:e,state:n,visible:!1,dirty:!0,lastFrame:0,phase:Gs(e.config)%1e3/100,frames:0,activity:"",tiltX:0,tiltY:0};this.registrations.add(r),this.observer.observe(t);let a=c=>{if(!r.options.interactive||r.options.reducedMotion)return;let h=t.getBoundingClientRect();r.tiltX=((c.clientX-h.left)/h.width-.5)*.3,r.tiltY=((c.clientY-h.top)/h.height-.5)*.16,r.dirty=!0,this.schedule()},o=()=>{r.tiltX=r.tiltY=0,r.dirty=!0,this.schedule()},l=t.parentElement;return l?.addEventListener("pointermove",a),l?.addEventListener("pointerleave",o),{update:c=>{r.options=c,r.dirty=!0,this.schedule()},dispose:()=>{this.registrations.delete(r),this.observer.unobserve(t),l?.removeEventListener("pointermove",a),l?.removeEventListener("pointerleave",o),this.registrations.size||(window.clearTimeout(this.timer),this.timer=0,this.releaseTimer=window.setTimeout(()=>{if(!this.registrations.size){for(let c of this.models.values())Sh(c);this.models.clear(),this.frames.clear(),this.texture?.dispose(),this.texture=null,this.renderer?.dispose(),this.renderer?.forceContextLoss(),this.renderer=null,this.lost=!1}},5e3))}}}setState(t,e){t.activity!==e&&(t.activity=e,t.frames&&t.state("webgl",e))}schedule(){this.timer||document.hidden||this.lost||!this.registrations.size||(this.timer=window.setTimeout(()=>{this.timer=0,this.tick()},16))}tick(){if(document.hidden||this.lost||!this.renderer)return;let t=performance.now(),e=0,n=0,s=!1,r=[...this.registrations].sort((a,o)=>Number(o.options.interactive)-Number(a.options.interactive)||Number(o.options.speaking)-Number(a.options.speaking));for(let a of r){if(!a.visible||!a.canvas.isConnected){this.setState(a,"paused");continue}let o=!a.options.reducedMotion&&(a.options.interactive?n++<Ng:e++<Dg);if(this.setState(a,o?"active":"static"),!a.dirty&&(!o||t-a.lastFrame<(a.options.interactive?1e3/24:125))){s||(s=o);continue}if(performance.now()-t>Ug){s=!0;continue}try{this.render(a,o?t/1e3:0)}catch{a.state("fallback","fallback","render-failed"),a.dirty=!1,a.visible=!1}s||(s=o)}s&&this.schedule()}render(t,e){let n=performance.now();try{this.paint(t,e)}finally{this.renderMs=performance.now()-n,this.maxRenderMs=Math.max(this.maxRenderMs,this.renderMs)}}paint(t,e){let{config:n,size:s,reducedMotion:r,speaking:a}=t.options,o=Math.min(Fg,Math.max(24,Math.round(s*Math.min(window.devicePixelRatio||1,2)))),l=`${JSON.stringify(n)}:${t.options.interactive||s>=96?"preview":"list"}`,c=`${l}:${o}`;t.canvas.width!==o&&(t.canvas.width=o,t.canvas.height=o);let h=e===0?this.frames.get(c):void 0;if(h)t.context.clearRect(0,0,o,o),t.context.drawImage(h,0,0);else{let d=this.models.get(l);if(d)this.models.delete(l),this.models.set(l,d);else for(d=Sl(n)?zg(n,this.texture,t.options.interactive||s>=96):Vg(n,this.texture,t.options.interactive||s>=96),this.models.set(l,d);this.models.size>Cg||this.models.size>1&&[...this.models.values()].reduce((m,f)=>m+bh(f),0)>Ig;){let m=this.models.entries().next().value;this.scene.remove(m[1].root),Sh(m[1]),this.models.delete(m[0])}if(!d.ready){if(!d.preparing){d.preparing=!0;let m=this.renderer,f=this.contextGeneration,T=performance.now();m.compileAsync(d.root,this.camera,this.scene).then(()=>{this.renderer!==m||f!==this.contextGeneration||this.models.get(l)!==d||(d.ready=!0,d.preparing=!1,this.maxCompileWaitMs=Math.max(this.maxCompileWaitMs,performance.now()-T),this.schedule())},()=>{this.models.get(l)===d&&(d.preparing=!1,t.visible=!1,t.state("fallback","fallback","shader-compile-failed"))})}return}let u=e?e+t.phase:0;d.root.rotation.set(e?Math.sin(u*.57)*.035+t.tiltY:0,-.085+(e?Math.sin(u*.65)*.1+t.tiltX:0),e?Math.sin(u*.47)*.025:0),d.root.position.y=Sl(n)?-.03:n.hat==="none"?0:-.13;let p=(u+t.phase)%5.4,_=e&&!r&&p<.16?Math.max(.12,Math.abs(p-.08)/.08):1;for(let m of d.eyes)m.scale.y=(m.userData.restY??.086)*_;let M=a&&!r&&e!==0;if(d.mouth.visible=M,d.smile.visible=!M,d.mouth.scale.y=.032+(M?(Math.sin(u*13)*.5+.5)*.053:0),M&&(d.root.rotation.x+=Math.sin(u*8)*.025),this.scene.add(d.root),this.renderer.setSize(o,o,!1),this.renderer.render(this.scene,this.camera),this.scene.remove(d.root),t.context.clearRect(0,0,o,o),t.context.drawImage(this.renderer.domElement,0,0,o,o),t.canvas.dataset.sceneRotation=d.root.rotation.y.toFixed(4),t.canvas.dataset.mouthScale=d.mouth.scale.y.toFixed(4),t.canvas.dataset.blink=_.toFixed(3),e===0){let m=document.createElement("canvas");for(m.width=m.height=o,m.getContext("2d").drawImage(t.canvas,0,0),this.frames.set(c,m);this.frames.size>Pg||this.frames.size>1&&[...this.frames.values()].reduce((f,T)=>f+T.width*T.height*4,0)>Lg;)this.frames.delete(this.frames.keys().next().value)}}t.canvas.dataset.frame=String(++t.frames),this.totalFrames++,t.state("webgl",t.activity),t.dirty=!1,t.lastFrame=performance.now()}};globalThis.__wandPlushRuntime=new bl;})();
|