0&&(n[l]=u,s=!0)}s&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone(t));let n=e.attributes;for(let c in n){let u=n[c];this.setAttribute(c,u.clone(t))}let s=e.morphAttributes;for(let c in s){let u=[],h=s[c];for(let d=0,p=h.length;d0){let n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(e,t){let i=this.geometry,n=this.material,s=this.matrixWorld;if(n===void 0||(i.boundingSphere===null&&i.computeBoundingSphere(),iu.copy(i.boundingSphere),iu.applyMatrix4(s),e.ray.intersectsSphere(iu)===!1)||(hf.copy(s).invert(),ms.copy(e.ray).applyMatrix4(hf),i.boundingBox!==null&&ms.intersectsBox(i.boundingBox)===!1))return;let o;if(i.isBufferGeometry){let a=i.index,l=i.attributes.position,c=i.morphAttributes.position,u=i.morphTargetsRelative,h=i.attributes.uv,d=i.attributes.uv2,p=i.groups,m=i.drawRange;if(a!==null)if(Array.isArray(n))for(let y=0,x=p.length;yt.far?null:{distance:c,point:la.clone(),object:r}}function ca(r,e,t,i,n,s,o,a,l,c,u,h){hn.fromBufferAttribute(n,c),dn.fromBufferAttribute(n,u),pn.fromBufferAttribute(n,h);let d=r.morphTargetInfluences;if(s&&d){ia.set(0,0,0),na.set(0,0,0),sa.set(0,0,0);for(let m=0,y=s.length;m0?1:-1,u.push(V.x,V.y,V.z),h.push(j/T),h.push(1-U/z),N+=1}}for(let U=0;U0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;let i={};for(let n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}};Zi.prototype.isShaderMaterial=!0;var Ur=class extends Ge{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new Ee,this.projectionMatrix=new Ee,this.projectionMatrixInverse=new Ee}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};Ur.prototype.isCamera=!0;var Et=class extends Ur{constructor(e=50,t=1,i=.1,n=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Au*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(zc*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Au*2*Math.atan(Math.tan(zc*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,n,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(zc*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,s=-.5*n,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*n/l,t-=o.offsetY*i/c,n*=o.width/l,i*=o.height/c}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,t,t-i,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};Et.prototype.isPerspectiveCamera=!0;var gs=90,ys=1,Hr=class extends Ge{constructor(e,t,i){if(super(),this.type="CubeCamera",i.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=i;let n=new Et(gs,ys,e,t);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new P(1,0,0)),this.add(n);let s=new Et(gs,ys,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new P(-1,0,0)),this.add(s);let o=new Et(gs,ys,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new P(0,1,0)),this.add(o);let a=new Et(gs,ys,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new P(0,-1,0)),this.add(a);let l=new Et(gs,ys,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new P(0,0,1)),this.add(l);let c=new Et(gs,ys,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new P(0,0,-1)),this.add(c)}update(e,t){this.parent===null&&this.updateMatrixWorld();let i=this.renderTarget,[n,s,o,a,l,c]=this.children,u=e.xr.enabled,h=e.getRenderTarget();e.xr.enabled=!1;let d=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,n),e.setRenderTarget(i,1),e.render(t,s),e.setRenderTarget(i,2),e.render(t,o),e.setRenderTarget(i,3),e.render(t,a),e.setRenderTarget(i,4),e.render(t,l),i.texture.generateMipmaps=d,e.setRenderTarget(i,5),e.render(t,c),e.setRenderTarget(h),e.xr.enabled=u,i.texture.needsPMREMUpdate=!0}},ks=class extends lt{constructor(e,t,i,n,s,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:co,super(e,t,i,n,s,o,a,l,c,u),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};ks.prototype.isCubeTexture=!0;var Pa=class extends Ht{constructor(e,t,i){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=i),super(e,e,t),t=t||{},this.texture=new ks(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Ft}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=Nt,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`
+}`,Zi=class extends ft{constructor(e){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=Pv,this.fragmentShader=Iv,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&(e.attributes!==void 0&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ns(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let n in this.uniforms){let o=this.uniforms[n].value;o&&o.isTexture?t.uniforms[n]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[n]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[n]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[n]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[n]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[n]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[n]={type:"m4",value:o.toArray()}:t.uniforms[n]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;let i={};for(let n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}};Zi.prototype.isShaderMaterial=!0;var Ur=class extends Ge{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new Ee,this.projectionMatrix=new Ee,this.projectionMatrixInverse=new Ee}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};Ur.prototype.isCamera=!0;var Et=class extends Ur{constructor(e=50,t=1,i=.1,n=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Au*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(zc*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Au*2*Math.atan(Math.tan(zc*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,n,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(zc*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,s=-.5*n,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*n/l,t-=o.offsetY*i/c,n*=o.width/l,i*=o.height/c}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,t,t-i,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};Et.prototype.isPerspectiveCamera=!0;var gs=90,ys=1,Hr=class extends Ge{constructor(e,t,i){if(super(),this.type="CubeCamera",i.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=i;let n=new Et(gs,ys,e,t);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new P(1,0,0)),this.add(n);let s=new Et(gs,ys,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new P(-1,0,0)),this.add(s);let o=new Et(gs,ys,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new P(0,1,0)),this.add(o);let a=new Et(gs,ys,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new P(0,-1,0)),this.add(a);let l=new Et(gs,ys,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new P(0,0,1)),this.add(l);let c=new Et(gs,ys,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new P(0,0,-1)),this.add(c)}update(e,t){this.parent===null&&this.updateMatrixWorld();let i=this.renderTarget,[n,s,o,a,l,c]=this.children,u=e.xr.enabled,h=e.getRenderTarget();e.xr.enabled=!1;let d=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,n),e.setRenderTarget(i,1),e.render(t,s),e.setRenderTarget(i,2),e.render(t,o),e.setRenderTarget(i,3),e.render(t,a),e.setRenderTarget(i,4),e.render(t,l),i.texture.generateMipmaps=d,e.setRenderTarget(i,5),e.render(t,c),e.setRenderTarget(h),e.xr.enabled=u,i.texture.needsPMREMUpdate=!0}},ks=class extends lt{constructor(e,t,i,n,s,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:co,super(e,t,i,n,s,o,a,l,c,u),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};ks.prototype.isCubeTexture=!0;var Pa=class extends Ht{constructor(e,t,i){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=i),super(e,e,t),t=t||{},this.texture=new ks(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Rt}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=Nt,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
@@ -50,7 +50,7 @@ Use (?: \u2026 ) instead`);if(!V.lineBreaks&&H.test(`
gl_FragColor = texture2D( tEquirect, sampleUV );
}
- `},n=new Vr(5,5,5),s=new Zi({name:"CubemapFromEquirect",uniforms:Ns(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:xt,blending:mn});s.uniforms.tEquirect.value=t;let o=new pt(n,s),a=t.minFilter;return t.minFilter===sl&&(t.minFilter=Ft),new Hr(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,n){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,n);e.setRenderTarget(s)}};Pa.prototype.isWebGLCubeRenderTarget=!0;var au=new P,Nv=new P,kv=new wt,di=class{constructor(e=new P(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let n=au.subVectors(i,t).cross(Nv.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){let i=e.delta(au),n=this.normal.dot(i);if(n===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/n;return s<0||s>1?null:t.copy(i).multiplyScalar(s).add(e.start)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||kv.getNormalMatrix(e),n=this.coplanarPoint(au).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};di.prototype.isPlane=!0;var xs=new Ci,ua=new P,Os=class{constructor(e=new di,t=new di,i=new di,n=new di,s=new di,o=new di){this.planes=[e,t,i,n,s,o]}set(e,t,i,n,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(n),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e){let t=this.planes,i=e.elements,n=i[0],s=i[1],o=i[2],a=i[3],l=i[4],c=i[5],u=i[6],h=i[7],d=i[8],p=i[9],m=i[10],y=i[11],x=i[12],g=i[13],f=i[14],E=i[15];return t[0].setComponents(a-n,h-l,y-d,E-x).normalize(),t[1].setComponents(a+n,h+l,y+d,E+x).normalize(),t[2].setComponents(a+s,h+c,y+p,E+g).normalize(),t[3].setComponents(a-s,h-c,y-p,E-g).normalize(),t[4].setComponents(a-o,h-u,y-m,E-f).normalize(),t[5].setComponents(a+o,h+u,y+m,E+f).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),xs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(xs)}intersectsSprite(e){return xs.center.set(0,0,0),xs.radius=.7071067811865476,xs.applyMatrix4(e.matrixWorld),this.intersectsSphere(xs)}intersectsSphere(e){let t=this.planes,i=e.center,n=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)0?e.max.x:e.min.x,ua.y=n.normal.y>0?e.max.y:e.min.y,ua.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(ua)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function pm(){let r=null,e=!1,t=null,i=null;function n(s,o){t(s,o),i=r.requestAnimationFrame(n)}return{start:function(){e!==!0&&t!==null&&(i=r.requestAnimationFrame(n),e=!0)},stop:function(){r.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function Ov(r,e){let t=e.isWebGL2,i=new WeakMap;function n(c,u){let h=c.array,d=c.usage,p=r.createBuffer();r.bindBuffer(u,p),r.bufferData(u,h,d),c.onUploadCallback();let m=5126;return h instanceof Float32Array?m=5126:h instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):h instanceof Uint16Array?c.isFloat16BufferAttribute?t?m=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):m=5123:h instanceof Int16Array?m=5122:h instanceof Uint32Array?m=5125:h instanceof Int32Array?m=5124:h instanceof Int8Array?m=5120:(h instanceof Uint8Array||h instanceof Uint8ClampedArray)&&(m=5121),{buffer:p,type:m,bytesPerElement:h.BYTES_PER_ELEMENT,version:c.version}}function s(c,u,h){let d=u.array,p=u.updateRange;r.bindBuffer(h,c),p.count===-1?r.bufferSubData(h,0,d):(t?r.bufferSubData(h,p.offset*d.BYTES_PER_ELEMENT,d,p.offset,p.count):r.bufferSubData(h,p.offset*d.BYTES_PER_ELEMENT,d.subarray(p.offset,p.offset+p.count)),p.count=-1)}function o(c){return c.isInterleavedBufferAttribute&&(c=c.data),i.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);let u=i.get(c);u&&(r.deleteBuffer(u.buffer),i.delete(c))}function l(c,u){if(c.isGLBufferAttribute){let d=i.get(c);(!d||d.version1?null:t.copy(i).multiplyScalar(s).add(e.start)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||kv.getNormalMatrix(e),n=this.coplanarPoint(au).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};di.prototype.isPlane=!0;var xs=new Ci,ua=new P,Os=class{constructor(e=new di,t=new di,i=new di,n=new di,s=new di,o=new di){this.planes=[e,t,i,n,s,o]}set(e,t,i,n,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(n),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e){let t=this.planes,i=e.elements,n=i[0],s=i[1],o=i[2],a=i[3],l=i[4],c=i[5],u=i[6],h=i[7],d=i[8],p=i[9],m=i[10],y=i[11],x=i[12],g=i[13],f=i[14],E=i[15];return t[0].setComponents(a-n,h-l,y-d,E-x).normalize(),t[1].setComponents(a+n,h+l,y+d,E+x).normalize(),t[2].setComponents(a+s,h+c,y+p,E+g).normalize(),t[3].setComponents(a-s,h-c,y-p,E-g).normalize(),t[4].setComponents(a-o,h-u,y-m,E-f).normalize(),t[5].setComponents(a+o,h+u,y+m,E+f).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),xs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(xs)}intersectsSprite(e){return xs.center.set(0,0,0),xs.radius=.7071067811865476,xs.applyMatrix4(e.matrixWorld),this.intersectsSphere(xs)}intersectsSphere(e){let t=this.planes,i=e.center,n=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)0?e.max.x:e.min.x,ua.y=n.normal.y>0?e.max.y:e.min.y,ua.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(ua)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function pm(){let r=null,e=!1,t=null,i=null;function n(s,o){t(s,o),i=r.requestAnimationFrame(n)}return{start:function(){e!==!0&&t!==null&&(i=r.requestAnimationFrame(n),e=!0)},stop:function(){r.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function Ov(r,e){let t=e.isWebGL2,i=new WeakMap;function n(c,u){let h=c.array,d=c.usage,p=r.createBuffer();r.bindBuffer(u,p),r.bufferData(u,h,d),c.onUploadCallback();let m=5126;return h instanceof Float32Array?m=5126:h instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):h instanceof Uint16Array?c.isFloat16BufferAttribute?t?m=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):m=5123:h instanceof Int16Array?m=5122:h instanceof Uint32Array?m=5125:h instanceof Int32Array?m=5124:h instanceof Int8Array?m=5120:(h instanceof Uint8Array||h instanceof Uint8ClampedArray)&&(m=5121),{buffer:p,type:m,bytesPerElement:h.BYTES_PER_ELEMENT,version:c.version}}function s(c,u,h){let d=u.array,p=u.updateRange;r.bindBuffer(h,c),p.count===-1?r.bufferSubData(h,0,d):(t?r.bufferSubData(h,p.offset*d.BYTES_PER_ELEMENT,d,p.offset,p.count):r.bufferSubData(h,p.offset*d.BYTES_PER_ELEMENT,d.subarray(p.offset,p.offset+p.count)),p.count=-1)}function o(c){return c.isInterleavedBufferAttribute&&(c=c.data),i.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);let u=i.get(c);u&&(r.deleteBuffer(u.buffer),i.delete(c))}function l(c,u){if(c.isGLBufferAttribute){let d=i.get(c);(!d||d.version
#include
#include
-}`,Ne={alphamap_fragment:zv,alphamap_pars_fragment:Vv,alphatest_fragment:Uv,alphatest_pars_fragment:Hv,aomap_fragment:Gv,aomap_pars_fragment:qv,begin_vertex:Wv,beginnormal_vertex:$v,bsdfs:jv,bumpmap_pars_fragment:Xv,clipping_planes_fragment:Yv,clipping_planes_pars_fragment:Zv,clipping_planes_pars_vertex:Jv,clipping_planes_vertex:Kv,color_fragment:Qv,color_pars_fragment:e2,color_pars_vertex:t2,color_vertex:i2,common:n2,cube_uv_reflection_fragment:s2,defaultnormal_vertex:r2,displacementmap_pars_vertex:o2,displacementmap_vertex:a2,emissivemap_fragment:l2,emissivemap_pars_fragment:c2,encodings_fragment:u2,encodings_pars_fragment:h2,envmap_fragment:d2,envmap_common_pars_fragment:p2,envmap_pars_fragment:f2,envmap_pars_vertex:m2,envmap_physical_pars_fragment:M2,envmap_vertex:g2,fog_vertex:y2,fog_pars_vertex:x2,fog_fragment:v2,fog_pars_fragment:w2,gradientmap_pars_fragment:b2,lightmap_fragment:_2,lightmap_pars_fragment:E2,lights_lambert_vertex:A2,lights_pars_begin:S2,lights_toon_fragment:D2,lights_toon_pars_fragment:T2,lights_phong_fragment:C2,lights_phong_pars_fragment:R2,lights_physical_fragment:F2,lights_physical_pars_fragment:L2,lights_fragment_begin:B2,lights_fragment_maps:P2,lights_fragment_end:I2,logdepthbuf_fragment:N2,logdepthbuf_pars_fragment:k2,logdepthbuf_pars_vertex:O2,logdepthbuf_vertex:z2,map_fragment:V2,map_pars_fragment:U2,map_particle_fragment:H2,map_particle_pars_fragment:G2,metalnessmap_fragment:q2,metalnessmap_pars_fragment:W2,morphnormal_vertex:$2,morphtarget_pars_vertex:j2,morphtarget_vertex:X2,normal_fragment_begin:Y2,normal_fragment_maps:Z2,normal_pars_fragment:J2,normal_pars_vertex:K2,normal_vertex:Q2,normalmap_pars_fragment:ew,clearcoat_normal_fragment_begin:tw,clearcoat_normal_fragment_maps:iw,clearcoat_pars_fragment:nw,output_fragment:sw,packing:rw,premultiplied_alpha_fragment:ow,project_vertex:aw,dithering_fragment:lw,dithering_pars_fragment:cw,roughnessmap_fragment:uw,roughnessmap_pars_fragment:hw,shadowmap_pars_fragment:dw,shadowmap_pars_vertex:pw,shadowmap_vertex:fw,shadowmask_pars_fragment:mw,skinbase_vertex:gw,skinning_pars_vertex:yw,skinning_vertex:xw,skinnormal_vertex:vw,specularmap_fragment:ww,specularmap_pars_fragment:bw,tonemapping_fragment:_w,tonemapping_pars_fragment:Ew,transmission_fragment:Aw,transmission_pars_fragment:Sw,uv_pars_fragment:Mw,uv_pars_vertex:Dw,uv_vertex:Tw,uv2_pars_fragment:Cw,uv2_pars_vertex:Rw,uv2_vertex:Fw,worldpos_vertex:Lw,background_vert:Bw,background_frag:Pw,cube_vert:Iw,cube_frag:Nw,depth_vert:kw,depth_frag:Ow,distanceRGBA_vert:zw,distanceRGBA_frag:Vw,equirect_vert:Uw,equirect_frag:Hw,linedashed_vert:Gw,linedashed_frag:qw,meshbasic_vert:Ww,meshbasic_frag:$w,meshlambert_vert:jw,meshlambert_frag:Xw,meshmatcap_vert:Yw,meshmatcap_frag:Zw,meshnormal_vert:Jw,meshnormal_frag:Kw,meshphong_vert:Qw,meshphong_frag:eb,meshphysical_vert:tb,meshphysical_frag:ib,meshtoon_vert:nb,meshtoon_frag:sb,points_vert:rb,points_frag:ob,shadow_vert:ab,shadow_frag:lb,sprite_vert:cb,sprite_frag:ub},re={common:{diffuse:{value:new ye(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new wt},uv2Transform:{value:new wt},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ye(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ye(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new wt}},sprite:{diffuse:{value:new ye(16777215)},opacity:{value:1},center:{value:new ee(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new wt}}},Ti={basic:{uniforms:Rt([re.common,re.specularmap,re.envmap,re.aomap,re.lightmap,re.fog]),vertexShader:Ne.meshbasic_vert,fragmentShader:Ne.meshbasic_frag},lambert:{uniforms:Rt([re.common,re.specularmap,re.envmap,re.aomap,re.lightmap,re.emissivemap,re.fog,re.lights,{emissive:{value:new ye(0)}}]),vertexShader:Ne.meshlambert_vert,fragmentShader:Ne.meshlambert_frag},phong:{uniforms:Rt([re.common,re.specularmap,re.envmap,re.aomap,re.lightmap,re.emissivemap,re.bumpmap,re.normalmap,re.displacementmap,re.fog,re.lights,{emissive:{value:new ye(0)},specular:{value:new ye(1118481)},shininess:{value:30}}]),vertexShader:Ne.meshphong_vert,fragmentShader:Ne.meshphong_frag},standard:{uniforms:Rt([re.common,re.envmap,re.aomap,re.lightmap,re.emissivemap,re.bumpmap,re.normalmap,re.displacementmap,re.roughnessmap,re.metalnessmap,re.fog,re.lights,{emissive:{value:new ye(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ne.meshphysical_vert,fragmentShader:Ne.meshphysical_frag},toon:{uniforms:Rt([re.common,re.aomap,re.lightmap,re.emissivemap,re.bumpmap,re.normalmap,re.displacementmap,re.gradientmap,re.fog,re.lights,{emissive:{value:new ye(0)}}]),vertexShader:Ne.meshtoon_vert,fragmentShader:Ne.meshtoon_frag},matcap:{uniforms:Rt([re.common,re.bumpmap,re.normalmap,re.displacementmap,re.fog,{matcap:{value:null}}]),vertexShader:Ne.meshmatcap_vert,fragmentShader:Ne.meshmatcap_frag},points:{uniforms:Rt([re.points,re.fog]),vertexShader:Ne.points_vert,fragmentShader:Ne.points_frag},dashed:{uniforms:Rt([re.common,re.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ne.linedashed_vert,fragmentShader:Ne.linedashed_frag},depth:{uniforms:Rt([re.common,re.displacementmap]),vertexShader:Ne.depth_vert,fragmentShader:Ne.depth_frag},normal:{uniforms:Rt([re.common,re.bumpmap,re.normalmap,re.displacementmap,{opacity:{value:1}}]),vertexShader:Ne.meshnormal_vert,fragmentShader:Ne.meshnormal_frag},sprite:{uniforms:Rt([re.sprite,re.fog]),vertexShader:Ne.sprite_vert,fragmentShader:Ne.sprite_frag},background:{uniforms:{uvTransform:{value:new wt},t2D:{value:null}},vertexShader:Ne.background_vert,fragmentShader:Ne.background_frag},cube:{uniforms:Rt([re.envmap,{opacity:{value:1}}]),vertexShader:Ne.cube_vert,fragmentShader:Ne.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ne.equirect_vert,fragmentShader:Ne.equirect_frag},distanceRGBA:{uniforms:Rt([re.common,re.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ne.distanceRGBA_vert,fragmentShader:Ne.distanceRGBA_frag},shadow:{uniforms:Rt([re.lights,re.fog,{color:{value:new ye(0)},opacity:{value:1}}]),vertexShader:Ne.shadow_vert,fragmentShader:Ne.shadow_frag}};Ti.physical={uniforms:Rt([Ti.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new ee(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new ye(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new ye(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new ye(1,1,1)},specularColorMap:{value:null}}]),vertexShader:Ne.meshphysical_vert,fragmentShader:Ne.meshphysical_frag};function hb(r,e,t,i,n,s){let o=new ye(0),a=n===!0?0:1,l,c,u=null,h=0,d=null;function p(y,x){let g=!1,f=x.isScene===!0?x.background:null;f&&f.isTexture&&(f=e.get(f));let E=r.xr,w=E.getSession&&E.getSession();w&&w.environmentBlendMode==="additive"&&(f=null),f===null?m(o,a):f&&f.isColor&&(m(f,1),g=!0),(r.autoClear||g)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),f&&(f.isCubeTexture||f.mapping===nl)?(c===void 0&&(c=new pt(new Vr(1,1,1),new Zi({name:"BackgroundCubeMaterial",uniforms:Ns(Ti.cube.uniforms),vertexShader:Ti.cube.vertexShader,fragmentShader:Ti.cube.fragmentShader,side:xt,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(_,M,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=f,c.material.uniforms.flipEnvMap.value=f.isCubeTexture&&f.isRenderTargetTexture===!1?-1:1,(u!==f||h!==f.version||d!==r.toneMapping)&&(c.material.needsUpdate=!0,u=f,h=f.version,d=r.toneMapping),y.unshift(c,c.geometry,c.material,0,0,null)):f&&f.isTexture&&(l===void 0&&(l=new pt(new Gr(2,2),new Zi({name:"BackgroundMaterial",uniforms:Ns(Ti.background.uniforms),vertexShader:Ti.background.vertexShader,fragmentShader:Ti.background.fragmentShader,side:Pr,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=f,f.matrixAutoUpdate===!0&&f.updateMatrix(),l.material.uniforms.uvTransform.value.copy(f.matrix),(u!==f||h!==f.version||d!==r.toneMapping)&&(l.material.needsUpdate=!0,u=f,h=f.version,d=r.toneMapping),y.unshift(l,l.geometry,l.material,0,0,null))}function m(y,x){t.buffers.color.setClear(y.r,y.g,y.b,x,s)}return{getClearColor:function(){return o},setClearColor:function(y,x=1){o.set(y),a=x,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(y){a=y,m(o,a)},render:p}}function db(r,e,t,i){let n=r.getParameter(34921),s=i.isWebGL2?null:e.get("OES_vertex_array_object"),o=i.isWebGL2||s!==null,a={},l=y(null),c=l;function u(S,B,L,C,N){let k=!1;if(o){let V=m(C,L,B);c!==V&&(c=V,d(c.object)),k=x(C,N),k&&g(C,N)}else{let V=B.wireframe===!0;(c.geometry!==C.id||c.program!==L.id||c.wireframe!==V)&&(c.geometry=C.id,c.program=L.id,c.wireframe=V,k=!0)}S.isInstancedMesh===!0&&(k=!0),N!==null&&t.update(N,34963),k&&(T(S,B,L,C),N!==null&&r.bindBuffer(34963,t.get(N).buffer))}function h(){return i.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function d(S){return i.isWebGL2?r.bindVertexArray(S):s.bindVertexArrayOES(S)}function p(S){return i.isWebGL2?r.deleteVertexArray(S):s.deleteVertexArrayOES(S)}function m(S,B,L){let C=L.wireframe===!0,N=a[S.id];N===void 0&&(N={},a[S.id]=N);let k=N[B.id];k===void 0&&(k={},N[B.id]=k);let V=k[C];return V===void 0&&(V=y(h()),k[C]=V),V}function y(S){let B=[],L=[],C=[];for(let N=0;N=0){let j=N[U];if(j===void 0&&(U==="instanceMatrix"&&S.instanceMatrix&&(j=S.instanceMatrix),U==="instanceColor"&&S.instanceColor&&(j=S.instanceColor)),j!==void 0){let ne=j.normalized,ae=j.itemSize,H=t.get(j);if(H===void 0)continue;let Te=H.buffer,ue=H.type,we=H.bytesPerElement;if(j.isInterleavedBufferAttribute){let oe=j.data,Ce=oe.stride,Ae=j.offset;if(oe&&oe.isInstancedInterleavedBuffer){for(let Z=0;Z0&&r.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";T="mediump"}return T==="mediump"&&r.getShaderPrecisionFormat(35633,36337).precision>0&&r.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext<"u"&&r instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&r instanceof WebGL2ComputeRenderingContext,a=t.precision!==void 0?t.precision:"highp",l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);let c=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,h=r.getParameter(34930),d=r.getParameter(35660),p=r.getParameter(3379),m=r.getParameter(34076),y=r.getParameter(34921),x=r.getParameter(36347),g=r.getParameter(36348),f=r.getParameter(36349),E=d>0,w=o||e.has("OES_texture_float"),_=E&&w,M=o?r.getParameter(36183):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:n,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:d,maxTextureSize:p,maxCubemapSize:m,maxAttributes:y,maxVertexUniforms:x,maxVaryings:g,maxFragmentUniforms:f,vertexTextures:E,floatFragmentTextures:w,floatVertexTextures:_,maxSamples:M}}function mb(r){let e=this,t=null,i=0,n=!1,s=!1,o=new di,a=new wt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d,p){let m=h.length!==0||d||i!==0||n;return n=d,t=u(h,p,0),i=h.length,m},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1,c()},this.setState=function(h,d,p){let m=h.clippingPlanes,y=h.clipIntersection,x=h.clipShadows,g=r.get(h);if(!n||m===null||m.length===0||s&&!x)s?u(null):c();else{let f=s?0:i,E=f*4,w=g.clippingState||null;l.value=w,w=u(m,d,E,p);for(let _=0;_!==E;++_)w[_]=t[_];g.clippingState=w,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=f}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(h,d,p,m){let y=h!==null?h.length:0,x=null;if(y!==0){if(x=l.value,m!==!0||x===null){let g=p+y*4,f=d.matrixWorldInverse;a.getNormalMatrix(f),(x===null||x.length0){let c=new Pa(l.height/2);return c.fromEquirectangularTexture(r,o),e.set(o,c),o.addEventListener("dispose",n),t(c.texture,o.mapping)}else return null}}return o}function n(o){let a=o.target;a.removeEventListener("dispose",n);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}var qr=class extends Ur{constructor(e=-1,t=1,i=1,n=-1,s=.1,o=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2,s=i-e,o=i+e,a=n+t,l=n-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}};qr.prototype.isOrthographicCamera=!0;var zs=class extends Zi{constructor(e){super(e),this.type="RawShaderMaterial"}};zs.prototype.isRawShaderMaterial=!0;var Ls=4,xn=8,Di=Math.pow(2,xn),fm=[.125,.215,.35,.446,.526,.582],mm=xn-Ls+1+fm.length,vs=20,lu=new qr,{_lodPlanes:_r,_sizeLods:df,_sigmas:ha}=yb(),pf=new ye,cu=null,zn=(1+Math.sqrt(5))/2,ws=1/zn,ff=[new P(1,1,1),new P(-1,1,1),new P(1,1,-1),new P(-1,1,-1),new P(0,zn,ws),new P(0,zn,-ws),new P(ws,0,zn),new P(-ws,0,zn),new P(zn,ws,0),new P(-zn,ws,0)],Ia=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=xb(vs),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,n=100){cu=this._renderer.getRenderTarget();let s=this._allocateTargets();return this._sceneToCubeUV(e,i,n,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapShader===null&&(this._cubemapShader=yf(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){this._equirectShader===null&&(this._equirectShader=gf(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose(),this._cubemapShader!==null&&this._cubemapShader.dispose(),this._equirectShader!==null&&this._equirectShader.dispose();for(let e=0;e<_r.length;e++)_r[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(cu),e.scissorTest=!1,da(e,0,0,e.width,e.height)}_fromTexture(e,t){cu=this._renderer.getRenderTarget();let i=t||this._allocateTargets(e);return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(e){let t={magFilter:Ft,minFilter:Ft,generateMipmaps:!1,type:Cs,format:Nt,encoding:bn,depthBuffer:!1},i=mf(t);return i.depthBuffer=!e,this._pingPongRenderTarget===null&&(this._pingPongRenderTarget=mf(t)),i}_compileMaterial(e){let t=new pt(_r[0],e);this._renderer.compile(t,lu)}_sceneToCubeUV(e,t,i,n){let a=new Et(90,1,t,i),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,d=u.toneMapping;u.getClearColor(pf),u.toneMapping=gn,u.autoClear=!1;let p=new zr({name:"PMREM.Background",side:xt,depthWrite:!1,depthTest:!1}),m=new pt(new Vr,p),y=!1,x=e.background;x?x.isColor&&(p.color.copy(x),e.background=null,y=!0):(p.color.copy(pf),y=!0);for(let g=0;g<6;g++){let f=g%3;f===0?(a.up.set(0,l[g],0),a.lookAt(c[g],0,0)):f===1?(a.up.set(0,0,l[g]),a.lookAt(0,c[g],0)):(a.up.set(0,l[g],0),a.lookAt(0,0,c[g])),da(n,f*Di,g>2?Di:0,Di,Di),u.setRenderTarget(n),y&&u.render(m,a),u.render(e,a)}m.geometry.dispose(),m.material.dispose(),u.toneMapping=d,u.autoClear=h,e.background=x}_textureToCubeUV(e,t){let i=this._renderer,n=e.mapping===co||e.mapping===uo;n?(this._cubemapShader===null&&(this._cubemapShader=yf()),this._cubemapShader.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectShader===null&&(this._equirectShader=gf());let s=n?this._cubemapShader:this._equirectShader,o=new pt(_r[0],s),a=s.uniforms;a.envMap.value=e,n||a.texelSize.value.set(1/e.image.width,1/e.image.height),da(t,0,0,3*Di,2*Di),i.setRenderTarget(t),i.render(o,lu)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let n=1;nvs&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${vs}`);let g=[],f=0;for(let M=0;Mxn-Ls?n-xn+Ls:0);da(t,w,_,3*E,2*E),l.setRenderTarget(t),l.render(h,lu)}};function yb(){let r=[],e=[],t=[],i=xn;for(let n=0;nxn-Ls?o=fm[n-xn+Ls-1]:n===0&&(o=0),t.push(o);let a=1/(s-1),l=-a/2,c=1+a/2,u=[l,l,c,l,c,c,l,l,c,c,l,c],h=6,d=6,p=3,m=2,y=1,x=new Float32Array(p*d*h),g=new Float32Array(m*d*h),f=new Float32Array(y*d*h);for(let w=0;w2?0:-1,T=[_,M,0,_+2/3,M,0,_+2/3,M+1,0,_,M,0,_+2/3,M+1,0,_,M+1,0];x.set(T,p*d*w),g.set(u,m*d*w);let z=[w,w,w,w,w,w];f.set(z,y*d*w)}let E=new Ke;E.setAttribute("position",new ht(x,p)),E.setAttribute("uv",new ht(g,m)),E.setAttribute("faceIndex",new ht(f,y)),r.push(E),i>Ls&&i--}return{_lodPlanes:r,_sizeLods:e,_sigmas:t}}function mf(r){let e=new Ht(3*Di,3*Di,r);return e.texture.mapping=nl,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function da(r,e,t,i,n){r.viewport.set(e,t,i,n),r.scissor.set(e,t,i,n)}function xb(r){let e=new Float32Array(r),t=new P(0,1,0);return new zs({name:"SphericalGaussianBlur",defines:{n:r},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:t}},vertexShader:Nh(),fragmentShader:`
+}`,Ne={alphamap_fragment:zv,alphamap_pars_fragment:Vv,alphatest_fragment:Uv,alphatest_pars_fragment:Hv,aomap_fragment:Gv,aomap_pars_fragment:qv,begin_vertex:Wv,beginnormal_vertex:$v,bsdfs:jv,bumpmap_pars_fragment:Xv,clipping_planes_fragment:Yv,clipping_planes_pars_fragment:Zv,clipping_planes_pars_vertex:Jv,clipping_planes_vertex:Kv,color_fragment:Qv,color_pars_fragment:e2,color_pars_vertex:t2,color_vertex:i2,common:n2,cube_uv_reflection_fragment:s2,defaultnormal_vertex:r2,displacementmap_pars_vertex:o2,displacementmap_vertex:a2,emissivemap_fragment:l2,emissivemap_pars_fragment:c2,encodings_fragment:u2,encodings_pars_fragment:h2,envmap_fragment:d2,envmap_common_pars_fragment:p2,envmap_pars_fragment:f2,envmap_pars_vertex:m2,envmap_physical_pars_fragment:M2,envmap_vertex:g2,fog_vertex:y2,fog_pars_vertex:x2,fog_fragment:v2,fog_pars_fragment:w2,gradientmap_pars_fragment:b2,lightmap_fragment:_2,lightmap_pars_fragment:E2,lights_lambert_vertex:A2,lights_pars_begin:S2,lights_toon_fragment:D2,lights_toon_pars_fragment:T2,lights_phong_fragment:C2,lights_phong_pars_fragment:R2,lights_physical_fragment:F2,lights_physical_pars_fragment:L2,lights_fragment_begin:B2,lights_fragment_maps:P2,lights_fragment_end:I2,logdepthbuf_fragment:N2,logdepthbuf_pars_fragment:k2,logdepthbuf_pars_vertex:O2,logdepthbuf_vertex:z2,map_fragment:V2,map_pars_fragment:U2,map_particle_fragment:H2,map_particle_pars_fragment:G2,metalnessmap_fragment:q2,metalnessmap_pars_fragment:W2,morphnormal_vertex:$2,morphtarget_pars_vertex:j2,morphtarget_vertex:X2,normal_fragment_begin:Y2,normal_fragment_maps:Z2,normal_pars_fragment:J2,normal_pars_vertex:K2,normal_vertex:Q2,normalmap_pars_fragment:ew,clearcoat_normal_fragment_begin:tw,clearcoat_normal_fragment_maps:iw,clearcoat_pars_fragment:nw,output_fragment:sw,packing:rw,premultiplied_alpha_fragment:ow,project_vertex:aw,dithering_fragment:lw,dithering_pars_fragment:cw,roughnessmap_fragment:uw,roughnessmap_pars_fragment:hw,shadowmap_pars_fragment:dw,shadowmap_pars_vertex:pw,shadowmap_vertex:fw,shadowmask_pars_fragment:mw,skinbase_vertex:gw,skinning_pars_vertex:yw,skinning_vertex:xw,skinnormal_vertex:vw,specularmap_fragment:ww,specularmap_pars_fragment:bw,tonemapping_fragment:_w,tonemapping_pars_fragment:Ew,transmission_fragment:Aw,transmission_pars_fragment:Sw,uv_pars_fragment:Mw,uv_pars_vertex:Dw,uv_vertex:Tw,uv2_pars_fragment:Cw,uv2_pars_vertex:Rw,uv2_vertex:Fw,worldpos_vertex:Lw,background_vert:Bw,background_frag:Pw,cube_vert:Iw,cube_frag:Nw,depth_vert:kw,depth_frag:Ow,distanceRGBA_vert:zw,distanceRGBA_frag:Vw,equirect_vert:Uw,equirect_frag:Hw,linedashed_vert:Gw,linedashed_frag:qw,meshbasic_vert:Ww,meshbasic_frag:$w,meshlambert_vert:jw,meshlambert_frag:Xw,meshmatcap_vert:Yw,meshmatcap_frag:Zw,meshnormal_vert:Jw,meshnormal_frag:Kw,meshphong_vert:Qw,meshphong_frag:eb,meshphysical_vert:tb,meshphysical_frag:ib,meshtoon_vert:nb,meshtoon_frag:sb,points_vert:rb,points_frag:ob,shadow_vert:ab,shadow_frag:lb,sprite_vert:cb,sprite_frag:ub},re={common:{diffuse:{value:new ye(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new wt},uv2Transform:{value:new wt},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ye(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ye(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new wt}},sprite:{diffuse:{value:new ye(16777215)},opacity:{value:1},center:{value:new ee(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new wt}}},Ti={basic:{uniforms:Ct([re.common,re.specularmap,re.envmap,re.aomap,re.lightmap,re.fog]),vertexShader:Ne.meshbasic_vert,fragmentShader:Ne.meshbasic_frag},lambert:{uniforms:Ct([re.common,re.specularmap,re.envmap,re.aomap,re.lightmap,re.emissivemap,re.fog,re.lights,{emissive:{value:new ye(0)}}]),vertexShader:Ne.meshlambert_vert,fragmentShader:Ne.meshlambert_frag},phong:{uniforms:Ct([re.common,re.specularmap,re.envmap,re.aomap,re.lightmap,re.emissivemap,re.bumpmap,re.normalmap,re.displacementmap,re.fog,re.lights,{emissive:{value:new ye(0)},specular:{value:new ye(1118481)},shininess:{value:30}}]),vertexShader:Ne.meshphong_vert,fragmentShader:Ne.meshphong_frag},standard:{uniforms:Ct([re.common,re.envmap,re.aomap,re.lightmap,re.emissivemap,re.bumpmap,re.normalmap,re.displacementmap,re.roughnessmap,re.metalnessmap,re.fog,re.lights,{emissive:{value:new ye(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ne.meshphysical_vert,fragmentShader:Ne.meshphysical_frag},toon:{uniforms:Ct([re.common,re.aomap,re.lightmap,re.emissivemap,re.bumpmap,re.normalmap,re.displacementmap,re.gradientmap,re.fog,re.lights,{emissive:{value:new ye(0)}}]),vertexShader:Ne.meshtoon_vert,fragmentShader:Ne.meshtoon_frag},matcap:{uniforms:Ct([re.common,re.bumpmap,re.normalmap,re.displacementmap,re.fog,{matcap:{value:null}}]),vertexShader:Ne.meshmatcap_vert,fragmentShader:Ne.meshmatcap_frag},points:{uniforms:Ct([re.points,re.fog]),vertexShader:Ne.points_vert,fragmentShader:Ne.points_frag},dashed:{uniforms:Ct([re.common,re.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ne.linedashed_vert,fragmentShader:Ne.linedashed_frag},depth:{uniforms:Ct([re.common,re.displacementmap]),vertexShader:Ne.depth_vert,fragmentShader:Ne.depth_frag},normal:{uniforms:Ct([re.common,re.bumpmap,re.normalmap,re.displacementmap,{opacity:{value:1}}]),vertexShader:Ne.meshnormal_vert,fragmentShader:Ne.meshnormal_frag},sprite:{uniforms:Ct([re.sprite,re.fog]),vertexShader:Ne.sprite_vert,fragmentShader:Ne.sprite_frag},background:{uniforms:{uvTransform:{value:new wt},t2D:{value:null}},vertexShader:Ne.background_vert,fragmentShader:Ne.background_frag},cube:{uniforms:Ct([re.envmap,{opacity:{value:1}}]),vertexShader:Ne.cube_vert,fragmentShader:Ne.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ne.equirect_vert,fragmentShader:Ne.equirect_frag},distanceRGBA:{uniforms:Ct([re.common,re.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ne.distanceRGBA_vert,fragmentShader:Ne.distanceRGBA_frag},shadow:{uniforms:Ct([re.lights,re.fog,{color:{value:new ye(0)},opacity:{value:1}}]),vertexShader:Ne.shadow_vert,fragmentShader:Ne.shadow_frag}};Ti.physical={uniforms:Ct([Ti.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new ee(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new ye(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new ye(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new ye(1,1,1)},specularColorMap:{value:null}}]),vertexShader:Ne.meshphysical_vert,fragmentShader:Ne.meshphysical_frag};function hb(r,e,t,i,n,s){let o=new ye(0),a=n===!0?0:1,l,c,u=null,h=0,d=null;function p(y,x){let g=!1,f=x.isScene===!0?x.background:null;f&&f.isTexture&&(f=e.get(f));let E=r.xr,w=E.getSession&&E.getSession();w&&w.environmentBlendMode==="additive"&&(f=null),f===null?m(o,a):f&&f.isColor&&(m(f,1),g=!0),(r.autoClear||g)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),f&&(f.isCubeTexture||f.mapping===nl)?(c===void 0&&(c=new pt(new Vr(1,1,1),new Zi({name:"BackgroundCubeMaterial",uniforms:Ns(Ti.cube.uniforms),vertexShader:Ti.cube.vertexShader,fragmentShader:Ti.cube.fragmentShader,side:xt,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(_,M,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=f,c.material.uniforms.flipEnvMap.value=f.isCubeTexture&&f.isRenderTargetTexture===!1?-1:1,(u!==f||h!==f.version||d!==r.toneMapping)&&(c.material.needsUpdate=!0,u=f,h=f.version,d=r.toneMapping),y.unshift(c,c.geometry,c.material,0,0,null)):f&&f.isTexture&&(l===void 0&&(l=new pt(new Gr(2,2),new Zi({name:"BackgroundMaterial",uniforms:Ns(Ti.background.uniforms),vertexShader:Ti.background.vertexShader,fragmentShader:Ti.background.fragmentShader,side:Pr,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=f,f.matrixAutoUpdate===!0&&f.updateMatrix(),l.material.uniforms.uvTransform.value.copy(f.matrix),(u!==f||h!==f.version||d!==r.toneMapping)&&(l.material.needsUpdate=!0,u=f,h=f.version,d=r.toneMapping),y.unshift(l,l.geometry,l.material,0,0,null))}function m(y,x){t.buffers.color.setClear(y.r,y.g,y.b,x,s)}return{getClearColor:function(){return o},setClearColor:function(y,x=1){o.set(y),a=x,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(y){a=y,m(o,a)},render:p}}function db(r,e,t,i){let n=r.getParameter(34921),s=i.isWebGL2?null:e.get("OES_vertex_array_object"),o=i.isWebGL2||s!==null,a={},l=y(null),c=l;function u(S,B,L,C,N){let k=!1;if(o){let V=m(C,L,B);c!==V&&(c=V,d(c.object)),k=x(C,N),k&&g(C,N)}else{let V=B.wireframe===!0;(c.geometry!==C.id||c.program!==L.id||c.wireframe!==V)&&(c.geometry=C.id,c.program=L.id,c.wireframe=V,k=!0)}S.isInstancedMesh===!0&&(k=!0),N!==null&&t.update(N,34963),k&&(T(S,B,L,C),N!==null&&r.bindBuffer(34963,t.get(N).buffer))}function h(){return i.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function d(S){return i.isWebGL2?r.bindVertexArray(S):s.bindVertexArrayOES(S)}function p(S){return i.isWebGL2?r.deleteVertexArray(S):s.deleteVertexArrayOES(S)}function m(S,B,L){let C=L.wireframe===!0,N=a[S.id];N===void 0&&(N={},a[S.id]=N);let k=N[B.id];k===void 0&&(k={},N[B.id]=k);let V=k[C];return V===void 0&&(V=y(h()),k[C]=V),V}function y(S){let B=[],L=[],C=[];for(let N=0;N=0){let j=N[U];if(j===void 0&&(U==="instanceMatrix"&&S.instanceMatrix&&(j=S.instanceMatrix),U==="instanceColor"&&S.instanceColor&&(j=S.instanceColor)),j!==void 0){let ne=j.normalized,ae=j.itemSize,H=t.get(j);if(H===void 0)continue;let Te=H.buffer,ue=H.type,we=H.bytesPerElement;if(j.isInterleavedBufferAttribute){let oe=j.data,Ce=oe.stride,Ae=j.offset;if(oe&&oe.isInstancedInterleavedBuffer){for(let Z=0;Z0&&r.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";T="mediump"}return T==="mediump"&&r.getShaderPrecisionFormat(35633,36337).precision>0&&r.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext<"u"&&r instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&r instanceof WebGL2ComputeRenderingContext,a=t.precision!==void 0?t.precision:"highp",l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);let c=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,h=r.getParameter(34930),d=r.getParameter(35660),p=r.getParameter(3379),m=r.getParameter(34076),y=r.getParameter(34921),x=r.getParameter(36347),g=r.getParameter(36348),f=r.getParameter(36349),E=d>0,w=o||e.has("OES_texture_float"),_=E&&w,M=o?r.getParameter(36183):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:n,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:d,maxTextureSize:p,maxCubemapSize:m,maxAttributes:y,maxVertexUniforms:x,maxVaryings:g,maxFragmentUniforms:f,vertexTextures:E,floatFragmentTextures:w,floatVertexTextures:_,maxSamples:M}}function mb(r){let e=this,t=null,i=0,n=!1,s=!1,o=new di,a=new wt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d,p){let m=h.length!==0||d||i!==0||n;return n=d,t=u(h,p,0),i=h.length,m},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1,c()},this.setState=function(h,d,p){let m=h.clippingPlanes,y=h.clipIntersection,x=h.clipShadows,g=r.get(h);if(!n||m===null||m.length===0||s&&!x)s?u(null):c();else{let f=s?0:i,E=f*4,w=g.clippingState||null;l.value=w,w=u(m,d,E,p);for(let _=0;_!==E;++_)w[_]=t[_];g.clippingState=w,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=f}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(h,d,p,m){let y=h!==null?h.length:0,x=null;if(y!==0){if(x=l.value,m!==!0||x===null){let g=p+y*4,f=d.matrixWorldInverse;a.getNormalMatrix(f),(x===null||x.length0){let c=new Pa(l.height/2);return c.fromEquirectangularTexture(r,o),e.set(o,c),o.addEventListener("dispose",n),t(c.texture,o.mapping)}else return null}}return o}function n(o){let a=o.target;a.removeEventListener("dispose",n);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}var qr=class extends Ur{constructor(e=-1,t=1,i=1,n=-1,s=.1,o=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2,s=i-e,o=i+e,a=n+t,l=n-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}};qr.prototype.isOrthographicCamera=!0;var zs=class extends Zi{constructor(e){super(e),this.type="RawShaderMaterial"}};zs.prototype.isRawShaderMaterial=!0;var Ls=4,xn=8,Di=Math.pow(2,xn),fm=[.125,.215,.35,.446,.526,.582],mm=xn-Ls+1+fm.length,vs=20,lu=new qr,{_lodPlanes:_r,_sizeLods:df,_sigmas:ha}=yb(),pf=new ye,cu=null,zn=(1+Math.sqrt(5))/2,ws=1/zn,ff=[new P(1,1,1),new P(-1,1,1),new P(1,1,-1),new P(-1,1,-1),new P(0,zn,ws),new P(0,zn,-ws),new P(ws,0,zn),new P(-ws,0,zn),new P(zn,ws,0),new P(-zn,ws,0)],Ia=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=xb(vs),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,n=100){cu=this._renderer.getRenderTarget();let s=this._allocateTargets();return this._sceneToCubeUV(e,i,n,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapShader===null&&(this._cubemapShader=yf(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){this._equirectShader===null&&(this._equirectShader=gf(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose(),this._cubemapShader!==null&&this._cubemapShader.dispose(),this._equirectShader!==null&&this._equirectShader.dispose();for(let e=0;e<_r.length;e++)_r[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(cu),e.scissorTest=!1,da(e,0,0,e.width,e.height)}_fromTexture(e,t){cu=this._renderer.getRenderTarget();let i=t||this._allocateTargets(e);return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(e){let t={magFilter:Rt,minFilter:Rt,generateMipmaps:!1,type:Cs,format:Nt,encoding:bn,depthBuffer:!1},i=mf(t);return i.depthBuffer=!e,this._pingPongRenderTarget===null&&(this._pingPongRenderTarget=mf(t)),i}_compileMaterial(e){let t=new pt(_r[0],e);this._renderer.compile(t,lu)}_sceneToCubeUV(e,t,i,n){let a=new Et(90,1,t,i),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,d=u.toneMapping;u.getClearColor(pf),u.toneMapping=gn,u.autoClear=!1;let p=new zr({name:"PMREM.Background",side:xt,depthWrite:!1,depthTest:!1}),m=new pt(new Vr,p),y=!1,x=e.background;x?x.isColor&&(p.color.copy(x),e.background=null,y=!0):(p.color.copy(pf),y=!0);for(let g=0;g<6;g++){let f=g%3;f===0?(a.up.set(0,l[g],0),a.lookAt(c[g],0,0)):f===1?(a.up.set(0,0,l[g]),a.lookAt(0,c[g],0)):(a.up.set(0,l[g],0),a.lookAt(0,0,c[g])),da(n,f*Di,g>2?Di:0,Di,Di),u.setRenderTarget(n),y&&u.render(m,a),u.render(e,a)}m.geometry.dispose(),m.material.dispose(),u.toneMapping=d,u.autoClear=h,e.background=x}_textureToCubeUV(e,t){let i=this._renderer,n=e.mapping===co||e.mapping===uo;n?(this._cubemapShader===null&&(this._cubemapShader=yf()),this._cubemapShader.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectShader===null&&(this._equirectShader=gf());let s=n?this._cubemapShader:this._equirectShader,o=new pt(_r[0],s),a=s.uniforms;a.envMap.value=e,n||a.texelSize.value.set(1/e.image.width,1/e.image.height),da(t,0,0,3*Di,2*Di),i.setRenderTarget(t),i.render(o,lu)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let n=1;nvs&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${vs}`);let g=[],f=0;for(let M=0;Mxn-Ls?n-xn+Ls:0);da(t,w,_,3*E,2*E),l.setRenderTarget(t),l.render(h,lu)}};function yb(){let r=[],e=[],t=[],i=xn;for(let n=0;nxn-Ls?o=fm[n-xn+Ls-1]:n===0&&(o=0),t.push(o);let a=1/(s-1),l=-a/2,c=1+a/2,u=[l,l,c,l,c,c,l,l,c,c,l,c],h=6,d=6,p=3,m=2,y=1,x=new Float32Array(p*d*h),g=new Float32Array(m*d*h),f=new Float32Array(y*d*h);for(let w=0;w2?0:-1,T=[_,M,0,_+2/3,M,0,_+2/3,M+1,0,_,M,0,_+2/3,M+1,0,_,M+1,0];x.set(T,p*d*w),g.set(u,m*d*w);let z=[w,w,w,w,w,w];f.set(z,y*d*w)}let E=new Ke;E.setAttribute("position",new ht(x,p)),E.setAttribute("uv",new ht(g,m)),E.setAttribute("faceIndex",new ht(f,y)),r.push(E),i>Ls&&i--}return{_lodPlanes:r,_sizeLods:e,_sigmas:t}}function mf(r){let e=new Ht(3*Di,3*Di,r);return e.texture.mapping=nl,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function da(r,e,t,i,n){r.viewport.set(e,t,i,n),r.scissor.set(e,t,i,n)}function xb(r){let e=new Float32Array(r),t=new P(0,1,0);return new zs({name:"SphericalGaussianBlur",defines:{n:r},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:t}},vertexShader:Nh(),fragmentShader:`
precision mediump float;
precision mediump int;
@@ -2962,7 +2962,7 @@ void main() {
gl_Position = vec4( position, 1.0 );
}
- `}function vb(r){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){let l=a.mapping,c=l===vu||l===wu,u=l===co||l===uo;if(c||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let h=e.get(a);return t===null&&(t=new Ia(r)),h=c?t.fromEquirectangular(a,h):t.fromCubemap(a,h),e.set(a,h),h.texture}else{if(e.has(a))return e.get(a).texture;{let h=a.image;if(c&&h&&h.height>0||u&&h&&n(h)){t===null&&(t=new Ia(r));let d=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,d),a.addEventListener("dispose",s),d.texture}else return null}}}return a}function n(a){let l=0,c=6;for(let u=0;ue.maxTextureSize&&(z=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);let W=new Float32Array(T*z*4*m),A=new Wr(W,T,z,m);A.format=Nt,A.type=Vn,A.needsUpdate=!0;let v=M*4;for(let S=0;S0)return r;let n=e*t,s=vf[n];if(s===void 0&&(s=new Float32Array(n),vf[n]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,r[o].toArray(s,a)}return s}function kt(r,e){if(r.length!==e.length)return!1;for(let t=0,i=r.length;t0||u&&h&&n(h)){t===null&&(t=new Ia(r));let d=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,d),a.addEventListener("dispose",s),d.texture}else return null}}}return a}function n(a){let l=0,c=6;for(let u=0;ue.maxTextureSize&&(z=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);let W=new Float32Array(T*z*4*m),A=new Wr(W,T,z,m);A.format=Nt,A.type=Vn,A.needsUpdate=!0;let v=M*4;for(let S=0;S0)return r;let n=e*t,s=vf[n];if(s===void 0&&(s=new Float32Array(n),vf[n]=s),e!==0){i.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,r[o].toArray(s,a)}return s}function kt(r,e){if(r.length!==e.length)return!1;for(let t=0,i=r.length;tu||n.y>u)&&(n.x>u&&(s.x=Math.floor(u/L.x),n.x=s.x*L.x,B.mapSize.x=s.x),n.y>u&&(s.y=Math.floor(u/L.y),n.y=s.y*L.y,B.mapSize.y=s.y)),B.map===null&&!B.isPointLightShadow&&this.type===Tr){let N={minFilter:Ft,magFilter:Ft,format:Nt};B.map=new Ht(n.x,n.y,N),B.map.texture.name=S.name+".shadowMap",B.mapPass=new Ht(n.x,n.y,N),B.camera.updateProjectionMatrix()}if(B.map===null){let N={minFilter:vt,magFilter:vt,format:Nt};B.map=new Ht(n.x,n.y,N),B.map.texture.name=S.name+".shadowMap",B.camera.updateProjectionMatrix()}r.setRenderTarget(B.map),r.clear();let C=B.getViewportCount();for(let N=0;N0){let S=v.uuid,B=M.uuid,L=c[S];L===void 0&&(L={},c[S]=L);let C=L[B];C===void 0&&(C=v.clone(),L[B]=C),v=C}return v.visible=M.visible,v.wireframe=M.wireframe,A===Tr?v.side=M.shadowSide!==null?M.shadowSide:M.side:v.side=M.shadowSide!==null?M.shadowSide:h[M.side],v.alphaMap=M.alphaMap,v.alphaTest=M.alphaTest,v.clipShadows=M.clipShadows,v.clippingPlanes=M.clippingPlanes,v.clipIntersection=M.clipIntersection,v.displacementMap=M.displacementMap,v.displacementScale=M.displacementScale,v.displacementBias=M.displacementBias,v.wireframeLinewidth=M.wireframeLinewidth,v.linewidth=M.linewidth,T.isPointLight===!0&&v.isMeshDistanceMaterial===!0&&(v.referencePosition.setFromMatrixPosition(T.matrixWorld),v.nearDistance=z,v.farDistance=W),v}function E(w,_,M,T,z){if(w.visible===!1)return;if(w.layers.test(_.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&z===Tr)&&(!w.frustumCulled||i.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,w.matrixWorld);let v=e.update(w),R=w.material;if(Array.isArray(R)){let S=v.groups;for(let B=0,L=S.length;B=1):C.indexOf("OpenGL ES")!==-1&&(L=parseFloat(/^OpenGL ES (\d)/.exec(C)[1]),B=L>=2);let N=null,k={},V=r.getParameter(3088),U=r.getParameter(2978),q=new $e().fromArray(V),j=new $e().fromArray(U);function ne(O,ge,pe){let Me=new Uint8Array(4),K=r.createTexture();r.bindTexture(O,K),r.texParameteri(O,10241,9728),r.texParameteri(O,10240,9728);for(let _e=0;_ese||I.height>se)&&(xe=se/Math.max(I.width,I.height)),xe<1||D===!0)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap){let Y=D?bv:Math.floor,be=Y(xe*I.width),ve=Y(xe*I.height);y===void 0&&(y=g(be,ve));let he=J?g(be,ve):y;return he.width=be,he.height=ve,he.getContext("2d").drawImage(I,0,0,be,ve),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+I.width+"x"+I.height+") to ("+be+"x"+ve+")."),he}else return"data"in I&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+I.width+"x"+I.height+")."),I;return I}function E(I){return Qp(I.width)&&Qp(I.height)}function w(I){return a?!1:I.wrapS!==Kt||I.wrapT!==Kt||I.minFilter!==vt&&I.minFilter!==Ft}function _(I,D){return I.generateMipmaps&&D&&I.minFilter!==vt&&I.minFilter!==Ft}function M(I){r.generateMipmap(I)}function T(I,D,J,se,xe=!1){if(a===!1)return D;if(I!==null){if(r[I]!==void 0)return r[I];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let Y=D;return D===6403&&(J===5126&&(Y=33326),J===5131&&(Y=33325),J===5121&&(Y=33321)),D===33319&&(J===5126&&(Y=33328),J===5131&&(Y=33327),J===5121&&(Y=33323)),D===6408&&(J===5126&&(Y=34836),J===5131&&(Y=34842),J===5121&&(Y=se===tt&&xe===!1?35907:32856),J===32819&&(Y=32854),J===32820&&(Y=32855)),(Y===33325||Y===33326||Y===33327||Y===33328||Y===34842||Y===34836)&&e.get("EXT_color_buffer_float"),Y}function z(I,D,J){return _(I,J)===!0||I.isFramebufferTexture&&I.minFilter!==vt&&I.minFilter!==Ft?Math.log2(Math.max(D.width,D.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?D.mipmaps.length:1}function W(I){return I===vt||I===Cp||I===Rp?9728:9729}function A(I){let D=I.target;D.removeEventListener("dispose",A),R(D),D.isVideoTexture&&m.delete(D),o.memory.textures--}function v(I){let D=I.target;D.removeEventListener("dispose",v),S(D)}function R(I){let D=i.get(I);D.__webglInit!==void 0&&(r.deleteTexture(D.__webglTexture),i.remove(I))}function S(I){let D=I.texture,J=i.get(I),se=i.get(D);if(I){if(se.__webglTexture!==void 0&&(r.deleteTexture(se.__webglTexture),o.memory.textures--),I.depthTexture&&I.depthTexture.dispose(),I.isWebGLCubeRenderTarget)for(let xe=0;xe<6;xe++)r.deleteFramebuffer(J.__webglFramebuffer[xe]),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer[xe]);else r.deleteFramebuffer(J.__webglFramebuffer),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&r.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer&&r.deleteRenderbuffer(J.__webglColorRenderbuffer),J.__webglDepthRenderbuffer&&r.deleteRenderbuffer(J.__webglDepthRenderbuffer);if(I.isWebGLMultipleRenderTargets)for(let xe=0,Y=D.length;xe=l&&console.warn("THREE.WebGLTextures: Trying to use "+I+" texture units while this GPU supports only "+l),B+=1,I}function N(I,D){let J=i.get(I);if(I.isVideoTexture&&de(I),I.version>0&&J.__version!==I.version){let se=I.image;if(se===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(se.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{H(J,I,D);return}}t.activeTexture(33984+D),t.bindTexture(3553,J.__webglTexture)}function k(I,D){let J=i.get(I);if(I.version>0&&J.__version!==I.version){H(J,I,D);return}t.activeTexture(33984+D),t.bindTexture(35866,J.__webglTexture)}function V(I,D){let J=i.get(I);if(I.version>0&&J.__version!==I.version){H(J,I,D);return}t.activeTexture(33984+D),t.bindTexture(32879,J.__webglTexture)}function U(I,D){let J=i.get(I);if(I.version>0&&J.__version!==I.version){Te(J,I,D);return}t.activeTexture(33984+D),t.bindTexture(34067,J.__webglTexture)}let q={[bu]:10497,[Kt]:33071,[_u]:33648},j={[vt]:9728,[Cp]:9984,[Rp]:9986,[Ft]:9729,[Zx]:9985,[sl]:9987};function ne(I,D,J){if(J?(r.texParameteri(I,10242,q[D.wrapS]),r.texParameteri(I,10243,q[D.wrapT]),(I===32879||I===35866)&&r.texParameteri(I,32882,q[D.wrapR]),r.texParameteri(I,10240,j[D.magFilter]),r.texParameteri(I,10241,j[D.minFilter])):(r.texParameteri(I,10242,33071),r.texParameteri(I,10243,33071),(I===32879||I===35866)&&r.texParameteri(I,32882,33071),(D.wrapS!==Kt||D.wrapT!==Kt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(I,10240,W(D.magFilter)),r.texParameteri(I,10241,W(D.minFilter)),D.minFilter!==vt&&D.minFilter!==Ft&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){let se=e.get("EXT_texture_filter_anisotropic");if(D.type===Vn&&e.has("OES_texture_float_linear")===!1||a===!1&&D.type===Cs&&e.has("OES_texture_half_float_linear")===!1)return;(D.anisotropy>1||i.get(D).__currentAnisotropy)&&(r.texParameterf(I,se.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,n.getMaxAnisotropy())),i.get(D).__currentAnisotropy=D.anisotropy)}}function ae(I,D){I.__webglInit===void 0&&(I.__webglInit=!0,D.addEventListener("dispose",A),I.__webglTexture=r.createTexture(),o.memory.textures++)}function H(I,D,J){let se=3553;D.isDataTexture2DArray&&(se=35866),D.isDataTexture3D&&(se=32879),ae(I,D),t.activeTexture(33984+J),t.bindTexture(se,I.__webglTexture),r.pixelStorei(37440,D.flipY),r.pixelStorei(37441,D.premultiplyAlpha),r.pixelStorei(3317,D.unpackAlignment),r.pixelStorei(37443,0);let xe=w(D)&&E(D.image)===!1,Y=f(D.image,xe,!1,u);Y=Se(D,Y);let be=E(Y)||a,ve=s.convert(D.format,D.encoding),he=s.convert(D.type),le=T(D.internalFormat,ve,he,D.encoding,D.isVideoTexture);ne(se,D,be);let Le,O=D.mipmaps,ge=a&&D.isVideoTexture!==!0,pe=I.__version===void 0,Me=z(D,Y,be);if(D.isDepthTexture)le=6402,a?D.type===Vn?le=36012:D.type===Ma?le=33190:D.type===Rs?le=35056:le=33189:D.type===Vn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),D.format===Hn&&le===6402&&D.type!==Ir&&D.type!==Ma&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),D.type=Ir,he=s.convert(D.type)),D.format===Ps&&le===6402&&(le=34041,D.type!==Rs&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),D.type=Rs,he=s.convert(D.type))),ge&&pe?t.texStorage2D(3553,1,le,Y.width,Y.height):t.texImage2D(3553,0,le,Y.width,Y.height,0,ve,he,null);else if(D.isDataTexture)if(O.length>0&&be){ge&&pe&&t.texStorage2D(3553,Me,le,O[0].width,O[0].height);for(let K=0,_e=O.length;K<_e;K++)Le=O[K],ge?t.texSubImage2D(3553,0,0,0,Le.width,Le.height,ve,he,Le.data):t.texImage2D(3553,K,le,Le.width,Le.height,0,ve,he,Le.data);D.generateMipmaps=!1}else ge?(pe&&t.texStorage2D(3553,Me,le,Y.width,Y.height),t.texSubImage2D(3553,0,0,0,Y.width,Y.height,ve,he,Y.data)):t.texImage2D(3553,0,le,Y.width,Y.height,0,ve,he,Y.data);else if(D.isCompressedTexture){ge&&pe&&t.texStorage2D(3553,Me,le,O[0].width,O[0].height);for(let K=0,_e=O.length;K<_e;K++)Le=O[K],D.format!==Nt?ve!==null?ge?t.compressedTexSubImage2D(3553,K,0,0,Le.width,Le.height,ve,Le.data):t.compressedTexImage2D(3553,K,le,Le.width,Le.height,0,Le.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?t.texSubImage2D(3553,K,0,0,Le.width,Le.height,ve,he,Le.data):t.texImage2D(3553,K,le,Le.width,Le.height,0,ve,he,Le.data)}else if(D.isDataTexture2DArray)ge?(pe&&t.texStorage3D(35866,Me,le,Y.width,Y.height,Y.depth),t.texSubImage3D(35866,0,0,0,0,Y.width,Y.height,Y.depth,ve,he,Y.data)):t.texImage3D(35866,0,le,Y.width,Y.height,Y.depth,0,ve,he,Y.data);else if(D.isDataTexture3D)ge?(pe&&t.texStorage3D(32879,Me,le,Y.width,Y.height,Y.depth),t.texSubImage3D(32879,0,0,0,0,Y.width,Y.height,Y.depth,ve,he,Y.data)):t.texImage3D(32879,0,le,Y.width,Y.height,Y.depth,0,ve,he,Y.data);else if(D.isFramebufferTexture)ge&&pe?t.texStorage2D(3553,Me,le,Y.width,Y.height):t.texImage2D(3553,0,le,Y.width,Y.height,0,ve,he,null);else if(O.length>0&&be){ge&&pe&&t.texStorage2D(3553,Me,le,O[0].width,O[0].height);for(let K=0,_e=O.length;K<_e;K++)Le=O[K],ge?t.texSubImage2D(3553,K,0,0,ve,he,Le):t.texImage2D(3553,K,le,ve,he,Le);D.generateMipmaps=!1}else ge?(pe&&t.texStorage2D(3553,Me,le,Y.width,Y.height),t.texSubImage2D(3553,0,0,0,ve,he,Y)):t.texImage2D(3553,0,le,ve,he,Y);_(D,be)&&M(se),I.__version=D.version,D.onUpdate&&D.onUpdate(D)}function Te(I,D,J){if(D.image.length!==6)return;ae(I,D),t.activeTexture(33984+J),t.bindTexture(34067,I.__webglTexture),r.pixelStorei(37440,D.flipY),r.pixelStorei(37441,D.premultiplyAlpha),r.pixelStorei(3317,D.unpackAlignment),r.pixelStorei(37443,0);let se=D&&(D.isCompressedTexture||D.image[0].isCompressedTexture),xe=D.image[0]&&D.image[0].isDataTexture,Y=[];for(let K=0;K<6;K++)!se&&!xe?Y[K]=f(D.image[K],!1,!0,c):Y[K]=xe?D.image[K].image:D.image[K],Y[K]=Se(D,Y[K]);let be=Y[0],ve=E(be)||a,he=s.convert(D.format,D.encoding),le=s.convert(D.type),Le=T(D.internalFormat,he,le,D.encoding),O=a&&D.isVideoTexture!==!0,ge=I.__version===void 0,pe=z(D,be,ve);ne(34067,D,ve);let Me;if(se){O&&ge&&t.texStorage2D(34067,pe,Le,be.width,be.height);for(let K=0;K<6;K++){Me=Y[K].mipmaps;for(let _e=0;_e0&&pe++,t.texStorage2D(34067,pe,Le,Y[0].width,Y[0].height));for(let K=0;K<6;K++)if(xe){O?t.texSubImage2D(34069+K,0,0,0,Y[K].width,Y[K].height,he,le,Y[K].data):t.texImage2D(34069+K,0,Le,Y[K].width,Y[K].height,0,he,le,Y[K].data);for(let _e=0;_ep+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=p-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));return a!==null&&(a.visible=n!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}},$r=class extends lt{constructor(e,t,i,n,s,o,a,l,c,u){if(u=u!==void 0?u:Hn,u!==Hn&&u!==Ps)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===Hn&&(i=Ir),i===void 0&&u===Ps&&(i=Rs),super(null,n,s,o,a,l,u,i,c),this.image={width:e,height:t},this.magFilter=a!==void 0?a:vt,this.minFilter=l!==void 0?l:vt,this.flipY=!1,this.generateMipmaps=!1}};$r.prototype.isDepthTexture=!0;var Ru=class extends Xi{constructor(e,t){super();let i=this,n=null,s=1,o=null,a="local-floor",l=e.extensions.has("WEBGL_multisampled_render_to_texture"),c=null,u=null,h=null,d=null,p=!1,m=null,y=t.getContextAttributes(),x=null,g=null,f=[],E=new Map,w=new Et;w.layers.enable(1),w.viewport=new $e;let _=new Et;_.layers.enable(2),_.viewport=new $e;let M=[w,_],T=new za;T.layers.enable(1),T.layers.enable(2);let z=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(U){let q=f[U];return q===void 0&&(q=new Fr,f[U]=q),q.getTargetRaySpace()},this.getControllerGrip=function(U){let q=f[U];return q===void 0&&(q=new Fr,f[U]=q),q.getGripSpace()},this.getHand=function(U){let q=f[U];return q===void 0&&(q=new Fr,f[U]=q),q.getHandSpace()};function A(U){let q=E.get(U.inputSource);q&&q.dispatchEvent({type:U.type,data:U.inputSource})}function v(){E.forEach(function(U,q){U.disconnect(q)}),E.clear(),z=null,W=null,e.setRenderTarget(x),d=null,h=null,u=null,n=null,g=null,V.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(U){s=U,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(U){a=U,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return o},this.getBaseLayer=function(){return h!==null?h:d},this.getBinding=function(){return u},this.getFrame=function(){return m},this.getSession=function(){return n},this.setSession=async function(U){if(n=U,n!==null){if(x=e.getRenderTarget(),n.addEventListener("select",A),n.addEventListener("selectstart",A),n.addEventListener("selectend",A),n.addEventListener("squeeze",A),n.addEventListener("squeezestart",A),n.addEventListener("squeezeend",A),n.addEventListener("end",v),n.addEventListener("inputsourceschange",R),y.xrCompatible!==!0&&await t.makeXRCompatible(),n.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let q={antialias:n.renderState.layers===void 0?y.antialias:!0,alpha:y.alpha,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(n,t,q),n.updateRenderState({baseLayer:d}),g=new Ht(d.framebufferWidth,d.framebufferHeight,{format:Nt,type:yn,encoding:e.outputEncoding})}else{p=y.antialias;let q=null,j=null,ne=null;y.depth&&(ne=y.stencil?35056:33190,q=y.stencil?Ps:Hn,j=y.stencil?Rs:Ir);let ae={colorFormat:e.outputEncoding===tt?35907:32856,depthFormat:ne,scaleFactor:s};u=new XRWebGLBinding(n,t),h=u.createProjectionLayer(ae),n.updateRenderState({layers:[h]}),p?g=new Or(h.textureWidth,h.textureHeight,{format:Nt,type:yn,depthTexture:new $r(h.textureWidth,h.textureHeight,j,void 0,void 0,void 0,void 0,void 0,void 0,q),stencilBuffer:y.stencil,ignoreDepth:h.ignoreDepthValues,useRenderToTexture:l,encoding:e.outputEncoding}):g=new Ht(h.textureWidth,h.textureHeight,{format:Nt,type:yn,depthTexture:new $r(h.textureWidth,h.textureHeight,j,void 0,void 0,void 0,void 0,void 0,void 0,q),stencilBuffer:y.stencil,ignoreDepth:h.ignoreDepthValues,encoding:e.outputEncoding})}g.isXRRenderTarget=!0,this.setFoveation(1),o=await n.requestReferenceSpace(a),V.setContext(n),V.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function R(U){let q=n.inputSources;for(let j=0;j0&&(g.alphaTest.value=f.alphaTest);let E=r.get(f).envMap;E&&(g.envMap.value=E,g.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=f.reflectivity,g.ior.value=f.ior,g.refractionRatio.value=f.refractionRatio),f.lightMap&&(g.lightMap.value=f.lightMap,g.lightMapIntensity.value=f.lightMapIntensity),f.aoMap&&(g.aoMap.value=f.aoMap,g.aoMapIntensity.value=f.aoMapIntensity);let w;f.map?w=f.map:f.specularMap?w=f.specularMap:f.displacementMap?w=f.displacementMap:f.normalMap?w=f.normalMap:f.bumpMap?w=f.bumpMap:f.roughnessMap?w=f.roughnessMap:f.metalnessMap?w=f.metalnessMap:f.alphaMap?w=f.alphaMap:f.emissiveMap?w=f.emissiveMap:f.clearcoatMap?w=f.clearcoatMap:f.clearcoatNormalMap?w=f.clearcoatNormalMap:f.clearcoatRoughnessMap?w=f.clearcoatRoughnessMap:f.specularIntensityMap?w=f.specularIntensityMap:f.specularColorMap?w=f.specularColorMap:f.transmissionMap?w=f.transmissionMap:f.thicknessMap?w=f.thicknessMap:f.sheenColorMap?w=f.sheenColorMap:f.sheenRoughnessMap&&(w=f.sheenRoughnessMap),w!==void 0&&(w.isWebGLRenderTarget&&(w=w.texture),w.matrixAutoUpdate===!0&&w.updateMatrix(),g.uvTransform.value.copy(w.matrix));let _;f.aoMap?_=f.aoMap:f.lightMap&&(_=f.lightMap),_!==void 0&&(_.isWebGLRenderTarget&&(_=_.texture),_.matrixAutoUpdate===!0&&_.updateMatrix(),g.uv2Transform.value.copy(_.matrix))}function n(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity}function s(g,f){g.dashSize.value=f.dashSize,g.totalSize.value=f.dashSize+f.gapSize,g.scale.value=f.scale}function o(g,f,E,w){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*E,g.scale.value=w*.5,f.map&&(g.map.value=f.map),f.alphaMap&&(g.alphaMap.value=f.alphaMap),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);let _;f.map?_=f.map:f.alphaMap&&(_=f.alphaMap),_!==void 0&&(_.matrixAutoUpdate===!0&&_.updateMatrix(),g.uvTransform.value.copy(_.matrix))}function a(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.rotation.value=f.rotation,f.map&&(g.map.value=f.map),f.alphaMap&&(g.alphaMap.value=f.alphaMap),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);let E;f.map?E=f.map:f.alphaMap&&(E=f.alphaMap),E!==void 0&&(E.matrixAutoUpdate===!0&&E.updateMatrix(),g.uvTransform.value.copy(E.matrix))}function l(g,f){f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap)}function c(g,f){g.specular.value.copy(f.specular),g.shininess.value=Math.max(f.shininess,1e-4),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap),f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===xt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===xt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}function u(g,f){f.gradientMap&&(g.gradientMap.value=f.gradientMap),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap),f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===xt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===xt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}function h(g,f){g.roughness.value=f.roughness,g.metalness.value=f.metalness,f.roughnessMap&&(g.roughnessMap.value=f.roughnessMap),f.metalnessMap&&(g.metalnessMap.value=f.metalnessMap),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap),f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===xt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===xt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),r.get(f).envMap&&(g.envMapIntensity.value=f.envMapIntensity)}function d(g,f,E){h(g,f),g.ior.value=f.ior,f.sheen>0&&(g.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),g.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(g.sheenColorMap.value=f.sheenColorMap),f.sheenRoughnessMap&&(g.sheenRoughnessMap.value=f.sheenRoughnessMap)),f.clearcoat>0&&(g.clearcoat.value=f.clearcoat,g.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(g.clearcoatMap.value=f.clearcoatMap),f.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap),f.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),g.clearcoatNormalMap.value=f.clearcoatNormalMap,f.side===xt&&g.clearcoatNormalScale.value.negate())),f.transmission>0&&(g.transmission.value=f.transmission,g.transmissionSamplerMap.value=E.texture,g.transmissionSamplerSize.value.set(E.width,E.height),f.transmissionMap&&(g.transmissionMap.value=f.transmissionMap),g.thickness.value=f.thickness,f.thicknessMap&&(g.thicknessMap.value=f.thicknessMap),g.attenuationDistance.value=f.attenuationDistance,g.attenuationColor.value.copy(f.attenuationColor)),g.specularIntensity.value=f.specularIntensity,g.specularColor.value.copy(f.specularColor),f.specularIntensityMap&&(g.specularIntensityMap.value=f.specularIntensityMap),f.specularColorMap&&(g.specularColorMap.value=f.specularColorMap)}function p(g,f){f.matcap&&(g.matcap.value=f.matcap),f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===xt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===xt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}function m(g,f){f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}function y(g,f){f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),g.referencePosition.value.copy(f.referencePosition),g.nearDistance.value=f.nearDistance,g.farDistance.value=f.farDistance}function x(g,f){f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===xt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===xt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}return{refreshFogUniforms:e,refreshMaterialUniforms:t}}function K1(){let r=kr("canvas");return r.style.display="block",r}function qe(r={}){let e=r.canvas!==void 0?r.canvas:K1(),t=r.context!==void 0?r.context:null,i=r.alpha!==void 0?r.alpha:!1,n=r.depth!==void 0?r.depth:!0,s=r.stencil!==void 0?r.stencil:!0,o=r.antialias!==void 0?r.antialias:!1,a=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,l=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,c=r.powerPreference!==void 0?r.powerPreference:"default",u=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,h=null,d=null,p=[],m=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=bn,this.physicallyCorrectLights=!1,this.toneMapping=gn,this.toneMappingExposure=1;let y=this,x=!1,g=0,f=0,E=null,w=-1,_=null,M=new $e,T=new $e,z=null,W=e.width,A=e.height,v=1,R=null,S=null,B=new $e(0,0,W,A),L=new $e(0,0,W,A),C=!1,N=new Os,k=!1,V=!1,U=null,q=new Ee,j=new P,ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ae(){return E===null?v:1}let H=t;function Te(F,G){for(let X=0;X0?d=m[m.length-1]:d=null,p.pop(),p.length>0?h=p[p.length-1]:h=null};function ot(F,G,X,$){if(F.visible===!1)return;if(F.layers.test(G.layers)){if(F.isGroup)X=F.renderOrder;else if(F.isLOD)F.autoUpdate===!0&&F.update(G);else if(F.isLight)d.pushLight(F),F.castShadow&&d.pushShadow(F);else if(F.isSprite){if(!F.frustumCulled||N.intersectsSprite(F)){$&&j.setFromMatrixPosition(F.matrixWorld).applyMatrix4(q);let Be=Se.update(F),Ie=F.material;Ie.visible&&h.push(F,Be,Ie,X,j.z,null)}}else if((F.isMesh||F.isLine||F.isPoints)&&(F.isSkinnedMesh&&F.skeleton.frame!==Ce.render.frame&&(F.skeleton.update(),F.skeleton.frame=Ce.render.frame),!F.frustumCulled||N.intersectsObject(F))){$&&j.setFromMatrixPosition(F.matrixWorld).applyMatrix4(q);let Be=Se.update(F),Ie=F.material;if(Array.isArray(Ie)){let Pe=Be.groups;for(let We=0,ze=Pe.length;We0&&Pi(Q,G,X),$&&oe.viewport(M.copy($)),Q.length>0&&Fo(Q,G,X),Fe.length>0&&Fo(Fe,G,X),Be.length>0&&Fo(Be,G,X)}function Pi(F,G,X){if(U===null){let Be=o===!0&&we.isWebGL2===!0?Or:Ht;U=new Be(1024,1024,{generateMipmaps:!0,type:be.convert(Cs)!==null?Cs:yn,minFilter:sl,magFilter:vt,wrapS:Kt,wrapT:Kt,useRenderToTexture:ue.has("WEBGL_multisampled_render_to_texture")})}let $=y.getRenderTarget();y.setRenderTarget(U),y.clear();let Q=y.toneMapping;y.toneMapping=gn,Fo(F,G,X),y.toneMapping=Q,Z.updateMultisampleRenderTarget(U),Z.updateRenderTargetMipmap(U),y.setRenderTarget($)}function Fo(F,G,X){let $=G.isScene===!0?G.overrideMaterial:null;for(let Q=0,Fe=F.length;Q=0&&G<=F.width-$&&X>=0&&X<=F.height-Q&&H.readPixels(G,X,$,Q,be.convert(We),be.convert(ze),Fe):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{let Pe=E!==null?Ae.get(E).__webglFramebuffer:null;oe.bindFramebuffer(36160,Pe)}}},this.copyFramebufferToTexture=function(F,G,X=0){if(G.isFramebufferTexture!==!0){console.error("THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.");return}let $=Math.pow(2,-X),Q=Math.floor(G.image.width*$),Fe=Math.floor(G.image.height*$);Z.setTexture2D(G,0),H.copyTexSubImage2D(3553,X,0,0,F.x,F.y,Q,Fe),oe.unbindTexture()},this.copyTextureToTexture=function(F,G,X,$=0){let Q=G.image.width,Fe=G.image.height,Be=be.convert(X.format),Ie=be.convert(X.type);Z.setTexture2D(X,0),H.pixelStorei(37440,X.flipY),H.pixelStorei(37441,X.premultiplyAlpha),H.pixelStorei(3317,X.unpackAlignment),G.isDataTexture?H.texSubImage2D(3553,$,F.x,F.y,Q,Fe,Be,Ie,G.image.data):G.isCompressedTexture?H.compressedTexSubImage2D(3553,$,F.x,F.y,G.mipmaps[0].width,G.mipmaps[0].height,Be,G.mipmaps[0].data):H.texSubImage2D(3553,$,F.x,F.y,Be,Ie,G.image),$===0&&X.generateMipmaps&&H.generateMipmap(3553),oe.unbindTexture()},this.copyTextureToTexture3D=function(F,G,X,$,Q=0){if(y.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Fe=F.max.x-F.min.x+1,Be=F.max.y-F.min.y+1,Ie=F.max.z-F.min.z+1,Pe=be.convert($.format),We=be.convert($.type),ze;if($.isDataTexture3D)Z.setTexture3D($,0),ze=32879;else if($.isDataTexture2DArray)Z.setTexture2DArray($,0),ze=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}H.pixelStorei(37440,$.flipY),H.pixelStorei(37441,$.premultiplyAlpha),H.pixelStorei(3317,$.unpackAlignment);let Ve=H.getParameter(3314),at=H.getParameter(32878),Bn=H.getParameter(3316),ns=H.getParameter(3315),Ue=H.getParameter(32877),vi=X.isCompressedTexture?X.mipmaps[0]:X.image;H.pixelStorei(3314,vi.width),H.pixelStorei(32878,vi.height),H.pixelStorei(3316,F.min.x),H.pixelStorei(3315,F.min.y),H.pixelStorei(32877,F.min.z),X.isDataTexture||X.isDataTexture3D?H.texSubImage3D(ze,Q,G.x,G.y,G.z,Fe,Be,Ie,Pe,We,vi.data):X.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),H.compressedTexSubImage3D(ze,Q,G.x,G.y,G.z,Fe,Be,Ie,Pe,vi.data)):H.texSubImage3D(ze,Q,G.x,G.y,G.z,Fe,Be,Ie,Pe,We,vi),H.pixelStorei(3314,Ve),H.pixelStorei(32878,at),H.pixelStorei(3316,Bn),H.pixelStorei(3315,ns),H.pixelStorei(32877,Ue),Q===0&&$.generateMipmaps&&H.generateMipmap(ze),oe.unbindTexture()},this.initTexture=function(F){Z.setTexture2D(F,0),oe.unbindTexture()},this.resetState=function(){g=0,f=0,E=null,oe.reset(),ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}qe.prototype.isWebGLRenderer=!0;var Fu=class extends qe{};Fu.prototype.isWebGL1Renderer=!0;var Lu=class r{constructor(e,t=25e-5){this.name="",this.color=new ye(e),this.density=t}clone(){return new r(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}};Lu.prototype.isFogExp2=!0;var Bu=class r{constructor(e,t=1,i=1e3){this.name="",this.color=new ye(e),this.near=t,this.far=i}clone(){return new r(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}};Bu.prototype.isFog=!0;var Vs=class extends Ge{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}};Vs.prototype.isScene=!0;var Gn=class{constructor(e,t){this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Nr,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=pi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,s=this.stride;ne.far||t.push({distance:l,point:Er.clone(),uv:Bt.getUV(Er,pa,Sr,fa,Pf,hu,If,new ee),face:null,object:this})}copy(e){return super.copy(e),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};Pu.prototype.isSprite=!0;function ma(r,e,t,i,n,s){As.subVectors(r,t).addScalar(.5).multiply(i),n!==void 0?(Ar.x=s*As.x-n*As.y,Ar.y=n*As.x+s*As.y):Ar.copy(As),r.copy(e),r.x+=Ar.x,r.y+=Ar.y,r.applyMatrix4(Am)}var Nf=new P,kf=new $e,Of=new $e,Q1=new P,zf=new Ee,Ua=class extends pt{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Ee,this.bindMatrixInverse=new Ee}copy(e){return super.copy(e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new $e,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;il)continue;d.applyMatrix4(this.matrixWorld);let z=e.ray.origin.distanceTo(d);ze.far||t.push({distance:z,point:h.clone().applyMatrix4(this.matrixWorld),index:E,face:null,faceIndex:null,object:this})}}else{let g=Math.max(0,o.start),f=Math.min(x.count,o.start+o.count);for(let E=g,w=f-1;El)continue;d.applyMatrix4(this.matrixWorld);let M=e.ray.origin.distanceTo(d);Me.far||t.push({distance:M,point:h.clone().applyMatrix4(this.matrixWorld),index:E,face:null,faceIndex:null,object:this})}}}else i.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,i=Object.keys(t);if(i.length>0){let n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}};Yr.prototype.isLine=!0;var Wf=new P,$f=new P,Zr=class extends Yr{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.isBufferGeometry)if(e.index===null){let t=e.attributes.position,i=[];for(let n=0,s=t.count;n0){let n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}};Vu.prototype.isPoints=!0;function Xf(r,e,t,i,n,s,o){let a=zu.distanceSqToPoint(r);if(an.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}var Uu=class extends lt{constructor(e,t,i,n,s,o,a,l,c){super(e,t,i,n,s,o,a,l,c),this.minFilter=o!==void 0?o:Ft,this.magFilter=s!==void 0?s:Ft,this.generateMipmaps=!1;let u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};Uu.prototype.isVideoTexture=!0;var Hu=class extends lt{constructor(e,t,i){super({width:e,height:t}),this.format=i,this.magFilter=vt,this.minFilter=vt,this.generateMipmaps=!1,this.needsUpdate=!0}};Hu.prototype.isFramebufferTexture=!0;var Gu=class extends lt{constructor(e,t,i,n,s,o,a,l,c,u,h,d){super(null,o,a,l,c,u,n,s,h,d),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}};Gu.prototype.isCompressedTexture=!0;var qu=class extends lt{constructor(e,t,i,n,s,o,a,l,c){super(e,t,i,n,s,o,a,l,c),this.needsUpdate=!0}};qu.prototype.isCanvasTexture=!0;var oM=new P,aM=new P,lM=new P,cM=new Bt;var Gt=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,n=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(n),t.push(s),n=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),n=0,s=i.length,o;t?o=t:o=e*i[s-1];let a=0,l=s-1,c;for(;a<=l;)if(n=Math.floor(a+(l-a)/2),c=i[n]-o,c<0)a=n+1;else if(c>0)l=n-1;else{l=n;break}if(n=l,i[n]===o)return n/(s-1);let u=i[n],d=i[n+1]-u,p=(o-u)/d;return(n+p)/(s-1)}getTangent(e,t){let n=e-1e-4,s=e+1e-4;n<0&&(n=0),s>1&&(s=1);let o=this.getPoint(n),a=this.getPoint(s),l=t||(o.isVector2?new ee:new P);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new P,n=[],s=[],o=[],a=new P,l=new Ee;for(let p=0;p<=e;p++){let m=p/e;n[p]=this.getTangentAt(m,new P)}s[0]=new P,o[0]=new P;let c=Number.MAX_VALUE,u=Math.abs(n[0].x),h=Math.abs(n[0].y),d=Math.abs(n[0].z);u<=c&&(c=u,i.set(1,0,0)),h<=c&&(c=h,i.set(0,1,0)),d<=c&&i.set(0,0,1),a.crossVectors(n[0],i).normalize(),s[0].crossVectors(n[0],a),o[0].crossVectors(n[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(n[p-1],n[p]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(Ut(n[p-1].dot(n[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(a,m))}o[p].crossVectors(n[p],s[p])}if(t===!0){let p=Math.acos(Ut(s[0].dot(s[e]),-1,1));p/=e,n[0].dot(a.crossVectors(s[0],s[e]))>0&&(p=-p);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(n[m],p*m)),o[m].crossVectors(n[m],s[m])}return{tangents:n,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Us=class extends Gt{constructor(e=0,t=0,i=1,n=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=n,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t){let i=t||new ee,n=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)n;)s-=n;s0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=n[(a-1)%s]:(wa.subVectors(n[0],n[1]).add(n[0]),c=wa);let h=n[a%s],d=n[(a+1)%s];if(this.closed||a+2n.length-2?n.length-1:o+1],h=n[o>n.length-3?n.length-1:o+2];return i.set(Yf(a,l.x,c.x,u.x,h.x),Yf(a,l.y,c.y,u.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){let o=n[s]-i,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,n=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){let h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);let u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},Wn=class extends eo{constructor(e){super(e),this.uuid=pi(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,n=this.holes.length;i80*t){a=c=r[0],l=u=r[1];for(let m=t;mc&&(c=h),d>u&&(u=d);p=Math.max(c-a,u-l),p=p!==0?1/p:0}return to(s,o,t,a,l,p),o}};function Mm(r,e,t,i,n){let s,o;if(n===E_(r,e,t,i)>0)for(s=e;s=e;s-=i)o=Zf(s,r[s],r[s+1],o);return o&&ol(o,o.next)&&(no(o),o=o.next),o}function En(r,e){if(!r)return r;e||(e=r);let t=r,i;do if(i=!1,!t.steiner&&(ol(t,t.next)||rt(t.prev,t,t.next)===0)){if(no(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function to(r,e,t,i,n,s,o){if(!r)return;!o&&s&&y_(r,i,n,s);let a=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?c_(r,i,n,s):l_(r)){e.push(l.i/t),e.push(r.i/t),e.push(c.i/t),no(r),r=c.next,a=c.next;continue}if(r=c,r===a){o?o===1?(r=u_(En(r),e,t),to(r,e,t,i,n,s,2)):o===2&&h_(r,e,t,i,n,s):to(En(r),e,t,i,n,s,1);break}}}function l_(r){let e=r.prev,t=r,i=r.next;if(rt(e,t,i)>=0)return!1;let n=r.next.next;for(;n!==r.prev;){if(Ts(e.x,e.y,t.x,t.y,i.x,i.y,n.x,n.y)&&rt(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function c_(r,e,t,i){let n=r.prev,s=r,o=r.next;if(rt(n,s,o)>=0)return!1;let a=n.xs.x?n.x>o.x?n.x:o.x:s.x>o.x?s.x:o.x,u=n.y>s.y?n.y>o.y?n.y:o.y:s.y>o.y?s.y:o.y,h=ju(a,l,e,t,i),d=ju(c,u,e,t,i),p=r.prevZ,m=r.nextZ;for(;p&&p.z>=h&&m&&m.z<=d;){if(p!==r.prev&&p!==r.next&&Ts(n.x,n.y,s.x,s.y,o.x,o.y,p.x,p.y)&&rt(p.prev,p,p.next)>=0||(p=p.prevZ,m!==r.prev&&m!==r.next&&Ts(n.x,n.y,s.x,s.y,o.x,o.y,m.x,m.y)&&rt(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;p&&p.z>=h;){if(p!==r.prev&&p!==r.next&&Ts(n.x,n.y,s.x,s.y,o.x,o.y,p.x,p.y)&&rt(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;m&&m.z<=d;){if(m!==r.prev&&m!==r.next&&Ts(n.x,n.y,s.x,s.y,o.x,o.y,m.x,m.y)&&rt(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function u_(r,e,t){let i=r;do{let n=i.prev,s=i.next.next;!ol(n,s)&&Dm(n,i,i.next,s)&&io(n,s)&&io(s,n)&&(e.push(n.i/t),e.push(i.i/t),e.push(s.i/t),no(i),no(i.next),i=r=s),i=i.next}while(i!==r);return En(i)}function h_(r,e,t,i,n,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&w_(o,a)){let l=Tm(o,a);o=En(o,o.next),l=En(l,l.next),to(o,e,t,i,n,s),to(l,e,t,i,n,s);return}a=a.next}o=o.next}while(o!==r)}function d_(r,e,t,i){let n=[],s,o,a,l,c;for(s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){let d=t.x+(n-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>s){if(s=d,d===i){if(n===t.y)return t;if(n===t.next.y)return t.next}o=t.x=t.x&&t.x>=l&&i!==t.x&&Ts(no.x||t.x===o.x&&g_(o,t)))&&(o=t,u=h)),t=t.next;while(t!==a);return o}function g_(r,e){return rt(r.prev,r,e.prev)<0&&rt(e.next,r,r.next)<0}function y_(r,e,t,i){let n=r;do n.z===null&&(n.z=ju(n.x,n.y,e,t,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==r);n.prevZ.nextZ=null,n.prevZ=null,x_(n)}function x_(r){let e,t,i,n,s,o,a,l,c=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,i=t,a=0,e=0;e0||l>0&&i;)a!==0&&(l===0||!i||t.z<=i.z)?(n=t,t=t.nextZ,a--):(n=i,i=i.nextZ,l--),s?s.nextZ=n:r=n,n.prevZ=s,s=n;t=i}s.nextZ=null,c*=2}while(o>1);return r}function ju(r,e,t,i,n){return r=32767*(r-t)*n,e=32767*(e-i)*n,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function v_(r){let e=r,t=r;do(e.x=0&&(r-o)*(i-a)-(t-o)*(e-a)>=0&&(t-o)*(s-a)-(n-o)*(i-a)>=0}function w_(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!b_(r,e)&&(io(r,e)&&io(e,r)&&__(r,e)&&(rt(r.prev,r,e.prev)||rt(r,e.prev,e))||ol(r,e)&&rt(r.prev,r,r.next)>0&&rt(e.prev,e,e.next)>0)}function rt(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function ol(r,e){return r.x===e.x&&r.y===e.y}function Dm(r,e,t,i){let n=_a(rt(r,e,t)),s=_a(rt(r,e,i)),o=_a(rt(t,i,r)),a=_a(rt(t,i,e));return!!(n!==s&&o!==a||n===0&&ba(r,t,e)||s===0&&ba(r,i,e)||o===0&&ba(t,r,i)||a===0&&ba(t,e,i))}function ba(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function _a(r){return r>0?1:r<0?-1:0}function b_(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Dm(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function io(r,e){return rt(r.prev,r,r.next)<0?rt(r,e,r.next)>=0&&rt(r,r.prev,e)>=0:rt(r,e,r.prev)<0||rt(r,r.next,e)<0}function __(r,e){let t=r,i=!1,n=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&n<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==r);return i}function Tm(r,e){let t=new Xu(r.i,r.x,r.y),i=new Xu(e.i,e.x,e.y),n=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=n,n.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function Zf(r,e,t,i){let n=new Xu(r,e,t);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function no(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Xu(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function E_(r,e,t,i){let n=0;for(let s=e,o=t-i;s2&&r[e-1].equals(r[0])&&r.pop()}function Kf(r,e){for(let t=0;tNumber.EPSILON){let J=Math.sqrt(I),se=Math.sqrt(Ze*Ze+je*je),xe=ie.x-Oe/J,Y=ie.y+Re/J,be=te.x-je/se,ve=te.y+Ze/se,he=((be-xe)*je-(ve-Y)*Ze)/(Re*je-Oe*Ze);fe=xe+Re*he-Z.x,de=Y+Oe*he-Z.y;let le=fe*fe+de*de;if(le<=2)return new ee(fe,de);Se=Math.sqrt(le/2)}else{let J=!1;Re>Number.EPSILON?Ze>Number.EPSILON&&(J=!0):Re<-Number.EPSILON?Ze<-Number.EPSILON&&(J=!0):Math.sign(Oe)===Math.sign(je)&&(J=!0),J?(fe=-Oe,de=Re,Se=Math.sqrt(I)):(fe=Re,de=Oe,Se=Math.sqrt(I/2))}return new ee(fe/Se,de/Se)}let V=[];for(let Z=0,ie=B.length,te=ie-1,fe=Z+1;Z=0;Z--){let ie=Z/x,te=p*Math.cos(ie*Math.PI/2),fe=m*Math.sin(ie*Math.PI/2)+y;for(let de=0,Se=B.length;de=0;){let fe=te,de=te-1;de<0&&(de=Z.length-1);for(let Se=0,Re=u+x*2;Se0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}};Zu.prototype.isMeshPhysicalMaterial=!0;var qs=class extends ft{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new ye(16777215),this.specular=new ye(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=il,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}};qs.prototype.isMeshPhongMaterial=!0;var Ju=class extends ft{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ye(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}};Ju.prototype.isMeshToonMaterial=!0;var Ku=class extends ft{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}};Ku.prototype.isMeshNormalMaterial=!0;var Qu=class extends ft{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new ye(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=il,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}};Qu.prototype.isMeshLambertMaterial=!0;var eh=class extends ft{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ye(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xs,this.normalScale=new ee(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this}};eh.prototype.isMeshMatcapMaterial=!0;var th=class extends qn{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};th.prototype.isLineDashedMaterial=!0;var it={arraySlice:function(r,e,t){return it.isTypedArray(r)?new r.constructor(r.subarray(e,t!==void 0?t:r.length)):r.slice(e,t)},convertArray:function(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)},isTypedArray:function(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)},getKeyframeOrder:function(r){function e(n,s){return r[n]-r[s]}let t=r.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort(e),i},sortedArray:function(r,e,t){let i=r.length,n=new r.constructor(i);for(let s=0,o=0;o!==i;++s){let a=t[s]*e;for(let l=0;l!==e;++l)n[o++]=r[a+l]}return n},flattenJSON:function(r,e,t,i){let n=1,s=r[0];for(;s!==void 0&&s[i]===void 0;)s=r[n++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[n++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[n++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=r[n++];while(s!==void 0)},subclip:function(r,e,t,i,n=30){let s=r.clone();s.name=e;let o=[];for(let l=0;l=i)){h.push(c.times[p]);for(let y=0;ys.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l=a.times[m]){let g=m*h+u,f=g+h-u;y=it.arraySlice(a.values,g,f)}else{let g=a.createInterpolant(),f=u,E=h-u;g.evaluate(s),y=it.arraySlice(g.resultBuffer,f,E)}l==="quaternion"&&new Lt().fromArray(y).normalize().conjugate().toArray(y);let x=c.times.length;for(let g=0;g=s)){let a=t[1];e=s)break t}o=i,i=0;break i}break e}for(;i>>1;et;)--o;if(++o,s!==0||o!==n){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=it.arraySlice(i,s,o),this.values=it.arraySlice(this.values,s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,n=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=i[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(n!==void 0&&it.isTypedArray(n))for(let a=0,l=n.length;a!==l;++a){let c=n[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=it.arraySlice(this.times),t=it.arraySlice(this.values),i=this.getValueSize(),n=this.getInterpolation()===kc,s=e.length-1,o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*i,l=o*i,c=0;c!==i;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=it.arraySlice(e,0,o),this.values=it.arraySlice(t,0,o*i)):(this.times=e,this.values=t),this}clone(){let e=it.arraySlice(this.times,0),t=it.arraySlice(this.values,0),i=this.constructor,n=new i(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}};ni.prototype.TimeBufferType=Float32Array;ni.prototype.ValueBufferType=Float32Array;ni.prototype.DefaultInterpolation=Ta;var An=class extends ni{};An.prototype.ValueTypeName="bool";An.prototype.ValueBufferType=Array;An.prototype.DefaultInterpolation=Da;An.prototype.InterpolantFactoryMethodLinear=void 0;An.prototype.InterpolantFactoryMethodSmooth=void 0;var Ya=class extends ni{};Ya.prototype.ValueTypeName="color";var Ws=class extends ni{};Ws.prototype.ValueTypeName="number";var sh=class extends Ri{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(i-t)/(n-t),c=e*a;for(let u=c+a;c!==u;c+=4)Lt.slerpFlat(s,0,o,c-a,o,c,l);return s}},$n=class extends ni{InterpolantFactoryMethodLinear(e){return new sh(this.times,this.values,this.getValueSize(),e)}};$n.prototype.ValueTypeName="quaternion";$n.prototype.DefaultInterpolation=Ta;$n.prototype.InterpolantFactoryMethodSmooth=void 0;var Sn=class extends ni{};Sn.prototype.ValueTypeName="string";Sn.prototype.ValueBufferType=Array;Sn.prototype.DefaultInterpolation=Da;Sn.prototype.InterpolantFactoryMethodLinear=void 0;Sn.prototype.InterpolantFactoryMethodSmooth=void 0;var $s=class extends ni{};$s.prototype.ValueTypeName="vector";var Za=class{constructor(e,t=-1,i,n=Ih){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=pi(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,n=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(T_(i[o]).scale(n));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(ni.toJSON(i[s]));return n}static CreateFromMorphTargetSequence(e,t,i,n){let s=t.length,o=[];for(let a=0;a1){let h=u[1],d=n[h];d||(n[h]=d=[]),d.push(c)}}let o=[];for(let a in n)o.push(this.CreateFromMorphTargetSequence(a,n[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,d,p,m,y){if(p.length!==0){let x=[],g=[];it.flattenJSON(p,x,g,m),x.length!==0&&y.push(new h(d,x,g))}},n=[],s=e.name||"default",o=e.fps||30,a=e.blendMode,l=e.length||-1,c=e.hierarchy||[];for(let h=0;h{t&&t(s),this.manager.itemEnd(e)},0),s;if(ji[e]!==void 0){ji[e].push({onLoad:t,onProgress:i,onError:n});return}ji[e]=[],ji[e].push({onLoad:t,onProgress:i,onError:n});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body.getReader===void 0)return c;let u=ji[e],h=c.body.getReader(),d=c.headers.get("Content-Length"),p=d?parseInt(d):0,m=p!==0,y=0,x=new ReadableStream({start(g){f();function f(){h.read().then(({done:E,value:w})=>{if(E)g.close();else{y+=w.byteLength;let _=new ProgressEvent("progress",{lengthComputable:m,loaded:y,total:p});for(let M=0,T=u.length;M{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,p=new TextDecoder(d);return c.arrayBuffer().then(m=>p.decode(m))}}}).then(c=>{js.add(e,c);let u=ji[e];delete ji[e];for(let h=0,d=u.length;h{let u=ji[e];if(u===void 0)throw this.manager.itemError(e),c;delete ji[e];for(let h=0,d=u.length;h{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}};var Ja=class extends Fi{constructor(e){super(e)}load(e,t,i,n){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=js.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=kr("img");function l(){u(),js.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(h){u(),n&&n(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.substr(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}},ah=class extends Fi{constructor(e){super(e)}load(e,t,i,n){let s=new ks,o=new Ja(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function l(c){o.load(e[c],function(u){s.images[c]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,n)}for(let c=0;c"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,n){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=js.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){js.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){n&&n(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}};mh.prototype.isImageBitmapLoader=!0;var Ea,R_={getContext:function(){return Ea===void 0&&(Ea=new(window.AudioContext||window.webkitAudioContext)),Ea},setContext:function(r){Ea=r}},gh=class extends Fi{constructor(e){super(e)}load(e,t,i,n){let s=this,o=new oh(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{let l=a.slice(0);R_.getContext().decodeAudioData(l,function(u){t(u)})}catch(l){n?n(l):console.error(l),s.manager.itemError(e)}},i,n)}},yh=class extends lo{constructor(e,t,i=1){super(void 0,i);let n=new ye().set(e),s=new ye().set(t),o=new P(n.r,n.g,n.b),a=new P(s.r,s.g,s.b),l=Math.sqrt(Math.PI),c=l*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(a).multiplyScalar(l),this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(c)}};yh.prototype.isHemisphereLightProbe=!0;var xh=class extends lo{constructor(e,t=1){super(void 0,t);let i=new ye().set(e);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}};xh.prototype.isAmbientLightProbe=!0;var vh=class extends Ge{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(i[l]!==i[l+t]){a.setValue(i,n);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let s=i,o=n;s!==o;++s)t[s]=t[n+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i=.5)for(let o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,n){Lt.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,s){let o=this._workIndex*s;Lt.multiplyQuaternionsFlat(e,o,e,t,e,i),Lt.slerpFlat(e,t,e,t,e,o,n)}_lerp(e,t,i,n,s){let o=1-n;for(let a=0;a!==s;++a){let l=t+a;e[l]=e[l]*o+e[i+a]*n}}_lerpAdditive(e,t,i,n,s){for(let o=0;o!==s;++o){let a=t+o;e[a]=e[a]+e[i+o]*n}}},Oh="\\[\\]\\.:\\/",F_=new RegExp("["+Oh+"]","g"),zh="[^"+Oh+"]",L_="[^"+Oh.replace("\\.","")+"]",B_=/((?:WC+[\/:])*)/.source.replace("WC",zh),P_=/(WCOD+)?/.source.replace("WCOD",L_),I_=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",zh),N_=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",zh),k_=new RegExp("^"+B_+P_+I_+N_+"$"),O_=["material","materials","bones"],_h=class{constructor(e,t,i){let n=i||Xe.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=i.length;n!==s;++n)i[n].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Xe=class r{constructor(e,t,i){this.path=t,this.parsedPath=i||r.parseTrackName(t),this.node=r.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new r.Composite(e,t,i):new r(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(F_,"")}static parseTrackName(e){let t=k_.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){let s=i.nodeName.substring(n+1);O_.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(!t||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let o=0;o=s){let h=s++,d=e[h];t[d.uuid]=u,e[u]=d,t[c]=h,e[h]=l;for(let p=0,m=n;p!==m;++p){let y=i[p],x=y[h],g=y[u];y[u]=x,y[h]=g}}}this.nCachedObjects_=s}uncache(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length,s=this.nCachedObjects_,o=e.length;for(let a=0,l=arguments.length;a!==l;++a){let c=arguments[a],u=c.uuid,h=t[u];if(h!==void 0)if(delete t[u],h0&&(t[p.uuid]=h),e[h]=p,e.pop();for(let m=0,y=n;m!==y;++m){let x=i[m];x[h]=x[d],x.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){let i=this._bindingsIndicesByPath,n=i[e],s=this._bindings;if(n!==void 0)return s[n];let o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,h=new Array(c);n=s.length,i[e]=n,o.push(e),a.push(t),s.push(h);for(let d=u,p=l.length;d!==p;++d){let m=l[d];h[d]=new Xe(m,e,t)}return h}unsubscribe_(e){let t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){let n=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=e[a];t[c]=i,o[i]=l,o.pop(),s[i]=s[a],s.pop(),n[i]=n[a],n.pop()}}};Eh.prototype.isAnimationObjectGroup=!0;var Ah=class{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;let s=t.tracks,o=s.length,a=new Array(o),l={endingStart:Ms,endingEnd:Ms};for(let c=0;c!==o;++c){let u=s[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=pv,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let n=this._clip.duration,s=e._clip.duration,o=s/n,a=n/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let n=this._mixer,s=n.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);let l=a.parameterPositions,c=a.sampleValues;return l[0]=s,l[1]=s+i,c[0]=e/o,c[1]=t/o,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,n){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let l=(e-s)*i;if(l<0||i===0)return;this._startTime=null,t=i*l}t*=this._updateTimeScale(e);let o=this._updateTime(t),a=this._updateWeight(e);if(a>0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case um:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case Ih:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(n,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,n=this.time+e,s=this._loopCount,o=i===fv;if(e===0)return s===-1?n:o&&(s&1)===1?t-n:n;if(i===dv){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else if(n<0)n=0;else{this.time=n;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),n>=t||n<0){let a=Math.floor(n/t);n-=t*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){let c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=n;if(o&&(s&1)===1)return t-n}return n}_setEndings(e,t,i){let n=this._interpolantSettings;i?(n.endingStart=Ds,n.endingEnd=Ds):(e?n.endingStart=this.zeroSlopeAtStart?Ds:Ms:n.endingStart=Ca,t?n.endingEnd=this.zeroSlopeAtEnd?Ds:Ms:n.endingEnd=Ca)}_scheduleFading(e,t,i){let n=this._mixer,s=n.time,o=this._weightInterpolant;o===null&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=t,a[1]=s+e,l[1]=i,this}},Sh=class extends Xi{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,n=e._clip.tracks,s=n.length,o=e._propertyBindings,a=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName,u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){let d=n[h],p=d.name,m=u[p];if(m!==void 0)++m.referenceCount,o[h]=m;else{if(m=o[h],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,p));continue}let y=t&&t._propertyBindings[h].binding.parsedPath;m=new bh(Xe.create(i,p,y),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,p),o[h]=m}a[h].resultBuffer=m.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,n=e._clip.uuid,s=this._actionsByClip[n];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,n,i)}let t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,n=t.length;i!==n;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,n=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(n,e,s,o);let a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return nm.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}};jn.prototype.isBox2=!0;var sm=new P,Aa=new P,Ch=class{constructor(e=new P,t=new P){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){sm.subVectors(e,this.start),Aa.subVectors(this.end,this.start);let i=Aa.dot(Aa),s=Aa.dot(sm)/i;return t&&(s=Ut(s,0,1)),s}closestPointToPoint(e,t,i){let n=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(n).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}};var fn=new P,Sa=new Ee,yu=new Ee,Rh=class extends Zr{constructor(e){let t=Cm(e),i=new Ke,n=[],s=[],o=new ye(0,0,1),a=new ye(0,1,0);for(let c=0;c0?-1:1)*.9,y:this.h*(s.y>0?-1:1)*.9,z:Math.random()*200+200},a=Math.abs(s.x/s.y);a>1?o.y/=a:o.x*=a;let l=this.makeRandomVector(n),c={x:l.x*i,y:l.y*i,z:-10},u={x:-(Math.random()*s.y*5+this.inertia*s.y),y:Math.random()*s.x*5+this.inertia*s.x,z:0},h={x:Math.random(),y:Math.random(),z:Math.random(),w:Math.random()};return{pos:o,velocity:c,angular:u,axis:h}}makeRandomVector(e){let t=Math.random()*Math.PI/5-Math.PI/5/2,i={x:e.x*Math.cos(t)-e.y*Math.sin(t),y:e.x*Math.sin(t)+e.y*Math.cos(t)};return i.x==0&&(i.x=.01),i.y==0&&(i.y=.01),i}get buffer(){return this.geometry.geometry}get result(){return this.getUpsideValue()}getUpsideValue(){let e=new P(0,0,this.sides==4?-1:1),t,i=Math.PI*2,n=this.buffer.getAttribute("normal").array;for(let o=0,a=this.buffer.groups.length;othis.sides;)o-=this.sides;for(;o<1;)o+=this.sides;t.groups[n].materialIndex=o+1}}this.updateMaterialsForValue(e-i),this.geometry.geometry=t}resetBody(){return this.body.vlambda=new b,this.body.position=new b,this.body.previousPosition=new b,this.body.initPosition=new b,this.body.velocity=new b,this.body.initVelocity=new b,this.body.force=new b,this.body.torque=new b,this.body.quaternion=new yt,this.body.initQuaternion=new yt,this.body.angularVelocity=new b,this.body.initAngularVelocity=new b,this.body.interpolatedPosition=new b,this.body.interpolatedQuaternion=new yt,this.body.inertia=new b,this.body.invInertia=new b,this.body.invInertiaWorld=new Mi,this.body.invInertiaSolve=new b,this.body.invInertiaWorldSolve=new Mi,this.body.wlambda=new b,this.body.updateMassProperties(),this}updateMaterialsForValue(e){}set(){this.geometry.position.set(this.body.position.x,this.body.position.y,this.body.position.z),this.geometry.quaternion.set(this.body.quaternion.x,this.body.quaternion.y,this.body.quaternion.z,this.body.quaternion.w)}recreate(e,t,i){this.w=t,this.h=i,this.vector=this.generateVector(e),this.stopped=!1,this.iterations=0,this.create()}create(){return this.body.position.set(this.vector.pos.x,this.vector.pos.y,this.vector.pos.z),this.body.quaternion.setFromAxisAngle(new b(this.vector.axis.x,this.vector.axis.y,this.vector.axis.z),this.vector.axis.w*Math.PI*2),this.body.angularVelocity.set(this.vector.angular.x,this.vector.angular.y,this.vector.angular.z),this.body.velocity.set(this.vector.velocity.x,this.vector.velocity.y,this.vector.velocity.z),this.body.linearDamping=.1,this.body.angularDamping=.1,this}},al=class extends Mn{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=20;this.inertia=6;s&&(this.vector=this.generateVector(s)),this.create()}},ll=class extends Mn{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=12;this.inertia=8;s&&(this.vector=this.generateVector(s)),this.create()}},Zs=class extends Mn{constructor(t,i,n,s,o=!1){super(t,i,n);this.w=t;this.h=i;this.data=n;this.isPercentile=o;this.sides=10;this.inertia=9;s&&(this.vector=this.generateVector(s)),this.create()}},cl=class extends Mn{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=8;this.inertia=10;s&&(this.vector=this.generateVector(s)),this.create()}},Js=class extends Mn{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=6;this.inertia=13;s&&(this.vector=this.generateVector(s)),this.create()}},ul=class extends Mn{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=4;this.inertia=5;s&&(this.vector=this.generateVector(s)),this.create()}};var At=class{constructor(e,t={value:`${e}`,conditions:[],type:"dice"}){this.lexeme=t;this.modifiers=new Map;this.possibilities=[];this.results=new Map;this.shapes=new Map;this.modifiersAllowed=!0;this.static=!1;this.conditions=[];this.fudge=!1;this.shouldRender=!1;if(!/(\-?\d+)[dD]?(\d+|%|\[\d+,\s?\d+\])?/.test(`${e}`))throw new Error("Non parseable dice string passed to DiceRoll.");this.dice=`${e}`.split(" ").join(""),/^-?\d+(?:\.\d+)?$/.test(this.dice)&&(this.static=!0,this.modifiersAllowed=!1);let[,i,n="1"]=this.dice.match(/(\-?\d+)[dD](%|F|-?\d+|\[\d+(?:[ \t]*[,-][ \t]*\d+)+\])/)||[,1,"1"];i=Number(i),this.multiplier=i<0?-1:1;let s=1,o=isNaN(Number(n))?1:Number(n);this.rolls=Math.abs(Number(i))||1,/\[\d+(?:[ \t]*,[ \t]*\d+)+\]/.test(n)?this.possibilities=n.replace(/[\[\]\s]/g,"").split(",").map(a=>Number(a)):/\[\d+(?:[ \t]*-[ \t]*\d+)+\]/.test(n)?([s,o]=n.replace(/[\[\]\s]/g,"").split("-").map(a=>Number(a)),this.possibilities=Array.from({length:o-s},(a,l)=>l+s)):(n==="%"?o=100:o=Number(n),Number(o)<0&&!s&&(s=-1),Number(o)a+s)),this.conditions=this.lexeme.conditions??[]}getType(){return`${this.faces.max}`}get faces(){return{max:this.possibilities[this.possibilities.length-1],min:this.possibilities[0]}}getShapes(e){if(this.shapes.has(e))return this.shapes.get(e);let t=Mt.getDiceForRoller(this);return e!=null&&this.shapes.set(e,t),t}get text(){return`${this.result}`}get result(){if(this.static)return this.multiplier*Number(this.dice);let e=[...this.results].map(([,{usable:t,value:i}])=>t?i:0);return this.multiplier*e.reduce((t,i)=>t+i,0)}get display(){if(this.static)return`${this.result}`;let e=[`[${[...this.results].map(([,{modifiers:t,display:i}])=>`${i}${[...t].join("")}`).join(", ")}]`];return this.conditions.length&&e.push(this.conditions.map(({result:t,operator:i})=>`${i}${t}`).join("")),e.join("")}get modifierText(){let e=this.conditions.map(({value:i})=>i).join(""),t=[...this.modifiers].map(([i,{conditionals:n,value:s}])=>{let o=n.map(a=>a.value);return`${s}${o.join("")}`}).join("");return`${e}${t}`}keepLow(e=1){if(!this.modifiersAllowed){new ho.Notice("Modifiers are only allowed on dice rolls.");return}this.results.size!==1&&[...this.results].sort((t,i)=>t[1].value-i[1].value).slice(e>this.results.size?this.results.size:e-this.results.size).forEach(([t])=>{let i=this.results.get(t);i.usable=!1,i.modifiers.add("d"),this.results.set(t,{...i})})}keepHigh(e=1){if(!this.modifiersAllowed){new ho.Notice("Modifiers are only allowed on dice rolls.");return}this.results.size!==1&&[...this.results].sort((t,i)=>i[1].value-t[1].value).slice(e).forEach(([t])=>{let i=this.results.get(t);i.usable=!1,i.modifiers.add("d"),this.results.set(t,{...i})})}async reroll(e,t){if(!this.modifiersAllowed){new ho.Notice("Modifiers are only allowed on dice rolls.");return}t.length||t.push({operator:"=",comparer:this.faces.min,lexemes:[{value:`${this.faces.min}`,text:`${this.faces.min}`,type:"dice"}],value:""});let i=0,n=[...this.results].filter(([,{value:s}])=>this.checkCondition(s,t));for(;i0;){let s=[];for(let[o,a]of n)s.push(new Promise(async l=>{a.modifiers.add("r");let c=this.getShapes(o),u=await this.getValue(c);a.value=u,a.display=`${u}`,l()}));await Promise.all(s),n=n.filter(([,{value:o}])=>this.checkCondition(o,t)),i++}n.forEach(([s,o])=>{this.results.set(s,o)})}async explode(e,t,i=!1){if(!this.modifiersAllowed){new ho.Notice("Modifiers are only allowed on dice rolls.");return}t.length||t.push({operator:"=",comparer:this.faces.max,lexemes:[{value:`${this.faces.max}`,text:`${this.faces.max}`,type:"dice"}],value:""});let n=[...this.results].filter(([,{value:o}])=>this.checkCondition(o,t)),s=0;await Promise.all(n.map(async([o,a])=>{if(i){let l=await this.getValue(),c=0;for(a.modifiers.add("!"),a.value+=l,a.display=`${a.value}`,this.results.set(o,a);cthis.faces.min+t).every(t=>this.possibilities.includes(t))}async getValue(e){let t;if(this.shouldRender&&this.canRender()){let i=e??Mt.getDiceForRoller(this)??[];await Mt.addDice(i),t=this.#e(i)}else t=this.getValueSync();return t}getValueSync(){return this.getRandomValue()}getMaxPossible(){if(this.static)return Number(this.dice);let e=this.rolls;return this.modifiers.has("kl")&&(e=e-this.modifiers.get("kl").data),this.modifiers.has("kh")&&(e=e-this.modifiers.get("kh").data),e<1&&(e=0),this.multiplier===-1?this.multiplier*Math.min(...this.possibilities)*e:Math.max(...this.possibilities)*e}getMinPossible(){if(this.static)return Number(this.dice);let e=this.rolls;return this.modifiers.has("kl")&&(e=e-this.modifiers.get("kl").data),this.modifiers.has("kh")&&(e=e-this.modifiers.get("kh").data),e<1&&(e=0),this.multiplier===-1?this.multiplier*Math.max(...this.possibilities)*e:Math.min(...this.possibilities)*e}#e(e=[]){if(!e.length)return this.getValueSync();let t=e.map(i=>i.getUpsideValue());if(this.faces.max===100){let[i,n]=t;return i===10&&n==10?100:(n==10&&(n=0),i==10&&(i=0),i*10+n)}return t.reduce((i,n)=>i+n)}#t(e=0){return{usable:!0,value:e,display:`${e}`,modifiers:new Set}}async applyModifiers(){for(let[e,t]of this.modifiers)e=="kh"||e=="kl"||await this.applyModifier(e,t);this.modifiers.has("kh")&&await this.applyModifier("kh",this.modifiers.get("kh")),this.modifiers.has("kl")&&await this.applyModifier("kl",this.modifiers.get("kl"))}setResults(e){this.results=new Map([...e].map(([t,i])=>[t,this.#t(i)])),this.updateResultArray()}rollSync(){let e=new Map;for(let t=0;t{let s=await this.getValue(this.getShapes(i));e.set(i,s),n()}));await Promise.all(t)}return e}applyConditions(){for(let e of this.results.values()){let t=this.conditions.find(({operator:n})=>n==="-="||n==="=-");if(t&&e.value===t.comparer){e.value=-1,e.modifiers.add("-");continue}this.checkCondition(e.value,this.conditions)?(e.modifiers.add("*"),e.value=1):e.usable=!1}}updateResultArray(){this.resultArray=[...this.results.values()].map(e=>e.value)}async applyModifier(e,t){switch(e){case"sort":{let i;t.value=="sa"?i=[...this.results.values()].sort((n,s)=>n.value-s.value):i=[...this.results.values()].sort((n,s)=>s.value-n.value),this.results=new Map([...this.results.keys()].map(n=>[n,i[n]])),this.updateResultArray();break}case"kh":{this.keepHigh(t.data);break}case"kl":{this.keepLow(t.data);break}case"!":{await this.explode(t.data,t.conditionals);break}case"!!":{await this.explode(t.data,t.conditionals,!0);break}case"r":{await this.reroll(t.data,t.conditionals);break}case"u":{await this.makeUnique();break}case"condition":}}async makeUnique(){let e=[...this.results.values()];if(new Set(this.possibilities).sizei.value)).size==this.results.size)return;let t=0;for(;new Set(e.map(i=>i.value)).size!=this.results.size&&t<100;){let i=[];for(let[n,s]of this.results)i.push(new Promise(async o=>{let a=e.find(l=>l.value==s.value&&l!=s);a&&(a.value=await this.getValue(this.getShapes(n)),a.display=`${a.value}`,a.modifiers.add("u")),o()}));await Promise.all(i),e=[...this.results.values()],t++}}checkCondition(e,t){if(!t||!t.length)return e;let i=!1;for(let n of t){let{operator:s,comparer:o,lexemes:a}=n;if(Number.isNaN(e)||!s?.length||!o)continue;let l=new hl(o,a);if(l.rollSync(),n.result=l.result,!Number.isNaN(n.result)){switch(s){case"=":i=e===n.result;break;case"!=":case"=!":i=e!==n.result;break;case"<":i=e":i=e>n.result;break;case">=":i=e>=n.result;break}if(i)return i}}return i}allowAverage(){return!0}average(){return this.possibilities.reduce((e,t)=>e+t)/this.possibilities.length}getRandomValue(){let e=Math.floor(Math.random()*this.possibilities.length);return this.possibilities[e]}getGeometries(){return[...this.shapes.values()].flat()}async render(){this.shouldRender=!0,await this.roll(),this.shouldRender=!1}};var Rm={specular:1515554,color:15790320,shininess:60,flatShading:!0},Dn={diceColor:"#202020",textColor:"#ffffff",textFont:"Arial"},fi=class{constructor(e,t,i={diceColor:"#202020",textColor:"#aaaaaa"},n){this.w=e;this.h=t;this.options=i;this.scaler=n;this.scale=50;this.labels=[" ","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"];this.fontFace="Arial";this.options={...Dn,...i},this.fontFace=this.options.textFont}setColor({diceColor:e,textColor:t}){e&&(this.options.diceColor=e),t&&(this.options.textColor=t)}get radius(){return this.scale*this.scaleFactor*(this.scaler??1)}get diceColor(){return this.options.diceColor}get textColor(){return this.options.textColor}get buffer(){return this.geometry.geometry}create(){this.textureSize=this.calculateTextureSize(this.scale/2+this.scale*this.margin)*2;let e=this.getGeometry(),t=this.getMaterials();return this.geometry=new pt(e,t),this.geometry.receiveShadow=!0,this.geometry.castShadow=!0,this.body.position.set(0+this.radius*2*Math.random(),0+this.radius*2*Math.random(),0+this.radius*4),this.body.velocity.x=500*Math.random()*2-1,this.body.velocity.y=500*Math.random()*2-1,this.body.angularVelocity.x=100*Math.random(),this.body.angularVelocity.y=100*Math.random(),this}getGeometry(){let e=new Array(this.vertices.length);for(let i=0;i=0&&u=0&&c!==l+1?a.unshift([s,c],[o,u]):a.push([s,c],[o,u]),l=c)}a.length===4&&i.push([i[a[0][0]][a[0][1]],i[a[1][0]][a[1][1]],i[a[3][0]][a[3][1]],i[a[2][0]][a[2][1]],-1])}for(let s=0;s=0&&u<4){--u===-1&&(u=3);let h=i[c][u];if(o.indexOf(h)>=0){a.push(h);break}}}--l}a.push(-1),i.push(a)}return{vectors:t,faces:i}}makeGeometry(e,t){let i=new Ke;for(let h=0;hu||n.y>u)&&(n.x>u&&(s.x=Math.floor(u/L.x),n.x=s.x*L.x,B.mapSize.x=s.x),n.y>u&&(s.y=Math.floor(u/L.y),n.y=s.y*L.y,B.mapSize.y=s.y)),B.map===null&&!B.isPointLightShadow&&this.type===Tr){let N={minFilter:Rt,magFilter:Rt,format:Nt};B.map=new Ht(n.x,n.y,N),B.map.texture.name=S.name+".shadowMap",B.mapPass=new Ht(n.x,n.y,N),B.camera.updateProjectionMatrix()}if(B.map===null){let N={minFilter:vt,magFilter:vt,format:Nt};B.map=new Ht(n.x,n.y,N),B.map.texture.name=S.name+".shadowMap",B.camera.updateProjectionMatrix()}r.setRenderTarget(B.map),r.clear();let C=B.getViewportCount();for(let N=0;N0){let S=v.uuid,B=M.uuid,L=c[S];L===void 0&&(L={},c[S]=L);let C=L[B];C===void 0&&(C=v.clone(),L[B]=C),v=C}return v.visible=M.visible,v.wireframe=M.wireframe,A===Tr?v.side=M.shadowSide!==null?M.shadowSide:M.side:v.side=M.shadowSide!==null?M.shadowSide:h[M.side],v.alphaMap=M.alphaMap,v.alphaTest=M.alphaTest,v.clipShadows=M.clipShadows,v.clippingPlanes=M.clippingPlanes,v.clipIntersection=M.clipIntersection,v.displacementMap=M.displacementMap,v.displacementScale=M.displacementScale,v.displacementBias=M.displacementBias,v.wireframeLinewidth=M.wireframeLinewidth,v.linewidth=M.linewidth,T.isPointLight===!0&&v.isMeshDistanceMaterial===!0&&(v.referencePosition.setFromMatrixPosition(T.matrixWorld),v.nearDistance=z,v.farDistance=W),v}function E(w,_,M,T,z){if(w.visible===!1)return;if(w.layers.test(_.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&z===Tr)&&(!w.frustumCulled||i.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,w.matrixWorld);let v=e.update(w),R=w.material;if(Array.isArray(R)){let S=v.groups;for(let B=0,L=S.length;B=1):C.indexOf("OpenGL ES")!==-1&&(L=parseFloat(/^OpenGL ES (\d)/.exec(C)[1]),B=L>=2);let N=null,k={},V=r.getParameter(3088),U=r.getParameter(2978),q=new $e().fromArray(V),j=new $e().fromArray(U);function ne(O,ge,pe){let Me=new Uint8Array(4),K=r.createTexture();r.bindTexture(O,K),r.texParameteri(O,10241,9728),r.texParameteri(O,10240,9728);for(let _e=0;_ese||I.height>se)&&(xe=se/Math.max(I.width,I.height)),xe<1||D===!0)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap){let Y=D?bv:Math.floor,be=Y(xe*I.width),ve=Y(xe*I.height);y===void 0&&(y=g(be,ve));let he=J?g(be,ve):y;return he.width=be,he.height=ve,he.getContext("2d").drawImage(I,0,0,be,ve),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+I.width+"x"+I.height+") to ("+be+"x"+ve+")."),he}else return"data"in I&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+I.width+"x"+I.height+")."),I;return I}function E(I){return Qp(I.width)&&Qp(I.height)}function w(I){return a?!1:I.wrapS!==Kt||I.wrapT!==Kt||I.minFilter!==vt&&I.minFilter!==Rt}function _(I,D){return I.generateMipmaps&&D&&I.minFilter!==vt&&I.minFilter!==Rt}function M(I){r.generateMipmap(I)}function T(I,D,J,se,xe=!1){if(a===!1)return D;if(I!==null){if(r[I]!==void 0)return r[I];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let Y=D;return D===6403&&(J===5126&&(Y=33326),J===5131&&(Y=33325),J===5121&&(Y=33321)),D===33319&&(J===5126&&(Y=33328),J===5131&&(Y=33327),J===5121&&(Y=33323)),D===6408&&(J===5126&&(Y=34836),J===5131&&(Y=34842),J===5121&&(Y=se===tt&&xe===!1?35907:32856),J===32819&&(Y=32854),J===32820&&(Y=32855)),(Y===33325||Y===33326||Y===33327||Y===33328||Y===34842||Y===34836)&&e.get("EXT_color_buffer_float"),Y}function z(I,D,J){return _(I,J)===!0||I.isFramebufferTexture&&I.minFilter!==vt&&I.minFilter!==Rt?Math.log2(Math.max(D.width,D.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?D.mipmaps.length:1}function W(I){return I===vt||I===Cp||I===Rp?9728:9729}function A(I){let D=I.target;D.removeEventListener("dispose",A),R(D),D.isVideoTexture&&m.delete(D),o.memory.textures--}function v(I){let D=I.target;D.removeEventListener("dispose",v),S(D)}function R(I){let D=i.get(I);D.__webglInit!==void 0&&(r.deleteTexture(D.__webglTexture),i.remove(I))}function S(I){let D=I.texture,J=i.get(I),se=i.get(D);if(I){if(se.__webglTexture!==void 0&&(r.deleteTexture(se.__webglTexture),o.memory.textures--),I.depthTexture&&I.depthTexture.dispose(),I.isWebGLCubeRenderTarget)for(let xe=0;xe<6;xe++)r.deleteFramebuffer(J.__webglFramebuffer[xe]),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer[xe]);else r.deleteFramebuffer(J.__webglFramebuffer),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&r.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer&&r.deleteRenderbuffer(J.__webglColorRenderbuffer),J.__webglDepthRenderbuffer&&r.deleteRenderbuffer(J.__webglDepthRenderbuffer);if(I.isWebGLMultipleRenderTargets)for(let xe=0,Y=D.length;xe=l&&console.warn("THREE.WebGLTextures: Trying to use "+I+" texture units while this GPU supports only "+l),B+=1,I}function N(I,D){let J=i.get(I);if(I.isVideoTexture&&de(I),I.version>0&&J.__version!==I.version){let se=I.image;if(se===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(se.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{H(J,I,D);return}}t.activeTexture(33984+D),t.bindTexture(3553,J.__webglTexture)}function k(I,D){let J=i.get(I);if(I.version>0&&J.__version!==I.version){H(J,I,D);return}t.activeTexture(33984+D),t.bindTexture(35866,J.__webglTexture)}function V(I,D){let J=i.get(I);if(I.version>0&&J.__version!==I.version){H(J,I,D);return}t.activeTexture(33984+D),t.bindTexture(32879,J.__webglTexture)}function U(I,D){let J=i.get(I);if(I.version>0&&J.__version!==I.version){Te(J,I,D);return}t.activeTexture(33984+D),t.bindTexture(34067,J.__webglTexture)}let q={[bu]:10497,[Kt]:33071,[_u]:33648},j={[vt]:9728,[Cp]:9984,[Rp]:9986,[Rt]:9729,[Zx]:9985,[sl]:9987};function ne(I,D,J){if(J?(r.texParameteri(I,10242,q[D.wrapS]),r.texParameteri(I,10243,q[D.wrapT]),(I===32879||I===35866)&&r.texParameteri(I,32882,q[D.wrapR]),r.texParameteri(I,10240,j[D.magFilter]),r.texParameteri(I,10241,j[D.minFilter])):(r.texParameteri(I,10242,33071),r.texParameteri(I,10243,33071),(I===32879||I===35866)&&r.texParameteri(I,32882,33071),(D.wrapS!==Kt||D.wrapT!==Kt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(I,10240,W(D.magFilter)),r.texParameteri(I,10241,W(D.minFilter)),D.minFilter!==vt&&D.minFilter!==Rt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){let se=e.get("EXT_texture_filter_anisotropic");if(D.type===Vn&&e.has("OES_texture_float_linear")===!1||a===!1&&D.type===Cs&&e.has("OES_texture_half_float_linear")===!1)return;(D.anisotropy>1||i.get(D).__currentAnisotropy)&&(r.texParameterf(I,se.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,n.getMaxAnisotropy())),i.get(D).__currentAnisotropy=D.anisotropy)}}function ae(I,D){I.__webglInit===void 0&&(I.__webglInit=!0,D.addEventListener("dispose",A),I.__webglTexture=r.createTexture(),o.memory.textures++)}function H(I,D,J){let se=3553;D.isDataTexture2DArray&&(se=35866),D.isDataTexture3D&&(se=32879),ae(I,D),t.activeTexture(33984+J),t.bindTexture(se,I.__webglTexture),r.pixelStorei(37440,D.flipY),r.pixelStorei(37441,D.premultiplyAlpha),r.pixelStorei(3317,D.unpackAlignment),r.pixelStorei(37443,0);let xe=w(D)&&E(D.image)===!1,Y=f(D.image,xe,!1,u);Y=Se(D,Y);let be=E(Y)||a,ve=s.convert(D.format,D.encoding),he=s.convert(D.type),le=T(D.internalFormat,ve,he,D.encoding,D.isVideoTexture);ne(se,D,be);let Le,O=D.mipmaps,ge=a&&D.isVideoTexture!==!0,pe=I.__version===void 0,Me=z(D,Y,be);if(D.isDepthTexture)le=6402,a?D.type===Vn?le=36012:D.type===Ma?le=33190:D.type===Rs?le=35056:le=33189:D.type===Vn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),D.format===Hn&&le===6402&&D.type!==Ir&&D.type!==Ma&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),D.type=Ir,he=s.convert(D.type)),D.format===Ps&&le===6402&&(le=34041,D.type!==Rs&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),D.type=Rs,he=s.convert(D.type))),ge&&pe?t.texStorage2D(3553,1,le,Y.width,Y.height):t.texImage2D(3553,0,le,Y.width,Y.height,0,ve,he,null);else if(D.isDataTexture)if(O.length>0&&be){ge&&pe&&t.texStorage2D(3553,Me,le,O[0].width,O[0].height);for(let K=0,_e=O.length;K<_e;K++)Le=O[K],ge?t.texSubImage2D(3553,0,0,0,Le.width,Le.height,ve,he,Le.data):t.texImage2D(3553,K,le,Le.width,Le.height,0,ve,he,Le.data);D.generateMipmaps=!1}else ge?(pe&&t.texStorage2D(3553,Me,le,Y.width,Y.height),t.texSubImage2D(3553,0,0,0,Y.width,Y.height,ve,he,Y.data)):t.texImage2D(3553,0,le,Y.width,Y.height,0,ve,he,Y.data);else if(D.isCompressedTexture){ge&&pe&&t.texStorage2D(3553,Me,le,O[0].width,O[0].height);for(let K=0,_e=O.length;K<_e;K++)Le=O[K],D.format!==Nt?ve!==null?ge?t.compressedTexSubImage2D(3553,K,0,0,Le.width,Le.height,ve,Le.data):t.compressedTexImage2D(3553,K,le,Le.width,Le.height,0,Le.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?t.texSubImage2D(3553,K,0,0,Le.width,Le.height,ve,he,Le.data):t.texImage2D(3553,K,le,Le.width,Le.height,0,ve,he,Le.data)}else if(D.isDataTexture2DArray)ge?(pe&&t.texStorage3D(35866,Me,le,Y.width,Y.height,Y.depth),t.texSubImage3D(35866,0,0,0,0,Y.width,Y.height,Y.depth,ve,he,Y.data)):t.texImage3D(35866,0,le,Y.width,Y.height,Y.depth,0,ve,he,Y.data);else if(D.isDataTexture3D)ge?(pe&&t.texStorage3D(32879,Me,le,Y.width,Y.height,Y.depth),t.texSubImage3D(32879,0,0,0,0,Y.width,Y.height,Y.depth,ve,he,Y.data)):t.texImage3D(32879,0,le,Y.width,Y.height,Y.depth,0,ve,he,Y.data);else if(D.isFramebufferTexture)ge&&pe?t.texStorage2D(3553,Me,le,Y.width,Y.height):t.texImage2D(3553,0,le,Y.width,Y.height,0,ve,he,null);else if(O.length>0&&be){ge&&pe&&t.texStorage2D(3553,Me,le,O[0].width,O[0].height);for(let K=0,_e=O.length;K<_e;K++)Le=O[K],ge?t.texSubImage2D(3553,K,0,0,ve,he,Le):t.texImage2D(3553,K,le,ve,he,Le);D.generateMipmaps=!1}else ge?(pe&&t.texStorage2D(3553,Me,le,Y.width,Y.height),t.texSubImage2D(3553,0,0,0,ve,he,Y)):t.texImage2D(3553,0,le,ve,he,Y);_(D,be)&&M(se),I.__version=D.version,D.onUpdate&&D.onUpdate(D)}function Te(I,D,J){if(D.image.length!==6)return;ae(I,D),t.activeTexture(33984+J),t.bindTexture(34067,I.__webglTexture),r.pixelStorei(37440,D.flipY),r.pixelStorei(37441,D.premultiplyAlpha),r.pixelStorei(3317,D.unpackAlignment),r.pixelStorei(37443,0);let se=D&&(D.isCompressedTexture||D.image[0].isCompressedTexture),xe=D.image[0]&&D.image[0].isDataTexture,Y=[];for(let K=0;K<6;K++)!se&&!xe?Y[K]=f(D.image[K],!1,!0,c):Y[K]=xe?D.image[K].image:D.image[K],Y[K]=Se(D,Y[K]);let be=Y[0],ve=E(be)||a,he=s.convert(D.format,D.encoding),le=s.convert(D.type),Le=T(D.internalFormat,he,le,D.encoding),O=a&&D.isVideoTexture!==!0,ge=I.__version===void 0,pe=z(D,be,ve);ne(34067,D,ve);let Me;if(se){O&&ge&&t.texStorage2D(34067,pe,Le,be.width,be.height);for(let K=0;K<6;K++){Me=Y[K].mipmaps;for(let _e=0;_e0&&pe++,t.texStorage2D(34067,pe,Le,Y[0].width,Y[0].height));for(let K=0;K<6;K++)if(xe){O?t.texSubImage2D(34069+K,0,0,0,Y[K].width,Y[K].height,he,le,Y[K].data):t.texImage2D(34069+K,0,Le,Y[K].width,Y[K].height,0,he,le,Y[K].data);for(let _e=0;_ep+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=p-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));return a!==null&&(a.visible=n!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}},$r=class extends lt{constructor(e,t,i,n,s,o,a,l,c,u){if(u=u!==void 0?u:Hn,u!==Hn&&u!==Ps)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===Hn&&(i=Ir),i===void 0&&u===Ps&&(i=Rs),super(null,n,s,o,a,l,u,i,c),this.image={width:e,height:t},this.magFilter=a!==void 0?a:vt,this.minFilter=l!==void 0?l:vt,this.flipY=!1,this.generateMipmaps=!1}};$r.prototype.isDepthTexture=!0;var Ru=class extends Xi{constructor(e,t){super();let i=this,n=null,s=1,o=null,a="local-floor",l=e.extensions.has("WEBGL_multisampled_render_to_texture"),c=null,u=null,h=null,d=null,p=!1,m=null,y=t.getContextAttributes(),x=null,g=null,f=[],E=new Map,w=new Et;w.layers.enable(1),w.viewport=new $e;let _=new Et;_.layers.enable(2),_.viewport=new $e;let M=[w,_],T=new za;T.layers.enable(1),T.layers.enable(2);let z=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(U){let q=f[U];return q===void 0&&(q=new Fr,f[U]=q),q.getTargetRaySpace()},this.getControllerGrip=function(U){let q=f[U];return q===void 0&&(q=new Fr,f[U]=q),q.getGripSpace()},this.getHand=function(U){let q=f[U];return q===void 0&&(q=new Fr,f[U]=q),q.getHandSpace()};function A(U){let q=E.get(U.inputSource);q&&q.dispatchEvent({type:U.type,data:U.inputSource})}function v(){E.forEach(function(U,q){U.disconnect(q)}),E.clear(),z=null,W=null,e.setRenderTarget(x),d=null,h=null,u=null,n=null,g=null,V.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(U){s=U,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(U){a=U,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return o},this.getBaseLayer=function(){return h!==null?h:d},this.getBinding=function(){return u},this.getFrame=function(){return m},this.getSession=function(){return n},this.setSession=async function(U){if(n=U,n!==null){if(x=e.getRenderTarget(),n.addEventListener("select",A),n.addEventListener("selectstart",A),n.addEventListener("selectend",A),n.addEventListener("squeeze",A),n.addEventListener("squeezestart",A),n.addEventListener("squeezeend",A),n.addEventListener("end",v),n.addEventListener("inputsourceschange",R),y.xrCompatible!==!0&&await t.makeXRCompatible(),n.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let q={antialias:n.renderState.layers===void 0?y.antialias:!0,alpha:y.alpha,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(n,t,q),n.updateRenderState({baseLayer:d}),g=new Ht(d.framebufferWidth,d.framebufferHeight,{format:Nt,type:yn,encoding:e.outputEncoding})}else{p=y.antialias;let q=null,j=null,ne=null;y.depth&&(ne=y.stencil?35056:33190,q=y.stencil?Ps:Hn,j=y.stencil?Rs:Ir);let ae={colorFormat:e.outputEncoding===tt?35907:32856,depthFormat:ne,scaleFactor:s};u=new XRWebGLBinding(n,t),h=u.createProjectionLayer(ae),n.updateRenderState({layers:[h]}),p?g=new Or(h.textureWidth,h.textureHeight,{format:Nt,type:yn,depthTexture:new $r(h.textureWidth,h.textureHeight,j,void 0,void 0,void 0,void 0,void 0,void 0,q),stencilBuffer:y.stencil,ignoreDepth:h.ignoreDepthValues,useRenderToTexture:l,encoding:e.outputEncoding}):g=new Ht(h.textureWidth,h.textureHeight,{format:Nt,type:yn,depthTexture:new $r(h.textureWidth,h.textureHeight,j,void 0,void 0,void 0,void 0,void 0,void 0,q),stencilBuffer:y.stencil,ignoreDepth:h.ignoreDepthValues,encoding:e.outputEncoding})}g.isXRRenderTarget=!0,this.setFoveation(1),o=await n.requestReferenceSpace(a),V.setContext(n),V.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function R(U){let q=n.inputSources;for(let j=0;j0&&(g.alphaTest.value=f.alphaTest);let E=r.get(f).envMap;E&&(g.envMap.value=E,g.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=f.reflectivity,g.ior.value=f.ior,g.refractionRatio.value=f.refractionRatio),f.lightMap&&(g.lightMap.value=f.lightMap,g.lightMapIntensity.value=f.lightMapIntensity),f.aoMap&&(g.aoMap.value=f.aoMap,g.aoMapIntensity.value=f.aoMapIntensity);let w;f.map?w=f.map:f.specularMap?w=f.specularMap:f.displacementMap?w=f.displacementMap:f.normalMap?w=f.normalMap:f.bumpMap?w=f.bumpMap:f.roughnessMap?w=f.roughnessMap:f.metalnessMap?w=f.metalnessMap:f.alphaMap?w=f.alphaMap:f.emissiveMap?w=f.emissiveMap:f.clearcoatMap?w=f.clearcoatMap:f.clearcoatNormalMap?w=f.clearcoatNormalMap:f.clearcoatRoughnessMap?w=f.clearcoatRoughnessMap:f.specularIntensityMap?w=f.specularIntensityMap:f.specularColorMap?w=f.specularColorMap:f.transmissionMap?w=f.transmissionMap:f.thicknessMap?w=f.thicknessMap:f.sheenColorMap?w=f.sheenColorMap:f.sheenRoughnessMap&&(w=f.sheenRoughnessMap),w!==void 0&&(w.isWebGLRenderTarget&&(w=w.texture),w.matrixAutoUpdate===!0&&w.updateMatrix(),g.uvTransform.value.copy(w.matrix));let _;f.aoMap?_=f.aoMap:f.lightMap&&(_=f.lightMap),_!==void 0&&(_.isWebGLRenderTarget&&(_=_.texture),_.matrixAutoUpdate===!0&&_.updateMatrix(),g.uv2Transform.value.copy(_.matrix))}function n(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity}function s(g,f){g.dashSize.value=f.dashSize,g.totalSize.value=f.dashSize+f.gapSize,g.scale.value=f.scale}function o(g,f,E,w){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*E,g.scale.value=w*.5,f.map&&(g.map.value=f.map),f.alphaMap&&(g.alphaMap.value=f.alphaMap),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);let _;f.map?_=f.map:f.alphaMap&&(_=f.alphaMap),_!==void 0&&(_.matrixAutoUpdate===!0&&_.updateMatrix(),g.uvTransform.value.copy(_.matrix))}function a(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.rotation.value=f.rotation,f.map&&(g.map.value=f.map),f.alphaMap&&(g.alphaMap.value=f.alphaMap),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest);let E;f.map?E=f.map:f.alphaMap&&(E=f.alphaMap),E!==void 0&&(E.matrixAutoUpdate===!0&&E.updateMatrix(),g.uvTransform.value.copy(E.matrix))}function l(g,f){f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap)}function c(g,f){g.specular.value.copy(f.specular),g.shininess.value=Math.max(f.shininess,1e-4),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap),f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===xt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===xt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}function u(g,f){f.gradientMap&&(g.gradientMap.value=f.gradientMap),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap),f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===xt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===xt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}function h(g,f){g.roughness.value=f.roughness,g.metalness.value=f.metalness,f.roughnessMap&&(g.roughnessMap.value=f.roughnessMap),f.metalnessMap&&(g.metalnessMap.value=f.metalnessMap),f.emissiveMap&&(g.emissiveMap.value=f.emissiveMap),f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===xt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===xt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),r.get(f).envMap&&(g.envMapIntensity.value=f.envMapIntensity)}function d(g,f,E){h(g,f),g.ior.value=f.ior,f.sheen>0&&(g.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),g.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(g.sheenColorMap.value=f.sheenColorMap),f.sheenRoughnessMap&&(g.sheenRoughnessMap.value=f.sheenRoughnessMap)),f.clearcoat>0&&(g.clearcoat.value=f.clearcoat,g.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(g.clearcoatMap.value=f.clearcoatMap),f.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap),f.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),g.clearcoatNormalMap.value=f.clearcoatNormalMap,f.side===xt&&g.clearcoatNormalScale.value.negate())),f.transmission>0&&(g.transmission.value=f.transmission,g.transmissionSamplerMap.value=E.texture,g.transmissionSamplerSize.value.set(E.width,E.height),f.transmissionMap&&(g.transmissionMap.value=f.transmissionMap),g.thickness.value=f.thickness,f.thicknessMap&&(g.thicknessMap.value=f.thicknessMap),g.attenuationDistance.value=f.attenuationDistance,g.attenuationColor.value.copy(f.attenuationColor)),g.specularIntensity.value=f.specularIntensity,g.specularColor.value.copy(f.specularColor),f.specularIntensityMap&&(g.specularIntensityMap.value=f.specularIntensityMap),f.specularColorMap&&(g.specularColorMap.value=f.specularColorMap)}function p(g,f){f.matcap&&(g.matcap.value=f.matcap),f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===xt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===xt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}function m(g,f){f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}function y(g,f){f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias),g.referencePosition.value.copy(f.referencePosition),g.nearDistance.value=f.nearDistance,g.farDistance.value=f.farDistance}function x(g,f){f.bumpMap&&(g.bumpMap.value=f.bumpMap,g.bumpScale.value=f.bumpScale,f.side===xt&&(g.bumpScale.value*=-1)),f.normalMap&&(g.normalMap.value=f.normalMap,g.normalScale.value.copy(f.normalScale),f.side===xt&&g.normalScale.value.negate()),f.displacementMap&&(g.displacementMap.value=f.displacementMap,g.displacementScale.value=f.displacementScale,g.displacementBias.value=f.displacementBias)}return{refreshFogUniforms:e,refreshMaterialUniforms:t}}function K1(){let r=kr("canvas");return r.style.display="block",r}function qe(r={}){let e=r.canvas!==void 0?r.canvas:K1(),t=r.context!==void 0?r.context:null,i=r.alpha!==void 0?r.alpha:!1,n=r.depth!==void 0?r.depth:!0,s=r.stencil!==void 0?r.stencil:!0,o=r.antialias!==void 0?r.antialias:!1,a=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,l=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,c=r.powerPreference!==void 0?r.powerPreference:"default",u=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,h=null,d=null,p=[],m=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=bn,this.physicallyCorrectLights=!1,this.toneMapping=gn,this.toneMappingExposure=1;let y=this,x=!1,g=0,f=0,E=null,w=-1,_=null,M=new $e,T=new $e,z=null,W=e.width,A=e.height,v=1,R=null,S=null,B=new $e(0,0,W,A),L=new $e(0,0,W,A),C=!1,N=new Os,k=!1,V=!1,U=null,q=new Ee,j=new P,ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ae(){return E===null?v:1}let H=t;function Te(F,G){for(let X=0;X0?d=m[m.length-1]:d=null,p.pop(),p.length>0?h=p[p.length-1]:h=null};function ot(F,G,X,$){if(F.visible===!1)return;if(F.layers.test(G.layers)){if(F.isGroup)X=F.renderOrder;else if(F.isLOD)F.autoUpdate===!0&&F.update(G);else if(F.isLight)d.pushLight(F),F.castShadow&&d.pushShadow(F);else if(F.isSprite){if(!F.frustumCulled||N.intersectsSprite(F)){$&&j.setFromMatrixPosition(F.matrixWorld).applyMatrix4(q);let Be=Se.update(F),Ie=F.material;Ie.visible&&h.push(F,Be,Ie,X,j.z,null)}}else if((F.isMesh||F.isLine||F.isPoints)&&(F.isSkinnedMesh&&F.skeleton.frame!==Ce.render.frame&&(F.skeleton.update(),F.skeleton.frame=Ce.render.frame),!F.frustumCulled||N.intersectsObject(F))){$&&j.setFromMatrixPosition(F.matrixWorld).applyMatrix4(q);let Be=Se.update(F),Ie=F.material;if(Array.isArray(Ie)){let Pe=Be.groups;for(let We=0,ze=Pe.length;We0&&Pi(Q,G,X),$&&oe.viewport(M.copy($)),Q.length>0&&Fo(Q,G,X),Fe.length>0&&Fo(Fe,G,X),Be.length>0&&Fo(Be,G,X)}function Pi(F,G,X){if(U===null){let Be=o===!0&&we.isWebGL2===!0?Or:Ht;U=new Be(1024,1024,{generateMipmaps:!0,type:be.convert(Cs)!==null?Cs:yn,minFilter:sl,magFilter:vt,wrapS:Kt,wrapT:Kt,useRenderToTexture:ue.has("WEBGL_multisampled_render_to_texture")})}let $=y.getRenderTarget();y.setRenderTarget(U),y.clear();let Q=y.toneMapping;y.toneMapping=gn,Fo(F,G,X),y.toneMapping=Q,Z.updateMultisampleRenderTarget(U),Z.updateRenderTargetMipmap(U),y.setRenderTarget($)}function Fo(F,G,X){let $=G.isScene===!0?G.overrideMaterial:null;for(let Q=0,Fe=F.length;Q=0&&G<=F.width-$&&X>=0&&X<=F.height-Q&&H.readPixels(G,X,$,Q,be.convert(We),be.convert(ze),Fe):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{let Pe=E!==null?Ae.get(E).__webglFramebuffer:null;oe.bindFramebuffer(36160,Pe)}}},this.copyFramebufferToTexture=function(F,G,X=0){if(G.isFramebufferTexture!==!0){console.error("THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.");return}let $=Math.pow(2,-X),Q=Math.floor(G.image.width*$),Fe=Math.floor(G.image.height*$);Z.setTexture2D(G,0),H.copyTexSubImage2D(3553,X,0,0,F.x,F.y,Q,Fe),oe.unbindTexture()},this.copyTextureToTexture=function(F,G,X,$=0){let Q=G.image.width,Fe=G.image.height,Be=be.convert(X.format),Ie=be.convert(X.type);Z.setTexture2D(X,0),H.pixelStorei(37440,X.flipY),H.pixelStorei(37441,X.premultiplyAlpha),H.pixelStorei(3317,X.unpackAlignment),G.isDataTexture?H.texSubImage2D(3553,$,F.x,F.y,Q,Fe,Be,Ie,G.image.data):G.isCompressedTexture?H.compressedTexSubImage2D(3553,$,F.x,F.y,G.mipmaps[0].width,G.mipmaps[0].height,Be,G.mipmaps[0].data):H.texSubImage2D(3553,$,F.x,F.y,Be,Ie,G.image),$===0&&X.generateMipmaps&&H.generateMipmap(3553),oe.unbindTexture()},this.copyTextureToTexture3D=function(F,G,X,$,Q=0){if(y.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Fe=F.max.x-F.min.x+1,Be=F.max.y-F.min.y+1,Ie=F.max.z-F.min.z+1,Pe=be.convert($.format),We=be.convert($.type),ze;if($.isDataTexture3D)Z.setTexture3D($,0),ze=32879;else if($.isDataTexture2DArray)Z.setTexture2DArray($,0),ze=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}H.pixelStorei(37440,$.flipY),H.pixelStorei(37441,$.premultiplyAlpha),H.pixelStorei(3317,$.unpackAlignment);let Ve=H.getParameter(3314),at=H.getParameter(32878),Bn=H.getParameter(3316),ns=H.getParameter(3315),Ue=H.getParameter(32877),vi=X.isCompressedTexture?X.mipmaps[0]:X.image;H.pixelStorei(3314,vi.width),H.pixelStorei(32878,vi.height),H.pixelStorei(3316,F.min.x),H.pixelStorei(3315,F.min.y),H.pixelStorei(32877,F.min.z),X.isDataTexture||X.isDataTexture3D?H.texSubImage3D(ze,Q,G.x,G.y,G.z,Fe,Be,Ie,Pe,We,vi.data):X.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),H.compressedTexSubImage3D(ze,Q,G.x,G.y,G.z,Fe,Be,Ie,Pe,vi.data)):H.texSubImage3D(ze,Q,G.x,G.y,G.z,Fe,Be,Ie,Pe,We,vi),H.pixelStorei(3314,Ve),H.pixelStorei(32878,at),H.pixelStorei(3316,Bn),H.pixelStorei(3315,ns),H.pixelStorei(32877,Ue),Q===0&&$.generateMipmaps&&H.generateMipmap(ze),oe.unbindTexture()},this.initTexture=function(F){Z.setTexture2D(F,0),oe.unbindTexture()},this.resetState=function(){g=0,f=0,E=null,oe.reset(),ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}qe.prototype.isWebGLRenderer=!0;var Fu=class extends qe{};Fu.prototype.isWebGL1Renderer=!0;var Lu=class r{constructor(e,t=25e-5){this.name="",this.color=new ye(e),this.density=t}clone(){return new r(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}};Lu.prototype.isFogExp2=!0;var Bu=class r{constructor(e,t=1,i=1e3){this.name="",this.color=new ye(e),this.near=t,this.far=i}clone(){return new r(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}};Bu.prototype.isFog=!0;var Vs=class extends Ge{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}};Vs.prototype.isScene=!0;var Gn=class{constructor(e,t){this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Nr,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=pi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,s=this.stride;ne.far||t.push({distance:l,point:Er.clone(),uv:Lt.getUV(Er,pa,Sr,fa,Pf,hu,If,new ee),face:null,object:this})}copy(e){return super.copy(e),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}};Pu.prototype.isSprite=!0;function ma(r,e,t,i,n,s){As.subVectors(r,t).addScalar(.5).multiply(i),n!==void 0?(Ar.x=s*As.x-n*As.y,Ar.y=n*As.x+s*As.y):Ar.copy(As),r.copy(e),r.x+=Ar.x,r.y+=Ar.y,r.applyMatrix4(Am)}var Nf=new P,kf=new $e,Of=new $e,Q1=new P,zf=new Ee,Ua=class extends pt{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Ee,this.bindMatrixInverse=new Ee}copy(e){return super.copy(e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new $e,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;il)continue;d.applyMatrix4(this.matrixWorld);let z=e.ray.origin.distanceTo(d);ze.far||t.push({distance:z,point:h.clone().applyMatrix4(this.matrixWorld),index:E,face:null,faceIndex:null,object:this})}}else{let g=Math.max(0,o.start),f=Math.min(x.count,o.start+o.count);for(let E=g,w=f-1;El)continue;d.applyMatrix4(this.matrixWorld);let M=e.ray.origin.distanceTo(d);Me.far||t.push({distance:M,point:h.clone().applyMatrix4(this.matrixWorld),index:E,face:null,faceIndex:null,object:this})}}}else i.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,i=Object.keys(t);if(i.length>0){let n=t[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}};Yr.prototype.isLine=!0;var Wf=new P,$f=new P,Zr=class extends Yr{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.isBufferGeometry)if(e.index===null){let t=e.attributes.position,i=[];for(let n=0,s=t.count;n