const Xe=0,Ge=1,Ve=2;const H="srgb",jt="srgb-linear",ge="display-p3",de="display-p3-linear",$t="linear",Qt="srgb",Kt="rec709";class Jt{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const i=this._listeners;return i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const i=this._listeners[t.type];if(i!==void 0){t.target=this;const s=i.slice(0);for(let r=0,u=s.length;r>8&255]+F[m>>16&255]+F[m>>24&255]+"-"+F[t&255]+F[t>>8&255]+"-"+F[t>>16&15|64]+F[t>>24&255]+"-"+F[e&63|128]+F[e>>8&255]+"-"+F[e>>16&255]+F[e>>24&255]+F[i&255]+F[i>>8&255]+F[i>>16&255]+F[i>>24&255]).toLowerCase()}function L(m,t,e){return Math.max(t,Math.min(e,m))}function be(m,t){return(m%t+t)%t}function Ot(m,t,e){return(1-e)*m+e*t}function $(m,t){switch(t.constructor){case Float32Array:return m;case Uint32Array:return m/4294967295;case Uint16Array:return m/65535;case Uint8Array:return m/255;case Int32Array:return Math.max(m/2147483647,-1);case Int16Array:return Math.max(m/32767,-1);case Int8Array:return Math.max(m/127,-1);default:throw new Error("Invalid component type.")}}function w(m,t){switch(t.constructor){case Float32Array:return m;case Uint32Array:return Math.round(m*4294967295);case Uint16Array:return Math.round(m*65535);case Uint8Array:return Math.round(m*255);case Int32Array:return Math.round(m*2147483647);case Int16Array:return Math.round(m*32767);case Int8Array:return Math.round(m*127);default:throw new Error("Invalid component type.")}}class j{constructor(t=0,e=0){j.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(L(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),s=Math.sin(e),r=this.x-t.x,u=this.y-t.y;return this.x=r*i-u*s+t.x,this.y=r*s+u*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ht{constructor(t,e,i,s,r,u,h,o,n){ht.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,s,r,u,h,o,n)}set(t,e,i,s,r,u,h,o,n){const a=this.elements;return a[0]=t,a[1]=s,a[2]=h,a[3]=e,a[4]=r,a[5]=o,a[6]=i,a[7]=u,a[8]=n,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,r=this.elements,u=i[0],h=i[3],o=i[6],n=i[1],a=i[4],l=i[7],d=i[2],c=i[5],y=i[8],p=s[0],g=s[3],x=s[6],S=s[1],B=s[4],z=s[7],_=s[2],A=s[5],b=s[8];return r[0]=u*p+h*S+o*_,r[3]=u*g+h*B+o*A,r[6]=u*x+h*z+o*b,r[1]=n*p+a*S+l*_,r[4]=n*g+a*B+l*A,r[7]=n*x+a*z+l*b,r[2]=d*p+c*S+y*_,r[5]=d*g+c*B+y*A,r[8]=d*x+c*z+y*b,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],u=t[4],h=t[5],o=t[6],n=t[7],a=t[8];return e*u*a-e*h*n-i*r*a+i*h*o+s*r*n-s*u*o}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],u=t[4],h=t[5],o=t[6],n=t[7],a=t[8],l=a*u-h*n,d=h*o-a*r,c=n*r-u*o,y=e*l+i*d+s*c;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const p=1/y;return t[0]=l*p,t[1]=(s*n-a*i)*p,t[2]=(h*i-s*u)*p,t[3]=d*p,t[4]=(a*e-s*o)*p,t[5]=(s*r-h*e)*p,t[6]=c*p,t[7]=(i*o-n*e)*p,t[8]=(u*e-i*r)*p,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,s,r,u,h){const o=Math.cos(r),n=Math.sin(r);return this.set(i*o,i*n,-i*(o*u+n*h)+u+t,-s*n,s*o,-s*(-n*u+o*h)+h+e,0,0,1),this}scale(t,e){return this.premultiply(Dt.makeScale(t,e)),this}rotate(t){return this.premultiply(Dt.makeRotation(-t)),this}translate(t,e){return this.premultiply(Dt.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let s=0;s<9;s++)if(e[s]!==i[s])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Dt=new ht;function _e(m){for(let t=m.length-1;t>=0;--t)if(m[t]>=65535)return!0;return!1}function te(m){return document.createElementNS("http://www.w3.org/1999/xhtml",m)}const ee={};function qt(m){m in ee||(ee[m]=!0,console.warn(m))}const ie=new ht().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),se=new ht().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),kt={[jt]:{transfer:$t,primaries:Kt,toReference:m=>m,fromReference:m=>m},[H]:{transfer:Qt,primaries:Kt,toReference:m=>m.convertSRGBToLinear(),fromReference:m=>m.convertLinearToSRGB()},[de]:{transfer:$t,primaries:"p3",toReference:m=>m.applyMatrix3(se),fromReference:m=>m.applyMatrix3(ie)},[ge]:{transfer:Qt,primaries:"p3",toReference:m=>m.convertSRGBToLinear().applyMatrix3(se),fromReference:m=>m.applyMatrix3(ie).convertLinearToSRGB()}},Me=new Set([jt,de]),D={enabled:!0,_workingColorSpace:jt,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(m){if(!Me.has(m))throw new Error(`Unsupported working color space, "${m}".`);this._workingColorSpace=m},convert:function(m,t,e){if(this.enabled===!1||t===e||!t||!e)return m;const i=kt[t].toReference,s=kt[e].fromReference;return s(i(m))},fromWorkingColorSpace:function(m,t){return this.convert(m,this._workingColorSpace,t)},toWorkingColorSpace:function(m,t){return this.convert(m,t,this._workingColorSpace)},getPrimaries:function(m){return kt[m].primaries},getTransfer:function(m){return m===""?$t:kt[m].transfer}};function gt(m){return m<.04045?m*.0773993808:Math.pow(m*.9478672986+.0521327014,2.4)}function Wt(m){return m<.0031308?m*12.92:1.055*Math.pow(m,.41666)-.055}let ct;class ze{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{ct===void 0&&(ct=te("canvas")),ct.width=t.width,ct.height=t.height;const i=ct.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=ct}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=te("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const s=i.getImageData(0,0,t.width,t.height),r=s.data;for(let u=0;u0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==300)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return qt("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===H?3001:3e3}set encoding(t){qt("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===3001?H:""}}rt.DEFAULT_IMAGE=null;rt.DEFAULT_MAPPING=300;rt.DEFAULT_ANISOTROPY=1;class wt{constructor(t=0,e=0,i=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=s}static slerpFlat(t,e,i,s,r,u,h){let o=i[s+0],n=i[s+1],a=i[s+2],l=i[s+3];const d=r[u+0],c=r[u+1],y=r[u+2],p=r[u+3];if(h===0){t[e+0]=o,t[e+1]=n,t[e+2]=a,t[e+3]=l;return}if(h===1){t[e+0]=d,t[e+1]=c,t[e+2]=y,t[e+3]=p;return}if(l!==p||o!==d||n!==c||a!==y){let g=1-h;const x=o*d+n*c+a*y+l*p,S=x>=0?1:-1,B=1-x*x;if(B>Number.EPSILON){const _=Math.sqrt(B),A=Math.atan2(_,x*S);g=Math.sin(g*A)/_,h=Math.sin(h*A)/_}const z=h*S;if(o=o*g+d*z,n=n*g+c*z,a=a*g+y*z,l=l*g+p*z,g===1-h){const _=1/Math.sqrt(o*o+n*n+a*a+l*l);o*=_,n*=_,a*=_,l*=_}}t[e]=o,t[e+1]=n,t[e+2]=a,t[e+3]=l}static multiplyQuaternionsFlat(t,e,i,s,r,u){const h=i[s],o=i[s+1],n=i[s+2],a=i[s+3],l=r[u],d=r[u+1],c=r[u+2],y=r[u+3];return t[e]=h*y+a*l+o*c-n*d,t[e+1]=o*y+a*d+n*l-h*c,t[e+2]=n*y+a*c+h*d-o*l,t[e+3]=a*y-h*l-o*d-n*c,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,s){return this._x=t,this._y=e,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,s=t._y,r=t._z,u=t._order,h=Math.cos,o=Math.sin,n=h(i/2),a=h(s/2),l=h(r/2),d=o(i/2),c=o(s/2),y=o(r/2);switch(u){case"XYZ":this._x=d*a*l+n*c*y,this._y=n*c*l-d*a*y,this._z=n*a*y+d*c*l,this._w=n*a*l-d*c*y;break;case"YXZ":this._x=d*a*l+n*c*y,this._y=n*c*l-d*a*y,this._z=n*a*y-d*c*l,this._w=n*a*l+d*c*y;break;case"ZXY":this._x=d*a*l-n*c*y,this._y=n*c*l+d*a*y,this._z=n*a*y+d*c*l,this._w=n*a*l-d*c*y;break;case"ZYX":this._x=d*a*l-n*c*y,this._y=n*c*l+d*a*y,this._z=n*a*y-d*c*l,this._w=n*a*l+d*c*y;break;case"YZX":this._x=d*a*l+n*c*y,this._y=n*c*l+d*a*y,this._z=n*a*y-d*c*l,this._w=n*a*l-d*c*y;break;case"XZY":this._x=d*a*l-n*c*y,this._y=n*c*l-d*a*y,this._z=n*a*y+d*c*l,this._w=n*a*l+d*c*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+u)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,s=Math.sin(i);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],s=e[4],r=e[8],u=e[1],h=e[5],o=e[9],n=e[2],a=e[6],l=e[10],d=i+h+l;if(d>0){const c=.5/Math.sqrt(d+1);this._w=.25/c,this._x=(a-o)*c,this._y=(r-n)*c,this._z=(u-s)*c}else if(i>h&&i>l){const c=2*Math.sqrt(1+i-h-l);this._w=(a-o)/c,this._x=.25*c,this._y=(s+u)/c,this._z=(r+n)/c}else if(h>l){const c=2*Math.sqrt(1+h-i-l);this._w=(r-n)/c,this._x=(s+u)/c,this._y=.25*c,this._z=(o+a)/c}else{const c=2*Math.sqrt(1+l-i-h);this._w=(u-s)/c,this._x=(r+n)/c,this._y=(o+a)/c,this._z=.25*c}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return iMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(L(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const s=Math.min(1,e/i);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,s=t._y,r=t._z,u=t._w,h=e._x,o=e._y,n=e._z,a=e._w;return this._x=i*a+u*h+s*n-r*o,this._y=s*a+u*o+r*h-i*n,this._z=r*a+u*n+i*o-s*h,this._w=u*a-i*h-s*o-r*n,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,s=this._y,r=this._z,u=this._w;let h=u*t._w+i*t._x+s*t._y+r*t._z;if(h<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,h=-h):this.copy(t),h>=1)return this._w=u,this._x=i,this._y=s,this._z=r,this;const o=1-h*h;if(o<=Number.EPSILON){const c=1-e;return this._w=c*u+e*this._w,this._x=c*i+e*this._x,this._y=c*s+e*this._y,this._z=c*r+e*this._z,this.normalize(),this}const n=Math.sqrt(o),a=Math.atan2(n,h),l=Math.sin((1-e)*a)/n,d=Math.sin(e*a)/n;return this._w=u*l+this._w*d,this._x=i*l+this._x*d,this._y=s*l+this._y*d,this._z=r*l+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=Math.random(),e=Math.sqrt(1-t),i=Math.sqrt(t),s=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(e*Math.cos(s),i*Math.sin(r),i*Math.cos(r),e*Math.sin(s))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class f{constructor(t=0,e=0,i=0){f.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(re.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(re.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*s,this.y=r[1]*e+r[4]*i+r[7]*s,this.z=r[2]*e+r[5]*i+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,r=t.elements,u=1/(r[3]*e+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*s+r[12])*u,this.y=(r[1]*e+r[5]*i+r[9]*s+r[13])*u,this.z=(r[2]*e+r[6]*i+r[10]*s+r[14])*u,this}applyQuaternion(t){const e=this.x,i=this.y,s=this.z,r=t.x,u=t.y,h=t.z,o=t.w,n=2*(u*s-h*i),a=2*(h*e-r*s),l=2*(r*i-u*e);return this.x=e+o*n+u*l-h*a,this.y=i+o*a+h*n-r*l,this.z=s+o*l+r*a-u*n,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*s,this.y=r[1]*e+r[5]*i+r[9]*s,this.z=r[2]*e+r[6]*i+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,s=t.y,r=t.z,u=e.x,h=e.y,o=e.z;return this.x=s*o-r*h,this.y=r*u-i*o,this.z=i*h-s*u,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Yt.copy(this).projectOnVector(t),this.sub(Yt)}reflect(t){return this.sub(Yt.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(L(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,s=this.z-t.z;return e*e+i*i+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const s=Math.sin(e)*t;return this.x=s*Math.sin(i),this.y=Math.cos(e)*t,this.z=s*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=(Math.random()-.5)*2,e=Math.random()*Math.PI*2,i=Math.sqrt(1-t**2);return this.x=i*Math.cos(e),this.y=i*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Yt=new f,re=new wt;class St{constructor(t=new f(1/0,1/0,1/0),e=new f(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,i=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,q),q.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(bt),vt.subVectors(this.max,bt),dt.subVectors(t.a,bt),mt.subVectors(t.b,bt),yt.subVectors(t.c,bt),tt.subVectors(mt,dt),et.subVectors(yt,mt),ot.subVectors(dt,yt);let e=[0,-tt.z,tt.y,0,-et.z,et.y,0,-ot.z,ot.y,tt.z,0,-tt.x,et.z,0,-et.x,ot.z,0,-ot.x,-tt.y,tt.x,0,-et.y,et.x,0,-ot.y,ot.x,0];return!Xt(e,dt,mt,yt,vt)||(e=[1,0,0,0,1,0,0,0,1],!Xt(e,dt,mt,yt,vt))?!1:(Ft.crossVectors(tt,et),e=[Ft.x,Ft.y,Ft.z],Xt(e,dt,mt,yt,vt))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,q).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(q).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(G[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),G[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),G[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),G[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),G[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),G[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),G[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),G[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(G),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const G=[new f,new f,new f,new f,new f,new f,new f,new f],q=new f,Ct=new St,dt=new f,mt=new f,yt=new f,tt=new f,et=new f,ot=new f,bt=new f,vt=new f,Ft=new f,ut=new f;function Xt(m,t,e,i,s){for(let r=0,u=m.length-3;r<=u;r+=3){ut.fromArray(m,r);const h=s.x*Math.abs(ut.x)+s.y*Math.abs(ut.y)+s.z*Math.abs(ut.z),o=t.dot(ut),n=e.dot(ut),a=i.dot(ut);if(Math.max(-Math.max(o,n,a),Math.min(o,n,a))>h)return!1}return!0}const Be=new St,_t=new f,Gt=new f;class Te{constructor(t=new f,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;e!==void 0?i.copy(e):Be.setFromPoints(t).getCenter(i);let s=0;for(let r=0,u=t.length;rthis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;_t.subVectors(t,this.center);const e=_t.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),s=(i-this.radius)*.5;this.center.addScaledVector(_t,s/i),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Gt.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(_t.copy(t.center).add(Gt)),this.expandByPoint(_t.copy(t.center).sub(Gt))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}class X{constructor(t,e,i,s,r,u,h,o,n,a,l,d,c,y,p,g){X.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,s,r,u,h,o,n,a,l,d,c,y,p,g)}set(t,e,i,s,r,u,h,o,n,a,l,d,c,y,p,g){const x=this.elements;return x[0]=t,x[4]=e,x[8]=i,x[12]=s,x[1]=r,x[5]=u,x[9]=h,x[13]=o,x[2]=n,x[6]=a,x[10]=l,x[14]=d,x[3]=c,x[7]=y,x[11]=p,x[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new X().fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,s=1/pt.setFromMatrixColumn(t,0).length(),r=1/pt.setFromMatrixColumn(t,1).length(),u=1/pt.setFromMatrixColumn(t,2).length();return e[0]=i[0]*s,e[1]=i[1]*s,e[2]=i[2]*s,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*u,e[9]=i[9]*u,e[10]=i[10]*u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,s=t.y,r=t.z,u=Math.cos(i),h=Math.sin(i),o=Math.cos(s),n=Math.sin(s),a=Math.cos(r),l=Math.sin(r);if(t.order==="XYZ"){const d=u*a,c=u*l,y=h*a,p=h*l;e[0]=o*a,e[4]=-o*l,e[8]=n,e[1]=c+y*n,e[5]=d-p*n,e[9]=-h*o,e[2]=p-d*n,e[6]=y+c*n,e[10]=u*o}else if(t.order==="YXZ"){const d=o*a,c=o*l,y=n*a,p=n*l;e[0]=d+p*h,e[4]=y*h-c,e[8]=u*n,e[1]=u*l,e[5]=u*a,e[9]=-h,e[2]=c*h-y,e[6]=p+d*h,e[10]=u*o}else if(t.order==="ZXY"){const d=o*a,c=o*l,y=n*a,p=n*l;e[0]=d-p*h,e[4]=-u*l,e[8]=y+c*h,e[1]=c+y*h,e[5]=u*a,e[9]=p-d*h,e[2]=-u*n,e[6]=h,e[10]=u*o}else if(t.order==="ZYX"){const d=u*a,c=u*l,y=h*a,p=h*l;e[0]=o*a,e[4]=y*n-c,e[8]=d*n+p,e[1]=o*l,e[5]=p*n+d,e[9]=c*n-y,e[2]=-n,e[6]=h*o,e[10]=u*o}else if(t.order==="YZX"){const d=u*o,c=u*n,y=h*o,p=h*n;e[0]=o*a,e[4]=p-d*l,e[8]=y*l+c,e[1]=l,e[5]=u*a,e[9]=-h*a,e[2]=-n*a,e[6]=c*l+y,e[10]=d-p*l}else if(t.order==="XZY"){const d=u*o,c=u*n,y=h*o,p=h*n;e[0]=o*a,e[4]=-l,e[8]=n*a,e[1]=d*l+p,e[5]=u*a,e[9]=c*l-y,e[2]=y*l-c,e[6]=h*a,e[10]=p*l+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Ee,t,Re)}lookAt(t,e,i){const s=this.elements;return P.subVectors(t,e),P.lengthSq()===0&&(P.z=1),P.normalize(),it.crossVectors(i,P),it.lengthSq()===0&&(Math.abs(i.z)===1?P.x+=1e-4:P.z+=1e-4,P.normalize(),it.crossVectors(i,P)),it.normalize(),It.crossVectors(P,it),s[0]=it.x,s[4]=It.x,s[8]=P.x,s[1]=it.y,s[5]=It.y,s[9]=P.y,s[2]=it.z,s[6]=It.z,s[10]=P.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,r=this.elements,u=i[0],h=i[4],o=i[8],n=i[12],a=i[1],l=i[5],d=i[9],c=i[13],y=i[2],p=i[6],g=i[10],x=i[14],S=i[3],B=i[7],z=i[11],_=i[15],A=s[0],b=s[4],Y=s[8],J=s[12],M=s[1],R=s[5],k=s[9],C=s[13],Q=s[2],v=s[6],K=s[10],At=s[14],Bt=s[3],Tt=s[7],Et=s[11],Rt=s[15];return r[0]=u*A+h*M+o*Q+n*Bt,r[4]=u*b+h*R+o*v+n*Tt,r[8]=u*Y+h*k+o*K+n*Et,r[12]=u*J+h*C+o*At+n*Rt,r[1]=a*A+l*M+d*Q+c*Bt,r[5]=a*b+l*R+d*v+c*Tt,r[9]=a*Y+l*k+d*K+c*Et,r[13]=a*J+l*C+d*At+c*Rt,r[2]=y*A+p*M+g*Q+x*Bt,r[6]=y*b+p*R+g*v+x*Tt,r[10]=y*Y+p*k+g*K+x*Et,r[14]=y*J+p*C+g*At+x*Rt,r[3]=S*A+B*M+z*Q+_*Bt,r[7]=S*b+B*R+z*v+_*Tt,r[11]=S*Y+B*k+z*K+_*Et,r[15]=S*J+B*C+z*At+_*Rt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],s=t[8],r=t[12],u=t[1],h=t[5],o=t[9],n=t[13],a=t[2],l=t[6],d=t[10],c=t[14],y=t[3],p=t[7],g=t[11],x=t[15];return y*(+r*o*l-s*n*l-r*h*d+i*n*d+s*h*c-i*o*c)+p*(+e*o*c-e*n*d+r*u*d-s*u*c+s*n*a-r*o*a)+g*(+e*n*l-e*h*c-r*u*l+i*u*c+r*h*a-i*n*a)+x*(-s*h*a-e*o*l+e*h*d+s*u*l-i*u*d+i*o*a)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],u=t[4],h=t[5],o=t[6],n=t[7],a=t[8],l=t[9],d=t[10],c=t[11],y=t[12],p=t[13],g=t[14],x=t[15],S=l*g*n-p*d*n+p*o*c-h*g*c-l*o*x+h*d*x,B=y*d*n-a*g*n-y*o*c+u*g*c+a*o*x-u*d*x,z=a*p*n-y*l*n+y*h*c-u*p*c-a*h*x+u*l*x,_=y*l*o-a*p*o-y*h*d+u*p*d+a*h*g-u*l*g,A=e*S+i*B+s*z+r*_;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/A;return t[0]=S*b,t[1]=(p*d*r-l*g*r-p*s*c+i*g*c+l*s*x-i*d*x)*b,t[2]=(h*g*r-p*o*r+p*s*n-i*g*n-h*s*x+i*o*x)*b,t[3]=(l*o*r-h*d*r-l*s*n+i*d*n+h*s*c-i*o*c)*b,t[4]=B*b,t[5]=(a*g*r-y*d*r+y*s*c-e*g*c-a*s*x+e*d*x)*b,t[6]=(y*o*r-u*g*r-y*s*n+e*g*n+u*s*x-e*o*x)*b,t[7]=(u*d*r-a*o*r+a*s*n-e*d*n-u*s*c+e*o*c)*b,t[8]=z*b,t[9]=(y*l*r-a*p*r-y*i*c+e*p*c+a*i*x-e*l*x)*b,t[10]=(u*p*r-y*h*r+y*i*n-e*p*n-u*i*x+e*h*x)*b,t[11]=(a*h*r-u*l*r-a*i*n+e*l*n+u*i*c-e*h*c)*b,t[12]=_*b,t[13]=(a*p*s-y*l*s+y*i*d-e*p*d-a*i*g+e*l*g)*b,t[14]=(y*h*s-u*p*s-y*i*o+e*p*o+u*i*g-e*h*g)*b,t[15]=(u*l*s-a*h*s+a*i*o-e*l*o-u*i*d+e*h*d)*b,this}scale(t){const e=this.elements,i=t.x,s=t.y,r=t.z;return e[0]*=i,e[4]*=s,e[8]*=r,e[1]*=i,e[5]*=s,e[9]*=r,e[2]*=i,e[6]*=s,e[10]*=r,e[3]*=i,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,s))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),s=Math.sin(e),r=1-i,u=t.x,h=t.y,o=t.z,n=r*u,a=r*h;return this.set(n*u+i,n*h-s*o,n*o+s*h,0,n*h+s*o,a*h+i,a*o-s*u,0,n*o-s*h,a*o+s*u,r*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,s,r,u){return this.set(1,i,r,0,t,1,u,0,e,s,1,0,0,0,0,1),this}compose(t,e,i){const s=this.elements,r=e._x,u=e._y,h=e._z,o=e._w,n=r+r,a=u+u,l=h+h,d=r*n,c=r*a,y=r*l,p=u*a,g=u*l,x=h*l,S=o*n,B=o*a,z=o*l,_=i.x,A=i.y,b=i.z;return s[0]=(1-(p+x))*_,s[1]=(c+z)*_,s[2]=(y-B)*_,s[3]=0,s[4]=(c-z)*A,s[5]=(1-(d+x))*A,s[6]=(g+S)*A,s[7]=0,s[8]=(y+B)*b,s[9]=(g-S)*b,s[10]=(1-(d+p))*b,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,i){const s=this.elements;let r=pt.set(s[0],s[1],s[2]).length();const u=pt.set(s[4],s[5],s[6]).length(),h=pt.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],W.copy(this);const n=1/r,a=1/u,l=1/h;return W.elements[0]*=n,W.elements[1]*=n,W.elements[2]*=n,W.elements[4]*=a,W.elements[5]*=a,W.elements[6]*=a,W.elements[8]*=l,W.elements[9]*=l,W.elements[10]*=l,e.setFromRotationMatrix(W),i.x=r,i.y=u,i.z=h,this}makePerspective(t,e,i,s,r,u,h=2e3){const o=this.elements,n=2*r/(e-t),a=2*r/(i-s),l=(e+t)/(e-t),d=(i+s)/(i-s);let c,y;if(h===2e3)c=-(u+r)/(u-r),y=-2*u*r/(u-r);else if(h===2001)c=-u/(u-r),y=-u*r/(u-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+h);return o[0]=n,o[4]=0,o[8]=l,o[12]=0,o[1]=0,o[5]=a,o[9]=d,o[13]=0,o[2]=0,o[6]=0,o[10]=c,o[14]=y,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,i,s,r,u,h=2e3){const o=this.elements,n=1/(e-t),a=1/(i-s),l=1/(u-r),d=(e+t)*n,c=(i+s)*a;let y,p;if(h===2e3)y=(u+r)*l,p=-2*l;else if(h===2001)y=r*l,p=-1*l;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+h);return o[0]=2*n,o[4]=0,o[8]=0,o[12]=-d,o[1]=0,o[5]=2*a,o[9]=0,o[13]=-c,o[2]=0,o[6]=0,o[10]=p,o[14]=-y,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let s=0;s<16;s++)if(e[s]!==i[s])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const pt=new f,W=new X,Ee=new f(0,0,0),Re=new f(1,1,1),it=new f,It=new f,P=new f,ne=new X,ae=new wt;class Nt{constructor(t=0,e=0,i=0,s=Nt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,s=this._order){return this._x=t,this._y=e,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const s=t.elements,r=s[0],u=s[4],h=s[8],o=s[1],n=s[5],a=s[9],l=s[2],d=s[6],c=s[10];switch(e){case"XYZ":this._y=Math.asin(L(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-a,c),this._z=Math.atan2(-u,r)):(this._x=Math.atan2(d,n),this._z=0);break;case"YXZ":this._x=Math.asin(-L(a,-1,1)),Math.abs(a)<.9999999?(this._y=Math.atan2(h,c),this._z=Math.atan2(o,n)):(this._y=Math.atan2(-l,r),this._z=0);break;case"ZXY":this._x=Math.asin(L(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-l,c),this._z=Math.atan2(-u,n)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-L(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(d,c),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-u,n));break;case"YZX":this._z=Math.asin(L(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-a,n),this._y=Math.atan2(-l,r)):(this._x=0,this._y=Math.atan2(h,c));break;case"XZY":this._z=Math.asin(-L(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,n),this._y=Math.atan2(h,r)):(this._x=Math.atan2(-a,c),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return ne.makeRotationFromQuaternion(t),this.setFromRotationMatrix(ne,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ae.setFromEuler(this),this.setFromQuaternion(ae,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Nt.DEFAULT_ORDER="XYZ";class ke{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let i=0;i0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(h=>({boxInitialized:h.boxInitialized,boxMin:h.box.min.toArray(),boxMax:h.box.max.toArray(),sphereInitialized:h.sphereInitialized,sphereRadius:h.sphere.radius,sphereCenter:h.sphere.center.toArray()})),s.maxGeometryCount=this._maxGeometryCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function r(h,o){return h[o.uuid]===void 0&&(h[o.uuid]=o.toJSON(t)),o.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);const h=this.geometry.parameters;if(h!==void 0&&h.shapes!==void 0){const o=h.shapes;if(Array.isArray(o))for(let n=0,a=o.length;n0){s.children=[];for(let h=0;h0){s.animations=[];for(let h=0;h0&&(i.geometries=h),o.length>0&&(i.materials=o),n.length>0&&(i.textures=n),a.length>0&&(i.images=a),l.length>0&&(i.shapes=l),d.length>0&&(i.skeletons=d),c.length>0&&(i.animations=c),y.length>0&&(i.nodes=y)}return i.object=s,i;function u(h){const o=[];for(const n in h){const a=h[n];delete a.metadata,o.push(a)}return o}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let i=0;i1&&(e-=1),e<1/6?m+(t-m)*6*e:e<1/2?t:e<2/3?m+(t-m)*6*(2/3-e):m}class ye{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(e===void 0&&i===void 0){const s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=H){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,D.toWorkingColorSpace(this,e),this}setRGB(t,e,i,s=D.workingColorSpace){return this.r=t,this.g=e,this.b=i,D.toWorkingColorSpace(this,s),this}setHSL(t,e,i,s=D.workingColorSpace){if(t=be(t,1),e=L(e,0,1),i=L(i,0,1),e===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+e):i+e-i*e,u=2*i-r;this.r=Vt(u,r,t+1/3),this.g=Vt(u,r,t),this.b=Vt(u,r,t-1/3)}return D.toWorkingColorSpace(this,s),this}setStyle(t,e=H){function i(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const u=s[1],h=s[2];switch(u){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(h))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(h))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(h))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=s[1],u=r.length;if(u===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(u===6)return this.setHex(parseInt(r,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=H){const i=me[t.toLowerCase()];return i!==void 0?this.setHex(i,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=gt(t.r),this.g=gt(t.g),this.b=gt(t.b),this}copyLinearToSRGB(t){return this.r=Wt(t.r),this.g=Wt(t.g),this.b=Wt(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=H){return D.fromWorkingColorSpace(I.copy(this),t),Math.round(L(I.r*255,0,255))*65536+Math.round(L(I.g*255,0,255))*256+Math.round(L(I.b*255,0,255))}getHexString(t=H){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=D.workingColorSpace){D.fromWorkingColorSpace(I.copy(this),e);const i=I.r,s=I.g,r=I.b,u=Math.max(i,s,r),h=Math.min(i,s,r);let o,n;const a=(h+u)/2;if(h===u)o=0,n=0;else{const l=u-h;switch(n=a<=.5?l/(u+h):l/(2-u-h),u){case i:o=(s-r)/l+(s0&&(t.userData=this.userData),this.parameters!==void 0){const o=this.parameters;for(const n in o)o[n]!==void 0&&(t[n]=o[n]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const o in i){const n=i[o];t.data.attributes[o]=n.toJSON(t.data)}const s={};let r=!1;for(const o in this.morphAttributes){const n=this.morphAttributes[o],a=[];for(let l=0,d=n.length;l0&&(s[o]=a,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const u=this.groups;u.length>0&&(t.data.groups=JSON.parse(JSON.stringify(u)));const h=this.boundingSphere;return h!==null&&(t.data.boundingSphere={center:h.center.toArray(),radius:h.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;i!==null&&this.setIndex(i.clone(e));const s=t.attributes;for(const n in s){const a=s[n];this.setAttribute(n,a.clone(e))}const r=t.morphAttributes;for(const n in r){const a=[],l=r[n];for(let d=0,c=l.length;d{e&&e(r),this.manager.itemEnd(t)},0),r;if(Z[t]!==void 0){Z[t].push({onLoad:e,onProgress:i,onError:s});return}Z[t]=[],Z[t].push({onLoad:e,onProgress:i,onError:s});const u=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),h=this.mimeType,o=this.responseType;fetch(u).then(n=>{if(n.status===200||n.status===0){if(n.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||n.body===void 0||n.body.getReader===void 0)return n;const a=Z[t],l=n.body.getReader(),d=n.headers.get("Content-Length")||n.headers.get("X-File-Size"),c=d?parseInt(d):0,y=c!==0;let p=0;const g=new ReadableStream({start(x){S();function S(){l.read().then(({done:B,value:z})=>{if(B)x.close();else{p+=z.byteLength;const _=new ProgressEvent("progress",{lengthComputable:y,loaded:p,total:c});for(let A=0,b=a.length;A{switch(o){case"arraybuffer":return n.arrayBuffer();case"blob":return n.blob();case"document":return n.text().then(a=>new DOMParser().parseFromString(a,h));case"json":return n.json();default:if(h===void 0)return n.text();{const l=/charset="?([^;"\s]*)"?/i.exec(h),d=l&&l[1]?l[1].toLowerCase():void 0,c=new TextDecoder(d);return n.arrayBuffer().then(y=>c.decode(y))}}}).then(n=>{ce.add(t,n);const a=Z[t];delete Z[t];for(let l=0,d=a.length;l{const a=Z[t];if(a===void 0)throw this.manager.itemError(t),n;delete Z[t];for(let l=0,d=a.length;l{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"160"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="160");export{pe as B,ye as C,je as F,$e as I,xe as L,Xe as T,f as V,at as a,Ne as b,Ze as c,fe as d,Ve as e,Ge as f}; //# sourceMappingURL=three.module-BB51Dq4E.js.map